Entity Aspect (in Spring)
- by niklassaers
Hi guys,
I'm having a bit of a problem defining my aspects. I've got a bunch of entities that I'd like to profile the get-methods in, so I've written the following pointcut and method
@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;
}
I've got weaving turned on in my configuration, and aspects weaving into the business layer work just fine. Is my pointcut correctly written? Or is there something about entities that make them non-weavable? (my entity is prefixed with @Entity before the class definition)
Cheers
Nik