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
.
Modifier | Constructor and Description |
---|---|
protected |
PortableRemoteObject()
The protected constructor calls
exportObject (this). |
Modifier and Type | Method and Description |
---|---|
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.
|
protected PortableRemoteObject() throws RemoteException
exportObject
(this).RemoteException
- if the exportObject(this) throws one.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.
target
- the target to connect to ORB, must be an instance of either
ObjectImpl
(Stubs and old-style ties) or Tie
.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
).RemoteException
- if the target is already connected to another ORB.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.
object
- the object to export.RemoteException
- if export fails due any reason.public static Object narrow(Object object, Class narrowToInstaceOf) throws ClassCastException
ORB.string_to_object(java.lang.String)
or from the naming service) can be narrowed
into interface, derived from Remote. The method will try to locate an
appropriate Stub
by the name pattern (_*_Stub). If the object being
narrowed is connected to an ORB, the returned instance will inherit that
connection, representing the same remote (or local) object, but now with
the possibility to invoke remote methods. Stub
class, if it is and passed as a second parameter. This allows
to use non-standard stubs without parameterless constructors.ObjectImpl
(may be Stub's)
can be narrowed one into another (a delegate is transferred). Tie
that can
later connected to an ORB, making the methods accessible remotely. The
Remote being narrowed normally provides a local implementation, but you can
also narrow remote Stub, creating "forwarding Tie".Tie
can be narrowed into Remote, representing the
implementation for this Tie (if one is set).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.ClassCastException
- if no narrowing is possible.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).
target
- a server side object implementation.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').public static void unexportObject(Remote object) throws NoSuchObjectException
Util.unexportObject(java.rmi.Remote)
object
- the object to unexport.NoSuchObjectException
- if the passed object is not currently
exported.