I'm trying to intercept all methods from the classes that extends certain class. I defined my aspect like this:
@Aspect
public class LogMethodAspect implements Serializable {
@Around("execution(* org.custom.es.GenericComponent+.*(..))") {
public Object measureExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
long startTime = System.currentTimeMillis();
Object result = joinPoint.proceed();
System.out.println(joinPoint+ " -> " + (System.currentTimeMillis() - startTime) + " ms");
return result;
}
}
The aspect declaration in Spring:
<bean id="logMethodAspect" class="org.custom.es.LogMethodAspect" />
The Superclass
package org.custom.es;
public abstract class GenericComponent {
//some code
}
An exampe of a subclass
package org.implementation.es;
public class InformationComponent extends GenericComponent {
//some code
}
However, it never intercepts it. What I figured is:
- The bean is being created.
- If I change the value of the @Around annotation to an annotated-based declaration (like @annotation(myanotation), and use that annotation on a subclass, it works properly, but I can't go an annotate every subclass (more could be created in the future).
I tried using the option given in this question How to specify single pointcut for all classes that extend a specific class but it doesn't work either.
Thanks for any help