com.nec.webotx.enterprise.web.connector.grizzly.comet
クラス CometContext<E>

java.lang.Object
  上位を拡張 com.nec.webotx.enterprise.web.connector.grizzly.comet.CometContext<E>

public class CometContext<E>
extends java.lang.Object

The main object used by CometHandler.
The CometContext is always available for CometHandler
and can be used to notify other CometHandler.

Attributes can be added/removed the same way HttpServletSession
is doing. It is not recommended to use attributes if this
CometContext is not shared amongs multiple
context path (uses HttpServletSession instead).


フィールドの概要
protected  boolean cancelled
          Is the CometContext instance been cancelled.
protected  int continuationType
          The CometContext continuationType.
protected static java.lang.String INVALID_COMET_HANDLER
          Generic error message
 
コンストラクタの概要
CometContext(java.lang.String contextPath, int continuationType)
          Create a new instance
 
メソッドの概要
protected  void addAsyncProcessorTask(AsyncProcessorTask asyncTask)
          Add a AsyncProcessorTask.
 void addAttribute(java.lang.Object key, java.lang.Object value)
          Add an attibute.
 int addCometHandler(CometHandler handler)
          Add a CometHandler.
 int addCometHandler(CometHandler handler, boolean completeExecution)
          Add a CometHandler.
protected static void addInProgressSelectionKey(java.nio.channels.SelectionKey key)
           
protected  java.util.concurrent.ConcurrentLinkedQueue<AsyncProcessorTask> getAsyncProcessorTask()
          Return the list of AsyncProcessorTask
 java.lang.Object getAttribute(java.lang.Object key)
          Retrive an attribute.
 CometHandler getCometHandler(int hashCode)
          Retrive a CometHandler using its hashKey;
protected  CometHandler getCometHandler(java.nio.channels.SelectionKey key)
          Retrive a CometHandler using its SelectionKey.
protected  CometSelector getCometSelector()
          Get the CometSelector associated with this instance.
 java.lang.String getContextPath()
          Get the context path associated with this instance.
 long getExpirationDelay()
          Return the long delay before a request is resumed.
 NotificationHandler getNotificationHandler()
           
protected  void initialize(java.nio.channels.SelectionKey key)
          Initialize the newly added CometHandler.
protected  void interrupt(java.nio.channels.SelectionKey key)
          Invoke CometHandler.onTerminate
 boolean isActive(CometHandler cometHandler)
          Return true if this CometHandler is still active, e.g. there is still a continuation associated with it.
 boolean isBlockingNotification()
          Return true if the invoker of notify() should block when notifying Comet Handlers.
protected  boolean isCancelled()
          Is this instance beeing cancelled by the CometSelector
protected  void notify(CometEvent event, int eventType, java.nio.channels.SelectionKey key)
          Notify all CometHandler.
 void notify(E attachment)
          Notify all CometHandler.
 void notify(E attachment, int eventType)
          Notify all CometHandler.
 void notify(E attachment, int eventType, int cometHandlerID)
          Notify a single CometHandler.
protected  void recycle()
          Recycle this object.
 boolean registerAsyncRead(CometHandler handler)
          Register for asynchronous read.
 boolean registerAsyncWrite(CometHandler handler)
          Register for asynchronous write.
 java.lang.Object removeAttribute(java.lang.Object key)
          Remove an attribute.
 void removeCometHandler(CometHandler handler)
          Remove a CometHandler.
 void removeCometHandler(int hashCode)
          Remove a CometHandler based on its hashcode.
protected static boolean removeInProgressSelectionKey(java.nio.channels.SelectionKey key)
           
 void resumeCometHandler(CometHandler handler)
          Resume the Comet request and remove it from the active CometHandler list.
protected  void resumeCometHandler(CometHandler handler, boolean remove)
          Resume the Comet request.
 void setBlockingNotification(boolean blockingNotification)
          Set to true if the invoker of notify() should block when notifying Comet Handlers.
protected  void setCancelled(boolean cancelled)
          Cancel this object or "uncancel".
protected  void setCometSelector(CometSelector cometSelector)
          Set the CometSelector associated with this instance.
 void setExpirationDelay(long expirationDelay)
          Set the long delay before a request is resumed.
 void setNotificationHandler(NotificationHandler notificationHandler)
           
 java.lang.String toString()
          Helper.
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

