Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Re: around in cflow

On Tue, 2003-06-17 at 12:40, Ron Bodkin wrote:
> Is this more of what you wanted?
> 
> pointcut gettingString() : call(String *.getAString());
> pointcut projectCtx(Project p) : cflow(execution(* Project+.*(..)) && this(p));
> 
> String around(Project p) : gettingString() && projectCtx(p) {
>        String origString = proceed();
>        // do the test for variables
>        if (origString.indexOf("$") >= 0) {
>              String changedString = p.mapString(origString);
>              return changedString;
>        }
>        return origString;
> }

That seems to work exactly the way I want! Much appreciated, that would
have taken me a while to figure that one out.

> Notes:
> 1) If you cared about the exact chain of calls, you could either use multiple 
> cflows (e.g., cflow(cflow(cflow(call(* getNM())) && call(* getNM-1())) ...) or do dynamic 
> tests on thisEnclosingJoinPoint at each "level".

No, what you whipped up worked great.

> 2) you could say just cflow(this(p)) instead of limiting it to execution of methods for Project 
> and subtypes, which would be the "most correct". However this would lead to less 
> inefficient code (lots of cflow push and pop operations). Conceivably, the compiler coul
> d optimize this code but currently it does a fair bit of extra work for cflow(this(p)).
> If you needed to handle constructors, it would be tricky (could you be sure 
> your map was initialized?)

The Map is guaranteeed to be intialized, I've added some pointcuts to
block the interpolation until the Map is initialized. 

> Ron
> 
> Ron Bodkin
> Chief Technology Officer
> New Aspects of Security
> m: (415) 509-2895
> 
> > ------------Original Message-------------
> > From: Jason van Zyl <jason@xxxxxxxxxxx>
> > To: aspectj-users@xxxxxxxxxxx
> > Date: Tue, Jun-17-2003 6:56 AM
> > Subject: Re: [aspectj-users] (no subject)
> > 
> > On Tue, 2003-06-17 at 06:44, Ken Horn wrote:
> > > How about something like (untested syntax):
> > > 
> > > String around() : call(* *.getAString()) {
> > >       String origString = proceed();
> > >       // do the test for variables
> > >       if (origString.indexOf("$") >= 0) {
> > >             String changedString = ... // eval vars
> > >             return changedString;
> > >       }
> > >       return origString;
> > > }
> > > 
> > > Not sure if the getAString was a specific method or an example signature.
> > 
> > I have tried variants of the above but I'm not getting quite what I
> > want. I actually need to know when the call starts with the Project
> > (shown below) because it is the object which contains the Map of values
> > I would like to interpolate into the String.
> > 
> > I figured I would need a flow construct of some sort. I'll keep
> > experimenting! 
> > 
> > > Hi,
> > > 
> > > Say I have the following:
> > > 
> > > Project p = createProject( f );
> > > String s =  p.getN0().getN1().getN2()...getNM().getAString()
> > >            ^
> > >            ^
> > >                 I
> > > 
> > > What is the best way to intercept the String returned by this call chain
> > > to perform some transformation?
> > > 
> > > Specifically p is an object that is created by unmarshalling an XML
> > > document which may contain ${foo} references. I would like to check I
> > > for any of these references and interpolate the real value of foo into
> > > the String before returning it to the caller.
> > > 
> > > --
> > > jvz.
> > > 
> > > Jason van Zyl
> > > jason@xxxxxxxxxxx
> > > http://tambora.zenplex.org
> > > 
> > > In short, man creates for himself a new religion of a rational
> > > and technical order to justify his work and to be justified in it.
> > > 
> > >   -- Jacques Ellul, The Technological Society
> > > 
> > > _______________________________________________
> > > aspectj-users mailing list
> > > aspectj-users@xxxxxxxxxxx
> > > http://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > 
> > > 
> > > 
> > > 
> > > 
> > > --
> > > 
> > > This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
> > > 
> > > 
> > > _______________________________________________
> > > aspectj-users mailing list
> > > aspectj-users@xxxxxxxxxxx
> > > http://dev.eclipse.org/mailman/listinfo/aspectj-users
> > -- 
> > jvz.
> > 
> > Jason van Zyl
> > jason@xxxxxxxxxxx
> > http://tambora.zenplex.org
> > 
> > In short, man creates for himself a new religion of a rational
> > and technical order to justify his work and to be justified in it.
> >   
> >   -- Jacques Ellul, The Technological Society
> > 
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/aspectj-users
> > 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
-- 
jvz.

Jason van Zyl
jason@xxxxxxxxxxx
http://tambora.zenplex.org

In short, man creates for himself a new religion of a rational
and technical order to justify his work and to be justified in it.
  
  -- Jacques Ellul, The Technological Society



Back to the top