Spring编程<七>
AOP第四种方法:
将一个POJO做成切面:需要在配置文件中
<bean id="myAdvisor" class="cn.hncu.v4.MyAdvisor"> </bean>
<aop:config>
<aop:aspect ref="myAdvisor">
<aop:pointcut expression="execution( * cn..Cat.*(..) ) " id="cut"/>
<aop:after method="aa" pointcut-ref="cut"/>
</aop:aspect>
</aop:config>
也可以只接在中间写切点语言:
<bean id="myAdvisor2" class="cn.hncu.v4.MyAdvisor2"> </bean>
<aop:config>
<aop:aspect ref="myAdvisor2">
<aop:before method="bf" pointcut="execution( * cn..Person.*(..) )"/>
<aop:around method="around" pointcut="execution( * cn..Person.run(..))"/>
</aop:aspect>
</aop:config>
演示结果: