Skip to main content

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

Hi Andreas,

Is the use of execution advice instead of call advice don't solve your problem ?

Exemple : 

	pointcut createConnection() : execution(public * javax.jms.*ConnectionFactory.create*Connection(..));

Mickaël


-----Message d'origine-----
De : aspectj-dev-admin@xxxxxxxxxxx
[mailto:aspectj-dev-admin@xxxxxxxxxxx]De la part de Andreas Mueller
Envoyé : vendredi 18 mars 2005 10:36
À : aspectj-dev@xxxxxxxxxxx
Objet : Re: [aspectj-dev] Pointcut question


Hi,

thanks for the answer.

Well, I tried to provide a simple example from my more complex code. 
However, this simple thing seems to work.

Here is what I want to do actually:

pointcut createConnection() : call(public * 
javax.jms.*ConnectionFactory.create*Connection(..));

If I look into the generated classes, the advice was inserted into

QueueConnectionFactory.createQueueConnection()

but not into

QueueConnectionFactory.createQueueConnection(String user, String password)

The implementation code of the javax.jms.*ConnectionFactory internally 
calls createQueueConnection(null,null) when createQueueConnection() is 
called.

Andreas

-- 

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

Dawrani, Roshan wrote:

> 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
> 


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


Back to the top