com.healthmarketscience.rmiio.exporter
Class RemoteOutputStreamClientProxy

java.lang.Object
  extended by com.healthmarketscience.rmiio.exporter.RemoteOutputStreamClientProxy
All Implemented Interfaces:
RemoteOutputStream, Flushable, Remote

public abstract class RemoteOutputStreamClientProxy
extends Object
implements RemoteOutputStream

Base RemoteOutputStream implementation which translates each method invocation into a call to the invoke(int, java.lang.Object...) method in a manner compatible with the RemoteStreamServerInvokerHelper invoke method for a RemoteOutputStreamServer. This class may be useful for exporting remote stream servers in alternative RPC frameworks.

Author:
James Ahlborn

Constructor Summary
RemoteOutputStreamClientProxy()
           
 
Method Summary
 void close(boolean readSuccess)
          Closes the output stream and releases the resources for this server object.
 void flush()
          Flushes the output stream and forces as much as possible of any buffered bytes to be written out.
protected abstract  Object invoke(int methodCode, Object... parameters)
          Invokes the given method name with the given parameters on the remote RemoteInputStreamServer and returns the results.
 boolean usingGZIPCompression()
          Returns true if the stream is using GZIP compression over the wire.
 void writePacket(byte[] packet, int packetId)
          Writes the next chunk of data to this stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteOutputStreamClientProxy

public RemoteOutputStreamClientProxy()
Method Detail

usingGZIPCompression

public boolean usingGZIPCompression()
                             throws IOException
Description copied from interface: RemoteOutputStream
Returns true if the stream is using GZIP compression over the wire.

Specified by:
usingGZIPCompression in interface RemoteOutputStream
Returns:
true iff the stream data is compressed, false otherwise
Throws:
IOException

close

public void close(boolean readSuccess)
           throws IOException
Description copied from interface: RemoteOutputStream
Closes the output stream and releases the resources for this server object. Note that the remote object may no longer be accessible after this call (depending on the implementation), so clients should not attempt to use this stream after making this call.

Specified by:
close in interface RemoteOutputStream
Parameters:
readSuccess - true iff all data was sent successfully from the client, false otherwise
Throws:
IOException

flush

public void flush()
           throws IOException
Description copied from interface: RemoteOutputStream
Flushes the output stream and forces as much as possible of any buffered bytes to be written out. Some of the layers of buffering may not be able to be flushed, so this method should not be depended upon to do much. The close() method will do any final flushing necessary (and can be depended upon).

Specified by:
flush in interface RemoteOutputStream
Specified by:
flush in interface Flushable
Throws:
IOException

writePacket

public void writePacket(byte[] packet,
                        int packetId)
                 throws IOException
Description copied from interface: RemoteOutputStream
Writes the next chunk of data to this stream. The given packetId parameter (if used correctly) allows this operation to be idempotent. This parameter must be a monotonically increasing, positive integer. If the client fails to write a given packet, it may reattempt to write the same packet by giving the same packetId as from the failed call. However, only the current packet may be reattempted (the client cannot attempt to write any other previous packets). When writing a new packet, the caller does not need to give a sequential id, just a greater one (hence the term monotonically increasing).

Specified by:
writePacket in interface RemoteOutputStream
Parameters:
packet - iff the packetId was the same one from the last read call, this chunk of data is ignored. Otherwise, writes this new chunk of data to the stream.
packetId - client specified id for this packet
Throws:
IOException

invoke

protected abstract Object invoke(int methodCode,
                                 Object... parameters)
                          throws IOException
Invokes the given method name with the given parameters on the remote RemoteInputStreamServer and returns the results.

Parameters:
methodCode - the name of the method to invoke, one of the RemoteStreamServerInvokerHelper.IN_*_METHOD constants
parameters - parameters for the method invocation (may be null if the method takes no parameters)
Returns:
the result of the method call, (or null for void methods)
Throws:
IOException - if the remote server throws or there is a communication failure.


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