0

I want to intercept (@AroundInvoke) a method call ... get the original method parameters (pass by reference) with ctx.getParameters() and replace them with others.. but I want the original parameters to be also modified (!), not just call the method with the new parameters.

Mike Argyriou
  • 1,250
  • 2
  • 18
  • 30
  • I don't understand... if the parameters are passed by reference when you change them and then call context.proceed() the changed ones will also end up in your @Interceptor annotated bean... Can you please clarify – Korgen Jul 10 '13 at 13:11

1 Answers1

0

I'd maybe try subclassing the class that has the method being called, and then modify the parameters before calling super.AroundInvoke(...), like

public class AroundInvokerOverrider extends ClassWithAroundInvokeMethod
{
    @override
    public void AroundInvoke(int a, char c, ...)
    {
        a += 1;
        c = 'A';

        super.AroundInvoke(a,c);
    }
}
samus
  • 6,102
  • 6
  • 31
  • 69
  • This doesn't modify the original arguments (which in your case are passed by value which means a copy of them is passed..which is not right). Just calls the method with modified arguments. What I want is afater the interception finishes the original arguments are changed! – Mike Argyriou Jul 10 '13 at 13:07
  • I don't think you can accomplish this (without some haxoring and circumventing anyway) b/c java doesn't support "pass by reference" http://stackoverflow.com/questions/40480/is-java-pass-by-reference – samus Jul 10 '13 at 13:11