Hi, I am having problems with pointcuts definitions using AspectJ.
This does work:
@Before("execution(public * *(..))")
public void printMessage() {
System.out.println("in printMessage");
}
Yet this does not:
@Pointcut("execution(public * *(..))")
public void allMethodCalls() { }
@Before("allMethodCalls()")
public void printMessage() {
System.out.println("in printMessage");
}
The following exception is thrown when loading Spring:
java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut allMethodCalls
Similarly, the following does not work:
@Pointcut("execution(* doSomeOperation(..))")
public void businessMethods() { }
@Around("businessMethods()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
System.out.println("Going to call the method.");
Object output = pjp.proceed();
System.out.println("Method execution completed.");
return output;
}
Any help is very much appreciated


Reply With Quote