[aosd-discuss] Accessing context from advices in AspectJ

Alan Cyment acyment at yahoo.com
Wed Aug 16 07:32:43 EST 2006


Forgot to mention it in the original post. I'd like to have base code remain as untouched as possible.

Cheers,
Alan
----- Original Message ----
From: Pascal Costanza <pc at p-cos.net>
To: Alan Cyment <acyment at yahoo.com>
Cc: discuss at aosd.net
Sent: Wednesday, August 16, 2006 4:20:12 AM
Subject: Re: [aosd-discuss] Accessing context from advices in AspectJ

Use OOP? Define a method getRegion() for graphical objects that you  
can use in your advice?

Pascal

On 15 Aug 2006, at 23:36, Alan Cyment wrote:

> Hi everyone out there! I'm currently working on an analysis of how  
> context is accessed by advice in AspectJ (i.e. how advice code  
> interacts with active objects either through pointcuts parameters  
> or by using the thisJoinPoint object).
>
> The example I'm working on is the classic Point & Line case: a  
> simplified drawing application that uses a Display object and that  
> offers the user the chance to define both Points and Lines. In the  
> original example, the only existing advice does not need to  
> interact with the Points and Lines, so I decided to change the  
> scenario a little bit: instead of updating the whole screen, we  
> wish to (in Windows terms) invalidate the smallest region that  
> contains the shapes that have changed their position.
>
> This new requirement forces the advice code to retrieve from the  
> shapes the region they take up on the screen. The following is the  
> cleanest solution I could find in AspectJ:
>
> public aspect UpdateSignaling {
>
>     pointcut changePoint(Point P):
>         ((execution(void Point.set*(int))) ||
>         (execution(void Point.moveBy(int,int))))
>         && target(P);
>
>     pointcut changeLine(Line L) :
>         (execution(void Line.moveBy(int,int)))
>         && target(L);
>
>     after(Point P) returning: changePoint(P){
>         Display.update(P.getX(),P.getY(),P.getX(),P.getY());}
>
>     after(Line L) returning: changeLine(L) {
>         Display.update(L.getP1().getX(),L.getP1().getY(),
>                                         L.getP2().getX(),L.getP2 
> ().getY());}
>
>  }
>
> Do you think there's a way of avoiding the need for two advices?  
> And for advices to actually have to know a shape's inner structure?
>
> Cheers,
> Alan
>
>
>
> _______________________________________________
> discuss mailing list    -    discuss at aosd.net
>
> To unsubscribe and change options, go to:
> http://aosd.net/mailman/listinfo/discuss_aosd.net
>
> Check out the AOSD.net Wiki: http://aosd.net/wiki

-- 
Pascal Costanza, mailto:pc at p-cos.net, http://p-cos.net
Vrije Universiteit Brussel, Programming Technology Lab
Pleinlaan 2, B-1050 Brussel, Belgium








-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/discuss_aosd.net/attachments/20060816/ccf9ae68/attachment.html 


More information about the discuss mailing list