Reputation: 437
I just want to understand something related to Spring AOP advice ordering.In the docs it says
When two pieces of advice defined in the same aspect both need to run at the same join point, the ordering is undefined (since there is no way to retrieve the declaration order via reflection for javac-compiled classes). Consider collapsing such advice methods into one advice method per join point in each aspect class, or refactor the pieces of advice into separate aspect classes - which can be ordered at the aspect level.
I get that we cannot define multiple advices for same pointcut in one Aspect.I just want to understand what does it mean by there is no way to retrieve the declaration order via reflection for javac-compiled classes ?.
I have put @Order annotations on multiple advices on same pointcut in one Aspect and clearly defined the orders from 1 to 3.Why it cannot get this numeric order value when it reads @Order annotations in the Aspect class via reflection and properly call the advices in correct order? Can any body please make me understand this.Many Thanks in advance
Upvotes: 1
Views: 2857
Reputation:
That's mean, that the order is undefined if not explicitly specified.
@Order
annotation has the runtime retention:
@Retention(value=RUNTIME)
@Target(value={TYPE,METHOD,FIELD})
public @interface Order
And it's possible to read order via reflection.
Upvotes: 1