Announcement Announcement Module
Collapse
No announcement yet.
Possible to specify auto-proxied @AspectJ style aspect ordering in context xml file? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Possible to specify auto-proxied @AspectJ style aspect ordering in context xml file?

    Hi all,

    We are using @AspectJ style with <aop:aspectj-autoproxy/>. Say there are two aspect classes, each containing an @AfterReturing method, and both methods cut at the same joinpoint, and these two aspect classes do not implement the Ordered interface or the @Order annotation.

    How is the execution order of the two advice methods defined?

    Can it be determined by comparing the relative position of the <bean .../> definition of these two aspect classes in the applicationContext.xml file? My colleague's attempt worked, but mine failed. If the bean definition location within the context xml file affects aspect ordering, can you point me to the
    reference document or relevant source code? Or is it just an implementation-specific behavior?

    We also tried @DeclarePrecedence and failed. It looks like Spring 2.0 does not support this annotation.

    We are using Spring-2.0.2.

    Some background info: one of the aspect class cannot be modified (so we can't add the Ordered interface or @Order annotation to that class), and the other aspect class is written newly by us, and the advice in the new aspect class must run after the advice in the unmodifiable aspect.

    My search so far suggests aspects without order are assigned the maximum order value possible as they are constructed by Spring. For two @AfterReturning advice methods, the one with aspect.order of a smaller value will be executed after the one with a larger aspect.order. So for our case, just implementing Ordered interface in our new aspect works for our case. But what if we need to have an @AfterReturning advice that executes before the unmodifiable advice method?

    Further, if
    1) we aren't allowed to modified existing aspect classes to implement the Ordered interface / @Order annotation
    2) <aop:aspectj-proxy/> is to stay
    3) and aspect ordering cannot be specified by the relation position of their <bean/> definitions in context xml file,
    what other methods can we use to specify the aspect ordering?

    Thanks,
    Samuel
Working...
X