Suppose we applied two advice one is type After and another of type AfterReturning on the same jointpoint(business function) then which advice will invoke first if the jointpoint executes successfully
Invocation of the advices of different type applied on the same jointpoint(core business related modules) as follows :
1.Around
2.Before and/or After
3.AfterReturning or AfterThrowing
Suppose we applied all five types of advices on the same jointpoint then the flow will be like :
Around type advice will be invoked and code before
pjp.proceed()
of Around type advice will be executed where pjp is the reference variable of ProceedingJoinPoint interface.Before type advice will be invoked and executed fully.
code inside jointpoint will be executed fully.
Code after
pjp.proceed()
of Around type advice will be executed if jointpoint executes successfully otherwise skip this step and go to step 5. If it's modified return value then this new return value will be effected to the followings advice or method invocation.After type advice will be invoked and executed fully.
AfterReturning type advice will be invoked and executed fully if jointpoint executes successfully else if jointpoint throws any error then AfterThrowing type advice will be invoked and executed fully.