1 7 8 package com.sun.corba.se.impl.presentation.rmi ; 9 10 import java.rmi.RemoteException ; 11 12 import javax.rmi.CORBA.Tie ; 13 14 import org.omg.CORBA.ORB ; 15 import org.omg.CORBA.SystemException ; 16 import org.omg.CORBA.BAD_OPERATION ; 17 import org.omg.CORBA.BAD_INV_ORDER ; 18 19 import org.omg.CORBA.portable.ObjectImpl ; 20 import org.omg.CORBA.portable.Delegate ; 21 22 import com.sun.corba.se.spi.presentation.rmi.StubAdapter; 23 24 import com.sun.corba.se.spi.logging.CORBALogDomains ; 25 26 import com.sun.corba.se.impl.util.Utility; 27 28 import com.sun.corba.se.impl.ior.StubIORImpl ; 29 30 import com.sun.corba.se.impl.logging.UtilSystemException ; 31 32 import com.sun.corba.se.impl.corba.CORBAObjectImpl ; 33 34 public abstract class StubConnectImpl 35 { 36 static UtilSystemException wrapper = UtilSystemException.get( 37 CORBALogDomains.RMIIIOP ) ; 38 39 45 public static StubIORImpl connect( StubIORImpl ior, org.omg.CORBA.Object proxy, 46 org.omg.CORBA.portable.ObjectImpl stub, ORB orb ) throws RemoteException 47 { 48 Delegate del = null ; 49 50 try { 51 try { 52 del = StubAdapter.getDelegate( stub ); 53 54 if (del.orb(stub) != orb) 55 throw wrapper.connectWrongOrb() ; 56 } catch (org.omg.CORBA.BAD_OPERATION err) { 57 if (ior == null) { 58 Tie tie = (javax.rmi.CORBA.Tie ) Utility.getAndForgetTie(proxy); 60 if (tie == null) 61 throw wrapper.connectNoTie() ; 62 63 ORB existingOrb = orb ; 66 try { 67 existingOrb = tie.orb(); 68 } catch (BAD_OPERATION exc) { 69 tie.orb(orb); 71 } catch (BAD_INV_ORDER exc) { 72 tie.orb(orb); 74 } 75 76 if (existingOrb != orb) 77 throw wrapper.connectTieWrongOrb() ; 78 79 del = StubAdapter.getDelegate( tie ) ; 81 ObjectImpl objref = new CORBAObjectImpl() ; 82 objref._set_delegate( del ) ; 83 ior = new StubIORImpl( objref ) ; 84 } else { 85 del = ior.getDelegate( orb ) ; 88 } 89 90 StubAdapter.setDelegate( stub, del ) ; 91 } 92 } catch (SystemException exc) { 93 throw new RemoteException ("CORBA SystemException", exc ); 94 } 95 96 return ior ; 97 } 98 } 99 | Popular Tags |