Spring、XML配置AOP
来源:互联网 发布:vue.js 双向绑定 编辑:程序博客网 时间:2024/05/21 11:03
新建一个AOP类:
public class MyInterceptor2 {public void doAccessCheck(){System.out.println("前置通知 ");}public void doAfterReturning(){System.out.println("后置通知 ");}public void doAfter(){System.out.println("最终通知");}public void doAround(ProceedingJoinPoint pjp) throws Throwable{System.out.println("环绕通知前");pjp.proceed();System.out.println("环绕通知后");}public void doAfterThrowing(Exception e){System.out.println("例外通知 例外 e:"+e);}}
在beans.xml中注入,并配置AOP:
<aop:aspectj-autoproxy /><bean id="personIService" class="cn.raffaello.service.impl.PersonServiceImpl"/><bean id="myInterceptor2" class="cn.raffaello.aop.MyInterceptor2" /><aop:config><!-- 定义切面 --><aop:aspect id="aspect" ref="myInterceptor2"><!-- 定义切入点 --><!-- 拦截所有返回值为String的方法:execution(java.lang.String cn.raffaello.service.impl.PersonServiceImpl.*(..)) --><!-- 拦截所有返回值非void的方法:execution(!void cn.raffaello.service.impl.PersonServiceImpl.*(..)) --><!-- 拦截第一个参数是String的方法:execution(* cn.raffaello.service.impl.PersonServiceImpl.*(java.lang.String,..)) --><!-- 拦截包级子包下的所有类的所有的方法:execution(* cn.raffaello.service.*.*(..)) --><!-- 拦截参数为String,并且参数名字为name: execution(* cn.raffaello.service.impl.PersonServiceImpl.*(String)) and args(name) --><aop:pointcut id="pointcut" expression="execution(* cn.raffaello.service.impl.PersonServiceImpl.*(java.lang.String))" /><!-- 前置通知 --><aop:before pointcut-ref="pointcut" method="doAccessCheck"/><!-- 后置通知 --><!-- 拦截返回值为String的方法 <aop:after-returning pointcut-ref="pointcut" method="doAfterReturning" returning="retv"/> --><aop:after-returning pointcut-ref="pointcut" method="doAfterReturning" /><!-- 最终通知 --><aop:after pointcut-ref="pointcut" method="doAfter" /><!-- 环绕通知 --><aop:around pointcut-ref="pointcut" method="doAround" /><!-- 例外通知 --><aop:after-throwing pointcut-ref="pointcut" method="doAfterThrowing" throwing="e"/></aop:aspect></aop:config>
0 0
- Spring、XML配置AOP
- spring aop xml配置
- Spring AOP配置(Annotation;Xml)
- Spring-XML配置AOP-案例
- Spring AOP之XML配置
- 使用XML配置Spring AOP
- Spring AOP xml配置方法
- Spring基于XML配置AOP
- spring aop xml配置事务
- spring-3-xml配置AOP
- Spring AOP XML配置实现
- Spring的AOP使用xml配置
- Spring AOP xml配置实现(sxt小结)
- Spring配置xml文件实现AOP
- 基于XML的spring AOP配置
- spring使用AOP如何配置ApplicationContext.xml
- Spring Aop实例之xml配置
- spring04 Spring Aop实例之xml配置
- iOS容易造成循环引用的三种场景,就在你我身边!
- 切蛋糕
- JavaScript验证客户端密码强度
- Android利用Soap读取WebService并且解析XML的DataSet数据
- 使用git、git-flow与gitlab工作 code review
- Spring、XML配置AOP
- 个人理解js
- 安卓中关于图片从网络获取,压缩,上传,下载,缩略图,缓存的一些处理总结(二)
- 应试教育的死穴,恰在于堵死了孩子“犯错”的空间
- 纠结的一早上||博客音乐播放器的添加QAQ
- 关于dyld: Library not loaded Reason: image not found
- 数据结构考研复习要点2016
- cocos2dx 2.2.6的2个js相关的错误--bad script XDR magic number
- 学密码学一定得学程序