Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Finding nested method calls within the same class

Hi Abraham,
maybe something like this could work :

before(Object me, Object other) :
  call(....) &&
  within(....) &&
  this(me) && 
  target(other) && 
  if (me != other) 
  {

  }

Adjust "..." in call and within so that they match your annotation. 

Basically, we are intercepting all calls between an annotated class and another annotated class, and applying only if the current "this" at the moment of the call is different than the target of the call. It should work also for around and other advice type, but unfortunately cannot be used for static operations, like declares etc...

Am I over-simplifying?

Simone

 

2011/1/29 menacher <abrahammenacherry@xxxxxxxxx>

Hi Aspect Gurus,

I am a noob so bear with me if this is kind of dumb....

I have an annotation @AppManaged which is used to signify classes that need
to have certain behavior woven in. One of the behavior is converting method
calls into concurrent GPars(a groovy parallel library) calls instead.

However I do not want to have 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 advises, 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 and prevent them from being advised.

Any help would be highly appreciated.

Thanks and Regards,
Abraham Menacherry.
--
View this message in context: http://aspectj.2085585.n4.nabble.com/Finding-nested-method-calls-within-the-same-class-tp3246144p3246144.html
Sent from the AspectJ - users mailing list archive at Nabble.com.
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top