Simple description of spring aop expression

 

  • Simple description of spring aop expression
Example 1:
<aop:config>
       <aop:pointcut id="userDAO"
           expression="execution(public * cn.dao.IUserDAO.*(..))" />
       <aop:advisor advice-ref="tx" pointcut-ref="userDAO"/>
</aop:config>

in the code above

public is a method for specifying public, or it can be written directly as: execution(* cn.dao.IUserDAO.*(..))
* any return value
cn.dao.IUserDAO.* Any method of the class in the specified directory
cn.dao.IUserDAO.insert* All methods starting with insert in the class in the specified directory
cn.dao.. Any method of any class in the specified directory
(..) any parameter
Full text: Match all methods under cn.dao.IUserDAO

There can be multiple methods in execution, for example:

 

execution(* com.action.userinfoAction..*(..))&&execution(* com.action.memberAction..*(..))&&!execution(* get*(..))&&!execution(* set*(..))

 

Example 2:

<aop:config>

<aop:advisor pointcut="execution(* *..*ServiceImpl.*(..))" advice-ref="transactionAdvice" />

</aop:config> 

 

in the above code

 

The first sign (*) any return value

The second symbol (*..) any package (test/com.mangocity.test)

The third symbol ( *ServiceImpl ) is any class ending in ServiceImpl

Fourth symbol (.*) Arbitrary method

The fifth symbol (..) Arbitrary parameter

Full text: Match all methods under any class whose package ends with ServiceImpl

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326980511&siteId=291194637