org.jboss.remoting.transport.multiplex
Class MultiplexingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.jboss.remoting.transport.multiplex.utility.GrowablePipedInputStream
          extended by org.jboss.remoting.transport.multiplex.MultiplexingInputStream
All Implemented Interfaces:
java.io.Closeable

public class MultiplexingInputStream
extends GrowablePipedInputStream

MultiplexingInputStream is the class returned by VirtualSocket.getInputStream(). It supports the methods and behavior implemented by the InputStream returned by java.net.Socket.getInputStream(). For more information about the behavior of the methods, see the javadoc for java.io.InputStream.

Copyright (c) 2005

Author:
Ron Sigal

Field Summary
protected static org.jboss.logging.Logger log
           
 
Constructor Summary
MultiplexingInputStream(GrowablePipedOutputStream sourceStream, MultiplexingManager manager)
           
MultiplexingInputStream(GrowablePipedOutputStream sourceStream, MultiplexingManager manager, VirtualSocket socket)
           
MultiplexingInputStream(GrowablePipedOutputStream sourceStream, MultiplexingManager manager, VirtualSocket socket, VirtualSelector virtualSelector)
           
 
Method Summary
 void close()
          See superclass javadoc.
protected  VirtualSocket getSocket()
           
protected  void handleRemoteShutdown()
          handleRemoteShutdown() is responsible for informing the MultiplexingInputStream that no more bytes will be coming from the remote MultiplexingOutputStream to which it is connected, because shutdownOutput() or close() has been called on the remote VirtualSocket.
protected  void interruptReadingThreads()
           
 int read()
          See superclass javadoc.
 int read(byte[] bytes)
          See superclass javadoc.
 int read(byte[] bytes, int off, int len)
          See superclass javadoc.
 int readInt()
          readInt() is borrowed from DataInputStream.
protected  void setEOF()
           
protected  void setReadException(java.io.IOException e)
           
protected  void setSkip(long n)
           
protected  void setSocket(VirtualSocket socket)
          A MultiplexingInputStream may be created without reference to a VirtualSocket.
 long skip(long n)
          See superclass javadoc.
 
Methods inherited from class org.jboss.remoting.transport.multiplex.utility.GrowablePipedInputStream
available, connect, getTimeout, isConnected, receive, receive, receive, register, setTimeout
 
Methods inherited from class java.io.InputStream
mark, markSupported, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.jboss.logging.Logger log
Constructor Detail

MultiplexingInputStream

public MultiplexingInputStream(GrowablePipedOutputStream sourceStream,
                               MultiplexingManager manager)
                        throws java.io.IOException
Parameters:
sourceStream -
manager -
Throws:
java.io.IOException

MultiplexingInputStream

public MultiplexingInputStream(GrowablePipedOutputStream sourceStream,
                               MultiplexingManager manager,
                               VirtualSocket socket)
                        throws java.io.IOException
Parameters:
sourceStream -
manager -
socket -
Throws:
java.io.IOException

MultiplexingInputStream

public MultiplexingInputStream(GrowablePipedOutputStream sourceStream,
                               MultiplexingManager manager,
                               VirtualSocket socket,
                               VirtualSelector virtualSelector)
                        throws java.io.IOException
Parameters:
sourceStream -
manager -
socket -
virtualSelector -
Throws:
java.io.IOException
Method Detail

close

public void close()
           throws java.io.IOException
See superclass javadoc.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class GrowablePipedInputStream
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
See superclass javadoc.

Overrides:
read in class GrowablePipedInputStream
Throws:
java.io.IOException

read

public int read(byte[] bytes)
         throws java.io.IOException
See superclass javadoc.

Overrides:
read in class GrowablePipedInputStream
Throws:
java.io.IOException

read

public int read(byte[] bytes,
                int off,
                int len)
         throws java.io.IOException
See superclass javadoc.

Overrides:
read in class GrowablePipedInputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
See superclass javadoc.

Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

getSocket

protected VirtualSocket getSocket()

handleRemoteShutdown

protected void handleRemoteShutdown()
                             throws java.io.IOException
handleRemoteShutdown() is responsible for informing the MultiplexingInputStream that no more bytes will be coming from the remote MultiplexingOutputStream to which it is connected, because shutdownOutput() or close() has been called on the remote VirtualSocket. The result is that once all bytes sent by the remote socket have been consumed, all subsequent calls to read() will return -1 and all subsequent calls to skip() will return 0, indicating end of file has been reached.

Throws:
java.io.IOException

interruptReadingThreads

protected void interruptReadingThreads()

readInt

public final int readInt()
                  throws java.io.IOException
readInt() is borrowed from DataInputStream. It saves the extra expense of creating a DataInputStream

Throws:
java.io.IOException

setEOF

protected void setEOF()

setReadException

protected void setReadException(java.io.IOException e)

setSkip

protected void setSkip(long n)
Parameters:
n -

setSocket

protected void setSocket(VirtualSocket socket)
A MultiplexingInputStream may be created without reference to a VirtualSocket. (See MultiplexingManager.getAnOutputStream().) setSocket() allows the socket to be set afterwards.

Parameters:
socket -


Copyright © 1998-2005 JBoss Inc . All Rights Reserved.