Reputation: 1533
I have a simple example of an aspectj implementation in a spring boot app and I'm trying to get each different method working.
If I use the following
@Before("execution(* com.example.test.controllers.ProductController.deleteProduct(..))")
public void specificInterception() {
System.out.println("pointcut interception working");
}
This works fine, and I can see a console output of the println
However, if I use
@Pointcut("execution(* com.example.test.controllers.ProductController.deleteProduct(..))")
public void specificInterception() {
System.out.println("pointcut interception working");
}
It fails to trigger. Why is this not working?
Upvotes: 0
Views: 82
Reputation: 44757
A method annotated with @Pointcut
on its own doesn't do anything. It only allows you re-use the same expression multiple times rather than having to redeclare it. I'm not even sure if the method body of such a method will be invoked.
In your case, you can use your pointcut like this:
@Pointcut("execution(* com.example.test.controllers.ProductController.deleteProduct(..))")
public void specificPointcut() {}
@Before("specificPointcut()")
public void specificInterception() {
System.out.println("pointcut interception working");
}
Upvotes: 2