Execute (* com.sample.service.impl ... (..))
Detailed description:
Execution (), the body of the expression.
The first ""symbol indicates that the return value type is arbitrary;
Com.sample.service.impl, the package name of the service cut by AOP, which is our business part.
".." after the package name indicates the current package and subpackages.
The second ""represents the class name, that is, all classes.
. (.), indicating any method name, parentheses indicating parameters, and two dots indicating any parameter type.
Execution expression syntax format
Execute (< modifier mode >; ? & lt return to type mode >< method name mode >; (< parameter mode >) < exception mode >? )
Everything is optional except the return type mode, method name mode and parameter mode.
Example introduction
Defines the tangent point by the method name.
Execution (public * * (...))
Matches the public methods of all target classes, the first indicates the method return value type, the second indicates the method name, and "..." indicates any method that accepts parameters;
Execute (* to (...))
All methods that match the target class with the suffix To. The first ""means any method return type, and "*To" means any method name ending in To.
Defining a Tangent Point through a Class
Execute (* com.taotao.Waiter.* (..))
Matches all methods in the Waiter interface, with the first ""indicating any return type and "com.taotao.Waiter" indicating all methods in the Waiter interface.
Execute (* com.taotao.Waiter+). *(..))
Methods to match the server interface and all its implementation classes.
Define the tangent point by the package name
Note: In the package name pattern string, ""means all classes under the package, while "... * *" means all classes under the package and descendant packages.
Execute (* com.taotao.* (..))
Match all methods of all classes under the com.taotao package.
Execute (* com.taotao..* (..))
Match all methods of all classes under the com.taotao package and its descendants, such as all methods of all classes under com.taotao.user.dao and com.taotao.user.service, etc.
Execute (* com ... Dao.find*(..))
A method that matches any package name with the suffix Dao, starting with com, and the method name prefixed with find, such as com. taotao.userdao # findbyid(),com。 Taotao.dao.forumdao # findbyid (), all of which are matching tangents.
The tangent point is defined by method parameters.
The parameter selection part of the method in the tangent point expression is complicated, and wildcards such as ""and "..." can be used, where ""means any type of parameter and "..." means any type of parameter, and the number of parameters is unlimited.
Execute (* joke(String, int))
Match the joke () method in the class, with the first parameter of type String and the second parameter of type int.
Execute (* joke (string, ...))
Match the joke () method in the target class. The first parameter of this method is String, followed by any number of parameters of any type.
Common tangent expression
Matching method signature
//Matches all methods in the specified package.
Execute (* com.xys.service.* (..))
//Match all public methods in the current package.
Execute (public * UserService. *(..))
//Matches all public methods in the specified package, and the return value is a method of type int.
execution(public int com . xys . service . *(..))
//Matches all public methods in the specified package. The first parameter is String, and the return value is a method of type int.
Execution (public int com. xys.service. * (string name, ...))
Matching type signature
//Matches all methods in the specified package, excluding subpackages.
Within (com.xys.service.*)
//Matches all methods in the specified package, including subpackages.
At (com.xys.service..* *)
//Match the method of the specified class in the current package.
Within the scope of (user service)
//Match the methods implemented in all implementation classes of the interface.
Within (UserDao+)
Matching Bean name
//Matches all methods in the bean that end with the specified name.
Bean (service)
Tangent point expression combination
//Match bean ending in Service or ServiceImpl.
bean( Service || *ServiceImpl)
//Match the Bean whose name ends in Service and is in the com.xys.service package.
Bean (service) and & are in (com.xys.service).