Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] More cflow queries..

For an example of binding variables from two different join points for use in one advice, see

http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/doc/faq.html#q:recursiveentrypoints

The problem with

   args(a,c) && ...

is that args(a,c) has to be true at one join point.

Wes

jianxiong pang wrote:

> Neil, The calls to "methodA" and "methodC" do not happen in the same context. (the same joinpoint) So it is semantically impossible to reference the context variables belong to different jointpoints. Specifically, when you cut methodA, you can see the context of methodA, and when you cut methodC you can see the context of methodC. That's all. My two cents. Cheers! Jianxiong
>
>      ----- Original Message -----
>      From: neil loughran
>      To: aspectj-users@xxxxxxxxxxx
>      Sent: Tuesday, August 26, 2003 11:37 PM
>      Subject: [aspectj-users] More cflow queries..
>       Continuing the cflow theme... ;-) Is it possible to expose the context of multiple joinpoints in a cflow? For instance. class Driver
>       {
>       public static void main(String args[])
>        {
>        Foo f = new Foo();
>        f.methodA("Hello World");
>        }
>       } class Foo
>          {
>          public void methodA(String s)
>              {
>              String t = s.toUpperCase();
>              }     public void methodB(String s)
>              {
>              StringBuffer t = new StringBuffer(s);
>              s = t.reverse().toString();
>              methodC(s);
>              }     public void methodC(String s)
>              {
>              s=s+s;        // etc..
>              }
>          } In the above example I simply process a string by passing it through different methods.  If I wanted to get the original values of the calls to MethodA and MethodC I could create separate advice for each method and perhaps create a field variable so that the advice can have access to the variable .  However if I wanted to create a single advice which exposed the original string passed to methodA and also that of methodC how would I go about it? I can create advice such as which exposes all the pointcuts in the flow of Foo.methodA aspect A
>       {
>       before () : cflow(call (void Foo.methodA(String))) && !within(A)
>        {
>        System.out.println("Cflow -- > "+thisJoinPoint);
>        }
>       } but how can I create an advice which does something like the following (which doesn't work incidentally!)? before(String a, String c) : args(a,c) && cflow(call (void Foo.methodA(String))) && call(void Foo.methodC(String)) && !within(A)
>          {    // where 'a' is context passed to methodA    // and 'c' is context passed to methodC     // evaluate something based upon a and c    } RegardsNeil Loughran
>



Back to the top