<!-- 利用正则表达式匹配 插入--> <bean id="regAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"> <property name="patterns" value=".*business1,.*business2"/> <property name="advice" ref="logBeforeDev"/> </bean> <!-- 利用introduction动态切入新方法 --> <bean id="otherAdvisor" class="org.springframework.aop.support.DefaultIntroductionAdvisor"> <constructor-arg ref="otherIntroduction"/> <constructor-arg value="com.hzp.interfaces.OtherInterface"/> </bean> <bean id="proxy" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces" value="com.hzp.interfaces.CInterface"/> <property name="target" ref="bus"/> <property name="interceptorNames"> <list> <value>otherAdvisor</value> </list> </property> </bean> <!-- 自动代理 --> <bean id="autoProxy" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <property name="beanNames"> <list> <value>bus</value> </list> </property> <property name="interceptorNames" value="regAdvisor"/> </bean> <!-- 利用aop标签 --> <aop:config> <aop:aspect id="proxy2" ref="logBeforeDev2"> <aop:before pointcut="execution(* com.hzp.interfaces.CInterface.*(..))" method="before"/> </aop:aspect> </aop:config>
关于spring Aop切入的方式
猜你喜欢
转载自hzp.iteye.com/blog/1685682
今日推荐
周排行