com.sas.net.rmi
Class AbstractRemoteObjectExporter

java.lang.Object
  |
  +--com.sas.net.rmi.AbstractRemoteObjectExporter
All Implemented Interfaces:
RemoteObjectExporterInterface
Direct Known Subclasses:
ActivatableExporter, UnicastRemoteObjectExporter

public abstract class AbstractRemoteObjectExporter
extends java.lang.Object
implements RemoteObjectExporterInterface

An abstract base class providing base implementations to export/unexport a remote object to/from the RMI system.

A concrete subclass must implement the following methods which are abstractly defined by this class:

  1. exportObject()
  2. unexportObject()

The following subclasses provide concrete implementations of these abstract behaviors:

Note that remote object implementation classes which do not extend UnicastRemoteObject must assume the responsibility for the correct semantics of the hashCode, equals, and toString methods inherited from the Object class, so that they behave appropriately for remote objects.

Since:
9.1.3
See Also:
ActivatableExporter, UnicastRemoteObjectExporter

Constructor Summary
AbstractRemoteObjectExporter(Remote remoteObject, int portNumber, RMIClientSocketFactory rmiClientSocketFactory, RMIServerSocketFactory rmiServerSocketFactory, boolean isForcibleUnexport)
          Constructs an instance specifying the server and client socket factories.
 
Method Summary
 Remote exportObject()
          Exports the remote object returning the remote object's stub.
protected abstract  Remote exportObject(Remote remoteObject, int port, RMIClientSocketFactory rmiClientSocketFactory, RMIServerSocketFactory rmiServerSocketFactory)
          Exports the remote object returning the remote object's stub.
 Remote getExportedRemoteObjectStub()
          Gets the remote object that has been exported to the RMI system using the exportObject() method.
 int getPortNumber()
          Gets the port number on which the remote object should be exported.
 Remote getRemotableObject()
          Gets the remote object that is to be exported to the RMI system.
 RMIClientSocketFactory getRMIClientSocketFactory()
          Gets the RMI client socket factory.
 RMIServerSocketFactory getRMIServerSocketFactory()
          Gets the RMI server socket factory.
 boolean isExported()
          Determines whether or not the remote object is currently exported.
 boolean isForcibleUnexport()
          Determines whether or not the exported remote object should be forcibly unexported.
 void setIsForcibleUnexport(boolean isForcibleUnexport)
          Determines whether or not the exported remote object should be forcibly unexported.
 boolean unexportObject()
          Unexports the remote object from the RMI system.
protected abstract  boolean unexportObject(Remote remoteObject, boolean isForcibleUnexport)
          Unexports the remote object previously exported using the exportObject() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRemoteObjectExporter

public AbstractRemoteObjectExporter(Remote remoteObject,
                                    int portNumber,
                                    RMIClientSocketFactory rmiClientSocketFactory,
                                    RMIServerSocketFactory rmiServerSocketFactory,
                                    boolean isForcibleUnexport)
                             throws IllegalArgumentException
Constructs an instance specifying the server and client socket factories.
Parameters:
remoteObject - The remote object that may be exported to the RMI system to create a remote object stub. Ensure that the remote object implementation correctly implements hashCode, equals, and toString methods to ensure correct behavior by the remote object.
portNumber - Port on which the object should be exported. Specify Constants.PORT_ANONYMOUS to designate an anonymous port or a value greater than 0 to designate a well-known port.
rmiClientSocketFactory - The client-side RMI socket factory is used to create sockets to make calls to the remote object or null if using the default.
rmiServerSocketFactory - The server-side RMI socket factory is used to create sockets to receive remote calls or null if using the default.
isForcibleUnexport - Specify true if the remote object should be unexported without regard to whether or not there are any active or pending remote calls or false if the remote object should not be unexported if there are active or pending calls.
Throws:
IllegalArgumentException - if an invalid remote object or port number is specified.
Method Detail

exportObject

public final Remote exportObject()
                          throws RemoteException
Exports the remote object returning the remote object's stub.

This is a template method which calls exportObject(Remote, int, RMIClientSocketFactory, RMIServerSocketFactory) passing the subclass implementation the object that is to be exported to the RMI system, the port, and the RMI socket factories.

