문제

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 +.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top