フィールドの詳細

INVALID_COMET_HANDLER

protected static final java.lang.String INVALID_COMET_HANDLER
Generic error message

関連項目:
定数フィールド値

cancelled

protected boolean cancelled
Is the CometContext instance been cancelled.


continuationType

protected int continuationType
The CometContext continuationType. See CometEngine

コンストラクタの詳細

CometContext

public CometContext(java.lang.String contextPath,
                    int continuationType)
Create a new instance

パラメータ:
contextPath - the context path
type - when the Comet processing will happen (see CometEngine).
メソッドの詳細

getContextPath

public java.lang.String getContextPath()
Get the context path associated with this instance.

戻り値:
contextPath the context path associated with this instance

addAttribute

public void addAttribute(java.lang.Object key,
                         java.lang.Object value)
Add an attibute.

パラメータ:
key - the key
value - the value

getAttribute

public java.lang.Object getAttribute(java.lang.Object key)
Retrive an attribute.

パラメータ:
key - the key
戻り値:
Object the value.

removeAttribute

public java.lang.Object removeAttribute(java.lang.Object key)
Remove an attribute.

パラメータ:
key - the key
戻り値:
Object the value

addCometHandler

public int addCometHandler(CometHandler handler,
                           boolean completeExecution)
Add a CometHandler. Client of this method might make sure the CometHandler is removed when the CometHandler.onInterrupt is invoked.

パラメータ:
handler - a new CometHandler
completeExecution - Add the Comethandler but don't block waiting for event.

addCometHandler

public int addCometHandler(CometHandler handler)
Add a CometHandler. Client on this method might make sure the CometHandler is removed when the CometHandler.onInterrupt is invoked.

パラメータ:
handler - a new CometHandler

getCometHandler

public CometHandler getCometHandler(int hashCode)
Retrive a CometHandler using its hashKey;


getCometHandler

protected CometHandler getCometHandler(java.nio.channels.SelectionKey key)
Retrive a CometHandler using its SelectionKey. The SelectionKey is not exposed to the Comet API, hence this method must be protected.


notify

protected void notify(CometEvent event,
                      int eventType,
                      java.nio.channels.SelectionKey key)
               throws java.io.IOException
Notify all CometHandler. The attachment can be null. The type will determine which code>CometHandler method will be invoked: CometEvent.INTERRUPT -> CometHandler.onInterrupt CometEvent.NOTIFY -> CometHandler.onEvent CometEvent.INITIALIZE -> CometHandler.onInitialize CometEvent.TERMINATE -> CometHandler.onTerminate CometEvent.READ -> CometHandler.onEvent CometEvent.WRITE -> CometHandler.onEvent

パラメータ:
attachment - An object shared amongst CometHandler.
type - The type of notification.
key - The SelectionKey associated with the CometHandler.
例外:
java.io.IOException

removeCometHandler

public void removeCometHandler(CometHandler handler)
Remove a CometHandler. If the continuation (connection) associated with this CometHandler no longer have CometHandler associated to it, it will be resumed.


removeCometHandler

public void removeCometHandler(int hashCode)
Remove a CometHandler based on its hashcode.


resumeCometHandler

public void resumeCometHandler(CometHandler handler)
Resume the Comet request and remove it from the active CometHandler list. Once resumed, a CometHandler should never manipulate the HttpServletRequest or HttpServletResponse as those are recycled. If you cache them for later reuse by another thread there is a possibility to introduce corrupted responses next time a request is made.


resumeCometHandler

protected void resumeCometHandler(CometHandler handler,
                                  boolean remove)
Resume the Comet request.

パラメータ:
handler - The CometHandler associated with the current continuation.
remove - true if the CometHandler needs to be removed.

isActive

public boolean isActive(CometHandler cometHandler)
Return true if this CometHandler is still active, e.g. there is still a continuation associated with it.


notify

public void notify(E attachment)
            throws java.io.IOException
Notify all CometHandler. The attachment can be null. All CometHandler.onEvent() will be invoked.

パラメータ:
attachment - An object shared amongst CometHandler.
例外:
java.io.IOException

notify

public void notify(E attachment,
                   int eventType,
                   int cometHandlerID)
            throws java.io.IOException
