edu.emory.mathcs.util.remote.io
Class RemoteOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byedu.emory.mathcs.util.remote.io.RemoteOutputStream
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class RemoteOutputStream
extends java.io.OutputStream
implements java.io.Externalizable

Serializable output stream that writes to an output stream on a remote host, using RMI. Since RMI itself can be enabled over various protocols and socket factories, this class allows to tunnel byte streams through a variety of protocols. For example, if used with RMIX, it is possible to tunnel streams via SOAP/HTTP. Typical usage pattern is to create the instance at the server side and then send it to the client via RMI:

 OutputStream getRemoteStream() throws RemoteException {
    OutputStream sink = ...;
    RemoteOutputStreamSrv srv = new RemoteOutputStreamSrvImpl(sink);
    // the following line for standard RMI only (not RMIX or JERI)
    UnicastRemoteObject.exportObject(srv);
    return new RemoteOutputStream(srv);
 }
 

Version:
1.0
Author:
Dawid Kurzyniec
See Also:
Serialized Form

Constructor Summary
RemoteOutputStream()
          for deserialization only
RemoteOutputStream(java.io.OutputStream out)
          Deprecated. this constructor does not work correctly with standard Java RMI (it only works with RMIX). See this class javadoc for instantiation instructions.
RemoteOutputStream(RemoteOutputStreamSrv server)
          Constructs a new serializable remote output stream that writes to the specified stream handle.
 
Method Summary
 void close()
           
 void flush()
           
 void readExternal(java.io.ObjectInput in)
           
 void write(byte[] buf)
           
 void write(byte[] buf, int off, int len)
           
 void write(int b)
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteOutputStream

public RemoteOutputStream()
for deserialization only


RemoteOutputStream

public RemoteOutputStream(java.io.OutputStream out)
Deprecated. this constructor does not work correctly with standard Java RMI (it only works with RMIX). See this class javadoc for instantiation instructions.

Constructs a new serializable remote output stream that writes to the specified stream.

Parameters:
out - the sink stream

RemoteOutputStream

public RemoteOutputStream(RemoteOutputStreamSrv server)
Constructs a new serializable remote output stream that writes to the specified stream handle. Use this constructor on the client side if the RMI handle to the server has been already created.

Parameters:
server - RMI handle to the source stream
Method Detail

write

public void write(int b)
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(byte[] buf)
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(byte[] buf,
                  int off,
                  int len)
           throws java.io.IOException
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException