问题描述
我创建了一个本地线程,如下所示:
@Bean(destroyMethod = "destroy")
public ThreadLocalTargetSource threadLocalTargetSource() {
ThreadLocalTargetSource result = new ThreadLocalTargetSource();
result.setTargetBeanName("userActionLogForThread");
return result;
}
@Primary
@Bean(name = "proxiedThreadLocalTargetSource")
public Proxyfactorybean proxiedThreadLocalTargetSource(
ThreadLocalTargetSource threadLocalTargetSource) {
Proxyfactorybean result = new Proxyfactorybean();
result.setTargetSource(threadLocalTargetSource);
return result;
}
@Bean(name = "userActionLogForThread")
@Scope(scopeName = "prototype")
public UserActionLogForThread UserActionLog() {
return new UserActionLogForThread();
}
并计算使用@Aspect花费的时间。
我将开始时间设置为@Before:
userActionLogForThread.setTiMetaken(System.currentTimeMillis());
然后计算@AfterThrowing和@AfterReturning的时间:
userActionLogForThread.setTiMetaken(System.currentTimeMillis()-userActionLogForThread.getTiMetaken());
我的问题是userActionLogForThread.getTiMetaken()
有时在进入@AfterThrowing时为0。
但是,userActionLogForThread中的其他参数也有价值。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)