/* 0 */ pointcut services(Server s): target(s) && call(public * *(..))
This pointcut, named services, picks out those points in the execution of the program when Server objects have their public methods called. It also allows anyone using the services pointcut to access the Server object whose method is being called. (taken from https://eclipse.org/aspectj/doc/released/progguide/language-anatomy.html)
I'm trying to understand AspectJ's pointcuts, and am quite a bit confused at the moment. My main question is: how do you read the above pointcut, and how do you "puzzle" its meaning together?
To illustrate my confusion, let's try to build things up from scratch:
The following pointcut would intercept all public method calls to any object, right?
/* 1 */ pointcut services() : call(public * *(..))
Now, what about this:
/* 2 */ pointcut services() : call(public * Server.*(..))
I assume that would intercept any points when public methods of the Server object are called.
Now, how do I get from here to the initial example 0? And how do I read it?
Would you first provide the parameter list when building the pointcut up?
/* 3a */ pointcut services(Server s) : call(public * *(..))
Is that the same as number 2 above? (I have a feeling it wouldn't work, and if it did, it would "intercept" every public method call, just like number 1.) Anyway, would the following be the same? (I'm not "capturing" s
with a native pointcut yet, so I can't really define it, can I?)
/* 4a */ pointcut services(Server /* only type, no variable */) : call(public * *(..))
Or would you start by specifying a native pointcut, to "capture" the target object, like so:
/* 3b */ pointcut services() : target(s) && call(public * *(..))
I suppose that would still intercept all public method calls on any object?
Would the following work to only intercept calls on the Server object, and to "capture" that object (without making it available to be passed on later, e.g. to an advice)?
/* 5 */ pointcut services(/*nothing here*/) : target(s) && call(public * Server.*(..))
Now, going back to the original pointcut:
/* 0 */ pointcut services(Server s): target(s) && call(public * *(..))
Is that the same as
/* 6 */ pointcut services(Server s): target(s) && call(public * Server.*(..))
So, to summarize: How do you start deciphering 0?
Do you first look at the target
pointcut, then at the paramter type of the services
pointcut and read it "inside out"/"from right to left"?
Or do you look at the parameter list first, and then look into the services
pointcut to see where the argument came from (i.e. target(s)
)?
Or am I making this far too complicated? Am I missing an important bit somewhere to help me understand this?
Edit: the manual explains it left to right - but where does the argument to parameter Server s
come from if I haven't "executed" target(s)
yet?