org.cometd.server
Class AbstractCometdServlet
java.lang.Object
javax.servlet.GenericServlet
org.cometd.server.AbstractCometdServlet
- All Implemented Interfaces:
- Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
- Direct Known Subclasses:
- ContinuationCometdServlet
public abstract class AbstractCometdServlet
- extends javax.servlet.GenericServlet
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.cometd.server.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
- maxInterval
- The max client side poll timeout in milliseconds (default 10000). A
client will be removed if a connection is not received in this time.
- maxLazyLatency
- The max time in ms(default 0) that a client with lazy messages will wait before
sending a response. If 0, then the client will wait until the next timeout or
non-lazy message.
- 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.
- filters
- the location of a JSON file describing
DataFilter instances to be
installed
- requestAvailable
- If true, the current request is made available via the
AbstractBayeux.getCurrentRequest() method
- logLevel
- 0=none, 1=info, 2=debug
- jsonDebug
- If true, JSON complete json input will be kept for debug.
- channelIdCacheLimit
- The limit of the
ChannelId cache: -1 to disable caching, 0 for no limits,
any positive value to clear the cache once the limit has been reached
- refsThreshold
- The number of message refs at which the a single message response will be
cached instead of being generated for every client delivered to. Done to
optimize a single message being sent to multiple clients.
- Author:
- gregw, aabeling: added JSONP transport
- See Also:
AbstractBayeux},
ChannelId},
Serialized Form
| 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 |
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
_jsonDebug
protected boolean _jsonDebug
AbstractCometdServlet
public AbstractCometdServlet()
getBayeux
public AbstractBayeux getBayeux()
newBayeux
protected abstract AbstractBayeux newBayeux()
init
public void init()
throws javax.servlet.ServletException
- Overrides:
init in class javax.servlet.GenericServlet
- Throws:
javax.servlet.ServletException
service
protected abstract void service(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
IOException
- Throws:
javax.servlet.ServletException
IOException
service
public void service(javax.servlet.ServletRequest req,
javax.servlet.ServletResponse resp)
throws javax.servlet.ServletException,
IOException
- Specified by:
service in interface javax.servlet.Servlet- Specified by:
service in class javax.servlet.GenericServlet
- Throws:
javax.servlet.ServletException
IOException
findBrowserId
protected String findBrowserId(javax.servlet.http.HttpServletRequest request)
setBrowserId
protected String setBrowserId(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
getMessages
protected Message[] getMessages(javax.servlet.http.HttpServletRequest request)
throws IOException,
javax.servlet.ServletException
- Throws:
IOException
javax.servlet.ServletException
handleJSONParseException
protected Message[] handleJSONParseException(javax.servlet.http.HttpServletRequest request,
String messageString,
Exception x)
throws javax.servlet.ServletException
- Override to customize the handling of JSON parse exceptions.
Default behavior is to log at warn level on logger "org.cometd.json" and to throw a ServletException that
wraps the original exception.
- Parameters:
request - the request objectmessageString - the JSON text, if available; can be null if the JSON is not buffered before being parsed.x - the exception thrown during parsing
- Returns:
- a non-null array of messages, possibly empty, if the JSON parse exception is recoverable
- Throws:
javax.servlet.ServletException - if the JSON parsing is not recoverable
Copyright © 2008-2011 Dojo Foundation. All Rights Reserved.