[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [aspectj-users] CFlow semantic and help
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi, Valerio.
Valerio Schiavoni wrote:
> Hello everyone
>
> this is what I would like to get:
> "when method A is executed after B, and method C is executed after
> A (so we have this sequence of methods :
> A,B,C), then do the ABCReactingAdvice".
No, you cannot do that with cflow since the methods are called
*after* each other and not *by* each other. So in a nutshell: What
you need are "stateful aspects". You have a state variable in an
aspect and perfoam a transition on each call:
aspect TrackABC {
private enum State {initial, matchedA, matchedB, matchedC};
private State state = State.initial;
after(): a() && if(this.state==State.initial) {
this.state = State.matchedA;
}
after(): b() && if(this.state==State.matchedA) {
this.state = State.matchedA;
}
after(): c() && if(this.state==State.matchedB) {
this.state = State.matchedA;
}
after(State s): set(TrackABC.state) && args(s) {
if(s==State.matchedC) {
//perform action
}
}
}
We are currently developing a tool that offers you an additional
layer of abstraction for such things. See
http://www.bodden.de/studies/publications/OOPSLA_04/.
Also you might wanna have a look at Rob Walker's "Declarativ Event
Patterns"/tracecuts which probably captures your particular case even
better.
Eric
- --
Eric Bodden
Chair I2 for Programming Languages and Program Analysis
RWTH Aachen University
-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.3
iQA/AwUBQihzvswiFCm7RlWCEQLdtACfQbkbBeaiTM2DBY8+zCD5ERwCSZYAoMnP
+qgPtBiituq235siWLvKp5/7
=rZOo
-----END PGP SIGNATURE-----