[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Need advice
|
Hi,
you can add a cflowbelow to the aspect:
aspect MyProblemAspect{
pointcut operationTracker(Foo foo): call ( * Foo.m1(..)) && target
(foo) && !cflowbelow(call ( * Foo.m1(String,String))) &&
!cflowbelow(call ( * Foo.m1(String,String,String)));
before(Foo foo): operationTracker(foo) {
System.out.println(foo.getXXX());
}
}
(the 2nd cflow below is just for preventing recursive calls in
m1(String,String,String))
- Stefan
Alexey Buistov wrote:
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