Oracle GlassFish Server 3.0.1 Application Development Guide

The Grizzly Comet API

Grizzly's support for Comet includes a small set of APIs that make it easy to add Comet functionality to your web applications. The Grizzly Comet APIs that developers use most often are the following:

The way a developer would use this API in a web component is to perform the following tasks:

  1. Register the context path of the application with the CometContext object:

    CometEngine cometEngine = 
    	CometEngine.getEngine();
    CometContext cometContext = 
    	cometEngine.register(contextPath) 
  2. Register the CometHandler implementation with the CometContext object:

    cometContext.addCometHandler(handler)
  3. Notify one or more CometHandler implementations when an event happens:

    cometContext.notify((Object)(handler))