com.healthmarketscience.rmiio
Class RemoteOutputStreamClient

java.lang.Object
  extended by com.healthmarketscience.rmiio.RemoteOutputStreamClient

public class RemoteOutputStreamClient
extends Object

Utility which provides a wrapper OutputStream for the client of a RemoteOutputStream. The wrapper will automagically handle any compression needs of the remote stream. RemoteException's will be retried using the given RemoteRetry implementation. Users should generally not need to wrap the returned stream with a BufferedOutputStream as buffering will be done by the returned implementation (unless *large* amounts of buffering are desired).

Warning, beware layering a PrintWriter or PrintStream on top of a RemoteOutputStream, as both of the aforementioned classes "swallow" IOExceptions (well, they don't swallow them, you just have to test for them). In such a scenario, a client will not detect a problem in the remote stream unless they specifically test for an error in the PrintWriter/PrintStream.

Author:
James Ahlborn

Field Summary
static Integer DEFAULT_CHUNK_SIZE
          default chunk size for shuffling data over the wire.
static RemoteRetry DEFAULT_RETRY
          The default retry policy used by this class's wrappers if none is specified by the caller.
protected static org.apache.commons.logging.Log LOG
           
 
Method Summary
static OutputStream wrap(RemoteOutputStream remoteOut)
          Wraps a RemoteOutputStream as an OutputStream using the RemoteRetry.SIMPLE retry policy.
static OutputStream wrap(RemoteOutputStream remoteOut, RemoteRetry retry)
          Wraps a RemoteOutputStream as an OutputStream using the given retry policy.
static OutputStream wrap(RemoteOutputStream remoteOut, RemoteRetry retry, Integer chunkSize)
          Wraps a RemoteOutputStream as an OutputStream using the given retry policy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_RETRY

public static final RemoteRetry DEFAULT_RETRY
The default retry policy used by this class's wrappers if none is specified by the caller.


LOG

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

DEFAULT_CHUNK_SIZE

public static final Integer DEFAULT_CHUNK_SIZE
default chunk size for shuffling data over the wire.

Method Detail

wrap

public static OutputStream wrap(RemoteOutputStream remoteOut)
                         throws IOException
Wraps a RemoteOutputStream as an OutputStream using the RemoteRetry.SIMPLE retry policy.

Parameters:
remoteOut - a remote output stream interface
Returns:
an OutputStream which will write to the given RemoteOutputStream
Throws:
IOException

wrap

public static OutputStream wrap(RemoteOutputStream remoteOut,
                                RemoteRetry retry)
                         throws IOException
Wraps a RemoteOutputStream as an OutputStream using the given retry policy.

Parameters:
remoteOut - a remote output stream interface
retry - RemoteException retry policy to use, if null, DEFAULT_RETRY will be used.
Returns:
an OutputStream which will write to the given RemoteOutputStream
Throws:
IOException

wrap

public static OutputStream wrap(RemoteOutputStream remoteOut,
                                RemoteRetry retry,
                                Integer chunkSize)
                         throws IOException
Wraps a RemoteOutputStream as an OutputStream using the given retry policy.

Parameters:
remoteOut - a remote output stream interface
retry - RemoteException retry policy to use, if null, DEFAULT_RETRY will be used.
chunkSize - target value for the byte size of the packets of data sent over the wire. note that this is a suggestion, actual packet sizes may vary. if null, DEFAULT_CHUNK_SIZE will be used.
Returns:
an OutputStream which will write to the given RemoteOutputStream
Throws:
IOException


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