Spring-XML配置AOP-案例
来源:互联网 发布:2016淘宝卖什么赚钱 编辑:程序博客网 时间:2024/04/20 17:33
需求:分别在AtithmeticCalculator.java实现了该接口的类的加减乘除的方法执行时打印方法执行情况,并在方法执行前判断所有参数是否都是int,用aop实现。
接口实现类:AtithmeticCalculatorImpl.java,和上一个案例一样:http://blog.csdn.net/cuigaochong/article/details/49592861
只是在类中去掉所有的注解:通过xml配置的方式完成
配置文件:applicationContext-xml.xml
<?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.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"><!-- 配置bean --><bean id="atithmeticCalculatorImpl" class="com.cgc.spring.aop.xml.impl.AtithmeticCalculatorImpl"></bean><!-- 配置切面bean --><bean id="loggingAspect" class="com.cgc.spring.aop.xml.impl.LoggingAspect"></bean><bean id="vlidationAspect" class="com.cgc.spring.aop.xml.impl.VlidationAspect"></bean><!-- 配置AOP --><aop:config><!-- 配置切点表达式 --><aop:pointcut expression="execution(* com.cgc.spring.aop.xml.impl.AtithmeticCalculatorImpl.*(int, int))" 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="ex"/><aop:after-returning method="afterReturning" pointcut-ref="pointcut" returning="result" /></aop:aspect><aop:aspect ref="vlidationAspect" order="1"><aop:before method="validateArrgs" pointcut-ref="pointcut"/></aop:aspect></aop:config></beans>
2 0
- Spring-XML配置AOP-案例
- Spring 基于XML配置的AOP入门案例
- Spring、XML配置AOP
- spring aop xml配置
- spring aop xml方式的配置案例 以及 annotation方式的配置aop
- Spring AOP配置(Annotation;Xml)
- Spring AOP之XML配置
- 使用XML配置Spring AOP
- Spring AOP xml配置方法
- Spring基于XML配置AOP
- spring aop xml配置事务
- spring-3-xml配置AOP
- Spring AOP XML配置实现
- Spring-注解的方式配置AOP-案例
- spring整合aspectj实现aop的一个简单案例(xml)
- Spring的AOP使用xml配置
- Spring AOP xml配置实现(sxt小结)
- Spring配置xml文件实现AOP
- 【转】tcp 出现rst情况整理
- js复制到剪切板
- js中的preventDefault与stopPropagation详解
- 开发apple watch 项目粗略流程
- LeetCode---Kth Smallest Element in a BST
- Spring-XML配置AOP-案例
- spring的事务配置
- GCC内联汇编
- RAID0 RAID1 RAID5 RAID10区别
- mqttandroidclient connect 调用序列:
- spring配置文件
- ios 多线程的理解
- C#中的List<string>泛型类示例
- [LeetCode]Plus One 优化