AOP
要使用aop相关功能,
如果在配置文件中开启,则加入配置 <aop:aspectj-autoproxy/>
如果在java类型中开启,在在启动类上加入 @EnableAspectJAutoProxy
配置文件中进行配置
<aop:config>
在切点方法的前后执行,执行的testA.handle(),
<aop:aspect id="aspectA" ref=testA" order="3">
<aop:around pointcut="@annotation(teAnnotation)" method="handle"/>
</aop:aspect>
在切点的方法的后面执行
returning="returnParam":这个表示切点方法的返回值是这returnParam,也就是testB.handle(),的入参中有一个参数是returnParam
<aop:aspect id="aspectB" ref="testB" order="1">
<aop:pointcut id="testPointcut" expression="@annotation(MyAnnotation)"/>
<aop:after-returning returning="returnParam" method="handle" pointcut-ref="uiRenderingPointcut"/>
</aop:aspect>
</aop:config>
注意:order属性表示该切面执行的顺序,数字越小越优先执行;例如,有多个切面的且切点都是同一个方法(都是在A类的a方法前或者后执行),则order属性就可以指定,多个切面方法执行的先后顺序,如果一个切点只有一个切面,那该属性就没用