To realize a dynamic proxy with JDK, we need to implement the interface that manages invocations.
package java.lang.reflect; public interface InvocationHandler { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable; }
The method to implement receives the proxy object, the invoked method, and the input parameters of the target method. An implementation would be made like this:
package org.springaop.chapter.three.handler; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; public class FooInvocationHandler implements InvocationHandler { public FooInvocationHandler(Object target) { this.target = target; } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { System.out.println("remove before fly :-)"); Object result = method.invoke(target, args); System.out.println(result+", mmh it's not rocket science "); return result; } public static Object createProxy(Object target...