Spring 【Aspectj】 pojo+xml 配置方式


<!--
观众(通知) --> <bean id="audience" class="aspectj.Audience"/> <!-- 通过配置元素 将 pojo变成一个切面类 --> <aop:config> <aop:aspect ref="audience"> <!-- 引入通知 ,types-matching:指定给哪些类增加新的属性与方法 implement-interface: 新接口 default-impl:新接口的默认实现--> <aop:declare-parents types-matching="aspectj.Singer" implement-interface="aspectj.IHeight" default-impl="aspectj.HeightImpl"/> <!-- 定义切入点, (重用) --> <aop:pointcut id="audiencePointcut" expression="execution (* aspectj.Performer.*(..))"/> <!-- 各种切入 --> <aop:before method="takeSeats" pointcut-ref="audiencePointcut"/> <aop:before method="turnOffCellPhone" pointcut-ref="audiencePointcut"/> <aop:after-throwing method="demandRefund" pointcut-ref="audiencePointcut" throwing="e"/> <aop:after-returning method="applaud" pointcut-ref="audiencePointcut" returning="ret"/> <aop:after method="goHome" pointcut-ref="audiencePointcut"/> <aop:around method="doWatch" pointcut-ref="audiencePointcut"/> </aop:aspect> </aop:config>

 

posted @ 2013-12-17 00:39  聆听自由  阅读(252)  评论(0编辑  收藏  举报