Spring Execution Expressions

Source: Internet
Author: User

Execution (Modifiers-pattern ret-type-pattern declaring-type-pattern? Name-pattern (Param-pattern) Throws-pattern?)
All parts are optional except the return type pattern (Ret-type-pattern in the code snippet above), the name pattern, and the parameter pattern. The return type mode determines that the return type of the method must match one connection point in turn. The most frequent return type pattern you will use is *, which represents the matching of any return type. A full-qualified type name will only match the method that returns the given type. The name pattern matches the method name. You can use the * wildcard character as all or part of the naming pattern. The parameter pattern is slightly more complex: () matches a method that does not accept any parameters, and (..) matches a method that accepts any number of parameters (0 or more). The pattern (*) matches a method that accepts a parameter of any type. Mode (*,string) matches a method that accepts two parameters, the first of which can be any type, and the second must be of type String.

Some examples of common pointcut expressions are given below.

Execution of any public method:
Execution (Public * * (..)) 
Any execution of a method that begins with "set":
Execution (* set* (..)) 
Execution of any method of the Accountservice interface:
Execution (* com.xyz.service.accountservice.* (..)) 
The execution of any method defined in the service package:
Execution (* com.xyz.service.*.* (..)) 
The execution of any method defined in a service package or a child package:
Execution (* com.xyz.service). *.*(..)) 
Any connection point in the service package (only method execution in spring AOP):
Within (com.xyz.service.*) 
Any connection point in the service package or child package (only method execution in spring AOP):
Within (Com.xyz.service. *) 
Any connection point that implements the proxy object for the Accountservice interface (only method execution in spring AOP):
This (Com.xyz.service.AccountService)
The ' This ' is used more in the binding form:-Please refer to the section in the following discussion notice about how to make the proxy object accessible within the notification body. 
Any connection point that implements the target object of the Accountservice interface (only method execution in spring AOP):
Target (Com.xyz.service.AccountService)
' Target ' is used more in the binding form:-Please refer to the section on how to make the target object accessible within the notification body in the following section of the discussion notice. 
Any one that takes only one parameter and the parameters passed in at run time implements the connection point for the Serializable interface (only method execution in spring AOP) 
Args (java.io.Serializable)
' args ' is used more in the binding form:-Please refer to the section in the following discussion notice about how to make a method parameter accessible within the notification body. Note that the pointcut given in the example is different from execution (* * (java.io.Serializable)): Args only matches when the incoming parameter is serializable (Serializable) at dynamic runtime, and execution The type of the signature declaration that passed in the parameter implements the Serializable interface when it is matched. 
Any connection point in the target object that has a @Transactional annotation (only method execution in spring AOP) 
@target (org.springframework.transaction.annotation.Transactional)
' @target ' can also be used in the binding form: Please refer to the section on how to make the annotation object accessible within the notification body in the following section of the discussion notice. 
The type of any target object declaration has a connection point @Transactional annotations (only method execution in spring AOP)
@within (org.springframework.transaction.annotation.Transactional)
' @within ' can also be used in the binding form:-Please refer to the section in the following discussion notice about how to make the annotation object accessible within the notification body. 
Any one of the methods executed has a connection point @Transactional annotation (only method execution in spring AOP) 
@annotation (org.springframework.transaction.annotation.Transactional)
' @annotation ' can also be used in the binding form:-Please refer to the section in the following discussion notice about how to make the annotation object accessible within the notification body. 
Any one accepts a parameter, and the passed-in parameter is implemented at run-time type @Classified annotation connection point (only method execution in spring AOP) 
@args (com.xyz.security.Classified)


Spring Execution Expressions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.