Spring-AOP:@After建议和@ AfterThrowing/@ AfterReturning之间的执行顺序 [英] Spring-AOP: Order of execution between @After advice and @AfterThrowing/@AfterReturning

查看:1375
本文介绍了Spring-AOP:@After建议和@ AfterThrowing/@ AfterReturning之间的执行顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对在@After建议和@ AfterThrowing/@ AfterReturning之间的执行顺序有疑问.

I have question about order of execution between @After advice and @AfterThrowing/@AfterReturning.

在某些资源中,我读到总是在@AfterThrowing/@AfterReturning建议之前运行@After建议.

In some resources, I've read that always @After advice runs before @AfterThrowing/@AfterReturning advice.

但是,在主题,似乎@After已在@AfterThrowing/@AfterReturning建议之后运行.

However, in this topic, it seems that @After has run after @AfterThrowing/@AfterReturning advice.

现在我对此感到困惑.这三种建议类型之间的执行顺序如何?

Now I'm confused about it. How is the order of execution between these three advice types?

推荐答案

以下是AspectJ的一些文档链接.除了在两个框架中声明显式方面优先级不同的事实外,它们以与Spring AOP类似的方式应用.但是对于给定优先级的执行顺序的解释是相同的:

Here are some documentation links for AspectJ. They apply in a similar way to Spring AOP except for the fact that explicit aspect precedence is declared differently in both frameworks. But the explanation of execution order for a given precedence is the same:

  • AspectJ manual on advice precedence
  • AspectJ in Action, 2nd edition on advice precedence

他们都同意您链接到的R.G的回答.

They both agree with the answer by R.G you linked to.

但是我仍然对证明您的陈述感兴趣:

But I am still interested in proof of this statement of yours:

在某些资源中,我读到始终在@AfterThrowing/@AfterReturning咨询之前运行@After咨询

请提供一个链接,然后让我看一下.如果没有链接,我的猜测是您只是记得错了或假设了什么,而不是检查文档.

Please provide a link, then I can take a look. If you have no link, my guess is you just remember wrong or assumed something instead of checking documentation.

这篇关于Spring-AOP:@After建议和@ AfterThrowing/@ AfterReturning之间的执行顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