Execution connection points for matching method execution
- Execution (Public * * (..))
- Execution (* set* (..))
- Execution (* com.xyz.service.accountservice.* (..))
- Execution (* com.xyz.service). (..))
- Execution (* Com.xyz.service ... (..))
- Within (com.xyz.service.*) (only in Spring AOP)
- Within (Com.xyz.service. *) (only in Spring AOP)
- This (Com.xyz.service.AccountService) (only in Spring AOP)
- ....
For a few examples:
- Execution (Public * * (..)) When a pointcut is executed for all public methods
- Execution (* set* (..)) The Pointcut is the method at which all set start is executed
- Execution (* com.xyz.service.accountservice.* (..)) When a pointcut is executed for all methods in the Accountservice class
- Execution (* com.xyz.service). (..)) When a pointcut is executed for all methods under the Com.xyz.service package
- Execution (* Com.xyz.service ... (..)) When a pointcut is executed for all methods under the Com.xyz.service package and its child packages
- Within (com.xyz.service.*) (only in Spring AOP)
- Within (Com.xyz.service. *) (only in Spring AOP) within used to match execution methods within the development type
- This (Com.xyz.service.AccountService) (only in Spring AOP) This is used to match the execution method of the current AOP proxy object type
Other
- Target (Com.xyz.service.AccountService) (only in Spring AOP) target is used to match the execution method of the current target object type
- Args (java.io.Serializable) (only in Spring AOP) args is used to match the currently executing method of the passed parameter to the specified type of execution method
annotation-based matching
- @target (Org.springframework.transaction.annotation.Transactional) (only in Spring AOP)
- @within (Org.springframework.transaction.annotation.Transactional) (only in Spring AOP)
- @annotation (Org.springframework.transaction.annotation.Transactional) (only in Spring AOP)
- @args (com.xyz.security.Classified) (only in Spring AOP)
Realize:
<aop:config> <aop:pointcut id= "businessservice" expression= "Execution (* com.aop.schema). (..))" > </aop:pointcut></aop:config>
Example:
Create a new two class
Package com.aop.schema;/** * * Slice class * */public class Myaspect {}
Package com.aop.schema;/** * * Business class * */public class Apsectbiz {}
XML configuration:
<?xml version= "1.0" encoding= "UTF-8"?> <beans xmlns= "Http://www.springframework.org/schema/beans" Xmlns:xs I= "Http://www.w3.org/2001/XMLSchema-instance" xmlns:aop= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP" Xmlns:co ntext= "Http://www.springframework.org/schema/context" xsi:schemalocation= "Http://www.springframework.org/schema /beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd HTTP://WWW.SPRINGFRAMEWORK.O Rg/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd "> <bea n id= "Myaspect" class= "Com.aop.schema.MyAspect" ></bean> <bean id= "apsectbiz" class= "com.aop.schema.Ap Sectbiz "></bean> <aop:config> <aop:aspect id=" MYASPECTAOP "ref=" Myaspect "> <aop:pointcut id= "mypointcut" expression= "Execution (* com.aop.schema.apsectbiz.* (..))"/> </aop:aspec T> </aop:config></beans>
Spring Learning (schema-based)---AOP (configuration-based AOP implementation)--Configuring Pointcuts Pointcut