![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=1739280721-vtvF90HyTgbPXTdEnYGZC8QuPbSB3j6s-0-27a0d5b278a62709fd1ab8ad2a3e2fb6)
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=1739280721-ErYkL9VHmqZ98de7OlflJwgswjhgHqKX-0-7c3e2aa74dc5c521f3613d7b6b0210ee)
Execution join point pattern