I'd like to intercept method calls with a certain signature with an Aspect.
My pointcut should look something like this:
execution(public Result * (Input))"
But Result
and Input
are abstract
.
Would this pointcut also match all Methods, that return a subtype of Result
and work with a subtype of Input
? Because that's my intention.
Very nearly. You need to add a plus sign immediately after the type name.
execution(public Result+ * (Input+))
Here is an example from AspectJ doc. Spring uses a restricted version of the AspectJ syntax.
pointcut callToUndefinedMethod():
call(* AbstractFacade+.*(..))
&& !call(* AbstractFacade.*(..));
And here is the (terse) documentation
SubtypePattern - all types in SubtypePattern, a pattern with a +.