Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[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


Back to the top