public abstract class Activatable extends RemoteServer
Activatable
class provides support for remote
objects that require persistent access over time and that
can be activated by the system.
For the constructors and static exportObject
methods,
the stub for a remote object being exported is obtained as described in
UnicastRemoteObject
.
An attempt to serialize explicitly an instance of this class will fail.
ref
Modifier | Constructor and Description |
---|---|
protected |
Activatable(ActivationID id,
int port)
Constructor used to activate/export the object on a specified
port.
|
protected |
Activatable(ActivationID id,
int port,
RMIClientSocketFactory csf,
RMIServerSocketFactory ssf)
Constructor used to activate/export the object on a specified
port.
|
protected |
Activatable(String location,
MarshalledObject<?> data,
boolean restart,
int port)
Constructs an activatable remote object by registering
an activation descriptor (with the specified location, data, and
restart mode) for this object, and exporting the object with the
specified port.
|
protected |
Activatable(String location,
MarshalledObject<?> data,
boolean restart,
int port,
RMIClientSocketFactory csf,
RMIServerSocketFactory ssf)
Constructs an activatable remote object by registering
an activation descriptor (with the specified location, data, and
restart mode) for this object, and exporting the object with the
specified port, and specified client and server socket factories.
|
Modifier and Type | Method and Description |
---|---|
static Remote |
exportObject(Remote obj,
ActivationID id,
int port)
Export the activatable remote object to the RMI runtime to make
the object available to receive incoming calls.
|
static Remote |
exportObject(Remote obj,
ActivationID id,
int port,
RMIClientSocketFactory csf,
RMIServerSocketFactory ssf)
Export the activatable remote object to the RMI runtime to make
the object available to receive incoming calls.
|
static ActivationID |
exportObject(Remote obj,
String location,
MarshalledObject<?> data,
boolean restart,
int port)
Registers an activation descriptor (with the specified location,
data, and restart mode) for the specified object, and exports that
object with the specified port.
|
static ActivationID |
exportObject(Remote obj,
String location,
MarshalledObject<?> data,
boolean restart,
int port,
RMIClientSocketFactory csf,
RMIServerSocketFactory ssf)
Registers an activation descriptor (with the specified location,
data, and restart mode) for the specified object, and exports that
object with the specified port, and the specified client and server
socket factories.
|
protected ActivationID |
getID()
Returns the object's activation identifier.
|
static boolean |
inactive(ActivationID id)
Informs the system that the object with the corresponding activation
id is currently inactive. |
static Remote |
register(ActivationDesc desc)
Register an object descriptor for an activatable remote
object so that is can be activated on demand.
|
static boolean |
unexportObject(Remote obj,
boolean force)
Remove the remote object, obj, from the RMI runtime.
|
static void |
unregister(ActivationID id)
Revokes previous registration for the activation descriptor
associated with
id . |
getClientHost, getLog, setLog
protected Activatable(String location, MarshalledObject<?> data, boolean restart, int port) throws ActivationException, RemoteException
Note: Using the Activatable
constructors that both register and export an activatable remote
object is strongly discouraged because the actions of registering
and exporting the remote object are not guaranteed to be
atomic. Instead, an application should register an activation
descriptor and export a remote object separately, so that exceptions
can be handled properly.
This method invokes the exportObject
method with this object, and the specified location,
data, restart mode, and port. Subsequent calls to getID()
will return the activation identifier returned from the call to
exportObject
.
location
- the location for classes for this objectdata
- the object's initialization dataport
- the port on which the object is exported (an anonymous
port is used if port=0)restart
- if true, the object is restarted (reactivated) when
either the activator is restarted or the object's activation group
is restarted after an unexpected crash; if false, the object is only
activated on demand. Specifying restart
to be
true
does not force an initial immediate activation of
a newly registered object; initial activation is lazy.ActivationException
- if object registration fails.RemoteException
- if either of the following fails:
a) registering the object with the activation system or b) exporting
the object to the RMI runtime.UnsupportedOperationException
- if and only if activation is
not supported by this implementation.protected Activatable(String location, MarshalledObject<?> data, boolean restart, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws ActivationException, RemoteException
Note: Using the Activatable
constructors that both register and export an activatable remote
object is strongly discouraged because the actions of registering
and exporting the remote object are not guaranteed to be
atomic. Instead, an application should register an activation
descriptor and export a remote object separately, so that exceptions
can be handled properly.
This method invokes the exportObject
method with this object, and the specified location,
data, restart mode, port, and client and server socket factories.
Subsequent calls to getID()
will return the activation
identifier returned from the call to exportObject
.
location
- the location for classes for this objectdata
- the object's initialization datarestart
- if true, the object is restarted (reactivated) when
either the activator is restarted or the object's activation group
is restarted after an unexpected crash; if false, the object is only
activated on demand. Specifying restart
to be
true
does not force an initial immediate activation of
a newly registered object; initial activation is lazy.port
- the port on which the object is exported (an anonymous
port is used if port=0)csf
- the client-side socket factory for making calls to the
remote objectssf
- the server-side socket factory for receiving remote callsActivationException
- if object registration fails.RemoteException
- if either of the following fails:
a) registering the object with the activation system or b) exporting
the object to the RMI runtime.UnsupportedOperationException
- if and only if activation is
not supported by this implementation.protected Activatable(ActivationID id, int port) throws RemoteException
ActivationID
), and
MarshalledObject
).
A concrete subclass of this class must call this constructor when it is
activated via the two parameter constructor described above. As
a side-effect of construction, the remote object is "exported"
to the RMI runtime (on the specified port
) and is
available to accept incoming calls from clients.
id
- activation identifier for the objectport
- the port number on which the object is exportedRemoteException
- if exporting the object to the RMI
runtime failsUnsupportedOperationException
- if and only if activation is
not supported by this implementationprotected Activatable(ActivationID id, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException
ActivationID
), and
MarshalledObject
).
A concrete subclass of this class must call this constructor when it is
activated via the two parameter constructor described above. As
a side-effect of construction, the remote object is "exported"
to the RMI runtime (on the specified port
) and is
available to accept incoming calls from clients.
id
- activation identifier for the objectport
- the port number on which the object is exportedcsf
- the client-side socket factory for making calls to the
remote objectssf
- the server-side socket factory for receiving remote callsRemoteException
- if exporting the object to the RMI
runtime failsUnsupportedOperationException
- if and only if activation is
not supported by this implementationprotected ActivationID getID()
public static Remote register(ActivationDesc desc) throws UnknownGroupException, ActivationException, RemoteException
desc
- the object's descriptorUnknownGroupException
- if group id in desc
is not registered with the activation systemActivationException
- if activation system is not runningRemoteException
- if remote call failsUnsupportedOperationException
- if and only if activation is
not supported by this implementationpublic static boolean inactive(ActivationID id) throws UnknownObjectException, ActivationException, RemoteException
id
is currently inactive. If the object is currently
active, the object is "unexported" from the RMI runtime (only if
there are no pending or in-progress calls)
so the that it can no longer receive incoming calls. This call
informs this VM's ActivationGroup that the object is inactive,
that, in turn, informs its ActivationMonitor. If this call
completes successfully, a subsequent activate request to the activator
will cause the object to reactivate. The operation may still
succeed if the object is considered active but has already
unexported itself.id
- the object's activation identifierUnknownObjectException
- if object is not known (it may
already be inactive)ActivationException
- if group is not activeRemoteException
- if call informing monitor failsUnsupportedOperationException
- if and only if activation is
not supported by this implementationpublic static void unregister(ActivationID id) throws UnknownObjectException, ActivationException, RemoteException
id
. An object can no longer be
activated via that id
.id
- the object's activation identifierUnknownObjectException
- if object (id
) is unknownActivationException
- if activation system is not runningRemoteException
- if remote call to activation system failsUnsupportedOperationException
- if and only if activation is
not supported by this implementationpublic static ActivationID exportObject(Remote obj, String location, MarshalledObject<?> data, boolean restart, int port) throws ActivationException, RemoteException
Note: Using this method (as well as the
Activatable
constructors that both register and export
an activatable remote object) is strongly discouraged because the
actions of registering and exporting the remote object are
not guaranteed to be atomic. Instead, an application should
register an activation descriptor and export a remote object
separately, so that exceptions can be handled properly.
This method invokes the exportObject
method with the specified object, location, data,
restart mode, and port, and null
for both client and
server socket factories, and then returns the resulting activation
identifier.
obj
- the object being exportedlocation
- the object's code locationdata
- the object's bootstrapping datarestart
- if true, the object is restarted (reactivated) when
either the activator is restarted or the object's activation group
is restarted after an unexpected crash; if false, the object is only
activated on demand. Specifying restart
to be
true
does not force an initial immediate activation of
a newly registered object; initial activation is lazy.port
- the port on which the object is exported (an anonymous
port is used if port=0)desc
, with the activation system
the wrong groupActivationException
- if activation group is not activeRemoteException
- if object registration or export failsUnsupportedOperationException
- if and only if activation is
not supported by this implementationpublic static ActivationID exportObject(Remote obj, String location, MarshalledObject<?> data, boolean restart, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws ActivationException, RemoteException
Note: Using this method (as well as the
Activatable
constructors that both register and export
an activatable remote object) is strongly discouraged because the
actions of registering and exporting the remote object are
not guaranteed to be atomic. Instead, an application should
register an activation descriptor and export a remote object
separately, so that exceptions can be handled properly.
This method first registers an activation descriptor for the
specified object as follows. It obtains the activation system by
invoking the method ActivationGroup.getSystem
. This method then obtains an ActivationID
for the object by invoking the activation system's
registerObject
method with
an ActivationDesc
constructed with the specified object's
class name, and the specified location, data, and restart mode. If
an exception occurs obtaining the activation system or registering
the activation descriptor, that exception is thrown to the caller.
Next, this method exports the object by invoking the exportObject
method with the specified remote object, the
activation identifier obtained from registration, the specified
port, and the specified client and server socket factories. If an
exception occurs exporting the object, this method attempts to
unregister the activation identifier (obtained from registration) by
invoking the activation system's unregisterObject
method with the
activation identifier. If an exception occurs unregistering the
identifier, that exception is ignored, and the original exception
that occurred exporting the object is thrown to the caller.
Finally, this method invokes the activeObject
method on the activation
group in this VM with the activation identifier and the specified
remote object, and returns the activation identifier to the caller.
obj
- the object being exportedlocation
- the object's code locationdata
- the object's bootstrapping datarestart
- if true, the object is restarted (reactivated) when
either the activator is restarted or the object's activation group
is restarted after an unexpected crash; if false, the object is only
activated on demand. Specifying restart
to be
true
does not force an initial immediate activation of
a newly registered object; initial activation is lazy.port
- the port on which the object is exported (an anonymous
port is used if port=0)csf
- the client-side socket factory for making calls to the
remote objectssf
- the server-side socket factory for receiving remote callsActivationException
- if activation group is not activeRemoteException
- if object registration or export failsUnsupportedOperationException
- if and only if activation is
not supported by this implementationpublic static Remote exportObject(Remote obj, ActivationID id, int port) throws RemoteException
port
is zero.
During activation, this exportObject
method should
be invoked explicitly by an "activatable" object, that does not
extend the Activatable
class. There is no need for objects
that do extend the Activatable
class to invoke this
method directly because the object is exported during construction.
obj
- the remote object implementationid
- the object's activation identifierport
- the port on which the object is exported (an anonymous
port is used if port=0)RemoteException
- if object export failsUnsupportedOperationException
- if and only if activation is
not supported by this implementationpublic static Remote exportObject(Remote obj, ActivationID id, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException
port
is zero.
During activation, this exportObject
method should
be invoked explicitly by an "activatable" object, that does not
extend the Activatable
class. There is no need for objects
that do extend the Activatable
class to invoke this
method directly because the object is exported during construction.
obj
- the remote object implementationid
- the object's activation identifierport
- the port on which the object is exported (an anonymous
port is used if port=0)csf
- the client-side socket factory for making calls to the
remote objectssf
- the server-side socket factory for receiving remote callsRemoteException
- if object export failsUnsupportedOperationException
- if and only if activation is
not supported by this implementationpublic static boolean unexportObject(Remote obj, boolean force) throws NoSuchObjectException
obj
- the remote object to be unexportedforce
- if true, unexports the object even if there are
pending or in-progress calls; if false, only unexports the object
if there are no pending or in-progress callsNoSuchObjectException
- if the remote object is not
currently exportedUnsupportedOperationException
- if and only if activation is
not supported by this implementation Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2024, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.