Re: Accessing context from advices in AspectJ
"Gregor Kiczales" <[email protected]>
| Newsgroups | gmane.comp.programming.aspect.general |
|---|---|
| Organization | UBC Dept. of Computer Science |
| Message-ID | <031201c6c149$478e0160$b21d678e@GregorT43> |
In which case you could declare the set of getRegion (aka getBoundingBox) methods as a crosscutting aspect of the shape classes using ITDs. _____ From: [email protected] [mailto:[email protected]] On Behalf Of Alan Cyment Sent: Wednesday, August 16, 2006 5:33 AM To: Pascal Costanza Cc: [email protected] Subject: Re: [aosd-discuss] Accessing context from advices in AspectJ 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 <[email protected]> To: Alan Cyment <[email protected]> Cc: [email protected] 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 - [email protected] > > 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:[email protected], http://p-cos.net Vrije Universiteit Brussel, Programming Technology Lab Pleinlaan 2, B-1050 Brussel, Belgium _______________________________________________ discuss mailing list - [email protected] 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