1. Configure Bean
<!--define a generic bean instance that will be used as the aspect bean--><bean id= "Fouradvicebean" class= " Org.crazyit.app.aspect.FourAdviceTest "/><!--again defines a normal bean instance that will be--><bean id= as a aspect bean" Secondadvicebean "class=" org.crazyit.app.aspect.SecondAdviceTest "/><bean id=" Hello "class=" Org.crazyit.app.service.impl.HelloImpl "/><bean id=" World "class=" Org.crazyit.app.service.impl.WorldImpl "/ >
2, configure AOP
<aop:config>,
<!--convert Fouradvicebean to tangent bean The new name is: fouradviceaspect Specifies that the plane has a priority of 2--
<aop:aspect id= "Fouradviceaspect" ref= "Fouradvicebean" order= "2";
<!--define an after enhancement processing, Specify the pointcut expression directly, using the release () method in the slice bean as the enhanced processing method-->
<aop:after pointcut= "Execution (* Org.crazyit.app.service.impl.*.* (..)) " method= "Release"/>
<!--define a before enhanced processing, directly specify Pointcut expressions take the authority () method in the slice bean as an enhanced processing method--
<aop:before pointcut= "Execution (* org.crazyit.app.service.impl.*.* (..))" method= "authority"/>
<!--define a afterreturning enhanced processing, directly specify Pointcut expressions use the log () method in the slice bean as an enhanced processing method-->
<aop: After-returning pointcut= "Execution (* org.crazyit.app.service.impl.*.* (..))" method= "Log" returning= "RVT"/
<!--define a around enhancement process that directly specifies the Pointcut expression PROCESSTX () method in the slice bean as an enhanced processing method-->
<aop:around pointcut= " Execution (* org.crazyit.app.service.impl.*.* (..)) " method=" Processtx "/>
</aop:aspect>
<!--The new name of the slice bean that transforms secondadvicebean into a tangent bean is: secondadviceaspect Specifies that the slice has a priority of 1, and that the enhanced processing in that slice is first woven-in
<aop:aspect id= "Secondadviceaspect" ref= "Secondadvicebean" order= "1" >
<!--defines a before enhancement process that must be of type string (determined by the type of MSG parameter in the Authority method declaration)-
<aop:before pointcut= "Execution (* org.crazyit.app.service.impl.*.* (..)) and args (aa) "method=" authority "/>
</aop:aspect>
</aop:config>
3. Another:
<aop:pointcut.../> elements can be used to define pointcuts, <aop:pointcut id= "xxx_id" expression= "Execution (* org.crazyit.app.service.impl.*.* (..))"/>
If as a <aop:aspect.../> sub-element it is only valid for that slice
<aop:config.../> a child element that can be shared by multiple slices, then
<aop:after pointcut= "Execution (* org.crazyit.app.service.impl.*.* (..))" method= "Release"/>
Can be changed to:
<aop:after pointcut-ref= "xxx_id" method= "release"/>
How Spring AOP is managed based on XML configuration files