@Component
Class A {
public String methodA() {
return methodB();
}
@Publish
public String methodB() {
return "abc";
}
}
@Component
@Aspect
public class PublishEvents {
@AfterReturning(value = "@annotation(Publish)", returning = "retVal")
public void sendEvent(JoinPoint joinPoint, Object retVal) {
system.out.println("sending event");
}
}
So I have an aspect class PublishEvents
defined with AfterReturning
Advice. This advice gets executed when I use @Publish
which is a custom defined annotation, over methodA
of class A but it does not get executed when I put it over methodB
of class A. Note that methodB
is called from methodA
.
Can someone tell me what I am missing here?