javax.rmi
Class PortableRemoteObject

java.lang.Object
  extended by javax.rmi.PortableRemoteObject

public class PortableRemoteObject
extends Object

An utility class for RMI/IDL server side object implementations. Server side implementation objects may inherit from this class, but this is not mandatory, as the needed methds are static. Server side implementations may choose to inherit from ObjectImpl or Servant instead.

The functionality of methods in this class is forwarded to the enclosed PortableRemoteObjectDelegate. This delegate can be altered by setting the system property "javax.rmi.CORBA.PortableRemoteObjectClass" to the name of the alternative class that must implement PortableRemoteObjectDelegate.


Constructor Summary
protected PortableRemoteObject()
          The protected constructor calls exportObject (this).
 
Method Summary
static void connect(Remote target, Remote source)
           Makes the remote object a_target ready for remote communication using the same communications runtime as for the passed a_source parameter.
static void exportObject(Remote object)
           Makes a server object ready for remote calls.
static Object narrow(Object object, Class narrowToInstaceOf)
          Narrows the passed object to conform to the given interface or IDL type.
static Remote toStub(Remote targetImpl)
           Takes a server implementation object (name pattern *imp) and returns a stub object that can be used to access that server object (target), name (pattern _*_Stub).
static void unexportObject(Remote object)
          Deregister a currently exported server object from the ORB runtimes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PortableRemoteObject

protected PortableRemoteObject()
                        throws RemoteException
The protected constructor calls exportObject (this).

Throws:
RemoteException - if the exportObject(this) throws one.
Method Detail

connect

public static void connect(Remote target,
                           Remote source)
                    throws RemoteException

Makes the remote object a_target ready for remote communication using the same communications runtime as for the passed a_source parameter. The a_target is connected to the same ORB (and, if applicable, to the same POA) as the a_source.

Parameters:
a_target - the target to connect to ORB, must be an instance of either ObjectImpl (Stubs and old-style ties) or Tie.
a_source - the object, providing the connection information, must be an instance of either ObjectImpl (Stubs and old-style ties) or Servant (the next-generation Ties supporting POA).
Throws:
RemoteException - if the target is already connected to another ORB.

exportObject

public static void exportObject(Remote object)
                         throws RemoteException

Makes a server object ready for remote calls. The subclasses of PortableRemoteObject do not need to call this method, as it is called by the constructor.

This method only creates a tie object and caches it for future usage. The created tie does not have a delegate or an ORB associated.

Parameters:
object - the object to export.
Throws:
RemoteException - if export fails due any reason.

narrow

public static Object narrow(Object object,
                            Class narrowToInstaceOf)
                     throws ClassCastException
Narrows the passed object to conform to the given interface or IDL type. In RMI-IIOP, this method replaces the narrow(org.omg.CORBA.Object) method that was present in the CORBA Helpers. This method frequently returns different instance and cannot be replaced by the direct cast. The typical narrowing cases (all supported by GNU Classpath) are:

Parameters:
object - the object like CORBA Object, Stub or Remote that must be narrowed to the given interface.
narrowToInstaceOf - the class of the interface to that the object must be narrowed.
Returns:
On success, an object of type narrowTo or null, if narrowFrom = null.
Throws:
ClassCastException - if no narrowing is possible.

toStub

public static Remote toStub(Remote targetImpl)
                     throws NoSuchObjectException

Takes a server implementation object (name pattern *imp) and returns a stub object that can be used to access that server object (target), name (pattern _*_Stub). The returned stub is not connected to any ORB and must be explicitly connected using connect(java.rmi.Remote, java.rmi.Remote).

The method signature prevents it from returning stubs that does not implement Remote (ClassCastException will be thrown).

Parameters:
target - a server side object implementation.
Returns:
a stub object that can be used to access that server object.
Throws:
NoSuchObjectException - if a stub class cannot be located by supposed name pattern, or an instance of stub fails to be instantiated.
ClassCastException - if the stub class can be located, but it does not inherit from Remote.
BAD_PARAM - if the name of the passed class does not match the implementation name pattern (does not end by 'Impl').

unexportObject

public static void unexportObject(Remote object)
                           throws NoSuchObjectException
Deregister a currently exported server object from the ORB runtimes. The object to becomes available for garbage collection. This is usually impemented via Util.unexportObject(java.rmi.Remote)

Parameters:
object - the object to unexport.
Throws:
NoSuchObjectException - if the passed object is not currently exported.