I have two pointcut expressions:
* *..*Repository.find*(..)
* *Repository.find*(..)
What is the difference between these two and what does the *..
part of the first pointcut means?
Do read through the official documentation section "Declaring a Pointcut". See the examples for more details.
execution(modifiers-pattern?
ret-type-pattern
declaring-type-pattern?name-pattern(param-pattern)
throws-pattern?)
* *..*Repository.find*(..)
Pattern type | Pattern | Description |
---|---|---|
ret-type-pattern | * |
any |
declaring-type-pattern | *..*Repository |
Type with a name that ends with Repository within any package except for the root (default) package |
?name-pattern(param-pattern) | find*(..) |
A method with a name that starts with find accepting any number (zero or more) of parameters |
* *Repository.find*(..)
Pattern type | Pattern | Description |
---|---|---|
ret-type-pattern | * |
any |
declaring-type-pattern | *Repository |
Type with a name that ends with Repository within root (default) package only |
?name-pattern(param-pattern) | find*(..) |
A method with a name that starts with find accepting any number (zero or more) of parameters |
The difference is that the second expression is specific about the package where the type exists. Please note that the first package noes not include the root package, which is one of the many reasons that Java code should never be declared in the default package.
..
is a special wildcard to match any number of arguments and *..*
in declaring-type-pattern
means starting from root package and any of its sub-package.