com.sun.grizzly.comet
Class CometTask

java.lang.Object
  extended by com.sun.grizzly.http.TaskBase
      extended by com.sun.grizzly.comet.CometTask
All Implemented Interfaces:
Task, TaskListener, Runnable, Callable

public class CometTask
extends TaskBase

A Task implementation that allow Grizzly ARP to notify CometHandler when new data (bytes) are available from the CometSelector.

Author:
Jeanfrancois Arcand

Nested Class Summary
static class CometTask.OP_EVENT
           
 
Field Summary
protected  CometTask.OP_EVENT upcoming_op
          The current non blocking operation.
 
Fields inherited from class com.sun.grizzly.http.TaskBase
listeners, pipeline, recycle, selectorThread, type
 
Fields inherited from interface com.sun.grizzly.http.Task
ACCEPT_TASK, PROCESSOR_TASK, READ_TASK
 
Constructor Summary
CometTask()
          New CometTask.
 
Method Summary
 void doTask()
          Notify the CometHandler that bytes are available for read.
 CometContext getCometContext()
          Return the CometContext associated with this instance.
 SelectionKey getCometKey()
          Return the CometSelector's SelectionKey.
 CometSelector getCometSelector()
          Return the CometSelector
 long getExpirationDelay()
          Return the delay before interrupting the polled request and cancelling the SelectionKey.
 long getExpireTime()
          Return the time in milliseconds before this object was registered the SelectionKey on the CometSelector
 SelectionKey getSelectionKey()
          Return the SelectionKey
 boolean isAsyncReadSupported()
           
 void recycle()
          Recycle this object.
 void setAsyncReadSupported(boolean asyncReadSupported)
           
 void setCometContext(CometContext cometContext)
          Set the CometContext used to notify CometHandler.
 void setCometKey(SelectionKey cometKey)
          Set the CometSelector's SelectionKey.
 void setCometSelector(CometSelector cometSelector)
          Set the CometSelector
 void setExpirationDelay(long expirationDelay)
          Set the delay before interrupting the polled request and cancelling the SelectionKey.
 void setExpireTime(long expireTime)
          Set the time in milliseconds before this object was registered the SelectionKey on the CometSelector
 void setSelectionKey(SelectionKey key)
          Set the SelectionKey
 void taskEvent(TaskEvent event)
          Not used.
 
Methods inherited from class com.sun.grizzly.http.TaskBase
addTaskListener, call, cancelTask, clearTaskListeners, execute, fireTaskEvent, getKeepAliveStats, getPipeline, getRecycle, getRequestGroupInfo, getSelectorThread, getSocket, getTaskListeners, getType, isMonitoringEnabled, removeTaskListener, run, setPipeline, setRecycle, setSelectorThread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

upcoming_op

protected CometTask.OP_EVENT upcoming_op
The current non blocking operation.

Constructor Detail

CometTask

public CometTask()
New CometTask.

Method Detail

doTask

public void doTask()
            throws IOException
Notify the CometHandler that bytes are available for read. The notification will invoke all CometContext

Throws:
IOException

taskEvent

public void taskEvent(TaskEvent event)
Not used.

Specified by:
taskEvent in interface TaskListener
Overrides:
taskEvent in class TaskBase

getCometContext

public CometContext getCometContext()
Return the CometContext associated with this instance.

Returns:
CometContext the CometContext associated with this instance.

setCometContext

public void setCometContext(CometContext cometContext)
Set the CometContext used to notify CometHandler.

Parameters:
cometContext - the CometContext used to notify CometHandler

getSelectionKey

public SelectionKey getSelectionKey()
Return the SelectionKey

Specified by:
getSelectionKey in interface Task
Overrides:
getSelectionKey in class TaskBase
Returns:
SelectionKey SelectionKey

setSelectionKey

public void setSelectionKey(SelectionKey key)
Set the SelectionKey

Specified by:
setSelectionKey in interface Task
Overrides:
setSelectionKey in class TaskBase
Parameters:
SelectionKey - SelectionKey

recycle

public void recycle()
Recycle this object.

Specified by:
recycle in interface Task
Overrides:
recycle in class TaskBase

getCometSelector

public CometSelector getCometSelector()
Return the CometSelector

Returns:
CometSelector the CometSelector

setCometSelector

public void setCometSelector(CometSelector cometSelector)
Set the CometSelector

Parameters:
cometSelector - the CometSelector

getExpireTime

public long getExpireTime()
Return the time in milliseconds before this object was registered the SelectionKey on the CometSelector

Returns:
long Return the time in milliseconds before this object was registered the SelectionKey on the CometSelector

setExpireTime

public void setExpireTime(long expireTime)
Set the time in milliseconds before this object was registered the SelectionKey on the CometSelector

Parameters:
expireTime - Return the time in milliseconds before this object was registered the SelectionKey on the CometSelector

getExpirationDelay

public long getExpirationDelay()
Return the delay before interrupting the polled request and cancelling the SelectionKey.

Returns:
long Return the delay before interrupting the polled request and cancelling the SelectionKey.

setExpirationDelay

public void setExpirationDelay(long expirationDelay)
Set the delay before interrupting the polled request and cancelling the SelectionKey.

Parameters:
expirationDelay - Return the delay before interrupting the polled request and cancelling the SelectionKey.

getCometKey

public SelectionKey getCometKey()
Return the CometSelector's SelectionKey.


setCometKey

public void setCometKey(SelectionKey cometKey)
Set the CometSelector's SelectionKey.


isAsyncReadSupported

public boolean isAsyncReadSupported()

setAsyncReadSupported

public void setAsyncReadSupported(boolean asyncReadSupported)


Copyright © 2011 SUN Microsystems. All Rights Reserved.