com.sun.grizzly.filter
Class RemoteInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.sun.grizzly.filter.RemoteInputStream
All Implemented Interfaces:
Closeable

public class RemoteInputStream
extends InputStream

Stream that blocks on empty read() until close() is called. This is usefull in scenarios where a server streams FragmentMessage to a client. Enables therefore Client to start processing bytes as soon as first FragmentMessage arrives. When finished a Server or Producer of bytes must call close() so that client is released from waiting on this stream.

Version:
1.0
Author:
John Vieten 24.06.2008

Constructor Summary
RemoteInputStream()
           
 
Method Summary
 void add(ByteBuffer buffer)
          Adds a ByteBuffer to the stream
 void add(List<ByteBuffer> bList)
          Adds a List of ByteBuffers to the Stream
 int available()
           
 void close()
          Adds EOF to end of Stream.
 long getTimeStamp()
           
 boolean isApplicationLayerException()
           
 int read()
          If no bytes are available blocks until close() is called.
 int read(byte[] bytes, int off, int len)
          If no bytes are available blocks until close() is called
 void setApplicationLayerException(boolean applicationLayerException)
           
 void setIOException(IOException exception)
           
 long skip(long n)
           
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteInputStream

public RemoteInputStream()
Method Detail

isApplicationLayerException

public boolean isApplicationLayerException()

setApplicationLayerException

public void setApplicationLayerException(boolean applicationLayerException)

setIOException

public void setIOException(IOException exception)

getTimeStamp

public long getTimeStamp()

add

public void add(ByteBuffer buffer)
Adds a ByteBuffer to the stream

Parameters:
buffer - bytes to add to inputstream

add

public void add(List<ByteBuffer> bList)
Adds a List of ByteBuffers to the Stream

Parameters:
bList - List of ByteBuffer containing stream bytes

close

public void close()
Adds EOF to end of Stream. This method must be called so that client stops waiting on this Inputstream.

Specified by:
close in interface Closeable
Overrides:
close in class InputStream

read

public int read()
         throws IOException
If no bytes are available blocks until close() is called.

Specified by:
read in class InputStream
Returns:
int next byte of the stream
Throws:
IOException

read

public int read(byte[] bytes,
                int off,
                int len)
         throws IOException
If no bytes are available blocks until close() is called

Overrides:
read in class InputStream
Parameters:
bytes - byte array to be filled
off - offset
len - size
Returns:
next bytes of the stream
Throws:
IOException

skip

public long skip(long n)
          throws IOException
Overrides:
skip in class InputStream
Throws:
IOException

available

public int available()
              throws IOException
Overrides:
available in class InputStream
Throws:
IOException


Copyright © 2012 Oracle Corporation. All Rights Reserved.