diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/util/SpringUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java similarity index 95% rename from ruoyi-framework/src/main/java/com/ruoyi/framework/util/SpringUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java index 99b0f05b..daf253ec 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/util/SpringUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.util; +package com.ruoyi.common.utils.spring; import org.springframework.beans.BeansException; import org.springframework.beans.factory.NoSuchBeanDefinitionException; diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java index 93628251..485a6317 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java @@ -4,7 +4,7 @@ import java.util.TimerTask; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import com.ruoyi.common.utils.Threads; -import com.ruoyi.framework.util.SpringUtils; +import com.ruoyi.common.utils.spring.SpringUtils; /** * 异步任务管理器 diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java index d924af51..a85d775e 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java @@ -5,11 +5,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.utils.AddressUtils; +import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.framework.shiro.session.OnlineSession; import com.ruoyi.framework.util.LogUtils; import com.ruoyi.framework.util.ServletUtils; import com.ruoyi.framework.util.ShiroUtils; -import com.ruoyi.framework.util.SpringUtils; import com.ruoyi.system.domain.SysLogininfor; import com.ruoyi.system.domain.SysOperLog; import com.ruoyi.system.domain.SysUserOnline; diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/session/OnlineWebSessionManager.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/session/OnlineWebSessionManager.java index 1c8edc6f..080567ee 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/session/OnlineWebSessionManager.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/session/OnlineWebSessionManager.java @@ -14,8 +14,8 @@ import org.apache.shiro.web.session.mgt.DefaultWebSessionManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.ruoyi.common.constant.ShiroConstants; +import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.framework.shiro.session.OnlineSession; -import com.ruoyi.framework.util.SpringUtils; import com.ruoyi.system.domain.SysUserOnline; import com.ruoyi.system.service.ISysUserOnlineService; diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/util/MessageUtils.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/util/MessageUtils.java index b787e1bd..f656392c 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/util/MessageUtils.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/util/MessageUtils.java @@ -1,6 +1,7 @@ package com.ruoyi.framework.util; import org.springframework.context.MessageSource; +import com.ruoyi.common.utils.spring.SpringUtils; /** * 获取i18n资源文件 diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleJob.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleJob.java index e3ced0aa..9b606bc5 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleJob.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleJob.java @@ -13,6 +13,7 @@ import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.ScheduleConstants; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.bean.BeanUtils; +import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.quartz.domain.SysJob; import com.ruoyi.quartz.domain.SysJobLog; import com.ruoyi.quartz.service.ISysJobLogService; @@ -28,9 +29,9 @@ public class ScheduleJob extends QuartzJobBean { private static final Logger log = LoggerFactory.getLogger(ScheduleJob.class); - private ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) SpringContextUtil.getBean("publicThreadPool"); + private ThreadPoolTaskExecutor executor = SpringUtils.getBean("threadPoolTaskExecutor"); - private final static ISysJobLogService jobLogService = (ISysJobLogService) SpringContextUtil.getBean("sysJobLogServiceImpl"); + private final static ISysJobLogService jobLogService = SpringUtils.getBean(ISysJobLogService.class); @Override protected void executeInternal(JobExecutionContext context) throws JobExecutionException diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleRunnable.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleRunnable.java index aea572b4..5a96a106 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleRunnable.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleRunnable.java @@ -5,6 +5,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.ReflectionUtils; import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.spring.SpringUtils; /** * 执行定时任务 @@ -23,7 +24,7 @@ public class ScheduleRunnable implements Runnable public ScheduleRunnable(String beanName, String methodName, String params) throws NoSuchMethodException, SecurityException { - this.target = SpringContextUtil.getBean(beanName); + this.target = SpringUtils.getBean(beanName); this.params = params; if (StringUtils.isNotEmpty(params)) diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/SpringContextUtil.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/SpringContextUtil.java deleted file mode 100644 index 6146b039..00000000 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/SpringContextUtil.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.ruoyi.quartz.util; - -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Service; - -/** - * spring管理环境中获取bean - * - * @author yangzz - */ -@Service("springContextUtil") -public class SpringContextUtil implements ApplicationContextAware -{ - // Spring应用上下文环境 - private static ApplicationContext applicationContext; - - /** - * 实现ApplicationContextAware接口的回调方法,设置上下文环境 - * - * @param applicationContext - */ - @Override - public void setApplicationContext(ApplicationContext applicationContext) - { - SpringContextUtil.applicationContext = applicationContext; - } - - /** - * @return ApplicationContext - */ - public static ApplicationContext getApplicationContext() - { - return applicationContext; - } - - /** - * 获取对象 - * - * @param name - * @return Object - * @throws BeansException - */ - public static Object getBean(String name) throws BeansException - { - return applicationContext.getBean(name); - } -}