【发布时间】:2017-03-16 11:33:45
【问题描述】:
我正在尝试记录使用自定义接口注释的方法的执行时间。
我正在使用 Spring AOP。
但这似乎不适用于内部方法。
我认为这是 Spring AOP 的限制
@Aspect
public class BusinessProfiler {
private static Log log = LogFactory.getLog(BusinessProfiler.class);
@Around("execution(* *(..)) && @annotation(TimeLog)")
public Object profile(ProceedingJoinPoint point) throws Throwable {
long start = System.currentTimeMillis();
Object result = point.proceed();
String format =
String.format("%s#%s: took [%s msec]", point.getTarget().getClass().getSimpleName(),
MethodSignature.class.cast(point.getSignature()).getMethod().getName(),
System.currentTimeMillis() - start);
log.info(format);
return result;
}
}
除了 Spring AOP 有什么替代品吗
【问题讨论】:
标签: java spring aspectj spring-aop