Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Need advice

Title: Need advice

Hello!
I'm having the following:

class Foo {
   public void m1(String a, String b){ m1(a,b,null); }
   public void m1(String a, String b, String c){
     System.out.println("123");
   }
   public String getXXX() {return "XXX";}
 }

 aspect MyProblemAspect{
   pointcut operationTracker(Foo foo): call ( * Foo.m1(..)) && target
(foo);

   before(Foo foo): operationTracker(foo) {
     System.out.println(foo.getXXX());
   }
 }

The output is:
XXX
XXX
123

The question is:
How do I modify MyProblemAspect in order to acheive the following behaviour:

1) 'before' advice executes ONLY ONCE when Foo.m1(String, String) is invoked
2) 'before' advice executes [once] when Foo.m1(String, String, String) is invoked
3) 'before' advice doesn't execute when Foo.m1(String, String, String) is invoked from Foo.m1(String, String)

Thanks in advance
Alexey


========
Alexey Buistov,
Software Engineer,
Miratech Ltd.
41 Nauki Ave,
03028 Kiev, Ukraine,
tel:   +38 044 206 4090 ext number
        +38 044 206 4099
fax:  +38 044 206 4091


Back to the top