com.nec.webotx.enterprise.web.connector.grizzly.comet
クラス CometEngine

java.lang.Object
  上位を拡張 com.nec.webotx.enterprise.web.connector.grizzly.comet.CometEngine

public class CometEngine
extends java.lang.Object

Main class allowing Comet support on top of Grizzly Asynchronous Request Processing mechanism. This class is the entry point to any component interested to execute Comet request style. Components can be Servlets, JSP, JSF or pure Java class. A component interested to support Comet request must do:

  1. First, register the cometContext path on which Comet support will be applied:
    CometEngine cometEngine = CometEngine.getEngine()
    CometContext cometContext = cometEngine.register(contextPath)
  2. Second, add an instance of CometHandler to the
    CometContext returned by the register method:
    cometContext.addCometHandler(handler);
  3. Finally, you can notify other CometHandler by doing:
    cometContext.notify(Object)(handler);

You can also select the stage where the request polling happens when registering the cometContext path (see register(String,int);


フィールドの概要
static int AFTER_RESPONSE_PROCESSING
          The token used to support BEFORE_RESPONSE_PROCESSING polling.
static int AFTER_SERVLET_PROCESSING
          The token used to support AFTER_SERVLET_PROCESSING polling.
static int BEFORE_REQUEST_PROCESSING
          The token used to support BEFORE_REQUEST_PROCESSING polling.
 
メソッドの概要
protected  java.nio.channels.SelectionKey activateContinuation(java.lang.Long threadId, CometContext cometContext, boolean continueExecution)
          Tell the CometEngine to activate Grizzly ARP on that CometContext.
 CometContext getCometContext(java.lang.String contextPath)
          Return the CometContext associated with the cometContext path.
protected  CometTask getCometTask(CometContext cometContext, java.nio.channels.SelectionKey key, Pipeline ctxPipeline)
          Return a clean and configured CometTask
static CometEngine getEngine()
          Return a singleton of this Class.
static java.lang.String getNotificationHandlerClassName()
           
protected  boolean handle(AsyncProcessorTask apt)
          Handle an interrupted(or polled) request by matching the current context path with the registered one.
protected  void interrupt(java.nio.channels.SelectionKey key)
          The CometSelector is expiring idle SelectionKey, hence we need to resume the current request.
static java.util.logging.Logger logger()
          Return the current logger.
 CometContext register(java.lang.String contextPath)
          Register a context path with this CometEngine.
 CometContext register(java.lang.String contextPath, int type)
          Register a context path with this CometEngine.
protected  void resume(java.nio.channels.SelectionKey key, CometContext cometContext)
          Resume the long polling request by unblocking the current SelectionKey
protected  void returnTask(CometTask cometTask)
          Return a Task to the pool.
static void setNotificationHandlerClassName(java.lang.String aNotificationHandlerClassName)
           
 CometContext unregister(java.lang.String contextPath)
          Unregister the CometHandler to the list of the CometContext.
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

BEFORE_REQUEST_PROCESSING

public static final int BEFORE_REQUEST_PROCESSING
The token used to support BEFORE_REQUEST_PROCESSING polling.

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

AFTER_SERVLET_PROCESSING

public static final int AFTER_SERVLET_PROCESSING
The token used to support AFTER_SERVLET_PROCESSING polling.

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

AFTER_RESPONSE_PROCESSING

public static final int AFTER_RESPONSE_PROCESSING
The token used to support BEFORE_RESPONSE_PROCESSING polling.

関連項目:
定数フィールド値
メソッドの詳細

getEngine

public static final CometEngine getEngine()
Return a singleton of this Class.

戻り値:
CometEngine the singleton.

unregister

public CometContext unregister(java.lang.String contextPath)
Unregister the CometHandler to the list of the CometContext.


register

public CometContext register(java.lang.String contextPath)
Register a context path with this CometEngine. The CometContext returned will be of type AFTER_SERVLET_PROCESSING, which means the request target (most probably a Servlet) will be executed first and then polled.

パラメータ:
contextPath - the context path used to create the CometContext
戻り値:
CometContext a configured CometContext.

register

public CometContext register(java.lang.String contextPath,
                             int type)
Register a context path with this CometEngine. The CometContext returned will be of type type.

パラメータ:
contextPath - the context path used to create the CometContext
戻り値:
CometContext a configured CometContext.

handle

protected boolean handle(AsyncProcessorTask apt)
                  throws java.io.IOException
Handle an interrupted(or polled) request by matching the current context path with the registered one. If required, the bring the target component (Servlet) to the proper execution stage and then notify the CometHandler

パラメータ:
apt - the current apt representing the request.
戻り値:
boolean true if the request can be polled.
例外:
java.io.IOException

activateContinuation

protected java.nio.channels.SelectionKey activateContinuation(java.lang.Long threadId,
                                                              CometContext cometContext,
                                                              boolean continueExecution)
Tell the CometEngine to activate Grizzly ARP on that CometContext. This method is called when CometContext.addCometHandler() is invoked.

パラメータ:
threadId - the Thread.getId().
cometContext - An instance of CometContext.
戻り値:
key The SelectionKey associated with the current request.

getCometTask

protected CometTask getCometTask(CometContext cometContext,
                                 java.nio.channels.SelectionKey key,
                                 Pipeline ctxPipeline)
Return a clean and configured CometTask

パラメータ:
cometContext - the CometContext to clean
key - The current SelectionKey
戻り値:
a new CometContext

getCometContext

public CometContext getCometContext(java.lang.String contextPath)
Return the CometContext associated with the cometContext path. XXX: This is not secure as a you can get a CometContext associated with another cometContext path. But this allow interesting application... MUST BE REVISTED.

パラメータ:
contextPath - the request's cometContext path.

interrupt

protected void interrupt(java.nio.channels.SelectionKey key)
The CometSelector is expiring idle SelectionKey, hence we need to resume the current request.

パラメータ:
key - the expired SelectionKey

returnTask

protected void returnTask(CometTask cometTask)
Return a Task to the pool.


resume

protected void resume(java.nio.channels.SelectionKey key,
                      CometContext cometContext)
Resume the long polling request by unblocking the current SelectionKey


getNotificationHandlerClassName

public static java.lang.String getNotificationHandlerClassName()

setNotificationHandlerClassName

public static void setNotificationHandlerClassName(java.lang.String aNotificationHandlerClassName)

logger

public static final java.util.logging.Logger logger()
Return the current logger.