Spring AOP的bug - @Around和@AfterThrowing不兼容
2011-05-13 16:57
267 查看
Spring2.5.6版本的测试结论:@Around和@AfterThrowing兼容,他们分别能与其他advice兼容
测试结果:共用时,@Around切入点中的内容执行,而@AfterThrowing切入点里面的内容没有执行
后来在spring的官网论坛上面找到一篇资料印证了自己的实验,请参考:http://forum.springsource.org/showthread.php?76794-aop-after-throwing-not-working
@Aspect @SuppressWarnings("unused") public class AdviceHandler { @Pointcut("execution(* com.alibaba.normandy.service.UserManager.add*(..)))") private void pointcutService() { }; @Pointcut("execution(* del*(..))") private void allAddMethod1() { }; @Around("pointcutService()") public void aroundServiceActions(ProceedingJoinPoint pjp) { // before action System.out.println("before aroundServiceActions invoked!"); try { pjp.proceed(); } catch (Throwable e) { e.printStackTrace(); } // after action System.out.println("after aroundServiceActions invoked!"); } //抛出异常后执行 @AfterThrowing("pointcutService()") public void exceptionServiceActions() { System.out.println("exception happened! exceptionServiceActions invoked!"); } }
测试结果:共用时,@Around切入点中的内容执行,而@AfterThrowing切入点里面的内容没有执行
before aroundServiceActions invoked! java.lang.RuntimeException: throw exception e at com.alibaba.normandy.service.UserManagerImpl.addUser(UserManagerImpl.java:7) ....... after aroundServiceActions invoked!
后来在spring的官网论坛上面找到一篇资料印证了自己的实验,请参考:http://forum.springsource.org/showthread.php?76794-aop-after-throwing-not-working
相关文章推荐
- Spring(12):使用注解(@AfterThrowing/@After/@Around)实现AOP异常增强与实例
- Spring:Aop before after afterReturn afterThrowing around 的原理
- spring AOP @Around @Before @After 区别
- Spring AOP Advices - After throwing advice example - xml based configuration
- 基于Annotation的Spring AOP: @AfterThrowing
- spring AOP @Around @Before @After 区别
- Spring2.0 AOP 之Before,After,Thrown,Around Advice(一)
- spring AOP @Around @Before @After 区别
- Spring2.0 AOP 之Before,After,Thrown,Around Advice(二)
- Spring AOP @Before @Around @After 等 advice 的执行顺序
- 【Spring-AOP-学习笔记-6】@AfterThrowing增强处理简单示例
- Spring AOP - AspectJ - @AfterThrowing example
- spring AOP @Around @Before @After 区别
- spring AOP @Around @Before @After 区别
- Spring AOP @Before @Around @After 等 advice 的执行顺序
- Spring AOP(三)之AfterThrowing增强处理
- spring AOP @Around @Before @After 区别
- Spring AOP 全部通知, 四种通知方式,Around, Before, After, Throws
- Spring AOP @Before @Around @After 等 advice 的执行顺序
- spring AOP @Around @Before @After 区别