Common notation for spring pointcut expressions

Source: Internet
Author: User

Execution of any public method:

Execution (Public * * (.. ))

The execution of a method whose name starts with a set:

Execution (* set* (.. ))

Accountservice the execution of any method defined by the interface:

Execution (* com.xyz.service.accountservice.* (.. ))

Execution of any method defined in the service package:

Execution (* com.xyz.service.*.* (.. ))

Execution of any method defined in a service package or its child packages:

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 its 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)

Any connection point that implements the target object of the Accountservice interface (only method execution in Spring AOP):

Target (Com.xyz.service.AccountService)

Either one takes only one parameter, and the arguments passed in at run time are the connection points of the Serializable interface (only method execution in Spring AOP):

Args (java.io.Serializable)

Note that the pointcut given in the example differs from execution (* * (Java.io.Serializable)), and the args version only matches when the parameter is Serializable when it is run dynamically, and execution The version declares a parameter of only one Serializable type in the method signature when matching.

There is an arbitrary connection point in the target object that @Transactional annotations (only method execution in Spring AOP):

@target (org.springframework.transaction.annotation.Transactional)

The type of any target object declaration has a connection point that @Transactional annotations (only method execution in Spring AOP):

@within (org.springframework.transaction.annotation.Transactional)

Any one of the methods executed has a connection point @Transactional annotations (only method execution in Spring AOP):

@annotation (org.springframework.transaction.annotation.Transactional)

Either one accepts only one parameter, and the parameter type passed in by the runtime has a connection point that @Classified annotations (only method execution in Spring AOP):

@args (com.xyz.security.Classified)

Any connection point above the spring bean named TradeService (only method execution in spring AOP):

Bean (TradeService)

Any *Service connection point above a spring bean whose name matches a wildcard expression (only method execution in spring AOP):

Bean (*service)

Among them,,,,, this tagart args @target @with , @annotation and @args in the binding form are more commonly used.

Reprint statement: This article is from the "Lava" blog, spring pointcut expressions commonly used in the wording.

Common notation for spring pointcut 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.