Search code examples
springaoppointcut

I need a Spring AOP pointcut explanation


I have seen two variations of pointcut patterns:

This

execution(* some.package.*.*(..))

and this

execution(* some.package.* *(..))

What is the meaning of the dot (or of it absence) between the last two *'s?


Solution

  • This appendix defines grammar of the pointcut expression langauge. For the execution expression the rule is the following:

    execution(MethodPattern)
    

    where

    MethodPattern = 
      [ModifiersPattern] TypePattern 
            [TypePattern . ] IdPattern (TypePattern | ".." , ... ) 
            [ throws ThrowsPattern ]
    

    That means that if you have 3 expressions (separated by space) before "(", then the first is modifier, second is class and third is method name. But if you have 2 expressions before "(", then first will be class and second will be method name.