xml方式配置AOP

<!-- 配置bean -->
<bean id = "arithmeticCalculator"
	class= "...ArithmeticCalculator"></bean>
<!-- 配置切面的bean -->
<bean id = "loggingAspect"
	class= "...LoggingAspecet"></bean>
<bean id = "vlidationAspect"
	class= "...ValidationAspect"></bean>
<!-- 配置AOP -->
<aop:config>
	<!-- 配置切点表达式 -->
	<aop:pointcut expression="excution()"
					id="pointcut"/>
	<!-- 配置切面及通知 -->
	<aop:aspect ref="loggingAspect" order="2">
		<aop:before method="beforeMethod" pointcut-ref="pointcut"/>
		<aop:after method="afterMethod" pointcut-ref="pointcut"/>
		<aop:after-throwing method="afterThrowing" pointcut-ref="pointcut" throwing="e"/>
		<aop:after-returning method="afterReturning" pointcut-ref="pointcut" returing="result"/>
	</aop:aspect>
	<aop:aspect ref="validationAspect" order="1">
		<aop:before method="validateArgs" pointcut-ref="pointcut"/>
	</aop:aspect>
</aop:config>

猜你喜欢

转载自blog.csdn.net/lky888666/article/details/80666558
今日推荐