Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] identifying a call within a method and harvest the parameter

hi,

i want to weave something around a call to a
method where the result of the around advice is dependent
on a paramater value given to the calling method.

<code>
public class Processor
{
  public Result process(Parameter _param)
  {
    ...
    Value val = createValue();
    ...
  }

  public Value createValue()
  {
    return null;
  }
}
</code>

now i want to do something like this

<code>
public aspect ProcessCreation
{
   pointcut creation(Parameter _param):
      withincode(public Result Processor.process(Parameter))
   && args(_param)
   && call(public Value Processor.createValue());

   Value around(Parameter _param): creation(_param)
   {
      Value result = null;
      if (_param.getValue() == 0)
      {
         result = new Value("OK");
      }
      else
      {
         result = new Value("FAILED");
      }
      return result;
   }
}
</code>

the problem is that as soon as i try to harvest the parameter
from the surrounding method the advice gets not executed anymore
(meaning the pointcut is not matched of course).

anybody any idea?

ciao robertj


Back to the top