com.healthmarketscience.rmiio
Class EncodingRemoteIteratorServer<DataType>

java.lang.Object
  extended by com.healthmarketscience.rmiio.RemoteIteratorServer<DataType>
      extended by com.healthmarketscience.rmiio.EncodingRemoteIteratorServer<DataType>
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
SerialRemoteIteratorServer

public abstract class EncodingRemoteIteratorServer<DataType>
extends RemoteIteratorServer<DataType>

Base class for implementing the server side of a RemoteIterator where the objects need to be encoded on the fly. This object sends objects to the RemoteIteratorClient through the internal RemoteInputStreamServer as needed. Implementations of this class must implement the writeNextObject() method, which should write the next object in the iteration to the local output stream (which in turn will forward to data to the RemoteIteratorClient). An Implementation should override closeIterator() to do cleanup (like flushing and closing the output stream) after the last object has been sent. The local output stream must only be written during a call to writeNextObject() or closeIterator(). Note, users of this class should ensure that the close() method is called one way or another, or shutdown of the process may be delayed.

Note, a real-time-ish iterator is available if compression is disabled and noDelay is enabled (noDelay is ignored if compression is enabled). This will attempt to send objects across the wire ASAP, at the expense of more wire traffic.

Author:
James Ahlborn

Field Summary
protected  OutputStream _localOStream
          the OutputStream which subclasses should use to write out an object during a call to writeNextObject() (and possibly closeIterator()).
 
Fields inherited from class com.healthmarketscience.rmiio.RemoteIteratorServer
_localIStream
 
Constructor Summary
EncodingRemoteIteratorServer()
           
EncodingRemoteIteratorServer(boolean useCompression)
           
EncodingRemoteIteratorServer(boolean useCompression, boolean noDelay)
           
EncodingRemoteIteratorServer(boolean useCompression, boolean noDelay, RemoteStreamMonitor<RemoteInputStreamServer> monitor)
           
EncodingRemoteIteratorServer(boolean useCompression, boolean noDelay, RemoteStreamMonitor<RemoteInputStreamServer> monitor, int chunkSize)
           
EncodingRemoteIteratorServer(boolean useCompression, RemoteStreamMonitor<RemoteInputStreamServer> monitor)
           
 
Method Summary
protected  void closeIterator()
          Closes any resources held by this iterator.
protected abstract  boolean writeNextObject()
          If there are more objects in the iteration, writes an object to the _localOStream and returns true, otherwise returns false.
 
Methods inherited from class com.healthmarketscience.rmiio.RemoteIteratorServer
abort, close, closeImpl, isClosed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_localOStream

protected OutputStream _localOStream
the OutputStream which subclasses should use to write out an object during a call to writeNextObject() (and possibly closeIterator()).

Constructor Detail

EncodingRemoteIteratorServer

public EncodingRemoteIteratorServer()
                             throws IOException
Throws:
IOException

EncodingRemoteIteratorServer

public EncodingRemoteIteratorServer(boolean useCompression)
                             throws IOException
Throws:
IOException

EncodingRemoteIteratorServer

public EncodingRemoteIteratorServer(boolean useCompression,
                                    boolean noDelay)
                             throws IOException
Throws:
IOException

EncodingRemoteIteratorServer

public EncodingRemoteIteratorServer(boolean useCompression,
                                    RemoteStreamMonitor<RemoteInputStreamServer> monitor)
                             throws IOException
Throws:
IOException

EncodingRemoteIteratorServer

public EncodingRemoteIteratorServer(boolean useCompression,
                                    boolean noDelay,
                                    RemoteStreamMonitor<RemoteInputStreamServer> monitor)
                             throws IOException
Throws:
IOException

EncodingRemoteIteratorServer

public EncodingRemoteIteratorServer(boolean useCompression,
                                    boolean noDelay,
                                    RemoteStreamMonitor<RemoteInputStreamServer> monitor,
                                    int chunkSize)
                             throws IOException
Throws:
IOException
Method Detail

closeIterator

protected void closeIterator()
                      throws IOException
Closes any resources held by this iterator. Subclasses should flush/close OutputStream during this call.

Throws:
IOException

writeNextObject

protected abstract boolean writeNextObject()
                                    throws IOException
If there are more objects in the iteration, writes an object to the _localOStream and returns true, otherwise returns false.

Throws:
IOException


Copyright © 2006-2009 Health Market Science. All Rights Reserved.