What pointcut call()
does is, as the name suggests, intercepts calls to a specific method / constructor. For this to work, the caller (i.e. the code fragment where the call is located) must be under your control, i.e. It must be gossip. So, if, for example, you wove the org.myapp..webapi..*
classes and the call was also issued from there, it should work. The fact that this does not work makes me assume that POST calls are coming from somewhere outside the woven code, for example. JRE or a third-party library.
So, if org.myapp..webapi..*
is under your control, i.e. you can insert aspect code into it, you must use pointcut execution()
. Unlike call()
it is woven into the called, that is, into the code where the method is defined, and not in many places where it is called. Thus, you can intercept all execution methods, regardless of whether they come from your application or from a third-party or JRE code. This will even work to execute methods called reflection.
call()
and execution()
have fundamentally different semantics that pay off in order to learn and understand. Generally, you should try to use execution()
whenever possible, i.e. Whenever the called person is available to you. call()
is just your recession if you cannot intertwine with the called user and use the caller. call()
may also make sense if for some reason you need to make any decisions based on the context of the join point, for example. in the around()
advice, which decides to call or not to call the original method based on some condition.
source share