Reputation: 9031
I have an annotation @AppManaged which is used to signify classes that need to have certain behavior woven in. One behavior woven in is converting method calls into concurrent GPars(a groovy parallel library) calls instead.
However I do not want nested method calls on the same class to be advised. So...
@AppManaged
class someclass
{
public void method1(){
method2(); **// should not be advised**
}
public void method2(){
}
}
But if the method call is from on AppManaged class to another, then it is supposed to be advised, hence something like !cflowbelow(@within(AppManaged)) does not help.
@AppManaged
class Someotherclass
{
private someclass s;
public void method3(){
s.method2();**// Should be advised.**
}
}
Basically I am looking for a pointcut which will match only nested calls within the same object instance and prevent them from being advised.
Any help would be highly appreciated.
Thanks and Regards Abraham Menacherry.
Upvotes: 2
Views: 2217
Reputation: 1284
How about:
pointcut appManagedExecution(Object appManaged) : execution(* (@AppManaged *).*(..)) && this(appManaged);
pointcut appManagedCall(Object called) : call(* (@AppManaged *).*(..)) && target(called);
pointcut routed(Object appManaged, Object called) : appManagedCall(called) && cflowbelow(appManagedExecution(appManaged)) && if(called != appManaged);
Upvotes: 4