![Hands-On High Performance with Spring 5](https://wfqqreader-1252317822.image.myqcloud.com/cover/793/36699793/b_36699793.jpg)
上QQ阅读APP看书,第一时间看更新
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=1739150305-TdSgI7Sg0VpMuDQvSQ3nJrwgkIR4Vk5d-0-c17960e6b63afdcb792c8c7f4f8947b7)
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=1739150305-pfzmNemyLlrHp5YSzGcEV7rX87OAyegm-0-ce2a3cd424600abd173990895f56e4db)
Execution join point pattern