1 22 package org.jboss.tm.remoting; 23 24 import java.lang.reflect.Proxy ; 25 26 import org.jboss.remoting.InvokerLocator; 27 28 35 public class RemoteProxy 36 { 37 46 public static Object create(Class interf, 47 long oid, 48 InvokerLocator[] locators) 49 { 50 try 51 { 52 ClientInvocationHandler handler = 53 new ClientInvocationHandler(interf, oid, locators); 54 return Proxy.newProxyInstance(interf.getClassLoader(), 55 new Class [] { interf }, 56 handler); 57 } 58 catch (Exception e) 59 { 60 e.printStackTrace(); 61 return null; 62 } 63 } 64 65 71 public static String toString(Proxy p) 72 { 73 ClientInvocationHandler handler = 74 (ClientInvocationHandler) Proxy.getInvocationHandler(p); 75 return handler.toString(); 76 } 77 78 85 public static Object fromString(String s) 86 throws Exception 87 { 88 ClientInvocationHandler handler = ClientInvocationHandler.fromString(s); 89 Class interf = handler.getClientInterface(); 90 return Proxy.newProxyInstance(interf.getClassLoader(), 91 new Class [] { interf }, 92 handler); 93 } 94 95 } 96 | Popular Tags |