1 22 package org.jboss.net.sockets; 23 24 25 import java.lang.reflect.Method ; 26 import java.lang.reflect.InvocationHandler ; 27 import java.io.Serializable ; 28 import java.util.Random ; 29 import java.rmi.Remote ; 30 31 36 public class RMIMultiSocketClient implements InvocationHandler , Serializable 37 { 38 protected Remote [] stubs; 39 protected Random random; 40 public RMIMultiSocketClient(Remote [] stubs) 41 { 42 this.stubs = stubs; 43 random = new Random (); 44 } 45 46 public Object invoke(Object proxy, Method method, Object [] args) throws Throwable 47 { 48 if (method.getName().equals("hashCode")) 49 { 50 return new Integer (stubs[0].hashCode()); 51 } 52 if (method.getName().equals("equals")) 53 { 54 return new Boolean (stubs[0].equals(args[0])); 55 } 56 int i = random.nextInt(stubs.length); 57 long hash = MethodHash.calculateHash(method); 58 RMIMultiSocket target = (RMIMultiSocket)stubs[i]; 59 return target.invoke(hash, args); 60 } 61 } 62 | Popular Tags |