(1) First, register the topic on which Comet support will be applied:
CometEngine cometEngine = CometEngine.getEngine()
CometContext cometContext = cometEngine.register(topic)
(2) Second, add an instance of CometHandler to the
CometContext returned by the register method:
CometContext#addCometHandler. Executing this operation
will tells Grizzly to suspend the response.
(3) Finally, you can CometContext#notify other CometHandler
to share information between CometHandler. When notified,
CometHandler can decides to push back the data, resume the
response, or simply ignore the content of the notification.
You can also select the stage where the suspension of the response happens when registering the
CometContext's topic (see register), which can be before, during or after invoking a
Servlet
There is known limitation related to HTTP pipelining, it can't work properly when
CometContext#isDetectClosedConnections() is enabled. So if you want to support HTTP pipelining, the
closed connection detection mechanism should be disabled via
CometContext#setDetectClosedConnections(boolean).
| Modifier and Type | Field and Description |
|---|---|
| protected final Map | activeContexts
The current active |
| public static final int | AFTER_RESPONSE_PROCESSING
Deprecated
The token used to support BEFORE_RESPONSE_PROCESSING polling.
|
| public static final int | AFTER_SERVLET_PROCESSING
Deprecated
The token used to support AFTER_SERVLET_PROCESSING polling.
|
| public static final int | BEFORE_REQUEST_PROCESSING
Deprecated
The token used to support BEFORE_REQUEST_PROCESSING polling.
|
| private static final CometEngine | cometEngine
The single instance of this class. |
| public static final int | DISABLE_CLIENT_DISCONNECTION_DETECTION
Deprecated
|
| public static final int | DISABLE_SUSPEND_TIMEOUT
Deprecated
|
| private boolean | isCometSupported
Is Grizzly ARP enabled? |
| protected static final Logger | logger
Main logger |
| protected ExecutorService | threadPool
The |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public CometContext | |
| public <E> CometContext | getCometContext(String
the topic used to creates the topic)CometContextReturn the |
| public static CometEngine | |
| protected boolean | interrupt(CometHandler<E>
The handler, boolean CometHandler encapsulating the suspended connection.Finish the current execution. finishExecution)
Deprecated
use the CometContext version
Interrupt a |
| protected void | interrupt0(CometHandler<E>
The handler, boolean CometHandler encapsulating the suspended connection.Finish the current execution. finishExecution)
Deprecated
use the CometContext version
Interrupt logic in its own method, so it can be executed either async or sync. |
| protected boolean | |
| public static Logger | |
| public <E> CometContext | Returns: CometContext a configuredCometContext.the context path used to create the topic, int CometContextwhen the request will be suspended type)
Deprecated
Use
register(String) instead
Register a context path with this |
| public <E> CometContext | Returns: CometContext a configuredCometContext.the context path used to create the topic)CometContextRegister a context path with this |
| public <E> CometContext | Returns: a newCometContext if not already created, or the existing one.the topic the new topic, Class<? extends NotificationHandler> notificationClass)CometContext will represent.Instantiate a new |
| public void | |
| public CometContext |
| activeContexts | back to summary |
|---|---|
| protected final Map<String, CometContext<E>> activeContexts The current active | |
| AFTER_RESPONSE_PROCESSING | back to summary |
|---|---|
| public static final int AFTER_RESPONSE_PROCESSING
Deprecated
The token used to support BEFORE_RESPONSE_PROCESSING polling. | |
| AFTER_SERVLET_PROCESSING | back to summary |
|---|---|
| public static final int AFTER_SERVLET_PROCESSING
Deprecated
The token used to support AFTER_SERVLET_PROCESSING polling. | |
| BEFORE_REQUEST_PROCESSING | back to summary |
|---|---|
| public static final int BEFORE_REQUEST_PROCESSING
Deprecated
The token used to support BEFORE_REQUEST_PROCESSING polling. | |
| cometEngine | back to summary |
|---|---|
| private static final CometEngine cometEngine The single instance of this class. | |
| DISABLE_CLIENT_DISCONNECTION_DETECTION | back to summary |
|---|---|
| public static final int DISABLE_CLIENT_DISCONNECTION_DETECTION
Deprecated
| |
| DISABLE_SUSPEND_TIMEOUT | back to summary |
|---|---|
| public static final int DISABLE_SUSPEND_TIMEOUT
Deprecated
| |
| isCometSupported | back to summary |
|---|---|
| private boolean isCometSupported Is Grizzly ARP enabled? By default we set it to false. | |
| logger | back to summary |
|---|---|
| protected static final Logger logger Main logger | |
| threadPool | back to summary |
|---|---|
| protected ExecutorService threadPool The | |
| CometEngine | back to summary |
|---|---|
| protected CometEngine() Create a singleton and initialize all lists required. | |
| deregister | back to summary |
|---|---|
| public CometContext Deregister the | |
| getCometContext | back to summary |
|---|---|
| public <E> CometContext Return the
| |
| getEngine | back to summary |
|---|---|
| public static CometEngine getEngine() Return a singleton of this Class.
| |
| interrupt | back to summary |
|---|---|
| protected boolean interrupt(CometHandler<E> handler, boolean finishExecution) throws IOException
Deprecated use the CometContext version Interrupt a
| |
| interrupt0 | back to summary |
|---|---|
| protected void interrupt0(CometHandler<E> handler, boolean finishExecution) throws IOException
Deprecated use the CometContext version Interrupt logic in its own method, so it can be executed either async or sync.
| |
| isCometEnabled | back to summary |
|---|---|
| protected boolean isCometEnabled() Return true if comet is enabled. | |
| logger | back to summary |
|---|---|
| public static Logger logger() Return the current logger. | |
| register | back to summary |
|---|---|
| public <E> CometContext Deprecated Use Register a context path with this
| |
| register | back to summary |
|---|---|
| public <E> CometContext Register a context path with this
| |
| register | back to summary |
|---|---|
| public <E> CometContext Instantiate a new
| |
| setCometSupported | back to summary |
|---|---|
| public void setCometSupported(boolean supported) | |
| unregister | back to summary |
|---|---|
| public CometContext Deprecated
Calls through to
| |