com.sun.grizzly.comet
Class CometSelector

java.lang.Object
  extended by com.sun.grizzly.comet.CometSelector

public class CometSelector
extends Object

NIO Selector allowing CometHandler to receive non-blocking requests bytes during request polling.

Author:
Jeanfrancois Arcand

Field Summary
protected  CometEngine cometEngine
          The CometEngine singleton
 
Constructor Summary
CometSelector(CometEngine cometEngine)
          New CometSelector
 
Method Summary
protected  void cancelKey(SelectionKey key)
          Cancel a SelectionKey, and delegate the request polling interruption to the CometEngine
 SelectionKey cometKeyFor(SelectableChannel channel)
          Return the SelectionKey associated with this channel.
protected  void expireIdleKeys()
          Expires registered SelectionKey.
 void registerKey(SelectionKey key, CometTask cometTask)
          Register the SelectionKey/code> to the Selector.
 void start()
          Start the java.nio.channels.Selector running on its Thread.
 void wakeup()
          Wakes up the java.nio.channels.Selector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cometEngine

protected CometEngine cometEngine
The CometEngine singleton

Constructor Detail

CometSelector

public CometSelector(CometEngine cometEngine)
New CometSelector

Parameters:
cometEngine - The CometEngine singleton
Method Detail

start

public void start()
Start the java.nio.channels.Selector running on its Thread.


expireIdleKeys

protected void expireIdleKeys()
Expires registered SelectionKey. If a SelectionKey is expired, the request will be resumed and the HTTP request will complete,


cancelKey

protected void cancelKey(SelectionKey key)
Cancel a SelectionKey, and delegate the request polling interruption to the CometEngine

Parameters:
key - the expired SelectionKey

registerKey

public void registerKey(SelectionKey key,
                        CometTask cometTask)
Register the SelectionKey/code> to the Selector. We cannot register the SelectionKey/code> directy on the Selector because there is a deadlock in the VM (see bug XXX).


wakeup

public void wakeup()
Wakes up the java.nio.channels.Selector


cometKeyFor

public SelectionKey cometKeyFor(SelectableChannel channel)
Return the SelectionKey associated with this channel.



Copyright © 2008 SUN Microsystems. All Rights Reserved.