Notify a single CometHandler. The attachment can be null. The type will determine which CometHandler method will be invoked:

CometEvent.INTERRUPT -> CometHandler.onInterrupt
CometEvent.NOTIFY -> CometHandler.onEvent
CometEvent.INITIALIZE -> CometHandler.onInitialize
CometEvent.TERMINATE -> CometHandler.onTerminate
CometEvent.READ -> CometHandler.onEvent

パラメータ:
attachment - An object shared amongst CometHandler.
type - The type of notification.
cometHandlerID - Notify a single CometHandler.
例外:
java.io.IOException

initialize

protected void initialize(java.nio.channels.SelectionKey key)
                   throws java.io.IOException
Initialize the newly added CometHandler.

パラメータ:
attachment - An object shared amongst CometHandler.
type - The type of notification.
key - The SelectionKey representing the CometHandler.
例外:
java.io.IOException

notify

public void notify(E attachment,
                   int eventType)
            throws java.io.IOException
Notify all CometHandler. The attachment can be null. The type will determine which CometHandler method will be invoked:

CometEvent.INTERRUPT -> CometHandler.onInterrupt
CometEvent.NOTIFY -> CometHandler.onEvent
CometEvent.INITIALIZE -> CometHandler.onInitialize
CometEvent.TERMINATE -> CometHandler.onTerminate
CometEvent.READ -> CometHandler.onEvent

パラメータ:
attachment - An object shared amongst CometHandler.
type - The type of notification.
例外:
java.io.IOException

registerAsyncRead

public boolean registerAsyncRead(CometHandler handler)
Register for asynchronous read. If your client supports http pipelining, invoking this method might result in a state where your CometHandler is invoked with a CometRead that will read the next http request. In that case, it is strongly recommended to not use that method unless your CometHandler can handle the http request.


registerAsyncWrite

public boolean registerAsyncWrite(CometHandler handler)
Register for asynchronous write.


recycle

protected void recycle()
Recycle this object.


isCancelled

protected boolean isCancelled()
Is this instance beeing cancelled by the CometSelector

戻り値:
boolean cancelled or not.

setCancelled

protected void setCancelled(boolean cancelled)
Cancel this object or "uncancel".

パラメータ:
cancelled - true or false.

addAsyncProcessorTask

protected void addAsyncProcessorTask(AsyncProcessorTask asyncTask)
Add a AsyncProcessorTask.

パラメータ:
asyncTask - the AsyncProcessorTask

getAsyncProcessorTask

protected java.util.concurrent.ConcurrentLinkedQueue<AsyncProcessorTask> getAsyncProcessorTask()
Return the list of AsyncProcessorTask

戻り値:
ConcurrentLinkedQueue the list of AsyncProcessorTask

getCometSelector

protected CometSelector getCometSelector()
Get the CometSelector associated with this instance.

戻り値:
CometSelector the CometSelector associated with this instance.

setCometSelector

protected void setCometSelector(CometSelector cometSelector)
Set the CometSelector associated with this instance.

パラメータ:
CometSelector - the CometSelector associated with this instance.

toString

public java.lang.String toString()
Helper.

オーバーライド:
クラス java.lang.Object 内の toString

getExpirationDelay

public long getExpirationDelay()
Return the long delay before a request is resumed.

戻り値:
long the long delay before a request is resumed.

setExpirationDelay

public void setExpirationDelay(long expirationDelay)
Set the long delay before a request is resumed.

パラメータ:
long - the long delay before a request is resumed.

interrupt

protected void interrupt(java.nio.channels.SelectionKey key)
Invoke CometHandler.onTerminate


isBlockingNotification

public boolean isBlockingNotification()
Return true if the invoker of notify() should block when notifying Comet Handlers.


setBlockingNotification

public void setBlockingNotification(boolean blockingNotification)
Set to true if the invoker of notify() should block when notifying Comet Handlers.


setNotificationHandler

public void setNotificationHandler(NotificationHandler notificationHandler)

getNotificationHandler

public NotificationHandler getNotificationHandler()

addInProgressSelectionKey

protected static void addInProgressSelectionKey(java.nio.channels.SelectionKey key)

removeInProgressSelectionKey

protected static boolean removeInProgressSelectionKey(java.nio.channels.SelectionKey key)