Search code examples
spring-bootaopspring-aop

Does the first asterick in pointcut expression stand for "any return type" or "any access modifier"?


Please consider this pointcut expression:

@Before("execution(* org.mycompany.service.*.get*())")

I understand that an advice annotated by the expression above will execute for all methods who belong to a class in the package org.mycompany.service and whose names start with "get". My question is: what does the first asterick stand for? Is it a wildcard for access modifier or for return type?


Solution

  • From the reference documentation

    The format of an execution expression follows:

    execution(modifiers-pattern? ret-type-pattern declaring-type-pattern?name-pattern(param-pattern) throws-pattern?)
    

    All parts except the returning type pattern (ret-type-pattern in the preceding snippet), the name pattern, and the parameters pattern are optional

    So in the given code , first * represents ret-type-pattern