|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface CometHandler<E>
This interface represents a suspended connection (or response). Passing an
instance of this class to CometContext.addCometHandler(com.sun.grizzly.comet.CometHandler, boolean)
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
CometContext.resumeCometHandler(CometHandler)
,
from onEvent(com.sun.grizzly.comet.CometEvent)
.
CometContext#resumeCometHandler(CometHandler),
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
{@link CometContext#notify(String)} is invoked or when
the {@link CometContext#getExpirationDelay()} expires.
With {@link Servlet}, it is recommended to attach the {@link HttpServletResponse}
and use this object to push back messages to the client.
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 Grizzly. |
void |
onTerminate(CometEvent event)
Receive CometEvent notification when the response
is resumed by a CometHandler or by the CometContext |
Method Detail |
---|
void attach(E attachment)
void onEvent(CometEvent event) throws IOException
CometEvent
notification. This method will be invoked
everytime a CometContext.notify(java.lang.Object)
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.grizzly.comet.CometHandler)
.
IOException
void onInitialize(CometEvent event) throws IOException
CometEvent
notification when Grizzly is about to
suspend the connection. This method is always invoked during the
processing of CometContext.addCometHandler(com.sun.grizzly.comet.CometHandler, boolean)
operations.
IOException
void onTerminate(CometEvent event) throws IOException
CometEvent
notification when the response
is resumed by a CometHandler
or by the CometContext
IOException
void onInterrupt(CometEvent event) throws IOException
CometEvent
notification when the underlying
tcp communication is resumed by Grizzly. This happens
when the CometContext.setExpirationDelay(long)
expires or when
the remote client close the connection.
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |