Quantcast
Channel: Spring AOP: Annotation on any method called x not working - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Spring AOP: Annotation on any method called x not working

$
0
0

I am getting started with AOP for the first time.

I have my first aspect as follows:

@Aspectpublic 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 Typeadvice defined in datasync.aop.aspects.SyncLoggingAspect has not been applied [Xlint:adviceDidNotMatch] SyncLoggingAspect.java /DataSync/src/main/datasync/aop/aspects"


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images