views:

54

answers:

1

Hello, 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 the 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?

+2  A: 

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.

Jason Gritman
Thanks Jason..this helped a lot!
peakit