Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Learning AspectJ: Beginner's questions (return statements in advice; reading pointcuts)

Hi all,

I'm trying to learn AspectJ at the moment, am going through the
documentation and have two questions, which I posted on StackOverflow
initially. I'd appreciate if someone could help me.

How do I read pointcuts? ===
http://stackoverflow.com/q/28969333/2018047

This is basically about the example from
https://eclipse.org/aspectj/doc/released/progguide/language-anatomy.html

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

I'm a bit confused how to read (and build up) pointcuts: the parameter
list specifies a parameter s of type Server, yet the "source" for s
seems to be the primitive pointcut target(s) - which hasn't executed
yet, has it?

The question basically boils down to: do you read/define pointcuts
outside-in/left to right and execute them inside-out/right to left?

Based on that, how do you build them up? (I have illustrated that bit
of the question on StackOverflow with examples, to illustrate where my
confusion comes from.)


What does a return statement do in an AspectJ advice? ===
http://stackoverflow.com/q/28984838/2018047

I don't quite understand why the following line from a before advice
requires a return statement - or what it does to begin with:

System.out.println("Illegal value for x"); return;

Will it basically "return form setX()" (the "intercepted" method)
before the method body is executed?

The full example is here:
https://eclipse.org/aspectj/doc/released/progguide/language-interType.html#example-pointassertions

Kind regards,

Christian


Back to the top