Joinpoints
Connection points, in layman's words, are those that want to be crosscutting, including methods, constructors (Constructor), Fields (field), Exceptions (Exception), Object and class initialization (objects and classes)
Pointcuts
Pointcuts are defined rules that are used to match the target connection point, where the pointcut consists of two parts advice (how to cut), expression (the regular expressions)
// expression Format throws?)
All of the above sections are optional except returning type and name and Paramter, and the returning type determines that the matching method must have a specified return type, which can be used to indicate any return type
The fully qualified class name is matched only if the method returns the specified type, and the name matches the method name, which can be used to match all or part of the method name
Parameters match is complex: () match an invisible parameter method, (..) Match any number of parameter methods (0~n), match with an arbitrary type of formal parameter method
(*,string) match with two parameters, first any type, second must be String type
Instance
Execution (Public * *(..)): Any public method
Execution (* set* (..)): Method name any method beginning with set
Execution (* com.xyz.service). (..)) : Any method under the service package
Execution (* Com.xyz.service ... (..)) : Any method under Service package or sub-package
Execution (public void Myclass.mymethod (String)): MyMethod method of MyClass class, method public access, void return value, parameter only one and String type
Execution (void Myclass.mymethod (..)): MyMethod method for MyClass class, arbitrary access, return value void, arbitrary parameter
Execution (* Myclass.mymethod (..)): MyMethod method for MyClass class, arbitrary return value, arbitrary parameter
Execution (* myclass.mymethod* (..)): Method with MyMethod beginning of MyClass class, arbitrary return value, arbitrary parameter
Execution (* myclass.mymethod* (String,..)): A method starting with the MyMethod of the MyClass class, any return value, the first parameter type is a String
Execution (* *.mymethod (..)): MyMethod method under any class execution (MyClass.New ()): No parameter constructor for any MyClass class
Execution (MyClass.New (..)): Arbitrary MyClass class of any parametric constructor execution (myclass+.new (..)): arbitrary MyClass or its subclass constructor
Execution (Public * com.mycompany). * * (..)): Com.mycompany All public methods for all classes under any sub-package
Spring AOP can only cut methods (that is, methods in any connection point), ASPECTJ can cut any member (any connection point, including class/object initialization block, field, method, constructor)
Within (com.xyz.service.*): Any connection point under service package
Within (Com.xyz.service. *): Any connection point under Service package or sub-package
This (Com.xyz.service.AccountService):AccountService接口的代理实现里的任意连接点
Target (Com.xyz.service.AccountService): The destination object implements theAccountService接口的任意连接点
Args (java.io.Serializable): Only one parameter and parameter at run time is any connection point of type Serializable
@target (org.springframework.transaction.annotation.Transactional): The target object has a @transactional annotation any connection point
@within (org.springframework.transaction.annotation.Transactional): The declaration type of the target object has a @transactional annotation arbitrary connection point
@annotation (org.springframework.transaction.annotation.Transactional): Execution method has a @transactional annotation for any connection point
@args (com.xyz.security.Classified): Any connection point with only one parameter and arguments with @classified annotations at run time parameters
Bean (TradeService): Spring Bean name istradeService的任意连接点
Bean (*service): The name of the Spring Bean is any connection point at the end of the Service
//表达式可以使用|| && !进行组合 在XML下就是 or and not
Execution (* com.xyz.myapp.service. . And this (service)//xml
Execution (* com.xyz.myapp.service. . && This (service)//java
An example of an expression of ASPECTJ