Open GoogleCodeExporter opened 9 years ago
Guice AOP supports changing the method parameters without modification. The
array returned by methodInvocation.getArguments() is fully mutable:
public class Scratch {
public static void main(String[] args) throws InterruptedException, IOException {
Injector injector = Guice.createInjector(new AbstractModule() {
protected void configure() {
bindInterceptor(Matchers.any(), Matchers.any(), new MethodInterceptor() {
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
methodInvocation.getArguments()[0] = "bar";
return methodInvocation.proceed();
}
});
}
});
injector.getInstance(Scratch.class).print("foo");
}
public void print(String p) {
System.out.println(p);
}
}
Original comment by limpbizkit
on 27 Nov 2009 at 11:46
Original issue reported on code.google.com by
chlupa...@gmail.com
on 27 Nov 2009 at 9:22Attachments: