Skip to main content

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

Jianxiong is right that cflow won't work here.
 
One approach to handling sequences of pointcuts is to track state in the aspect. E.g., use a ThreadLocal in the aspect to store the args from methodA, and access when in/below methodB...
 
Ron
 
Ron Bodkin
Chief Technology Officer
New Aspects of Security
m: (415) 509-2895
 
 
------------Original Message-------------
From: "jianxiong pang" <j.pang@xxxxxxxxxxxxxxx>
To: <aspectj-users@xxxxxxxxxxx>
Date: Wed, Aug-27-2003 4:30 AM
Subject: Re: [aspectj-users] More cflow queries..
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 -----
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    
    }
 
Regards
Neil Loughran
 
 
 
 
 
 

Back to the top