spring aop 学习备忘

来源:互联网 发布:sql 表加列 编辑:程序博客网 时间:2024/06/03 01:09
定义异常切面
<!-- 异常切面 --><bean id="exceptionPointcutAdvisor" class="org.springframework.aop.support.DefaultPointcutAdvisor"><property name="pointcut"><ref bean="exceptionPointcut" /></property><property name="advice"><ref bean="exceptionAdvice" /></property></bean>


 

<!-- 异常真正执行的切点 --><bean id="regexpMethodPointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut"><property name="patterns"><list><value>com.huawei.*.*.facade.*..*</value></list></property></bean>


<!-- 异常标识切点 --><bean id="exceptionPointcut" class="com.csy.exception.advice.ExceptionPointcut"><property name="regexpMethodPointcut"><ref bean="regexpMethodPointcut"/></property></bean>

 

<!-- 异常通知类 --><bean id="exceptionAdvice" class="com.csy.exception.advice.ExceptionAdvice" />


  

<aop:aspectj-autoproxy proxy-target-class="true" />

//通知

public class ExceptionAdvice implements ThrowsAdvice//,  MethodBeforeAdvice, AfterReturningAdvice 

//切点 

public class ExceptionPointcut extends StaticMethodMatcherPointcut{    private JdkRegexpMethodPointcut regexpMethodPointcut;

spring中最强大的Advisor-DefaultPointcutAdvisor




 

原创粉丝点击