1 package dynaop; 2 3 import java.io.Serializable ; 4 import java.lang.reflect.InvocationHandler ; 5 import java.lang.reflect.Method ; 6 7 12 class DynamicProxyInvocationHandler extends ProxyInvocationHandler 13 implements InvocationHandler { 14 15 static long serialVersionUID = 0; 16 Object wrapped; 17 18 DynamicProxyInvocationHandler(ProxyType proxyType, Object wrapped) { 19 super(proxyType); 20 this.wrapped = wrapped; 21 } 22 23 26 public Object invoke(Object proxy, Method method, Object [] arguments) 27 throws Throwable { 28 return invoke(proxy, this.wrapped, method, arguments); 29 } 30 31 public boolean isClassProxy() { 32 return false; 33 } 34 35 protected Handle createHandle() { 36 return new HandleImpl(getProxy()); 37 } 38 39 public Object unwrap() { 40 return this.wrapped; 41 } 42 43 46 static class HandleImpl implements Handle, Serializable { 47 48 Proxy proxy; 49 50 HandleImpl(Proxy proxy) { 51 this.proxy = proxy; 52 } 53 54 public Proxy getProxy() { 55 return this.proxy; 56 } 57 } 58 } 59 | Popular Tags |