/** * Makes a server object ready to receive remote calls. Note * that subclasses of PortableRemoteObject do not need to call this * method, as it is called by the constructor. * @param obj the server object to export. * @exception RemoteException if export fails. */ public void exportObject(Remote obj) throws RemoteException { if (obj == null) { throw new NullPointerException("invalid argument"); } // Has this object already been exported to IIOP? if (Util.getTie(obj) != null) { // Yes, so this is an error... throw new ExportException (obj.getClass().getName() + " already exported"); } // Can we load a Tie? Tie theTie = Utility.loadTie(obj); if (theTie != null) { // Yes, so export it to IIOP... Util.registerTarget(theTie,obj); } else { // No, so export to JRMP. If this is called twice for the // same object, it will throw an ExportException... UnicastRemoteObject.exportObject(obj); } }
Util.registerTarget(theTie, obj);
public void exportObject(Remote obj) throws java.rmi.RemoteException { RMIState state = RMIState.current(); try { state.checkShutDown(); } catch (BAD_INV_ORDER ex) { throw new RemoteException("RMIState is deactivated", ex); } Tie tie = javax.rmi.CORBA.Util.getTie(obj); if (tie != null) throw new java.rmi.RemoteException("object already exported"); RMIServant servant = new RMIServant(state); javax.rmi.CORBA.Util.registerTarget(servant, obj); logger.finer("exporting instance of " + obj.getClass().getName() + " in " + state.getName()); try { servant._id = state.getPOA().activate_object(servant); } catch (org.omg.PortableServer.POAPackage.ServantAlreadyActive ex) { throw new java.rmi.RemoteException("internal error: " + ex.getMessage(), ex); } catch (org.omg.PortableServer.POAPackage.WrongPolicy ex) { throw new java.rmi.RemoteException("internal error: " + ex.getMessage(), ex); } }
Util.registerTarget(theTie, obj);
/** * Export an RMI object as a CORBA object * @see javax.rmi.CORBA.PortableRemoteObjectDelegate#exportObject(java.rmi.Remote) */ public void exportObject( java.rmi.Remote obj ) throws java.rmi.RemoteException { if (obj == null) { throw new IllegalArgumentException(); } if ( obj instanceof Stub ) { throw new java.rmi.server.ExportException( "Attempted to export a stub class" ); } Tie tie = Util.getTie( obj ); if ( tie != null ) { throw new java.rmi.server.ExportException( "Object already exported" ); } tie = toTie( obj ); tie.orb( getORB() ); Util.registerTarget( tie, obj ); }
if (theTie != null) { Util.registerTarget(theTie, obj); } else { logger.error("Tie not found");