How do I write a Spring @AspectJ point-cut (@Pointcut
) expression that matches all public methods in a class, regardless of their argument list?
I want an aspect that has @AfterThrowing
point-cuts for all the public methods of a particular class that have a particular annotation, @MyAnnotation
(similar to what someone else wanted in a previous SO question). At present my aspect is like this:
@Aspect
public final class ServiceDataAccessExceptionReporter {
@Pointcut("execution(public * com.example.Service.*(..)) && @annotation(com.example.MyAnnotation))")
public void annotatedMethod() {}
@AfterThrowing(pointcut = "annotatedMethod()", throwing = "exception")
public void reportException(final DataAccessException exception) {
...
}
}
The Eclipse Spring plug-in indicates (using arrow annotations in the source-code windows) this as correctly advising a method com.example.Service.getNames()
. But it does not indicate that methods that have arguments, such as com.example.Service.getTimes(String name)
, have been advised.
Is that because the method with the @Pointcut
annotation has no arguments? How can I make the point-cut be all methods, regardless of their argument list? Or must I have a separate @Pointcut
for each kind of argument list in my com.example.Service
class?