我在定义我的方面时遇到了一些问题。我有一堆实体,我想在其中分析 get 方法,所以我编写了以下切入点和方法
@Pointcut("execution(* tld.myproject.data.entities.*.get*()")
public void getEntityProperty() {}
@Around("getEntityProperty()")
public Object profileGetEntityProperty(ProceedingJoinPoint pjp) throws Throwable {
long start = System.currentTimeMillis();
String name = pjp.getSignature().getName();
Object output = pjp.proceed();
long elapsedTime = System.currentTimeMillis() - start;
if(elapsedTime > 100)
System.err.println("profileGetEntityProperty: Entity method " + name + " execution time: " + elapsedTime + " ms.");
return output;
}
我已经在我的配置中打开了编织,并且将方面编织到业务层中工作得很好。我的切入点写对了吗?或者是否有一些关于实体的东西使它们不可编织?(我的实体在类定义之前以 @Entity 为前缀)
干杯
尼克