In the following list, we name each join point with its corresponding pointcut because it was initially not apparent to me how to capsure all calls (or executions). You cannot use one single * wildcard to match all method and constructor calls. You need to define a composite pointcut which capsures on the one hand all method calls and on the other hand all constructor calls. This differentiation by AspectJ is not directly reflected by the documentation, but only by AspectJ’s different pattern syntax for call
(or execution
). To capsure method calls, you need to use MethodPattern. To capsure constructor calls, you need to use ConstructorPattern. The complete syntax for all patterns of AspectJ can be found here.
- method-calls: call(MethodPattern)
- method-execution: execution(MethodPattern)
- ctor-calls: call(ConstructorPattern)
- ctor-execution: execution(ConstructorPattern)
- static init: staticinitialization(TypePattern)
- preinit: preinitialization(ConstructorPattern)
- init: initialization(ConstructorPattern)
- field-reference (a.k.a. field-read): get(FieldPattern)
- field-set (a.k.a. field-write): set(FieldPattern)
- handler: handler(TypePattern)
- advice-execution: adviceexecution()