[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-dev] Pointcut question

Hi,
	I don't think you are doing anything wrong here. The way you
have defined the pointcut will make sure that advice covers both
overloads of doStuff. 
I just tried writing an aspect with your pointcut and a test class with
the 2 doStuff overloads as follows:

public aspect Test {
	pointcut myPointcut() : call(public void doStuff(..));

	before() : myPointcut(){
		System.out.println("myPointcut = '"
				+
thisJoinPoint.getStaticPart().getSignature()
				+ "'");
	}
}

public class Test {
	public static void main(String[] args) {
		Test test = new Test();
		test.doStuff();
	}

	public void doStuff()
	{
	   doStuff(null);
	}


	public void doStuff(String s)
	{
	}
}

And the output that I get is: 
myPointcut = 'void com.aspect.experiments.classes.Test.doStuff()'
myPointcut = 'void com.aspect.experiments.classes.Test.doStuff(String)'
So, the advice is covering both the overloaded methods, right? I am also
new to AOP. Correct me if I am wrong or if I have misunderstood your
question. 

Thanks.
Roshan


-----Original Message-----
From: Andreas Mueller [mailto:am@xxxxxx] 
Sent: Friday, March 18, 2005 2:17 PM
To: aspectj-dev@xxxxxxxxxxx
Subject: [aspectj-dev] Pointcut question


Hi,

let's say I have the following methods in a class:

public void doStuff()
{
   doStuff(null);
}


public void doStuff(String s)
{
   // do stuff
}

Here is the point cut:

pointcut myPointcut() : call(public void doStuff(..));

I would expect that an advice would be inserted in both doStuff methods.

But it's only inserted into doStuff(), not in doStuff(String). I've 
tried also to define the point cut as follows:

pointcut myPointcut() : call(public void doStuff()) ||
			call(public void doStuff(String));

With the same result.

Any hints how do I get the trick to get the advice inserted into both 
methods?

Thanks,
Andreas

-- 

Andreas Mueller
IIT GmbH, Bremen/Germany
http://www.swiftmq.com


_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-dev