Commit c8030ef8 authored by yanzg's avatar yanzg

修复等待时间

parent 24f81781
...@@ -4,13 +4,10 @@ import com.yanzuoguang.cloud.CloudConfig; ...@@ -4,13 +4,10 @@ import com.yanzuoguang.cloud.CloudConfig;
import com.yanzuoguang.cloud.aop.LogFeign; import com.yanzuoguang.cloud.aop.LogFeign;
import com.yanzuoguang.util.thread.ThreadNext; import com.yanzuoguang.util.thread.ThreadNext;
import com.yanzuoguang.util.vo.LogVo; 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.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.*;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Optional;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
/** /**
...@@ -19,43 +16,23 @@ import java.util.concurrent.LinkedBlockingQueue; ...@@ -19,43 +16,23 @@ import java.util.concurrent.LinkedBlockingQueue;
* @author 颜佐光 * @author 颜佐光
*/ */
@Component @Component
public class LogBase implements ThreadNext.Next, InitializingBean, ApplicationContextAware { public class LogBase implements ThreadNext.Next, InitializingBean {
/** /**
* 缓存队列 * 缓存队列
*/ */
protected volatile LinkedBlockingQueue<LogVo> cache = new LinkedBlockingQueue<>(); protected volatile LinkedBlockingQueue<LogVo> cache = new LinkedBlockingQueue<>();
@Autowired private final CloudConfig cloudConfig;
private CloudConfig cloudConfig; private final LogFeignBase logFeign;
private LogFeignBase logFeign; public LogBase(CloudConfig cloudConfig, LogFeignBase logFeignBase, Optional<LogFeign> logFeign) {
this.cloudConfig = cloudConfig;
/** if (logFeign.isPresent()) {
* Set the ApplicationContext that this object runs in. this.logFeign = logFeign.get();
* Normally this call will be used to initialize the object. } else {
* <p>Invoked after population of normal bean properties but before an init callback such this.logFeign = logFeignBase;
* 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 {
// 获取个人实例话的对象
try {
this.logFeign = applicationContext.getBean(LogFeign.class);
} catch (Exception ex) {
System.err.println("请添加处理日志服务,实现LogFeign接口!"); System.err.println("请添加处理日志服务,实现LogFeign接口!");
} }
// 默认实例话对象
if (this.logFeign == null) {
this.logFeign = applicationContext.getBean(LogFeignBase.class);
}
} }
/** /**
......
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