com.sun.grizzly.comet
Class CometReader

java.lang.Object
  extended by com.sun.grizzly.comet.CometReader
Direct Known Subclasses:
CometReader

public class CometReader
extends Object

Non blocking IO reader. This class can be used from a CometHandler to execute non blocking read. This is usefull when the client is pipelining data. The CometHandler will be notified as soon as bytes are arriving. CometHandler who wants to be notified just need to register themself by calling CometContext.registerAsyncRead()

Author:
Jeanfrancois Arcand

Constructor Summary
CometReader()
           
 
Method Summary
 boolean isReady()
          Return true if this instance is ready to read.
 int read(byte[] buf)
          Read bytes without blocking.
 int read(byte[] buf, int off, int len)
          Read bytes without blocking.
 void recycle()
          Recycle this object.
 void setByteBuffer(ByteBuffer byteBuffer)
           
protected  void setChannel(SocketChannel socketChannel)
          Set the underlying SocketChannel.
 void setNRead(int nRead)
           
 void setReady(boolean ready)
          false if this instance is no longer ready to read.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CometReader

public CometReader()
Method Detail

setChannel

protected void setChannel(SocketChannel socketChannel)
Set the underlying SocketChannel.


read

public int read(byte[] buf)
         throws IOException
Read bytes without blocking.

Throws:
IOException

read

public int read(byte[] buf,
                int off,
                int len)
         throws IOException
Read bytes without blocking.

Throws:
IOException

recycle

public void recycle()
Recycle this object.


setByteBuffer

public void setByteBuffer(ByteBuffer byteBuffer)

setNRead

public void setNRead(int nRead)

isReady

public boolean isReady()
Return true if this instance is ready to read.


setReady

public void setReady(boolean ready)
false if this instance is no longer ready to read.



Copyright © 2011 SUN Microsystems. All Rights Reserved.