Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[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