1 4 package com.tc.common.proxy; 5 6 import java.lang.reflect.Proxy ; 7 8 11 public class DelegateHelper { 12 13 22 public static Object createDelegate(Class [] theInterfaces, Object delegate) { 23 return Proxy.newProxyInstance(DelegateHelper.class.getClassLoader(), theInterfaces, 24 new GenericInvocationHandler(delegate)); 25 } 26 27 public static Object createDelegate(Class theInterface, Object delegate) { 28 return createDelegate(new Class [] { theInterface }, delegate); 29 } 30 31 41 public static Object createDelegate(Class [] theInterfaces, Object delegate, Object overrider) { 42 return Proxy.newProxyInstance(DelegateHelper.class.getClassLoader(), theInterfaces, 43 new DelegatingInvocationHandler(delegate, overrider)); 44 } 45 46 public static Object createDelegate(Class theInterface, Object delegate, Object overrider) { 47 return createDelegate(new Class [] { theInterface }, delegate, overrider); 48 } 49 50 } | Popular Tags |