In Spring about AOP/AspectJ exists the MethodInterceptor interface. It is used internally to decide if an @Aspect
class must be called or not - really an advice method - according with a pointcut.
About its implementations exists (see the former link):
- AspectJAfterAdvice
- AspectJAfterThrowingAdvice
- AspectJAroundAdvice
Question
What is the reason or Why does not exist the AspectJBeforeAdvice
class?
This is not meant to be a conclusive answer, because I cannot speak for the Spring AOP team or speculate more than just a little bit about their design goals and motives. Insofar, this question is not a good fit for Stack Overflow, because it does not present a programming problem to be solved by a correct answer.
Anyway, actually it seems that the AOP Alliance's
MethodInterceptor
interface is not implemented for before advice types. Either it is not necessary or was an oversight. I think, however, that Spring AOP mostly revolves around theAdvice
interface and, where necessary, its subinterfacesBeforeAdvice
andAfterAdvice
. Moreover, all concrete advice types extendAbstractAspectJAdvice
. This is a screenshot from my IDE:Please note on the bottom of the picture, that
MethodInterceptor
itself extendsInterceptor
, which again interceptsAdvice
. So,Advice
is the common denominator for all advice types, no matter if they are alsoMethodInterceptor
s or not.