I am getting started with AOP for the first time.
I have my first aspect as follows:
@Aspect
public class SyncLoggingAspect {
private final Logger logger = Logger.getLogger(this.getClass());
@Before("execution(public * *(..))")
public void anyPublic() {
System.out.println("HIT POINTCUT");
}
}
This sucessfully proceeds to be invoked on any method call which is public. However when I change it to this:
@Before("execution(public * doPoll(..))")
public void anyPublic() {
System.out.println("HIT POINTCUT");
}
I would expect it to work on any public method called "doPoll", yet when a method such as this is called nothing happens:
public class GmailContactPoller extends ContactPoller<GoogleUser, ContactPusher<GoogleUser>> {
Logger logger = Logger.getLogger(this.getClass());
@Override
public List<? extends ContactPusher<GoogleUser>> doPoll() throws PollException {
...
}
}
Is there something I am missing with the EL syntax? Or is this something to do with the inheritance hierarchy? The superclass method of doPoll is abstract in an abstract class called Poller. Does not having an interface cause problems?
Edit: I just noticed my IDE enables spring aspect tooling, and now I have the following compiler warning by the method:
"Description Resource Path Location Type advice defined in datasync.aop.aspects.SyncLoggingAspect has not been applied [Xlint:adviceDidNotMatch] SyncLoggingAspect.java /DataSync/src/main/datasync/aop/aspects"
Yes we can. Because we are accessing the class level members.
Spring AOP Proxies and aspectJ had some differences mainly:
You can have a look to sections 8.4 & 8.5 of Spring's Documentation for more information.
Currently you have two solutions:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With