[aspectc-user] Order advice
Olaf Spinczyk
Olaf.Spinczyk at informatik.uni-erlangen.de
Thu Dec 2 09:43:05 CET 2004
Hi Marko,
Marko Bozikovic wrote:
> Hi!
>
> I need some help with the order advice... How do I use it? :)
>
> (Olaf, I'm using samples from your AOSD 2004 tutorial)
> I have a Queue class and two aspects (ElementCounter and QueueException)
> Each of them defines (among others) an after advice for Queue::Dequeue
> function.
>
> By default, QueueException advice is executed first, and ElementCounter
> advice second. This is ok, but I wanted to try order advice, so I
> defined the Order aspect like this:
>
> aspect Order {
>
> public:
> advice "% Queue::Enqueue(...)" || "% Queue::Dequeue(...)" :
> order("ElementCounter", "QueueException");
> };
>
> Everything compiles ok, but QueueException after advice still gets
> executed before ElementCounter after advice in Queue::Dequeue function.
>
> I've tried swapping aspects in the order advice, and resulting .acc file
> is identical to the original one.
>
> What am I doing wrong?
>
> TIA,
Use before or around advice and it will work. If you want after advice
and QueueExeption should be the last advice, you have to change the
aspect precedence to order("QueueException", "ElementCounter").
The point is that order(...) defines the aspect precedence, which is an
indicator for its priority or importance. The idea is that an important
aspect wraps a less important aspect. Therefore, higher precedence for
*before* advice means that the advice will be executed first. However,
for *after* advice a higher precedence means that the advice code is
executed last.
This is one of the few documented features in the Language Reference
Manual ;-).
Olaf
More information about the aspectc-user
mailing list