开发者

Spring - How 'multiple' AOP behaviors to services are resolved?

I want to know that whether we can apply 'multiple' AOP behaviors to our service classes or not?

Lets just say, i do this to my BankServiceImpl class:

  • @Transactional on top of one of the method, accountTransfer(), and
  • and some custom <aop> pointcut on th开发者_JAVA百科e execution of another method someOtherMethod().

Then will Spring be able to generate one proxy where accountTransfer() is made transactional and someOtherMethod() is also given aop behaviour?

Does any one has an idea on how Spring resolves multiple AOP behaviors?


It looks like Spring creates a single proxy object with all of the advice types in it. This proxy object will implement the org.springframework.aop.framework.Advised regardless of if it's a JDK dynamic proxy or a CGLIB proxy.

If you have multiple advisors, the order of their execution is undefined unless you make it explict by implementing the Ordered interface or the @Ordered annotation. You can find more on ordering here. Springs transactional aspects default to lowest priority.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