I am trying understand the ordering of advices. The @Order annotation seems to be working perfectly fine with @Before and @Around but its working is pretty different in case of @After and @AfterReturning.
When I gave @Before advice order(1) and @Around order(2) the ordering was working in the desired order. But when I applied order(1) to @After and order(2) to @AfterReturning then order of execution is completly opposite and the advice with the highest order is executed first.
My application context file looks like this:-
Code:
<!-- The @AspectJ support is enabled by including the below tag -->
<aop:aspectj-autoproxy/>
<bean id="afterReturningAspect"class="com.springtest.aspect.AfterReturningTestAspect" />
<bean id="afterPartyAspect" class="com.springtest.aspect.AfterTestAspect" />
and code of aspects like
Code:
@Aspect
@Order(1)
public class AfterReturningTestAspect {
@AfterReturning(".......")
public void doit(){
System.out.println("@AfterReturning executed");
}
}
Code:
@Aspect
@Order(2)
public class AfterTestAspect {
@After(".......")
public void doSomethin(){
System.out.println("@After executed");
}
}
Could you please let me know what I am doing wrong!