Specified by:
exportObject in interface RemoteObjectExporterInterface
Returns:
Exported remote object's stub.
Throws:
RemoteException - if unable to unexport the remote object.

unexportObject

public final boolean unexportObject()
                             throws NoSuchObjectException
Unexports the remote object from the RMI system.

This is a template method which calls unexportObject(Remote exportedRemoteObject, boolean isForcibleUnexport) passing the subclass implementation the remote object that was originally passed to the exportObject(Remote, int, RMIClientSocketFactory, RMIServerSocketFactory) and exported to the RMI system.

Specified by:
unexportObject in interface RemoteObjectExporterInterface
Returns:
true if the unexport operation was successfully completed.
Throws:
NoSuchObjectException - if unable to unexport the remote object.

exportObject

protected abstract Remote exportObject(Remote remoteObject,
                                       int port,
                                       RMIClientSocketFactory rmiClientSocketFactory,
                                       RMIServerSocketFactory rmiServerSocketFactory)
                                throws RemoteException
Exports the remote object returning the remote object's stub. The returned stub should be unexported from the RMI system when it is no longer needed by the calling unexportObject() method.

This method is only intended to be called by this abstract implementation's exportObject() method which will provide the appropriate parameters.

Returns:
Exported remote object's stub or null if no object was exported.
Throws:
RemoteException - if unable to export the remote object.

unexportObject

protected abstract boolean unexportObject(Remote remoteObject,
                                          boolean isForcibleUnexport)
                                   throws NoSuchObjectException
Unexports the remote object previously exported using the exportObject() method.

This method is only intended to be called by this abstract implementation's unexportObject() method which will provide the appropriate parameters.

Parameters:
remoteObject - The remote object which was exported to the RMI system.
isForcibleUnexport - true if the remote object's stub should be forcibly removed from the RMI system without regard to whether or not there are any active or pending calls. Specify false if the stub should not be unexported if there are active or pending calls.
Returns:
true if the unexport operation was successfully completed.
Throws:
NoSuchObjectException - if unable to unexport the remote object.

getRemotableObject

public final Remote getRemotableObject()
Gets the remote object that is to be exported to the RMI system.
Returns:
remote object that is to be exported.

getPortNumber

public final int getPortNumber()
Gets the port number on which the remote object should be exported.

Constants.PORT_ANONYMOUS designates an anonymous port.

Returns:
Port number on which the remote object should be exported.

isExported

public final boolean isExported()
Determines whether or not the remote object is currently exported.
Specified by:
isExported in interface RemoteObjectExporterInterface
Returns:
true if the remote object is currently exported.

isForcibleUnexport

public final boolean isForcibleUnexport()
Determines whether or not the exported remote object should be forcibly unexported.
Returns:
true if the exported remote object should be forcibly unexported.

setIsForcibleUnexport

public final void setIsForcibleUnexport(boolean isForcibleUnexport)
Determines whether or not the exported remote object should be forcibly unexported.
Parameters:
isForcibleUnexport - true if the exported remote object should be forcibly unexported. A forcible unexport will forcibly drop all active connections to the remote object.

getExportedRemoteObjectStub

public final Remote getExportedRemoteObjectStub()
Gets the remote object that has been exported to the RMI system using the exportObject() method.
Specified by:
getExportedRemoteObjectStub in interface RemoteObjectExporterInterface
Returns:
Remotable object that has been exported to the RMI system or null if an object is not currently exported.

getRMIClientSocketFactory

public final RMIClientSocketFactory getRMIClientSocketFactory()
Gets the RMI client socket factory.
Returns:
RMI client-side socket factory that is used to create sockets to make calls to the remote object. Note that a null is returned if a default factory is desired.

getRMIServerSocketFactory

public final RMIServerSocketFactory getRMIServerSocketFactory()
Gets the RMI server socket factory.
Returns:
RMI client-side socket factory that is used to create sockets to make calls to the remote object. Note that a null is returned if a default factory is desired.




Copyright © 2005 SAS Institute Inc. All Rights Reserved.
javadoc generated Thu, 16 Feb 2006 02:04:20