Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Method parameters

Nils,

You could use thisEnclosingJoinPointStaticPart to determine the types of these arguments, but you can't access their values directly in advice on another JP. You probably can still use AJ to achieve the same effect by coordinating 2 pieces of advice. Might use advice on the execution join point to either capture the values in advance (with before advice) or defer the "real work" to after returning or after throwing on the execution, and use some mechanism to coordinate the handler advice with the execution advice.

Ron Bodkin
Chief Technology Officer
New Aspects of Security
m: (415) 509-2895

> ------------Original Message------------
> From: "Nils-Helge Garli" <nilsga@xxxxxxxxxxxxx>
> To: aspectj-users@xxxxxxxxxxx
> Date: Thu, Nov-13-2003 6:10 AM
> Subject: [aspectj-users] Method parameters
> 
> Hi!
> 
> I was wondering if it is possible to get information about method parameters within an advice. I know I can use the thisJoinPoint.getArgs() to get this information in a call() pointcut, but when using a handler() pointcut, getArgs() will only give me the information about the exception that was caught, not the parameters that was passed into the method where the catch block is.
> 
> To give an example, this is what I want to be able to do:
> 
> The original java method:
> 
> public void someMethod(String a, Integer b) {
>   try {
>       doSomeWork();
>   }
>   catch(java.io.IOException e) {
>   }
> }
> 
> public void someOtherMethod(String a, Integer b, Object c) {
>   try {
>       doSomeWork();
>   }
>   catch(java.io.IOException e) {
>   }
> }
> 
> The aspect:
> 
> pointcut myPointcut() : handler(java.io.Exception);
> 
> before() : myPointcut() {
>     //In here, I want to be able to see method parameters
>     //a and b from someMethod(String a, Integer b) or
>     //someMethod(String a, Integer b, Object c), not only
>     //the exception e
> }
> 
> 
> Does it make sense? Is it possible?
> 
> Thank you.
> 
> Sincererly,
> 
> Nils-Helge Garli
> -- 
> ___________________________________________________
> OperaMail free e-mail - http://www.operamail.com
> OperaMail Premium - 28MB, POP3, more! US$29.99/year
> 
> Powered by Outblaze
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 


Back to the top