【发布时间】:2018-06-17 12:29:11
【问题描述】:
下面是我的 aspectJ 类的代码
public aspect TestAspect {
String str;
long time;
pointcut callLoggingAspect():call(* com.dilip.bdp..*.*(..));
before() : callLoggingAspect() {
str = thisJoinPoint.getSignature().toShortString();
time = System.nanoTime();
}
after() : callLoggingAspect() {
System.out.println(thisJoinPoint.getSignature().toShortString()+":Before="+str);
System.out.println("Time taken by method "+thisJoinPoint.getSignature().toShortString()+" to execute ="+(System.nanoTime()-time));
}
}
我需要的是在 before() 中捕获一些东西,并在 after() 中使用该值用于相同的方法。 我正在设置一些值的当前代码是类级变量,在多线程环境中不起作用。 请建议我如何实现它
【问题讨论】:
标签: java aop aspectj spring-aop