javax.rmi

Class 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 {@link ObjectImpl} or {@link 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 {@link PortableRemoteObjectDelegate}.

Constructor Summary
protected PortableRemoteObject()
The protected constructor calls {@link exportObject} (this).
Method Summary
static voidconnect(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 voidexportObject(Remote object)

Makes a server object ready for remote calls.

static Objectnarrow(Object object, Class narrowToInstaceOf)
Narrows the passed object to conform to the given interface or IDL type.
static RemotetoStub(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 voidunexportObject(Remote object)
Deregister a currently exported server object from the ORB runtimes.

Constructor Detail

PortableRemoteObject

protected PortableRemoteObject()
The protected constructor calls {@link exportObject} (this).

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

Method Detail

connect

public 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. The a_target is connected to the same ORB (and, if applicable, to the same {@link POA}) as the a_source.

Parameters: a_target the target to connect to ORB, must be an instance of either {@link ObjectImpl} (Stubs and old-style ties) or {@link Tie}. a_source the object, providing the connection information, must be an instance of either {@link ObjectImpl} (Stubs and old-style ties) or {@link Servant} (the next-generation Ties supporting {@link POA}).

Throws: RemoteException if the target is already connected to another ORB.

exportObject

public static void exportObject(Remote object)

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)
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)

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 {@link #connect}.

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)
Deregister a currently exported server object from the ORB runtimes. The object to becomes available for garbage collection. This is usually impemented via {@link Util#unexportObject}

Parameters: object the object to unexport.

Throws: NoSuchObjectException if the passed object is not currently exported.