com.healthmarketscience.rmiio.exporter
Class RemoteStreamExporter

java.lang.Object
  extended by com.healthmarketscience.rmiio.exporter.RemoteStreamExporter
Direct Known Subclasses:
DefaultRemoteStreamExporter

public abstract class RemoteStreamExporter
extends Object

Base class for objects which manage exporting RemoteStreamServers. "Exporting" is the act of making a RemoteStreamServer available remotely via some RPC framework (such as RMI). This class allows the rmiio utilities to be used with any RPC framework by separating the server implementation from the RPC integration.

See the getInstance() method for details on how the default exporter can be specified as a system property.

RemoteStreamExporter implementations are expected to be thread-safe and reentrant after construction.

For some helper classes which may be useful for alternative RPC frameworks, see RemoteStreamServerInvokerHelper, RemoteInputStreamClientProxy, and RemoteOutputStreamClientProxy.

Author:
James Ahlborn

Field Summary
static String DEFAULT_EXPORTER_CLASS_NAME
          name of the default exporter implementation returned by getInstance() if none is specified via system property
static String EXPORTER_PROPERTY
          system property used by getInstance() to determine which exporter implementation to return
protected static org.apache.commons.logging.Log LOG
           
 
Constructor Summary
protected RemoteStreamExporter()
           
 
Method Summary
<StreamType,StreamServerType extends RemoteStreamServer<?,StreamType>>
StreamType
export(StreamServerType server)
          Exports the given stream server via the desired RPC framework and returns the "remote" instance (often some sort of serializable stub object).
protected abstract  Object exportImpl(RemoteStreamServer<?,?> server)
          Called by export(StreamServerType) to do the actual export work for the relevant RPC framework.
static RemoteStreamExporter getInstance()
          Returns the default RemoteStreamExporter to use.
 void unexport(RemoteStreamServer<?,?> server)
          Unexports the given previously exported stream server from the desired RPC framework.
protected abstract  void unexportImpl(RemoteStreamServer<?,?> server)
          Called by unexport(com.healthmarketscience.rmiio.RemoteStreamServer) to do the actual unexport work for the relevant RPC framework.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.commons.logging.Log LOG

EXPORTER_PROPERTY

public static final String EXPORTER_PROPERTY
system property used by getInstance() to determine which exporter implementation to return

See Also:
Constant Field Values

DEFAULT_EXPORTER_CLASS_NAME

public static final String DEFAULT_EXPORTER_CLASS_NAME
name of the default exporter implementation returned by getInstance() if none is specified via system property

Constructor Detail

RemoteStreamExporter

protected RemoteStreamExporter()
Method Detail

getInstance

public static RemoteStreamExporter getInstance()
Returns the default RemoteStreamExporter to use.

Returns:
the default RemoteStreamExporter to use, either specified by the system property EXPORTER_PROPERTY or an instance of DEFAULT_EXPORTER_CLASS_NAME. The exporter is instantiated once, on demand, and returned thereafter.

export

public <StreamType,StreamServerType extends RemoteStreamServer<?,StreamType>> StreamType export(StreamServerType server)
                  throws RemoteException
Exports the given stream server via the desired RPC framework and returns the "remote" instance (often some sort of serializable stub object). The given stream instance should now be reachable from a remote call.

Returns:
the remote stub used for interacting with this stream instance from a remote client
Throws:
RemoteException - if the stream instance could not be exported

unexport

public void unexport(RemoteStreamServer<?,?> server)
Unexports the given previously exported stream server from the desired RPC framework. The given stream instance will no longer be reachable from a remote call.


exportImpl

protected abstract Object exportImpl(RemoteStreamServer<?,?> server)
                              throws RemoteException
Called by export(StreamServerType) to do the actual export work for the relevant RPC framework. This method will be called synchronized on the given stream instance, so it will not overlap an unexport(com.healthmarketscience.rmiio.RemoteStreamServer) call for the same instance.

Note, RemoteStreamServer implements Unreferenced, which is an rmi interface used to clean up servers which have lost their clients. RPC frameworks which export remote streams should attempt to handle abnormal client termination, and are encouraged to make use of the Unreferenced interface to shutdown an orphaned stream server.

Returns:
the remote stub, which should be an instance of the remote interface of this server
Throws:
RemoteException - if the stream instance could not be exported

unexportImpl

protected abstract void unexportImpl(RemoteStreamServer<?,?> server)
                              throws Exception
Called by unexport(com.healthmarketscience.rmiio.RemoteStreamServer) to do the actual unexport work for the relevant RPC framework. This method will be called synchronized on the given stream instance, so it will not overlap an export(StreamServerType) call for the same instance. This method call is allowed break existing connections to this stream instance. Any exceptions thrown will be logged, but otherwise ignored.

Throws:
Exception - if the unexport failed


Copyright © 2006–2016 Health Market Science. All rights reserved.