com.sun.enterprise.web.connector.grizzly.comet
Interface CometHandler<E>

All Known Subinterfaces:
CometdHandler
All Known Implementing Classes:
BayeuxCometHandler, BayeuxCometHandlerBase, DataHandler, DefaultConcurrentCometHandler

public interface CometHandler<E>

This interface represents a suspended connection (or response). Passing an instance of this class to CometContext.addCometListener automatically tells Grizzly Comet to suspend the underlying connection and to avoid commiting the response. Since the response is not commited, the connection is considered as suspended and can be resumed later when an event happens by invoking, from onEvent(com.sun.enterprise.web.connector.grizzly.comet.CometEvent) or eveyrwhere, the CometContext.resumeCometHandler(com.sun.enterprise.web.connector.grizzly.comet.CometHandler), which resume the connection by commiting the response. As an example, a browser icons will spins when a connection is suspended, as the complete response hasn't been sent back. Components that implement this interface will be notified when another CometHandler notify them using CometContext.notify(E) With Servlet, it is recommended to attach the HTTPServletResponse and use this object to push back messages to the client.

Author:
Jeanfrancois Arcand

Method Summary
 void attach(E attachment)
          Attach an intance of E to this class.
 void onEvent(CometEvent event)
          Receive CometEvent notification.
 void onInitialize(CometEvent event)
          Receive CometEvent notification when Grizzly is about to suspend the connection.
 void onInterrupt(CometEvent event)
          Receive CometEvent notification when the underlying tcp communication is resumed by the Grizzly ARP.
 void onTerminate(CometEvent event)
          Receive CometEvent notification when the response is resumed by a CometHandler or by the CometContext
 

Method Detail

attach

void attach(E attachment)
Attach an intance of E to this class.


onEvent

void onEvent(CometEvent event)
             throws IOException
Receive CometEvent notification. This method will be invoked everytime a CometContext.notify(E) 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(com.sun.enterprise.web.connector.grizzly.comet.CometHandler).

Throws:
IOException

onInitialize

void onInitialize(CometEvent event)
                  throws IOException
Receive CometEvent notification when Grizzly is about to suspend the connection. This method is always invoked during the processing of CometContext.addCometHandler(com.sun.enterprise.web.connector.grizzly.comet.CometHandler, boolean) operations.

Throws:
IOException

onTerminate

void onTerminate(CometEvent event)
                 throws IOException
Receive CometEvent notification when the response is resumed by a CometHandler or by the CometContext

Throws:
IOException

onInterrupt

void onInterrupt(CometEvent event)
                 throws IOException
Receive CometEvent notification when the underlying tcp communication is resumed by the Grizzly ARP. This happens when the CometContext.setExpirationDelay(long) expires or when the remote client close the connection.

Throws:
IOException


Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.