1 25 26 package org.objectweb.carol.rmi.iiop.util; 27 28 import java.io.IOException ; 29 30 import javax.naming.InitialContext ; 31 import javax.naming.NamingException ; 32 import javax.rmi.CORBA.Stub ; 33 34 import org.omg.CORBA.BAD_OPERATION ; 35 import org.omg.CORBA.ORB ; 36 import org.omg.CORBA.portable.ObjectImpl ; 37 38 import org.objectweb.carol.util.configuration.TraceCarol; 39 40 45 public class RmiIiopUtility { 46 47 51 private RmiIiopUtility() { 52 } 53 54 60 public static void reconnectStub2Orb(Object object) throws IOException { 61 62 if (TraceCarol.isDebugRmiCarol()) { 63 TraceCarol.debugRmiCarol("object=" + object); 64 } 65 if (object instanceof ObjectImpl ) { 67 try { 68 ObjectImpl objectImpl = (ObjectImpl ) object; 70 objectImpl._get_delegate(); 71 if (TraceCarol.isDebugRmiCarol()) { 72 TraceCarol.debugRmiCarol("still connected to ORB"); 73 } 74 } catch (BAD_OPERATION e) { 75 try { 76 if (TraceCarol.isDebugRmiCarol()) { 78 TraceCarol.debugRmiCarol("must be reconnect to ORB"); 79 } 80 Stub stub = (Stub ) object; 81 ORB orb = (ORB ) new InitialContext ().lookup("java:comp/ORB"); 82 stub.connect(orb); 85 if (TraceCarol.isDebugRmiCarol()) { 86 TraceCarol.debugRmiCarol("reconnected"); 87 } 88 } catch (NamingException ne) { 89 throw new IOException ("Unable to lookup java:comp/ORB"); 90 } 91 } 92 } else { 93 throw new IOException ("Not an ObjectImpl " + object.getClass().getName()); 94 } 95 } 96 } | Popular Tags |