org.mortbay.cometd
Class AbstractCometdServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.mortbay.cometd.AbstractCometdServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig
Direct Known Subclasses:
ContinuationCometdServlet

public abstract class AbstractCometdServlet
extends HttpServlet

Cometd Filter Servlet implementing the AbstractBayeux protocol. The Servlet can be initialized with a json file mapping channels to DataFilter definitions. The servlet init parameter "filters" should point to a webapplication resource containing a JSON array of filter definitions. For example:

  [
    { 
      "channels": "/**",
      "class"   : "org.mortbay.cometd.filter.NoMarkupFilter",
      "init"    : {}
    }
  ]
 
The following init parameters can be used to configure the servlet:
timeout
The server side poll timeout in milliseconds (default 250000). This is how long the server will hold a reconnect request before responding.
interval
The client side poll timeout in milliseconds (default 0). How long a client will wait between reconnects
multiFrameInterval
the client side poll timeout if multiple connections are detected from the same browser (default 1500).
JSONCommented
If "true" then the server will accept JSON wrapped in a comment and will generate JSON wrapped in a comment. This is a defence against Ajax Hijacking.
alwaysResumePoll
If true, then reconnect requests will always be resumed when a message is delivered. This may be needed for some cross domain transports that need strict ordering of responses.
filters
the location of a JSON file describing DataFilter instances to be installed
loglevel
<0=none, 1=info, 2=debug/dd>

Author:
gregw, aabeling: added JSONP transport
See Also:
AbstractBayeux}, ChannelId}, Serialized Form

Field Summary
protected  AbstractBayeux _bayeux
           
protected  long _timeout
           
static String BROWSER_ID
           
static String CLIENT_ATTR
           
static String HTTP_CLIENT_ID
           
static String MESSAGE_PARAM
           
static String TRANSPORT_ATTR
           
static String TUNNEL_INIT_PARAM
           
 
Constructor Summary
AbstractCometdServlet()
           
 
Method Summary
protected  String browserId(HttpServletRequest request)
           
 AbstractBayeux getBayeux()
           
protected  List<Map<String,Object>> getMessages(HttpServletRequest request)
           
 void init()
          A convenience method which can be overridden so that there's no need to call super.init(config).
protected abstract  AbstractBayeux newBayeux()
           
protected  String newBrowserId(HttpServletRequest request, HttpServletResponse response)
           
protected  void service(HttpServletRequest req, HttpServletResponse resp)
          Receives standard HTTP requests from the public service method and dispatches them to the doXXX methods defined in this class.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLIENT_ATTR

public static final String CLIENT_ATTR
See Also:
Constant Field Values

TRANSPORT_ATTR

public static final String TRANSPORT_ATTR
See Also:
Constant Field Values

MESSAGE_PARAM

public static final String MESSAGE_PARAM
See Also:
Constant Field Values

TUNNEL_INIT_PARAM

public static final String TUNNEL_INIT_PARAM
See Also:
Constant Field Values

HTTP_CLIENT_ID

public static final String HTTP_CLIENT_ID
See Also:
Constant Field Values

BROWSER_ID

public static final String BROWSER_ID
See Also:
Constant Field Values

_bayeux

protected AbstractBayeux _bayeux

_timeout

protected long _timeout
Constructor Detail

AbstractCometdServlet

public AbstractCometdServlet()
Method Detail

getBayeux

public AbstractBayeux getBayeux()

newBayeux

protected abstract AbstractBayeux newBayeux()

init

public void init()
          throws ServletException
Description copied from class: GenericServlet
A convenience method which can be overridden so that there's no need to call super.init(config).

Instead of overriding GenericServlet.init(ServletConfig), simply override this method and it will be called by GenericServlet.init(ServletConfig config). The ServletConfig object can still be retrieved via GenericServlet.getServletConfig().

Overrides:
init in class GenericServlet
Throws:
ServletException - if an exception occurs that interrupts the servlet's normal operation

service

protected void service(HttpServletRequest req,
                       HttpServletResponse resp)
                throws ServletException,
                       IOException
Description copied from class: HttpServlet
Receives standard HTTP requests from the public service method and dispatches them to the doXXX methods defined in this class. This method is an HTTP-specific version of the Servlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) method. There's no need to override this method.

Overrides:
service in class HttpServlet
Parameters:
req - the HttpServletRequest object that contains the request the client made of the servlet
resp - the HttpServletResponse object that contains the response the servlet returns to the client
Throws:
ServletException - if the HTTP request cannot be handled
IOException - if an input or output error occurs while the servlet is handling the HTTP request
See Also:
Servlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)

browserId

protected String browserId(HttpServletRequest request)

newBrowserId

protected String newBrowserId(HttpServletRequest request,
                              HttpServletResponse response)

getMessages

protected List<Map<String,Object>> getMessages(HttpServletRequest request)
                                        throws IOException
Throws:
IOException


Copyright © 2007 Mort Bay Consulting. All Rights Reserved.