to.etc.webapp.ajax.eventmanager
Class AjaxEventManager

java.lang.Object
  extended by to.etc.webapp.ajax.eventmanager.AjaxEventManager

public class AjaxEventManager
extends java.lang.Object

Singleton AJAX event manager. This allows Java code to post an event to browsers waiting for them. This singleton uses JSON to communicate with the browser; it uses a specific CometContext implementation to allow asynchronous IO where the servlet container supports it.

This implementation has support for "lossless" event retrieval. This means that the browser will see all events, even when it's comet connection has been used and returned. When events occur while the browser has abn outstanding Comet call then all is well, and the events can be sent using that call. If however the call has just been returned and a new event occurs then the browser would loose that event because no comet call is present to sent it on.

This gets fixed by assigning all events an unique number that gets incremented for every event. Every time a browser issues a new Comet call it passes in the last event number it has seen. The event manager will queue the events from the last few minutes and will sent all of the events queued thus far to the browser.

Author:
Frits Jalvingh Created on Oct 25, 2006

Constructor Summary
AjaxEventManager()
           
 
Method Summary
 void destroy()
          Called when the application will die.
static AjaxEventManager getInstance()
           
static void initialize()
           
 void postEvent(java.lang.String channel, java.lang.Object data)
          Sends an event to the specified channels.
 void registerEventFilter(java.lang.String channel, AjaxEventFilterFactory ajaxEventFilterFactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AjaxEventManager

public AjaxEventManager()
Method Detail

getInstance

public static AjaxEventManager getInstance()

initialize

public static void initialize()

registerEventFilter

public void registerEventFilter(java.lang.String channel,
                                AjaxEventFilterFactory ajaxEventFilterFactory)

postEvent

public void postEvent(java.lang.String channel,
                      java.lang.Object data)
Sends an event to the specified channels. All listerers to the event get the event, and the event gets queued.

Parameters:
channels -
data -

destroy

public void destroy()
Called when the application will die. This releases all requests and cancels the timers.