/*
* @(#)PortableRemoteObject.java 1.33 05/11/17
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*
* Licensed Materials - Property of IBM
* RMI-IIOP v1.0
* Copyright IBM Corp. 1998 1999 All Rights Reserved
*
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
package javax.rmi;
import java.lang.reflect.Method ;
import org.omg.CORBA.INITIALIZE;
import javax.rmi.CORBA.Util;
import java.rmi.RemoteException;
import java.rmi.NoSuchObjectException;
import java.rmi.Remote;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
import java.net.MalformedURLException ;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.rmi.server.RMIClassLoader;
import com.sun.corba.se.impl.orbutil.GetPropertyAction;
/**
* Server implementation objects may either inherit from
* javax.rmi.PortableRemoteObject or they may implement a remote interface
* and then use the exportObject method to register themselves as a server object.
* The toStub method takes a server implementation and returns a stub that
* can be used to access that server object.
* The connect method makes a Remote object ready for remote communication.
* The unexportObject method is used to deregister a server object, allowing it to become
* available for garbage collection.
* The narrow method takes an object reference or abstract interface type and
* attempts to narrow it to conform to
* the given interface. If the operation is successful the result will be an
* object of the specified type, otherwise an exception will be thrown.
*/
public class PortableRemoteObject {
private static javax.rmi.CORBA.PortableRemoteObjectDelegate proDelegate = null;
private static final String PortableRemoteObjectClassKey =
"javax.rmi.CORBA.PortableRemoteObjectClass";
private static final String defaultPortableRemoteObjectImplName =
"com.sun.corba.se.impl.javax.rmi.PortableRemoteObject";
static {
proDelegate = (javax.rmi.CORBA.PortableRemoteObjectDelegate)
createDelegateIfSpecified(PortableRemoteObjectClassKey);
}
/**
* Initializes the object by calling <code>exportObject(this)</code>.
* @exception RemoteException if export fails.
*/
protected PortableRemoteObject() throws RemoteException {
if (proDelegate != null) {
PortableRemoteObject.exportObject((Remote)this);
}
}
/**
* 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 static void exportObject(Remote obj)
throws RemoteException {
// Let the delegate do everything, including error handling.
if (proDelegate != null) {
proDelegate.exportObject(obj);
}
}
/**
* Returns a stub for the given server object.
* @param obj the server object for which a stub is required. Must either be a subclass
* of PortableRemoteObject or have been previously the target of a call to
* {@link #exportObject}.
* @return the most derived stub for the object.
* @exception NoSuchObjectException if a stub cannot be located for the given server object.
*/
public static Remote toStub (Remote obj)
throws NoSuchObjectException {
=1= |