Defining pointcuts
As we learned before, pointcuts define a point where advice should be applied. Spring AOP uses AspectJ's expression language to define a point where advice should be applied. The following are the set of pointcut designators supported in Spring AOP:
![](https://epubservercos.yuewen.com/C5B52B/19470392601561206/epubprivate/OEBPS/Images/004.jpg?sign=1738947765-uKwV4yxJyt6w4sn2PN7TYADsjZyOD70m-0-e93c45d7ad8e182cb28ea2fb7e363dd3)
Let's see how to write the point expression using the execution designator:
- Using execution(<method-pattern>): Method matching to the pattern would be advised. The following is the method pattern:
[Modifiers] ReturnType [ClassType]
MethodName ([Arguments]) [throws ExceptionType]
- To create composite pointcuts by joining other pointcuts, we can use the &&, ||, and ! operators (these mean AND, OR, and NOT, respectively).
In the preceding method pattern, anything defined in [ ] is optional. Values without [ ] are mandatory to define.
The following diagram will illustrate point expression using the execution designator to apply advice whenever the findAccountById() method is executed:
![](https://epubservercos.yuewen.com/C5B52B/19470392601561206/epubprivate/OEBPS/Images/Chapter_7.jpg?sign=1738947765-vNGdjujnGJLGLmLkMZOLnKdkXLNxYhWR-0-64875d0ab64627b5d19ad7f1cb0c9b78)
Execution join point pattern