spring工具类移至common

dep_wangsr
RuoYi 6 years ago committed by Limy
parent 683572d57f
commit b0a73ca642

@ -1,4 +1,4 @@
package com.ruoyi.framework.util; package com.ruoyi.common.utils.spring;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoSuchBeanDefinitionException;

@ -4,7 +4,7 @@ import java.util.TimerTask;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import com.ruoyi.common.utils.Threads; import com.ruoyi.common.utils.Threads;
import com.ruoyi.framework.util.SpringUtils; import com.ruoyi.common.utils.spring.SpringUtils;
/** /**
* *

@ -5,11 +5,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.AddressUtils; import com.ruoyi.common.utils.AddressUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.framework.shiro.session.OnlineSession; import com.ruoyi.framework.shiro.session.OnlineSession;
import com.ruoyi.framework.util.LogUtils; import com.ruoyi.framework.util.LogUtils;
import com.ruoyi.framework.util.ServletUtils; import com.ruoyi.framework.util.ServletUtils;
import com.ruoyi.framework.util.ShiroUtils; import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.framework.util.SpringUtils;
import com.ruoyi.system.domain.SysLogininfor; import com.ruoyi.system.domain.SysLogininfor;
import com.ruoyi.system.domain.SysOperLog; import com.ruoyi.system.domain.SysOperLog;
import com.ruoyi.system.domain.SysUserOnline; import com.ruoyi.system.domain.SysUserOnline;

@ -14,8 +14,8 @@ import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.ruoyi.common.constant.ShiroConstants; import com.ruoyi.common.constant.ShiroConstants;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.framework.shiro.session.OnlineSession; import com.ruoyi.framework.shiro.session.OnlineSession;
import com.ruoyi.framework.util.SpringUtils;
import com.ruoyi.system.domain.SysUserOnline; import com.ruoyi.system.domain.SysUserOnline;
import com.ruoyi.system.service.ISysUserOnlineService; import com.ruoyi.system.service.ISysUserOnlineService;

@ -1,6 +1,7 @@
package com.ruoyi.framework.util; package com.ruoyi.framework.util;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import com.ruoyi.common.utils.spring.SpringUtils;
/** /**
* i18n * i18n

@ -13,6 +13,7 @@ import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.ScheduleConstants; import com.ruoyi.common.constant.ScheduleConstants;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils; 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.SysJob;
import com.ruoyi.quartz.domain.SysJobLog; import com.ruoyi.quartz.domain.SysJobLog;
import com.ruoyi.quartz.service.ISysJobLogService; 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 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 @Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException protected void executeInternal(JobExecutionContext context) throws JobExecutionException

@ -5,6 +5,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
import com.ruoyi.common.utils.StringUtils; 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) public ScheduleRunnable(String beanName, String methodName, String params)
throws NoSuchMethodException, SecurityException throws NoSuchMethodException, SecurityException
{ {
this.target = SpringContextUtil.getBean(beanName); this.target = SpringUtils.getBean(beanName);
this.params = params; this.params = params;
if (StringUtils.isNotEmpty(params)) if (StringUtils.isNotEmpty(params))

@ -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;
/**
* springbean
*
* @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);
}
}
Loading…
Cancel
Save