Sometimes you can achieve an effect like
this by having multiple advices that just dispatch to a helper method, e.g.,
aspect Recorder {
after(String s) returning:
saySmthng(s) {
recordSpeech(s);
//handle specific
requirements here
}
after(String s) returning: sayWorld(s)
{
recordSpeech(s);
//handle specific
requirements here
}
private void recordSpeech(String s)
{
System.out.println("smthg"
+ s);
}
}
You might also just use an extra piece of
advice:
aspect Recorder {
after(String s) returning: (saySmthng(s)
|| sayWorld(s)) {
recordSpeech(s);
}
after(String s) returning:
saySmthng(s) {
//handle specific
requirements here
}
after(String s) returning: sayWorld(s)
{
//handle specific
requirements here
}
…
}
However, I don't know what you hope to
achieve by "sequencing" though. You can track state of a sequence
of join points with state in the aspect (possibly holding state in a thread
local or using a percflow instantiation model). You could also advise
adviceexecution, which would let you do consistent logic before each advice
runs although it
By the way, in past I've seen issues
where the compiler complains about "ambiguous binding of parameter(s)"
but when you are binding to the same thing (e.g., args(s)) in both forks of the
or, it seems to work. E.g., this works:
pointcut a(Object o) :
execution(* foo(..)) && args(o);
pointcut b(Object o) :
execution(!static * *(..)) && args(o);
pointcut aOrB(Object
o): a(o) || b(o);
But this fails:
pointcut a(Object o) :
execution(* foo(..)) && this(o);
pointcut b(Object o) :
execution(!static * *(..)) && args(o);
pointcut aOrB(Object
o): a(o) || b(o);
I would prefer to have short-circuit
evaluation rules so that if a matches o is bound to this, but I gather this was
changed to improve performance?