com.healthmarketscience.rmiio
Class SerialRemoteIteratorClient<DataType>
java.lang.Object
com.healthmarketscience.rmiio.RemoteIteratorClient<DataType>
com.healthmarketscience.rmiio.SerialRemoteIteratorClient<DataType>
- All Implemented Interfaces:
- CloseableIOIterator<DataType>, IOIterator<DataType>, RemoteClient, RemoteIterator<DataType>, Closeable, Serializable
public class SerialRemoteIteratorClient<DataType>
- extends RemoteIteratorClient<DataType>
- implements Serializable
Implementation of RemoteIteratorClient which uses java serialization to
receive objects from the RemoteIteratorServer. Objects are deserialized
from the underlying remote input stream as needed and returned to the
ultimate consumer of the objects.
Note, the objects are read from the ObjectInputStream using the
ObjectInputStream.readUnshared() method. This is because
memory can build up in the ObjectInputStream over time and a large data set
can run the client and/or server out of memory. In general, the objects
being iterated over most likely do not have shared references, so nothing
will be lost by this choice. However, if shared references are desired,
the deserializeObject(java.io.ObjectInputStream) method can be overriden by a custom subclass
to change this behavior.
- Author:
- James Ahlborn
- See Also:
- Serialized Form
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SerialRemoteIteratorClient
public SerialRemoteIteratorClient(RemoteIteratorServer<DataType> server)
throws IOException
- Throws:
IOException
SerialRemoteIteratorClient
public SerialRemoteIteratorClient(RemoteIteratorServer<DataType> server,
RemoteStreamExporter exporter)
throws IOException
- Throws:
IOException
initialize
protected void initialize(InputStream istream)
throws IOException
- Description copied from class:
RemoteIteratorClient
- Initializes the subclass with a handle to the underlying remote input
stream. Will be called before any call to readNextObject().
- Specified by:
initialize in class RemoteIteratorClient<DataType>
- Throws:
IOException
readNextObject
protected DataType readNextObject()
throws IOException
- Description copied from class:
RemoteIteratorClient
- Reads the next object from the underlying input stream and returns it.
- Specified by:
readNextObject in class RemoteIteratorClient<DataType>
- Throws:
IOException
closeIterator
protected void closeIterator()
throws IOException
- Description copied from class:
RemoteIteratorClient
- Closes any resources held by this iterator.
- Overrides:
closeIterator in class RemoteIteratorClient<DataType>
- Throws:
IOException
deserializeObject
protected Object deserializeObject(ObjectInputStream istream)
throws IOException,
ClassNotFoundException
- Reads the next object from the given input stream. The default
implementation uses
ObjectInputStream.readUnshared().
Subclasses may choose to change this behavior by overriding this method.
- Parameters:
istream - the input stream from which to read the next object
- Returns:
- the next object read
- Throws:
IOException
ClassNotFoundException
Copyright © 2006-2009 Health Market Science. All Rights Reserved.