Spring-AOP:@After建议和@ AfterThrowing/@ AfterReturning之间的执行顺序 [英] Spring-AOP: Order of execution between @After advice and @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手册
- 《 AspectJ in Action,第二版》 关于建议优先级
- 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屋!