java.rmi.activation

Class Activatable

Implemented Interfaces:
Remote, Serializable

public abstract class Activatable
extends RemoteServer

A common ancestor for the implementations of the activatable objects. Such objects require persistent access over time and can be activated by the system. The derived classes also implements the needed interface of some remote object and usually have the two parameter constructor, the first parameter being the ActivationID and the second the MarshalledObject. Activatable is the main class that developers need to use to implement and manage activatable objects. It also contains methods for making activatable remote objects that are not derived from the Activatable class.
See Also:
Serialized Form

Field Summary

Fields inherited from class java.rmi.server.RemoteObject

ref

Constructor Summary

Activatable(String codebase, MarshalledObject data, boolean restart, int port)
This constructor is used to register export the object on the given port.
Activatable(String codebase, MarshalledObject data, boolean restart, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)
This constructor is used to register export the object on the given port, additionally specifying the socket factories.
Activatable(ActivationID anId, int port)
Creates the new instance of activatable with the given activation id and is listening at the given port.
Activatable(ActivationID anId, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)
Creates the new instance of activatable with the given activation id and is listening at the given port, using the specified client and server sockets factories.

Method Summary

static ActivationID
exportObject(Remote obj, String location, MarshalledObject data, boolean restart, int port)
Register and export the object that activatable object that is not derived from the Activatable super class.
static ActivationID
exportObject(Remote obj, String location, MarshalledObject<T> data, boolean restart, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)
Register and export the object that activatable object that is not derived from the Activatable super class.
static Remote
exportObject(Remote obj, ActivationID id, int port)
During activation, this exportObject method should be invoked explicitly by the activatable object, that does is not derived from the Activatable class.
static Remote
exportObject(Remote obj, ActivationID id, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)
During activation, this exportObject method should be invoked explicitly by the activatable object, that does is not derived from the Activatable class.
protected ActivationID
getID()
Get the objects activation identifier.
static boolean
inactive(ActivationID id)
Inactivates and unexports the object.
static Remote
register(ActivationDesc desc)
This method registers an activatable object.
static boolean
unexportObject(Remote obj, boolean force)
Make the remote object unavailable for incoming calls.
static void
unregister(ActivationID id)
Unregister the object (the object will no longer be activable with that id)

Methods inherited from class java.rmi.server.RemoteServer

getClientHost, getLog, setLog

Methods inherited from class java.rmi.server.RemoteObject

equals, getRef, hashCode, toString, toStub

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

Activatable

protected Activatable(String codebase,
                      MarshalledObject data,
                      boolean restart,
                      int port)
            throws ActivationException,
                   RemoteException
This constructor is used to register export the object on the given port. A subclass of the Activatable class calls this constructor to register and export the object during initial construction. As a side-effect of activatable object construction, the remote object is both "registered" with the activation system and "exported" (on an anonymous port, if port is zero) to the RMI runtime so that it is available to accept incoming calls from clients.
Parameters:
codebase - the object code base url
data - the data, needed to activate the object.
restart - specifies reactivation mode after crash. If true, the object is activated when activator is restarted or the activation group is restarted. If false, the object is only activated on demand. This flag does has no effect during the normal operation (the object is normally activated on demand).
port - the port, on which the object will become available. The value 0 means anonymous port.
Throws:
ActivationException - if the activation failed
RemoteException - if the remote call failed.

Activatable

protected Activatable(String codebase,
                      MarshalledObject data,
                      boolean restart,
                      int port,
                      RMIClientSocketFactory csf,
                      RMIServerSocketFactory ssf)
            throws ActivationException,
                   RemoteException
This constructor is used to register export the object on the given port, additionally specifying the socket factories. A subclass of the Activatable class calls this constructor to register and export the object during initial construction.
Parameters:
codebase - the object code base url
data - the data, needed to activate the object.
restart - specifies reactivation mode after crash. If true, the object is activated when activator is restarted or the activation group is restarted. If false, the object is only activated on demand. This flag does has no effect during the normal operation (the object is normally activated on demand).
port - the port, on which the object will become available. The value 0 means anonymous port.
csf - the client socket factory
ssf - the server socket factory
Throws:
ActivationException - if the activation failed
RemoteException - if the remote call failed.

Activatable

protected Activatable(ActivationID anId,
                      int port)
            throws RemoteException
Creates the new instance of activatable with the given activation id and is listening at the given port. A subclass of the Activatable class calls this constructor when the object itself is activated via its special "activation" constructor with the two parameters (ActivationID, MarshalledObject). As a side effect, the object is exported and is available to accept incoming calls.
Parameters:
anId - the activation id
port - the port, on which the activatable will be listening
Throws:
RemoteException - if the activation failed.

Activatable

protected Activatable(ActivationID anId,
                      int port,
                      RMIClientSocketFactory csf,
                      RMIServerSocketFactory ssf)
            throws RemoteException
