|
From a theoretical point of view one can interpret the order of advice execution for an aspect-oriented program at a given joinpoint as a partial order:
First we assume that all pieces of advice are around advice. This is WLOG because any piece of advice can be translated in such a way.
For any given joinpoint p, we have a set advice(p) of pieces of advice that match p. (This set may of course be empty.) This leads to the partial order
- <math>\forall a \in advice(p): a > p<math>.
Usually for such pieces of advice it is undetermined which one is executed first. Some languages as AspectJ always give the first piece of advice that appears in a given compilattion unit the highest priority. But at the latest if those pieces of advice are spread over various aspects, this leads to confusion and indeterminism. Thus actually all AOP frameworks enable programmers to specify certain precedences of aspects over others. In combination with the "first stated, first executed" rule, this leads to the following total order:
- <math>\forall a \in advice(p): a > p<math>
- <math>\forall a_1,a_2 \in advice(p): a_1 > a_2<math> iff
- <math>aspect(a_1)<math> has higher prescedence than <math>aspect(a_2)<math> or
- <math>aspect(a_1) == aspect(a_2)<math> and <math>a_1<math> stated before <math>a_2<math>.
Note that this is really only a total order if for all pairs of aspects, prescedences are declared - which is hardly never the case, especially when aspects come from different partys.
Also note that even without AOP it is not always obvious, what method exactly is being called by a given method call. In Object-oriented programming, always the method of the lowest subclass that overrides the given signature is actually called. Thus, the receipient of a call can always be uniquely determined (opposed to AOP), however, it can change during runtime, depending on what runtime type a declared object actually possesses.
|