學習筆記之aop基於IOC容器的配置(MSTzhang)
阿新 • • 發佈:2019-01-28
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<bean id="atithemeticCalculator2" class="com.zhangyisheng.aopxml.AtithemeticCalculatorIMP"></bean>
<bean id="aopCut" class="com.zhangyisheng.aopxml.AopCut"></bean>
<aop:config>
<aop:pointcut expression="execution(* com.zhangyisheng.aopxml.AtithemeticCalculator2.*(*,*))" id="pointcut"></aop:pointcut>
<aop:aspect ref="aopCut" order="1">
<aop:before method="beforeMethod" pointcut-ref="pointcut"/>
<aop:after method="afterMethod" pointcut-ref="pointcut"/>
<aop:after-returning method="afterReturning" pointcut-ref="pointcut" returning="result"/>
<aop:after-throwing method="afterThrowing" pointcut-ref="pointcut" throwing="e"/>
</aop:aspect>
</aop:config>
</beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<bean id="atithemeticCalculator2" class="com.zhangyisheng.aopxml.AtithemeticCalculatorIMP"></bean>
<bean id="aopCut" class="com.zhangyisheng.aopxml.AopCut"></bean>
<aop:config>
<aop:pointcut expression="execution(* com.zhangyisheng.aopxml.AtithemeticCalculator2.*(*,*))" id="pointcut"></aop:pointcut>
<aop:aspect ref="aopCut" order="1">
<aop:before method="beforeMethod" pointcut-ref="pointcut"/>
<aop:after method="afterMethod" pointcut-ref="pointcut"/>
<aop:after-returning method="afterReturning" pointcut-ref="pointcut" returning="result"/>
<aop:after-throwing method="afterThrowing" pointcut-ref="pointcut" throwing="e"/>
</aop:aspect>
</aop:config>
</beans>