[aspectwerkz-user] 'after returning' syntax

"Marc Candle" <[email protected]> Tue, 19 Jul 2005 12:56:31 +0200
Newsgroups gmane.comp.java.aspectwerkz.user
Message-ID <[email protected]>
Hi,

I'm using AspectWerkz 2.0 under Tomcat 5.5.9 but it's unclear to me how to
use the "after returning" directive. Basically, I cannot find examples of
how to access the returning variable from the aspect. Are there any
available examples online?

Here is my example:
	
I declare a simple Class:
	
	package test;

	public class MyClass {

	MyClass() {};

	public String returnSomething(String tp)
	   return tp+" hello";

	}

Then in AOP.XML I add :

	<pointcut name="returntest" expression="call(* test.MyClass.
returnSomething(..))"/>

	<advice name="returnAspect " type="after
returning(java.lang.String)" bind-to="returntest"/>

Finally in my Aspect class, I have:

	public void returnAspect (JoinPoint joinPoint, Object returnValue)
	         throws Throwable {
		//do something with returnValue
	}
  
Which generates the following error:

	org.codehaus.aspectwerkz.exception.DefinitionException: could not
find 	advice method [returnAspect] in [MyAspect] (are you using a compiler
extension that you have not registered?) (are you using XML defined
advice, with StaticJoinPoint bindings without specifying the 	fullsource
like signature?)

The following version works, but then I can't access the returned value.

	public void returnAspect (JoinPoint joinPoint)
	         throws Throwable {
		//no access to returnValue
	}     

Any help would be appreciated,

Regards

Mark