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

I replied to your question on SO. Check if that works for you:
http://stackoverflow.com/questions/4850182/aspectj-how-to-find-a-method-of-an-annotated-class-is-calling-another-method-of

-Ramnivas

On Mon, Jan 31, 2011 at 6:48 AM, menacher <abrahammenacherry@xxxxxxxxx> wrote:
Hi Simone, Thanks for your reply, but the this and target are both returning the same instance! I am providing a snippet from my aspect class below
// Point cut that matches any private method
pointcut anyPrivate() : call(private * *.*(..));

// Point cut that matches all methods which return a void and are not private.
pointcut allNonPrivateVoid() : call(void *.*(..)) && !anyPrivate();

// Matches non-private, void methods in all classes that are annotated with @AppManaged 
pointcut doParallelForVoid(AgentWrapper wrapper) : 
         @within(AppManaged) && allNonPrivateVoid() && this(wrapper);
// Note that the AgentWrapper is an interface I introduced to the aspect to wrap a GPars Agent class

// The advice
void around(final AgentWrapper wrapper, final Object me, final Object other) : 
doParallelForVoid (wrapper) && this(me) && target(other){	
	Agent agentOfAppManaged = wrapper.getAgent();
	// If agent is null, then this app managed object is not really an agent.
	if(null != agentOfAppManaged && me!=other) 
         // rest of the code.
Am I doing something wrong? The me!=other is failing, since both are the same class for some reason.
// Not adviced test class
TestClass{
       AdvisedClass ad = new AdvisedClass();
       ad.someMethod();// When it reaches the around advise I get the
      //me and the other as "AdvisedClass" while I was expecting "me" to be 
      //TestClass
}


View this message in context: Re: Finding nested method calls within the same class

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