【第六章】 AOP 之 6.4 基于@AspectJ的AOP ——跟我学spring3
? ? ? ?Spring除了支持Schema方式配置AOP,还支持注解方式:使用@AspectJ风格的切面声明。
6.4.1? 启用对@AspectJ的支持?????? Spring默认不支持@AspectJ风格的切面声明,为了支持需要使用如下配置:
?
?
5、在chapter6/advice2.xml配置文件中进行如下配置:
?
???
其中测试代码与Schema方式几乎一样,在此就不演示了,如果需要请参考AopTest.java中的testAnnotationAfterReturningAdvice测试方法。
?
三、后置异常通知:使用org.aspectj.lang.annotation 包下的@AfterThrowing注解声明;
?
?
其中测试代码与Schema方式几乎一样,在此就不演示了,如果需要请参考AopTest.java中的testAnnotationAfterThrowingAdvice测试方法。
?
四、后置最终通知:使用org.aspectj.lang.annotation 包下的@After注解声明;
?
?
? ? ? ?value:匹配需要引入接口的目标对象的AspectJ语法类型表达式;与Schema方式中的types-matching属性同义;
? ? ? ?private Interface interface:指定需要引入的接口;
? ? ? ?defaultImpl:指定引入接口的默认实现类,没有与Schema方式中的delegate-ref属性同义的定义方式;
?
@DeclareParents( value="cn.javass..*.IHelloWorldService+", defaultImpl=cn.javass.spring.chapter6.service.impl.IntroductiondService.class)private IIntroductionService introductionService;?
?????? 其中测试代码与Schema方式几乎一样,在此就不演示了,如果需要请参考AopTest.java中的testAnnotationIntroduction测试方法。
?
原创内容,转载请注明出处【http://sishuok.com/forum/blogPost/list/0/2471.html】
1 楼 whatfangfang 2012-03-29 哥们问个问题:Caused by: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut allMethods