Top Description Fields Constructors Methods
org.glassfish.grizzly.comet

public Class DefaultCometHandler<E>

extends Object
implements CometHandler<E>
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.comet.CometHandler
Imports
java.io.IOException, org.glassfish.grizzly.http.server.Response

A basic default implementation of CometHandler to take care of tracking the Response and CometContext.

Field Summary

Modifier and TypeField and Description
private CometContext<E>
private Response

Constructor Summary

AccessConstructor and Description
public
public
DefaultCometHandler(final CometContext<E> cometContext, final Response response)

Method Summary

Modifier and TypeMethod and Description
public CometContext<E>
public Response
public void
onEvent(final CometEvent<E> event)

Implements org.glassfish.grizzly.comet.CometHandler.onEvent.

Receive CometEvent notification.

public void
onInitialize(final CometEvent<E> event)

Implements org.glassfish.grizzly.comet.CometHandler.onInitialize.

Receive CometEvent notification when Grizzly is about to suspend the connection.

public void
onInterrupt(final CometEvent<E> event)

Implements org.glassfish.grizzly.comet.CometHandler.onInterrupt.

Receive CometEvent notification when the underlying tcp communication is resumed by Grizzly.

public void
onTerminate(final CometEvent<E> event)

Implements org.glassfish.grizzly.comet.CometHandler.onTerminate.

Receive CometEvent notification when the response is resumed by a CometHandler or by the CometContext

public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cometContextback to summary
private CometContext<E> cometContext
responseback to summary
private Response response

Constructor Detail

DefaultCometHandlerback to summary
public DefaultCometHandler()
DefaultCometHandlerback to summary
public DefaultCometHandler(final CometContext<E> cometContext, final Response response)

Method Detail

getCometContextback to summary
public CometContext<E> getCometContext()

Implements org.glassfish.grizzly.comet.CometHandler.getCometContext.

Annotations
@Override
getResponseback to summary
public Response getResponse()

Implements org.glassfish.grizzly.comet.CometHandler.getResponse.

Annotations
@Override
onEventback to summary
public void onEvent(final CometEvent<E> event) throws IOException

Implements org.glassfish.grizzly.comet.CometHandler.onEvent.

Doc from org.glassfish.grizzly.comet.CometHandler.onEvent.

Receive CometEvent notification. This method will be invoked every time a CometContext#notify is invoked. The CometEvent will contains the message that can be pushed back to the remote client, cached or ignored. This method can also be used to resume a connection once a notified by invoking CometContext#resumeCometHandler.
its not optimal to flush outputstream in this method for long polling, flush is performed in each CometContext.resume call.
flushing multiple times can fragment the data into several tcp packets, that leads to extra IO and overhead in general due to client ack for each packet etc.

Annotations
@Override
onInitializeback to summary
public void onInitialize(final CometEvent<E> event) throws IOException

Implements org.glassfish.grizzly.comet.CometHandler.onInitialize.

Doc from org.glassfish.grizzly.comet.CometHandler.onInitialize.

Receive CometEvent notification when Grizzly is about to suspend the connection. This method is always invoked during the processing of CometContext#addCometHandler operations.

Annotations
@Override
onInterruptback to summary
public void onInterrupt(final CometEvent<E> event) throws IOException

Implements org.glassfish.grizzly.comet.CometHandler.onInterrupt.

Doc from org.glassfish.grizzly.comet.CometHandler.onInterrupt.

Receive CometEvent notification when the underlying tcp communication is resumed by Grizzly. This happens when the CometContext#setExpirationDelay expires or when the remote client close the connection.

Annotations
@Override
onTerminateback to summary
public void onTerminate(final CometEvent<E> event) throws IOException

Implements org.glassfish.grizzly.comet.CometHandler.onTerminate.

Doc from org.glassfish.grizzly.comet.CometHandler.onTerminate.

Receive CometEvent notification when the response is resumed by a CometHandler or by the CometContext

Annotations
@Override
setCometContextback to summary
public void setCometContext(final CometContext<E> cometContext)

Implements org.glassfish.grizzly.comet.CometHandler.setCometContext.

Annotations
@Override
setResponseback to summary
public void setResponse(final Response response)

Implements org.glassfish.grizzly.comet.CometHandler.setResponse.

Annotations
@Override