Commit 9ef4a9e9 authored by yanzg's avatar yanzg

修改实例化关系

parent 5544d55e
......@@ -15,11 +15,8 @@ import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.amqp.core.Message;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -38,34 +35,16 @@ import java.util.List;
*
* @author 颜佐光
*/
public class BaseRequestAspect implements ApplicationContextAware {
public class BaseRequestAspect {
@Autowired
protected LogLocal logLocal;
@Autowired
protected CloudConfig cloudConfig;
private ResponseResult responseDefault = new ResponseResult();
/**
* Set the ApplicationContext that this object runs in.
* Normally this call will be used to initialize the object.
* <p>Invoked after population of normal bean properties but before an init callback such
* as {@link InitializingBean#afterPropertiesSet()}
* or a custom init-method. Invoked after {@link ResourceLoaderAware#setResourceLoader},
* {@link ApplicationEventPublisherAware#setApplicationEventPublisher} and
* {@link MessageSourceAware}, if applicable.
*
* @param applicationContext the ApplicationContext object to be used by this object
* @throws ApplicationContextException in case of context initialization errors
* @throws BeansException if thrown by application context methods
* @see BeanInitializationException
*/
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.logLocal = applicationContext.getBean(LogLocal.class);
this.cloudConfig = applicationContext.getBean(CloudConfig.class);
}
/**
* 开始记录日志对象
*
......
......@@ -17,6 +17,7 @@ import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.*;
import org.springframework.stereotype.Component;
......@@ -31,10 +32,11 @@ import java.lang.reflect.Type;
*/
@Aspect
@Component
public class WebAspect extends BaseRequestAspect {
public class WebAspect extends BaseRequestAspect implements ApplicationContextAware {
private static final String TAG = WebAspect.class.getSimpleName();
@Autowired
private TokenServiceCall tokenServiceCall;
/**
* 是否存在初始化方法
......@@ -57,8 +59,6 @@ public class WebAspect extends BaseRequestAspect {
*/
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
super.setApplicationContext(applicationContext);
this.tokenServiceCall = applicationContext.getBean(TokenServiceCall.class);
try {
this.webAspectInit = applicationContext.getBean(WebAspectInit.class);
} catch (Exception ex) {
......
......@@ -7,6 +7,7 @@ import com.yanzuoguang.util.vo.LogVo;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.*;
import org.springframework.stereotype.Component;
......@@ -24,6 +25,7 @@ public class LogBase implements ThreadNext.Next, InitializingBean, ApplicationCo
*/
protected volatile LinkedBlockingQueue<LogVo> cache = new LinkedBlockingQueue<>();
@Autowired
private CloudConfig cloudConfig;
private LogFeignBase logFeign;
......@@ -44,7 +46,6 @@ public class LogBase implements ThreadNext.Next, InitializingBean, ApplicationCo
*/
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.cloudConfig = applicationContext.getBean(CloudConfig.class);
// 获取个人实例话的对象
try {
this.logFeign = applicationContext.getBean(LogFeign.class);
......
......@@ -6,10 +6,8 @@ import com.yanzuoguang.util.helper.DateHelper;
import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.thread.ThreadNext;
import com.yanzuoguang.util.vo.LogVo;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
......@@ -24,7 +22,7 @@ import java.util.concurrent.ConcurrentHashMap;
* @author 颜佐光
*/
@Component
public class LogLocal implements ThreadNext.Next, InitializingBean, ApplicationContextAware {
public class LogLocal implements ThreadNext.Next, InitializingBean {
/**
* 超时状态
*/
......@@ -37,30 +35,12 @@ public class LogLocal implements ThreadNext.Next, InitializingBean, ApplicationC
/**
* 日志基础
*/
@Autowired
private LogBase logBase;
@Autowired
private CloudConfig cloudConfig;
/**
* Set the ApplicationContext that this object runs in.
* Normally this call will be used to initialize the object.
* <p>Invoked after population of normal bean properties but before an init callback such
* as {@link InitializingBean#afterPropertiesSet()}
* or a custom init-method. Invoked after {@link ResourceLoaderAware#setResourceLoader},
* {@link ApplicationEventPublisherAware#setApplicationEventPublisher} and
* {@link MessageSourceAware}, if applicable.
*
* @param applicationContext the ApplicationContext object to be used by this object
* @throws ApplicationContextException in case of context initialization errors
* @throws BeansException if thrown by application context methods
* @see BeanInitializationException
*/
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
logBase = applicationContext.getBean(LogBase.class);
cloudConfig = applicationContext.getBean(CloudConfig.class);
}
/**
* Invoked by a BeanFactory after it has set all bean properties supplied
* (and satisfied BeanFactoryAware and ApplicationContextAware).
......
......@@ -4,10 +4,7 @@ import com.yanzuoguang.cloud.CloudConfig;
import com.yanzuoguang.util.helper.FileHelper;
import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.vo.file.YzgFileBaseVo;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.File;
......@@ -18,29 +15,11 @@ import java.io.File;
* @author 颜佐光
*/
@Component
public class YzgFileConfig implements ApplicationContextAware {
public class YzgFileConfig {
@Autowired
private CloudConfig cloudConfig;
/**
* Set the ApplicationContext that this object runs in.
* Normally this call will be used to initialize the object.
* <p>Invoked after population of normal bean properties but before an init callback such
* as {@link InitializingBean#afterPropertiesSet()}
* or a custom init-method. Invoked after {@link ResourceLoaderAware#setResourceLoader},
* {@link ApplicationEventPublisherAware#setApplicationEventPublisher} and
* {@link MessageSourceAware}, if applicable.
*
* @param applicationContext the ApplicationContext object to be used by this object
* @throws ApplicationContextException in case of context initialization errors
* @throws BeansException if thrown by application context methods
* @see BeanInitializationException
*/
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.cloudConfig = applicationContext.getBean(CloudConfig.class);
}
/**
* 初始化视频
*
......
......@@ -9,10 +9,8 @@ import com.yanzuoguang.util.helper.JsonHelper;
import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.vo.file.YzgFileMoveReqVo;
import com.yanzuoguang.util.vo.file.YzgFileVideoImageReqVo;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
......@@ -23,38 +21,19 @@ import java.util.Date;
* @author 颜佐光
*/
@Component
public class YzgFileProcedure implements InitializingBean, ApplicationContextAware {
public class YzgFileProcedure implements InitializingBean {
public static final String YZG_REMOVE_TEMP_FOLDER = "YZG_REMOVE_TEMP_FOLDER";
public static final String YZG_MOVE_FILE = "YZG_MOVE_FILE";
public static final String YZG_CONVERT_IMAGE = "YZG_CONVERT_IMAGE";
public static final String YZG_CONVERT_VIDEO = "YZG_CONVERT_VIDEO";
private MqService mqService;
/**
* 缓存24小时
*/
private MemoryCache<Boolean> folderCache = new MemoryCache<>(24 * 60 * 60);
/**
* Set the ApplicationContext that this object runs in.
* Normally this call will be used to initialize the object.
* <p>Invoked after population of normal bean properties but before an init callback such
* as {@link InitializingBean#afterPropertiesSet()}
* or a custom init-method. Invoked after {@link ResourceLoaderAware#setResourceLoader},
* {@link ApplicationEventPublisherAware#setApplicationEventPublisher} and
* {@link MessageSourceAware}, if applicable.
*
* @param applicationContext the ApplicationContext object to be used by this object
* @throws ApplicationContextException in case of context initialization errors
* @throws BeansException if thrown by application context methods
* @see BeanInitializationException
*/
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
mqService = applicationContext.getBean(MqService.class);
}
@Autowired
private MqService mqService;
/**
* Invoked by a BeanFactory after it has set all bean properties supplied
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment