org.cometd.server.transport
Class LongPollingTransport

java.lang.Object
  extended by org.cometd.server.AbstractServerTransport
      extended by org.cometd.server.transport.HttpTransport
          extended by org.cometd.server.transport.LongPollingTransport
All Implemented Interfaces:
ServerTransport, Transport
Direct Known Subclasses:
JSONPTransport, JSONTransport

public abstract class LongPollingTransport
extends HttpTransport

Abstract Long Polling Transport.

Transports based on this class can be configured with servlet init parameters:

browserId
The Cookie name used to save a browser ID.
maxSessionsPerBrowser
The maximum number of long polling sessions allowed per browser.
multiSessionInterval
The polling interval to use once max session per browser is exceeded.
autoBatch
If true a batch will be automatically created to span the handling of messages received from a session.
allowMultiSessionsNoBrowser
Allows multiple sessions even when the browser identifier cannot be retrieved.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.cometd.server.AbstractServerTransport
AbstractServerTransport.OneTimeScheduler, AbstractServerTransport.Scheduler
 
Field Summary
static String ALLOW_MULTI_SESSIONS_NO_BROWSER_OPTION
           
static String AUTOBATCH_OPTION
           
static String BROWSER_ID_OPTION
           
static String MAX_SESSIONS_PER_BROWSER_OPTION
           
static String MULTI_SESSION_INTERVAL_OPTION
           
static String PREFIX
           
 
Fields inherited from class org.cometd.server.transport.HttpTransport
JSON_DEBUG_OPTION, MESSAGE_PARAM
 
Fields inherited from class org.cometd.server.AbstractServerTransport
INTERVAL_OPTION, MAX_INTERVAL_OPTION, MAX_LAZY_OPTION, META_CONNECT_DELIVERY_OPTION, TIMEOUT_OPTION
 
Constructor Summary
protected LongPollingTransport(BayeuxServerImpl bayeux, String name)
           
 
Method Summary
protected abstract  void complete(PrintWriter writer)
           
protected  void decBrowserId(String browserId)
           
protected  void doSweep()
          Sweep the transport for old Browser IDs
protected  String findBrowserId(javax.servlet.http.HttpServletRequest request)
           
 void handle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected  void handleJSONParseException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String json, Throwable exception)
           
protected  boolean incBrowserId(String browserId)
          Increment the browser ID count.
protected  void init()
          Initialise the transport.
protected abstract  boolean isAlwaysFlushingAfterHandle()
           
protected abstract  PrintWriter send(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, PrintWriter writer, ServerMessage message)
           
protected  String setBrowserId(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 
Methods inherited from class org.cometd.server.transport.HttpTransport
accept, getContext, getCurrentLocalAddress, getCurrentRemoteAddress, getCurrentRequest, parseMessages, setCurrentRequest
 
Methods inherited from class org.cometd.server.AbstractServerTransport
getAdvice, getBayeux, getInterval, getMaxInterval, getMaxLazyTimeout, getName, getOption, getOption, getOption, getOption, getOption, getOptionNames, getOptionPrefix, getTimeout, isMetaConnectDeliveryOnly, setAdvice, setInterval, setMaxInterval, setMaxLazyTimeout, setMetaConnectDeliveryOnly, setOption, setOptionPrefix, setTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREFIX

public static final String PREFIX
See Also:
Constant Field Values

BROWSER_ID_OPTION

public static final String BROWSER_ID_OPTION
See Also:
Constant Field Values

MAX_SESSIONS_PER_BROWSER_OPTION

public static final String MAX_SESSIONS_PER_BROWSER_OPTION
See Also:
Constant Field Values

MULTI_SESSION_INTERVAL_OPTION

public static final String MULTI_SESSION_INTERVAL_OPTION
See Also:
Constant Field Values

AUTOBATCH_OPTION

public static final String AUTOBATCH_OPTION
See Also:
Constant Field Values

ALLOW_MULTI_SESSIONS_NO_BROWSER_OPTION

public static final String ALLOW_MULTI_SESSIONS_NO_BROWSER_OPTION
See Also:
Constant Field Values
Constructor Detail

LongPollingTransport

protected LongPollingTransport(BayeuxServerImpl bayeux,
                               String name)
Method Detail

init

protected void init()
Description copied from class: AbstractServerTransport
Initialise the transport. Initialise the transport, resolving default and direct options. After the call to init, the #getMutableOptions() set should be reset to reflect only the options that can be changed on a running transport. This implementation clears the mutable options set.

Overrides:
init in class HttpTransport

findBrowserId

protected String findBrowserId(javax.servlet.http.HttpServletRequest request)

setBrowserId

protected String setBrowserId(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)

incBrowserId

protected boolean incBrowserId(String browserId)
Increment the browser ID count.

Parameters:
browserId - the browser ID to increment the count for
Returns:
true if the browser ID count is below the max sessions per browser value. If false is returned, the count is not incremented.

decBrowserId

protected void decBrowserId(String browserId)

handle

public void handle(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws IOException,
                   javax.servlet.ServletException
Specified by:
handle in class HttpTransport
Throws:
IOException
javax.servlet.ServletException

handleJSONParseException

protected void handleJSONParseException(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response,
                                        String json,
                                        Throwable exception)
                                 throws javax.servlet.ServletException,
                                        IOException
Throws:
javax.servlet.ServletException
IOException

doSweep

protected void doSweep()
Sweep the transport for old Browser IDs

Overrides:
doSweep in class AbstractServerTransport
See Also:
AbstractServerTransport.doSweep()

isAlwaysFlushingAfterHandle

protected abstract boolean isAlwaysFlushingAfterHandle()
Returns:
true if the transport always flushes at the end of a call to handle(HttpServletRequest, HttpServletResponse).

send

protected abstract PrintWriter send(javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response,
                                    PrintWriter writer,
                                    ServerMessage message)
                             throws IOException
Throws:
IOException

complete

protected abstract void complete(PrintWriter writer)
                          throws IOException
Throws:
IOException


Copyright © 2008-2010 Dojo Foundation. All Rights Reserved.