Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*    */ package org.jboss.net.sockets;
 /*    */ 
 /*    */ import java.lang.reflect.Method;
 /*    */ import java.lang.reflect.Proxy;
 /*    */ import java.rmi.NoSuchObjectException;
 /*    */ import java.rmi.Remote;
 /*    */ import java.rmi.RemoteException;
/*    */ import java.util.HashMap;
/*    */ 
/*    */ public class RMIMultiSocketServer
/*    */ {
/* 40 */   private static HashMap handlermap = new HashMap();
/* 41 */   private static HashMap stubmap = new HashMap();
/*    */ 
/*    */   public static Remote exportObject(Remote objint portRMIClientSocketFactory csfRMIServerSocketFactory ssfClass[] interfacesint numSockets)
/*    */     throws RemoteException
/*    */   {
/* 51 */     Remote[] stubs = new Remote[numSockets];
/*    */ 
/* 53 */     Method[] methods = obj.getClass().getMethods();
/*    */ 
/* 55 */     HashMap invokerMap = new HashMap();
/* 56 */     for (int i = 0; i < methods.lengthi++) {
/* 57 */       Long methodkey = new Long(MethodHash.calculateHash(methods[i]));
/* 58 */       invokerMap.put(methodkeymethods[i]);
/*    */     }
/*    */ 
/* 61 */     RMIMultiSocketHandler[] handlers = new RMIMultiSocketHandler[numSockets];
/* 62 */     for (int i = 0; i < numSocketsi++)
/*    */     {
/* 64 */       int theport = port == 0 ? 0 : port + i;
/* 65 */       handlers[i] = new RMIMultiSocketHandler(objinvokerMap);
/* 66 */       stubs[i] = UnicastRemoteObject.exportObject(handlers[i], theportcsfssf);
/*    */     }
/*    */ 
/* 69 */     Remote remote = (Remote)Proxy.newProxyInstance(obj.getClass().getClassLoader(), interfacesnew RMIMultiSocketClient(stubs));
/*    */ 
/* 73 */     .put(remotestubs);
/* 74 */     .put(remotehandlers);
/* 75 */     return remote;
/*    */   }
/*    */ 
/*    */   public static Remote exportObject(Remote objint portRMIClientSocketFactory csfRMIServerSocketFactory ssfint numSockets)
/*    */     throws RemoteException
/*    */   {
/* 85 */     return exportObject(objportcsfssfobj.getClass().getInterfaces(), numSockets);
/*    */   }
/*    */ 
/*    */   public static boolean unexportObject(Remote objboolean force)
/*    */     throws NoSuchObjectException
/*    */   {
/* 91 */     .remove(obj);
/* 92 */     Remote[] stubs = (Remote[])(Remote[]).remove(obj);
/* 93 */     for (int i = 0; i < stubs.lengthi++)
/*    */     {
/* 95 */       UnicastRemoteObject.unexportObject(stubs[i], force);
/*    */     }
/*    */ 
/* 98 */     return true;
/*    */   }
/*    */ }
/* Location:           /home/mnovotny/projects/EMBEDDED_JBOSS_BETA3_COMMUNITY/embedded/output/lib/embedded-jboss/lib/jboss-embedded-all.jar
 * Qualified Name:     org.jboss.net.sockets.RMIMultiSocketServer
 * JD-Core Version:    0.6.0
 */
New to GrepCode? Check out our FAQ X