public final class JrmpExporter extends Object implements Exporter
JrmpExporter contains the information necessary to export a
single remote object to the
JRMP runtime. It
acts as an adapter between existing methods for (un)exporting remote objects
over JRMP (e.g, UnicastRemoteObject.exportObject(Remote),
Activatable.exportObject(Remote, ActivationID, int)) and the
Exporter interface.
An object exported via a JrmpExporter can customize the
following properties that govern invocation behavior and other
characteristics of the exported remote object and its stub:
port: the port number for the ServerSocket
on which the JRMP runtime will listen for incoming calls to the exported
object.
RMIClientSocketFactory: the factory object used by client stubs
to create Socket objects over which to issue calls to the
exported object. If null, then the global JRMP socket factory
will be used (i.e., the value returned by
RMISocketFactory.getSocketFactory()), or if there
isn't one set, then the default global JRMP socket factory will be used
(i.e., the value returned by
RMISocketFactory.getDefaultSocketFactory()).
RMIServerSocketFactory: the factory object used by the JRMP
runtime to create ServerSocket objects over which to receive
calls to the exported object. If null, then the global JRMP
socket factory will be used, or if there isn't one set, then the default
global JRMP socket factory will be used. The default global JRMP socket
factory returns a ServerSocket for an anonymous port if passed
a port number of zero.
ActivationID: the ActivationID identifying this
remote object to the activation system, or null if the remote
object is not to be exported as activatable.
This exporter is a front-end adapter on top of
UnicastRemoteObject and Activatable; exporting
remote objects through this exporter is equivalent to doing so directly via
the various exportObject methods defined by the aforementioned
classes.
| Constructor and Description |
|---|
JrmpExporter()
Creates an exporter for a non-activatable JRMP "unicast" remote object
that exports on an anonymous port and does not use custom socket
factories.
|
JrmpExporter(ActivationID id,
int port)
Creates an exporter for an activatable JRMP remote object with the given
activation ID that exports on the specified TCP port and does not use
custom socket factories.
|
JrmpExporter(ActivationID id,
int port,
RMIClientSocketFactory csf,
RMIServerSocketFactory ssf)
Creates an exporter for an activatable JRMP remote object with the given
activation ID that exports on the specified TCP port and uses sockets
created by the given custom socket factories.
|
JrmpExporter(int port)
Creates an exporter for a non-activatable JRMP "unicast" remote object
that exports on the specified TCP port and does not use custom socket
factories.
|
JrmpExporter(int port,
RMIClientSocketFactory csf,
RMIServerSocketFactory ssf)
Creates an exporter for a non-activatable JRMP "unicast" remote object
that exports on the specified TCP port and uses sockets created by the
given custom socket factories.
|
| Modifier and Type | Method and Description |
|---|---|
Remote |
export(Remote impl)
Exports a remote object,
impl, to the JRMP runtime and
returns a proxy (stub) for the remote object. |
ActivationID |
getActivationID()
Returns the activation ID associated with the object exported by this
exporter, or
null if activation is not being used with this
exporter. |
RMIClientSocketFactory |
getClientSocketFactory()
Returns the client socket factory for this exporter, or
null if none (in which case Socket objects
are created directly). |
int |
getPort()
Returns the port used by this exporter, or zero if an anonymous port is
used.
|
RMIServerSocketFactory |
getServerSocketFactory()
Returns the server socket factory for this exporter, or
null if none (in which case
java.net.ServerSocket objects are created directly). |
String |
toString()
Returns the string representation for this exporter.
|
boolean |
unexport(boolean force)
Unexports the remote object exported via this exporter's
export method such that the object can no longer
accept incoming remote calls that were possible as a result of
exporting via this exporter. |
public JrmpExporter()
public JrmpExporter(int port)
port - number of the port on which an exported object will
receive calls (if zero, an anonymous port will be chosen)public JrmpExporter(int port,
RMIClientSocketFactory csf,
RMIServerSocketFactory ssf)
port - number of the port on which an exported object will
receive calls (if zero, an anonymous port will be chosen)csf - client-side socket factory (if null, the global JRMP socket
factory or, if necessary, the default global JRMP socket
factory will be used to create client-side sockets)ssf - server-side socket factory (if null, the global JRMP socket
factory or, if necessary, the default global JRMP socket
factory will be used to create server-side sockets)public JrmpExporter(ActivationID id, int port)
id - activation ID associated with the object to exportport - number of the port on which an exported object will
receive calls (if zero, an anonymous port will be chosen)NullPointerException - if id is nullpublic JrmpExporter(ActivationID id, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)
id - activation ID associated with the object to exportport - number of the port on which an exported object will
receive calls (if zero, an anonymous port will be chosen)csf - client-side socket factory (if null, the global JRMP socket
factory or, if necessary, the default global JRMP socket
factory will be used to create client-side sockets)ssf - server-side socket factory (if null, the global JRMP socket
factory or, if necessary, the default global JRMP socket
factory will be used to create server-side sockets)NullPointerException - if id is nullpublic int getPort()
public RMIClientSocketFactory getClientSocketFactory()
null if none (in which case Socket objects
are created directly).null if nonepublic RMIServerSocketFactory getServerSocketFactory()
null if none (in which case
java.net.ServerSocket objects are created directly).null if nonepublic ActivationID getActivationID()
null if activation is not being used with this
exporter.null if nonepublic Remote export(Remote impl) throws ExportException
impl, to the JRMP runtime and
returns a proxy (stub) for the remote object. This method cannot be
called more than once to export a remote object or an
IllegalStateException will be thrown.
If this exporter was created with a constructor that accepted a
java.rmi.activation.ActivationID, then calling this method
is equivalent to invoking
java.rmi.activation.Activatable.exportObject with the
appropriate impl, ActivationID, port,
RMIClientSocketFactory, and
RMIServerSocketFactory values. Otherwise, calling this
method is equivalent to invoking
java.rmi.server.UnicastRemoteObject.exportObject with the
appropriate impl, port, RMIClientSocketFactory, and
RMIServerSocketFactory values.
export in interface Exporterimpl - a remote object to exportNullPointerException - if impl is nullIllegalStateException - if an object has already been exported
with this Exporter instanceExportException - if a problem occurs exporting the objectStartablepublic boolean unexport(boolean force)
export method such that the object can no longer
accept incoming remote calls that were possible as a result of
exporting via this exporter.
If force is true, the object is forcibly
unexported even if there are pending or in progress calls to the remote
object via this exporter. If force is false,
the object is only unexported if there are no pending or in progress
calls to the remote object via this exporter. This method is equivalent
to calling java.rmi.activation.Activatable.unexportObject
or java.rmi.server.UnicastRemoteObject.unexportObject and
passing the "impl" that was previously passed to this exporter's
export method, depending on whether or not this exporter
was created with a constructor that accepted a
java.rmi.activation.ActivationID value.
The return value is true if the object is (or was
previously) unexported, and false if the object is still
exported.
unexport in interface Exporterforce - if true, the remote object will be
unexported even if there are remote calls pending or in progress;
if false, the remote object may only be unexported if
there are no known remote calls pending or in progresstrue if the remote object is unexported when
this method returns and false otherwiseIllegalStateException - if an object has not been exported
with this Exporter instanceCopyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.