1 9 package org.jboss.portal.common.util; 10 11 import java.lang.reflect.Constructor ; 12 import java.lang.reflect.InvocationHandler ; 13 import java.lang.reflect.InvocationTargetException ; 14 import java.lang.reflect.Method ; 15 16 22 public class ProxyInfo 23 { 24 25 private static final Class [] EMPTY_SIGNATURE = new Class [0]; 26 private static final Class [] EQUALS_SIGNATURE = new Class []{Object .class}; 27 private static final Class [] INVOCATION_HANDLER_SIGNATURE = new Class []{InvocationHandler .class}; 28 29 30 private final Constructor ctor; 31 32 33 private final Method toString; 34 35 36 private final Method hashCode; 37 38 39 private final Method equals; 40 41 public ProxyInfo(Class clazz) throws Exception 42 { 43 this.ctor = clazz.getConstructor(INVOCATION_HANDLER_SIGNATURE); 44 45 toString = Object .class.getMethod("toString", EMPTY_SIGNATURE); 47 hashCode = Object .class.getMethod("hashCode", EMPTY_SIGNATURE); 48 equals = Object .class.getMethod("equals", EQUALS_SIGNATURE); 49 } 50 51 57 public Object instantiate(InvocationHandler handler) throws IllegalAccessException , InvocationTargetException , InstantiationException 58 { 59 return ctor.newInstance(new Object []{handler}); 60 } 61 62 public Method getToString() 63 { 64 return toString; 65 } 66 67 public Method getHashCode() 68 { 69 return hashCode; 70 } 71 72 public Method getEquals() 73 { 74 return equals; 75 } 76 } 77 | Popular Tags |