Creates the new instance of activatable with the given activation id and is listening at the given port, using the specified client and server sockets factories. A subclass of the Activatable class calls this constructor when the object itself is activated via its special "activation" constructor with the two parameters (ActivationID, MarshalledObject). As a side effect, the object is exported and is available to accept incoming calls.
Parameters:
anId - the activation id
port - the port, on which the activatable will be listening
csf - the client socket factory
ssf - the server socket factory
Throws:
RemoteException - if the remote call failed

Method Details

exportObject

public static ActivationID exportObject(Remote obj,
                                        String location,
                                        MarshalledObject data,
                                        boolean restart,
                                        int port)
            throws ActivationException,
                   RemoteException
Register and export the object that activatable object that is not derived from the Activatable super class. It creates and registers the object activation descriptor. There is no need to call this method if the object extends Activable, as its work is done in the constructor Activatable(String, MarshalledObject, boolean, int).
Parameters:
obj - the object, that is exported, becoming available at the given port.
location - the object code location (codebase).
data - the data, needed to activate the object
restart - the restart mode
port - the port, where the object will be available
Returns:
the created object activation ID.
Throws:
ActivationException - if the activation group is not active
RemoteException - if the registration or export fails

exportObject

public static ActivationID exportObject(Remote obj,
                                        String location,
                                        MarshalledObject<T> data,
                                        boolean restart,
                                        int port,
                                        RMIClientSocketFactory csf,
                                        RMIServerSocketFactory ssf)
            throws ActivationException,
                   RemoteException
Register and export the object that activatable object that is not derived from the Activatable super class. It creates and registers the object activation descriptor. There is no need to call this method if the object extends Activable, as its work is done in the constructor Activatable(String, MarshalledObject, boolean, int, RMIClientSocketFactory, RMIServerSocketFactory)
Parameters:
obj - the object, that is exported, becoming available at the given port.
location - the object code location (codebase).
data - the data, needed to activate the object
restart - the restart mode
port - the port, where the object will be available
csf - the client socket factory
ssf - the server socket factory
Returns:
the created object activation ID.
Throws:
ActivationException - if the activation group is not active
RemoteException - if the registration or export fails

exportObject

public static Remote exportObject(Remote obj,
                                  ActivationID id,
                                  int port)
            throws RemoteException
During activation, this exportObject method should be invoked explicitly by the activatable object, that does is not derived from the Activatable class. There is no need to call this method if the object extends Activable, as its work is done in the constructor Activatable(ActivationID,int)
Parameters:
obj - the object
id - the known activation id
port - the object port
Returns:
the remote stub of the activatable object
Throws:
RemoteException - if the object export fails

exportObject

public static Remote exportObject(Remote obj,
                                  ActivationID id,
                                  int port,
                                  RMIClientSocketFactory csf,
                                  RMIServerSocketFactory ssf)
            throws RemoteException
During activation, this exportObject method should be invoked explicitly by the activatable object, that does is not derived from the Activatable class. There is no need to call this method if the object extends Activable, as its work is done in the constructor Activatable(ActivationID,int)
Parameters:
obj - the object
id - the known activation id
port - the object port
csf - the client socket factory
ssf - the server socket factory
Returns:
the remote stub of the activatable object
Throws:
RemoteException - if the object export fails

getID

protected ActivationID getID()
Get the objects activation identifier.
Returns:
the object activation identifier

inactive

public static boolean inactive(ActivationID id)
            throws UnknownObjectException,
                   ActivationException,
                   RemoteException
Inactivates and unexports the object. The subsequent calls will activate the object again. The object is not inactivated if it is currently executing calls.
Parameters:
id - the id of the object being inactivated
Returns:
true if the object has been inactivated, false if it has not been inactivated because of the running or pending calls.
Throws:
UnknownObjectException - if the object is unknown.
ActivationException - if the object group is not active
RemoteException - if the remote call fails

register

public static Remote register(ActivationDesc desc)
            throws UnknownGroupException,
                   ActivationException,
                   RemoteException
This method registers an activatable object. The object is expected to be on the anonymous port (null client and server socket factories).
Parameters:
desc - the object description.
Returns:
the remote stub for the activatable object (the first call on this stub will activate the object).
Throws:
UnknownGroupException - if the object group identifier is unknown
ActivationException - if the activation system is not running
RemoteException - if the remote call fails

unexportObject

public static boolean unexportObject(Remote obj,
                                     boolean force)
            throws NoSuchObjectException
Make the remote object unavailable for incoming calls. This method also unregisters the object, so it cannot be activated again by incoming call (unless registered).
Parameters:
obj - the object to unexport
force - if true, cancel all pending or running calls to that object (if false, the object with such calls is not unexported and false is returned by this method).
Returns:
if the object was successfully unexported, false otherwise
Throws:
NoSuchObjectException - if such object is not known

unregister

public static void unregister(ActivationID id)
            throws UnknownObjectException,
                   ActivationException,
                   RemoteException
Unregister the object (the object will no longer be activable with that id)
Parameters:
id - the object id
Throws:
UnknownObjectException - if the id is unknown
ActivationException - if the activation system is not running
RemoteException - if the remote call fails.

Activatable.java -- A common ancestor for the activatable objects. Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.