org.atmosphere.cpr
Class AtmosphereFramework

java.lang.Object
  extended by org.atmosphere.cpr.AtmosphereFramework
All Implemented Interfaces:
ServletContextProvider

public class AtmosphereFramework
extends Object
implements ServletContextProvider

The AtmosphereFramework is the entry point for the framework. This class can be used to from Servlet/filter to dispatch AtmosphereRequest and AtmosphereResponse. The framework can also be configured using the setXXX method. The life cycle of this class is

 AtmosphereFramework f = new AtmosphereFramework();
 f.init();
 f.doCometSupport(AtmosphereRequest, AtmosphereResource);
 f.destroy();
 

Author:
Jeanfrancois Arcand

Nested Class Summary
static class AtmosphereFramework.AtmosphereHandlerWrapper
           
 
Field Summary
protected  boolean allowAllClassesScan
           
protected  boolean annotationFound
           
protected  LinkedList<String> annotationPackages
           
protected  String annotationProcessorClassName
           
protected  AsyncSupport asyncSupport
           
protected  List<AsyncSupportListener> asyncSupportListeners
           
protected  String atmosphereDotXmlPath
           
protected  Map<String,AtmosphereFramework.AtmosphereHandlerWrapper> atmosphereHandlers
           
protected  boolean autoDetectHandlers
           
protected  String broadcasterCacheClassName
           
protected  String broadcasterClassName
           
protected  BroadcasterFactory broadcasterFactory
           
protected  String broadcasterFactoryClassName
           
protected  List<String> broadcasterFilters
           
protected  String broadcasterLifeCyclePolicy
           
protected  List<BroadcasterListener> broadcasterListeners
           
protected  ConcurrentLinkedQueue<String> broadcasterTypes
           
protected  AtmosphereConfig config
           
static String DEFAULT_ATMOSPHERE_CONFIG_PATH
           
static String DEFAULT_HANDLER_PATH
           
static String DEFAULT_LIB_PATH
           
protected  Class<? extends AtmosphereInterceptor>[] defaultInterceptors
           
protected  EndpointMapper<AtmosphereFramework.AtmosphereHandlerWrapper> endpointMapper
           
protected  boolean executeFirstSet
           
protected  boolean externalizeDestroy
           
protected  String handlersPath
           
protected  HashMap<String,String> initParams
           
protected  ConcurrentLinkedQueue<BroadcasterCacheInspector> inspectors
           
protected  LinkedList<AtmosphereInterceptor> interceptors
           
protected  boolean isBroadcasterSpecified
           
protected  AtomicBoolean isCometSupportConfigured
           
protected  boolean isCometSupportSpecified
           
protected  boolean isDestroyed
           
protected  boolean isFilter
           
protected  boolean isInit
           
protected  boolean isSessionSupportSpecified
           
protected  boolean isThrowExceptionOnClonedRequestSpecified
           
protected  String libPath
           
protected static org.slf4j.Logger logger
           
static String MAPPING_REGEX
           
protected  String mappingRegex
           
protected  List<String> packages
           
protected  ArrayList<String> possibleComponentsCandidate
           
static AtmosphereHandler REFLECTOR_ATMOSPHEREHANDLER
          An implementation of AbstractReflectorAtmosphereHandler.
static String ROOT
           
protected  boolean scanDone
           
protected  javax.servlet.ServletConfig servletConfig
           
protected  boolean sharedThreadPools
           
protected  boolean useBlockingImplementation
           
protected  boolean useNativeImplementation
           
protected  boolean useServlet30
           
protected  boolean useStreamForFlushingComments
           
protected  boolean webSocketEnabled
           
protected  String webSocketProcessorClassName
           
protected  WebSocketProtocol webSocketProtocol
           
protected  String webSocketProtocolClassName
           
protected  boolean webSocketProtocolInitialized
           
 
Constructor Summary
AtmosphereFramework()
          Create an AtmosphereFramework.
AtmosphereFramework(boolean isFilter, boolean autoDetectHandlers)
          Create an AtmosphereFramework.
AtmosphereFramework(javax.servlet.ServletConfig sc)
          Create an AtmosphereFramework and initialize it via init(javax.servlet.ServletConfig).
 
Method Summary
 AtmosphereFramework addAnnotationPackage(Class<?> clazz)
          Add support for package detection of Atmosphere's Component.
 AtmosphereFramework addAtmosphereHandler(String mapping, AtmosphereHandler h)
          Add an AtmosphereHandler serviced by the Servlet This API is exposed to allow embedding an Atmosphere application.
 AtmosphereFramework addAtmosphereHandler(String mapping, AtmosphereHandler h, Broadcaster broadcaster)
          Add an AtmosphereHandler serviced by the Servlet.
 AtmosphereFramework addAtmosphereHandler(String mapping, AtmosphereHandler h, Broadcaster broadcaster, List<AtmosphereInterceptor> l)
          Add an AtmosphereHandler serviced by the Servlet.
 AtmosphereFramework addAtmosphereHandler(String mapping, AtmosphereHandler h, List<AtmosphereInterceptor> l)
          Add an AtmosphereHandler serviced by the Servlet This API is exposed to allow embedding an Atmosphere application.
 AtmosphereFramework addAtmosphereHandler(String mapping, AtmosphereHandler h, String broadcasterId)
          Add an AtmosphereHandler serviced by the Servlet.
 AtmosphereFramework addAtmosphereHandler(String mapping, AtmosphereHandler h, String broadcasterId, List<AtmosphereInterceptor> l)
          Add an AtmosphereHandler serviced by the Servlet.
 AtmosphereFramework addBroadcasterCacheInjector(BroadcasterCacheInspector b)
          Add a BroadcasterCacheInspector which will be associated with the defined BroadcasterCache.
 AtmosphereFramework addBroadcasterListener(BroadcasterListener b)
          Add BroadcasterListener to all created Broadcasters.
 AtmosphereFramework addBroadcasterType(String broadcasterTypeString)
          Add a new Broadcaster class name that AtmosphereServlet can use when initializing requests, and when the atmosphere.xml broadcaster element is unspecified.
 AtmosphereFramework addCustomAnnotationPackage(Class p)
          Add a package containing classes annotated with AtmosphereAnnotation.
 AtmosphereFramework addInitParameter(String name, String value)
          Add init-param like if they were defined in web.xml
 AtmosphereFramework addWebSocketHandler(String path, WebSocketHandler handler)
          Add an WebSocketHandler mapped to the path.
 AtmosphereFramework addWebSocketHandler(String path, WebSocketHandler handler, AtmosphereHandler h)
          Add an WebSocketHandler mapped to the path and the AtmosphereHandler in case Broadcaster are used.
 AtmosphereFramework addWebSocketHandler(String path, WebSocketHandler handler, AtmosphereHandler h, List<AtmosphereInterceptor> l)
          Add an WebSocketHandler mapped to the path and the AtmosphereHandler in case Broadcaster are used.
 AtmosphereFramework addWebSocketHandler(WebSocketHandler handler)
          Add an WebSocketHandler mapped to "/*".
protected  void analytics()
           
 AtmosphereFramework annotationProcessorClassName(String annotationProcessorClassName)
          Set the AnnotationProcessor class name.
 AtmosphereFramework annotationScanned(boolean b)
          Invoked when a AnnotationProcessor found an annotation.
 AtmosphereFramework asyncSupportListener(AsyncSupportListener asyncSupportListener)
          Add an AsyncSupportListener.
 List<AsyncSupportListener> asyncSupportListeners()
          Return the list of AsyncSupportListeners.
protected  void autoConfigureService(javax.servlet.ServletContext sc)
           
 void autoDetectAtmosphereHandlers(javax.servlet.ServletContext servletContext, URLClassLoader classloader)
          Auto detect instance of AtmosphereHandler in case META-INF/atmosphere.xml is missing.
protected  void autoDetectContainer()
          Auto detect the underlying Servlet Container we are running on.
protected  void autoDetectWebSocketHandler(javax.servlet.ServletContext servletContext, URLClassLoader classloader)
          Auto detect instance of WebSocketHandler in case META-INF/atmosphere.xml is missing.
 List<String> broadcasterFilters()
          Return the list of BroadcastFilters.
 AtmosphereFramework broadcasterFilters(BroadcastFilter f)
          Add a BroadcastFilter.
protected  void configureAtmosphereInterceptor(javax.servlet.ServletConfig sc)
          Configure the list of AtmosphereInterceptor.
protected  void configureBroadcaster()
           
 void configureBroadcasterFactory()
           
protected  Map<String,String> configureQueryStringAsRequest(AtmosphereRequest request)
           
 AtmosphereFramework configureRequestResponse(AtmosphereRequest req, AtmosphereResponse res)
          Configure some attributes on the AtmosphereRequest.
protected  void configureScanningPackage(javax.servlet.ServletConfig sc, String value)
           
protected  void configureWebDotXmlAtmosphereHandler(javax.servlet.ServletConfig sc)
           
protected  AsyncSupportResolver createAsyncSupportResolver()
          Returns an instance of AsyncSupportResolver AsyncSupportResolver.
 List<String> customAnnotationPackages()
          Return the list of packages the framework should look for AtmosphereAnnotation.
 AtmosphereFramework destroy()
           
protected  boolean detectSupportedFramework(javax.servlet.ServletConfig sc)
          Auto-detect Jersey when no atmosphere.xml file is specified.
 Action doCometSupport(AtmosphereRequest req, AtmosphereResponse res)
          Invoke the proprietary AsyncSupport.
protected  void doInitParams(javax.servlet.ServletConfig sc)
          Read init params from web.xml and apply them.
protected  void doInitParamsForWebSocket(javax.servlet.ServletConfig sc)
           
 EndpointMapper<AtmosphereFramework.AtmosphereHandlerWrapper> endPointMapper()
          The current EndpointMapper used to map requests to AtmosphereHandler.
 AtmosphereFramework endPointMapper(EndpointMapper endpointMapper)
          Set the EndpointMapper.
 AtmosphereFramework externalizeDestroy(boolean externalizeDestroy)
          If set to true, the task of finishing the request/response lifecycle will not be handled by this class.
 AsyncSupport getAsyncSupport()
          Return the current AsyncSupport.
 AtmosphereConfig getAtmosphereConfig()
          Return a configured instance of AtmosphereConfig.
 String getAtmosphereDotXmlPath()
           
 Map<String,AtmosphereFramework.AtmosphereHandlerWrapper> getAtmosphereHandlers()
           
 String getBroadcasterCacheClassName()
          Return the BroadcasterCache class name.
 BroadcasterFactory getBroadcasterFactory()
          Get the BroadcasterFactory which is used by Atmosphere to construct Broadcaster.
 AsyncSupport getCometSupport()
          Deprecated. Use getAsyncSupport
 String getDefaultBroadcasterClassName()
          Return the default Broadcaster class name.
 String getHandlersPath()
           
 String getLibPath()
          Return the location of the JARs containing the application classes.
 javax.servlet.ServletConfig getServletConfig()
           
 javax.servlet.ServletContext getServletContext()
           
 String getWebSocketProcessorClassName()
          The current WebSocketProcessor used to handle websocket requests.
 WebSocketProtocol getWebSocketProtocol()
           
 String getWebSocketProtocolClassName()
           
 AtmosphereFramework init()
          Initialize the AtmosphereFramework.
 AtmosphereFramework init(javax.servlet.ServletConfig sc)
          Initialize the AtmosphereFramework using the ServletContext.
 AtmosphereFramework init(javax.servlet.ServletConfig sc, boolean wrap)
          Initialize the AtmosphereFramework using the ServletContext.
 void initAtmosphereHandler(javax.servlet.ServletConfig sc)
          Initialize AtmosphereServletProcessor.
 void initEndpointMapper()
           
protected  void initGlobalInterceptors()
           
protected  void initHandlerInterceptors(AtmosphereFramework.AtmosphereHandlerWrapper w)
           
protected  void initInterceptors()
           
 void initWebSocket()
           
protected  ConcurrentLinkedQueue<BroadcasterCacheInspector> inspectors()
          Return the list of BroadcasterCacheInspectors.
protected  void installAnnotationProcessor(javax.servlet.ServletConfig sc)
           
 AtmosphereFramework interceptor(AtmosphereInterceptor c)
          Add an AtmosphereInterceptor implementation.
 LinkedList<AtmosphereInterceptor> interceptors()
          Return the list of AtmosphereInterceptor.
 boolean isShareExecutorServices()
          Returns true if ExecutorService is shared among all components.
 boolean isUseBlockingImplementation()
           
 boolean isUseNativeImplementation()
           
 boolean isUseStreamForFlushingComments()
          true if Atmosphere uses AtmosphereResponse.getOutputStream() by default for write operation.
protected  void loadAtmosphereDotXml(InputStream stream, URLClassLoader c)
          Load AtmosphereHandler defined under META-INF/atmosphere.xml.
 void loadAtmosphereHandlersFromPath(URLClassLoader classloader, String realPath)
           
 void loadConfiguration(javax.servlet.ServletConfig sc)
           
protected  void loadWebSocketFromPath(URLClassLoader classloader, String realPath)
           
protected  String lookupDefaultBroadcasterType(String defaultB)
           
protected  AtmosphereInterceptor newAInterceptor(Class<? extends AtmosphereInterceptor> a)
           
 void notify(Action.TYPE type, AtmosphereRequest request, AtmosphereResponse response)
           
 void patchContainer()
          Path specific container using their own property.
protected  void positionInterceptor(InvokationOrder.PRIORITY p, AtmosphereInterceptor c)
           
protected  void preventOOM()
          Prevent Atmosphere from scanning the entire class path.
protected  void readSystemProperties()
           
 AtmosphereFramework removeAllAtmosphereHandler()
          Remove all AtmosphereHandlers.
 AtmosphereFramework removeAllInitParams()
          Remove all init parameters.
 AtmosphereFramework removeAtmosphereHandler(String mapping)
          Remove an AtmosphereHandler.
 void sessionSupport(boolean sessionSupport)
           
 AtmosphereFramework setAsyncSupport(AsyncSupport asyncSupport)
          Set the AsyncSupport implementation.
 AtmosphereFramework setAtmosphereDotXmlPath(String atmosphereDotXmlPath)
           
 AtmosphereFramework setBroadcasterCacheClassName(String broadcasterCacheClassName)
          Set the BroadcasterCache class name.
 AtmosphereFramework setBroadcasterFactory(BroadcasterFactory broadcasterFactory)
          Set the BroadcasterFactory which is used by Atmosphere to construct Broadcaster.
 AtmosphereFramework setCometSupport(AsyncSupport asyncSupport)
           
 AtmosphereFramework setDefaultBroadcasterClassName(String bccn)
          Set the default Broadcaster class name.
 AtmosphereFramework setHandlersPath(String handlersPath)
           
 AtmosphereFramework setLibPath(String libPath)
          Set the location of the JARs containing the application.
 AtmosphereFramework setUseBlockingImplementation(boolean useBlockingImplementation)
           
 AtmosphereFramework setUseNativeImplementation(boolean useNativeImplementation)
           
 AtmosphereFramework setUseStreamForFlushingComments(boolean useStreamForFlushingComments)
          Set to true so Atmosphere uses AtmosphereResponse.getOutputStream() by default for write operation.
 AtmosphereFramework setWebsocketProcessorClassName(String webSocketProcessorClassName)
          Set the WebSocketProcessor class name used to process WebSocket requests.
 AtmosphereFramework setWebSocketProtocolClassName(String webSocketProtocolClassName)
           
 AtmosphereFramework shareExecutorServices(boolean sharedThreadPools)
          Set to true to have a ExecutorService shared among all components.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ATMOSPHERE_CONFIG_PATH

public static final String DEFAULT_ATMOSPHERE_CONFIG_PATH
See Also:
Constant Field Values

DEFAULT_LIB_PATH

public static final String DEFAULT_LIB_PATH
See Also:
Constant Field Values

DEFAULT_HANDLER_PATH

public static final String DEFAULT_HANDLER_PATH
See Also:
Constant Field Values

MAPPING_REGEX

public static final String MAPPING_REGEX
See Also:
Constant Field Values

ROOT

public static final String ROOT
See Also:
Constant Field Values

logger

protected static final org.slf4j.Logger logger

broadcasterFilters

protected final List<String> broadcasterFilters

asyncSupportListeners

protected final List<AsyncSupportListener> asyncSupportListeners

possibleComponentsCandidate

protected final ArrayList<String> possibleComponentsCandidate

initParams

protected final HashMap<String,String> initParams

config

protected final AtmosphereConfig config

isCometSupportConfigured

protected final AtomicBoolean isCometSupportConfigured

isFilter

protected final boolean isFilter

atmosphereHandlers

protected final Map<String,AtmosphereFramework.AtmosphereHandlerWrapper> atmosphereHandlers

broadcasterTypes

protected final ConcurrentLinkedQueue<String> broadcasterTypes

inspectors

protected final ConcurrentLinkedQueue<BroadcasterCacheInspector> inspectors

mappingRegex

protected String mappingRegex

useNativeImplementation

protected boolean useNativeImplementation

useBlockingImplementation

protected boolean useBlockingImplementation

useStreamForFlushingComments

protected boolean useStreamForFlushingComments

useServlet30

protected boolean useServlet30

asyncSupport

protected AsyncSupport asyncSupport

broadcasterClassName

protected String broadcasterClassName

isCometSupportSpecified

protected boolean isCometSupportSpecified

isBroadcasterSpecified

protected boolean isBroadcasterSpecified

isSessionSupportSpecified

protected boolean isSessionSupportSpecified

isThrowExceptionOnClonedRequestSpecified

protected boolean isThrowExceptionOnClonedRequestSpecified

broadcasterFactory

protected BroadcasterFactory broadcasterFactory

broadcasterFactoryClassName

protected String broadcasterFactoryClassName

broadcasterCacheClassName

protected String broadcasterCacheClassName

webSocketEnabled

protected boolean webSocketEnabled

broadcasterLifeCyclePolicy

protected String broadcasterLifeCyclePolicy

webSocketProtocolClassName

protected String webSocketProtocolClassName

webSocketProtocol

protected WebSocketProtocol webSocketProtocol

handlersPath

protected String handlersPath

servletConfig

protected javax.servlet.ServletConfig servletConfig

autoDetectHandlers

protected boolean autoDetectHandlers

atmosphereDotXmlPath

protected String atmosphereDotXmlPath

interceptors

protected final LinkedList<AtmosphereInterceptor> interceptors

scanDone

protected boolean scanDone

annotationProcessorClassName

protected String annotationProcessorClassName

broadcasterListeners

protected final List<BroadcasterListener> broadcasterListeners

webSocketProcessorClassName

protected String webSocketProcessorClassName

webSocketProtocolInitialized

protected boolean webSocketProtocolInitialized

endpointMapper

protected EndpointMapper<AtmosphereFramework.AtmosphereHandlerWrapper> endpointMapper

libPath

protected String libPath

isInit

protected boolean isInit

sharedThreadPools

protected boolean sharedThreadPools

packages

protected final List<String> packages

annotationPackages

protected final LinkedList<String> annotationPackages

allowAllClassesScan

protected boolean allowAllClassesScan

annotationFound

protected boolean annotationFound

executeFirstSet

protected boolean executeFirstSet

isDestroyed

protected boolean isDestroyed

externalizeDestroy

protected boolean externalizeDestroy

defaultInterceptors

protected final Class<? extends AtmosphereInterceptor>[] defaultInterceptors

REFLECTOR_ATMOSPHEREHANDLER

public static final AtmosphereHandler REFLECTOR_ATMOSPHEREHANDLER
An implementation of AbstractReflectorAtmosphereHandler.

Constructor Detail

AtmosphereFramework

public AtmosphereFramework()
Create an AtmosphereFramework.


AtmosphereFramework

public AtmosphereFramework(javax.servlet.ServletConfig sc)
                    throws javax.servlet.ServletException
Create an AtmosphereFramework and initialize it via init(javax.servlet.ServletConfig).

Throws:
javax.servlet.ServletException

AtmosphereFramework

public AtmosphereFramework(boolean isFilter,
                           boolean autoDetectHandlers)
Create an AtmosphereFramework.

Parameters:
isFilter - true if this instance is used as an AtmosphereFilter
Method Detail

addAtmosphereHandler

public AtmosphereFramework addAtmosphereHandler(String mapping,
                                                AtmosphereHandler h,
                                                List<AtmosphereInterceptor> l)
Add an AtmosphereHandler serviced by the Servlet This API is exposed to allow embedding an Atmosphere application.

Parameters:
mapping - The servlet mapping (servlet path)
h - implementation of an AtmosphereHandler
l - An array of AtmosphereInterceptor.

addAtmosphereHandler

public AtmosphereFramework addAtmosphereHandler(String mapping,
                                                AtmosphereHandler h)
Add an AtmosphereHandler serviced by the Servlet This API is exposed to allow embedding an Atmosphere application.

Parameters:
mapping - The servlet mapping (servlet path)
h - implementation of an AtmosphereHandler

addAtmosphereHandler

public AtmosphereFramework addAtmosphereHandler(String mapping,
                                                AtmosphereHandler h,
                                                String broadcasterId,
                                                List<AtmosphereInterceptor> l)
Add an AtmosphereHandler serviced by the Servlet. This API is exposed to allow embedding an Atmosphere application.

Parameters:
mapping - The servlet mapping (servlet path)
h - implementation of an AtmosphereHandler
broadcasterId - The Broadcaster.getID() value.
l - An attay of AtmosphereInterceptor

addAtmosphereHandler

public AtmosphereFramework addAtmosphereHandler(String mapping,
                                                AtmosphereHandler h,
                                                String broadcasterId)
Add an AtmosphereHandler serviced by the Servlet. This API is exposed to allow embedding an Atmosphere application.

Parameters:
mapping - The servlet mapping (servlet path)
h - implementation of an AtmosphereHandler
broadcasterId - The Broadcaster.getID() value

addAtmosphereHandler

public AtmosphereFramework addAtmosphereHandler(String mapping,
                                                AtmosphereHandler h,
                                                Broadcaster broadcaster,
                                                List<AtmosphereInterceptor> l)
Add an AtmosphereHandler serviced by the Servlet. This API is exposed to allow embedding an Atmosphere application.

Parameters:
mapping - The servlet mapping (servlet path)
h - implementation of an AtmosphereHandler
broadcaster - The Broadcaster associated with AtmosphereHandler
l - A list of AtmosphereInterceptors

addAtmosphereHandler

public AtmosphereFramework addAtmosphereHandler(String mapping,
                                                AtmosphereHandler h,
                                                Broadcaster broadcaster)
Add an AtmosphereHandler serviced by the Servlet. This API is exposed to allow embedding an Atmosphere application.

Parameters:
mapping - The servlet mapping (servlet path)
h - implementation of an AtmosphereHandler
broadcaster - The Broadcaster associated with AtmosphereHandler.

removeAtmosphereHandler

public AtmosphereFramework removeAtmosphereHandler(String mapping)
Remove an AtmosphereHandler.

Parameters:
mapping - the mapping used when invoking addAtmosphereHandler(String, AtmosphereHandler);
Returns:
true if removed

removeAllAtmosphereHandler

public AtmosphereFramework removeAllAtmosphereHandler()
Remove all AtmosphereHandlers.


removeAllInitParams

public AtmosphereFramework removeAllInitParams()
Remove all init parameters.


addInitParameter

public AtmosphereFramework addInitParameter(String name,
                                            String value)
Add init-param like if they were defined in web.xml

Parameters:
name - The name
value - The value

readSystemProperties

protected void readSystemProperties()

patchContainer

public void patchContainer()
Path specific container using their own property.


init

public AtmosphereFramework init()
Initialize the AtmosphereFramework. Invoke this method after having properly configured this class using the setters.


init

public AtmosphereFramework init(javax.servlet.ServletConfig sc)
                         throws javax.servlet.ServletException
Initialize the AtmosphereFramework using the ServletContext.

Parameters:
sc - the ServletContext
Throws:
javax.servlet.ServletException

preventOOM

protected void preventOOM()
Prevent Atmosphere from scanning the entire class path.


init

public AtmosphereFramework init(javax.servlet.ServletConfig sc,
                                boolean wrap)
                         throws javax.servlet.ServletException
Initialize the AtmosphereFramework using the ServletContext.

Parameters:
sc - the ServletContext
Throws:
javax.servlet.ServletException

analytics

protected void analytics()

configureAtmosphereInterceptor

protected void configureAtmosphereInterceptor(javax.servlet.ServletConfig sc)
Configure the list of AtmosphereInterceptor.

Parameters:
sc - a ServletConfig

newAInterceptor

protected AtmosphereInterceptor newAInterceptor(Class<? extends AtmosphereInterceptor> a)

initGlobalInterceptors

protected void initGlobalInterceptors()

initHandlerInterceptors

protected void initHandlerInterceptors(AtmosphereFramework.AtmosphereHandlerWrapper w)

initInterceptors

protected void initInterceptors()

configureWebDotXmlAtmosphereHandler

protected void configureWebDotXmlAtmosphereHandler(javax.servlet.ServletConfig sc)

configureScanningPackage

protected void configureScanningPackage(javax.servlet.ServletConfig sc,
                                        String value)

configureBroadcasterFactory

public void configureBroadcasterFactory()

configureBroadcaster

protected void configureBroadcaster()

installAnnotationProcessor

protected void installAnnotationProcessor(javax.servlet.ServletConfig sc)

doInitParamsForWebSocket

protected void doInitParamsForWebSocket(javax.servlet.ServletConfig sc)

doInitParams

protected void doInitParams(javax.servlet.ServletConfig sc)
Read init params from web.xml and apply them.

Parameters:
sc - ServletConfig

loadConfiguration

public void loadConfiguration(javax.servlet.ServletConfig sc)
                       throws javax.servlet.ServletException
Throws:
javax.servlet.ServletException

detectSupportedFramework

protected boolean detectSupportedFramework(javax.servlet.ServletConfig sc)
                                    throws ClassNotFoundException,
                                           IllegalAccessException,
                                           InstantiationException,
                                           NoSuchMethodException,
                                           InvocationTargetException
Auto-detect Jersey when no atmosphere.xml file is specified.

Parameters:
sc - ServletConfig
Returns:
true if Jersey classes are detected
Throws:
ClassNotFoundException
IllegalAccessException
InstantiationException
NoSuchMethodException
InvocationTargetException

lookupDefaultBroadcasterType

protected String lookupDefaultBroadcasterType(String defaultB)

sessionSupport

public void sessionSupport(boolean sessionSupport)

initAtmosphereHandler

public void initAtmosphereHandler(javax.servlet.ServletConfig sc)
                           throws javax.servlet.ServletException
Initialize AtmosphereServletProcessor.

Parameters:
sc - the ServletConfig
Throws:
javax.servlet.ServletException

initWebSocket

public void initWebSocket()

initEndpointMapper

public void initEndpointMapper()

destroy

public AtmosphereFramework destroy()

loadAtmosphereDotXml

protected void loadAtmosphereDotXml(InputStream stream,
                                    URLClassLoader c)
                             throws IOException,
                                    javax.servlet.ServletException
Load AtmosphereHandler defined under META-INF/atmosphere.xml.

Parameters:
stream - The input stream we read from.
c - The classloader
Throws:
IOException
javax.servlet.ServletException

setAsyncSupport

public AtmosphereFramework setAsyncSupport(AsyncSupport asyncSupport)
Set the AsyncSupport implementation. Make sure you don't set an implementation that only works on some container. See BlockingIOCometSupport for an example.

Parameters:
asyncSupport -

setCometSupport

public AtmosphereFramework setCometSupport(AsyncSupport asyncSupport)
Parameters:
asyncSupport -
Returns:

getAsyncSupport

public AsyncSupport getAsyncSupport()
Return the current AsyncSupport.

Returns:
the current AsyncSupport

getCometSupport

public AsyncSupport getCometSupport()
Deprecated. Use getAsyncSupport

Return the current AsyncSupport.

Returns:
the current AsyncSupport

createAsyncSupportResolver

protected AsyncSupportResolver createAsyncSupportResolver()
Returns an instance of AsyncSupportResolver AsyncSupportResolver.

Returns:
CometSupportResolver

autoDetectContainer

protected void autoDetectContainer()
Auto detect the underlying Servlet Container we are running on.


autoDetectAtmosphereHandlers

public void autoDetectAtmosphereHandlers(javax.servlet.ServletContext servletContext,
                                         URLClassLoader classloader)
                                  throws MalformedURLException,
                                         URISyntaxException
Auto detect instance of AtmosphereHandler in case META-INF/atmosphere.xml is missing.

Parameters:
servletContext - ServletContext
classloader - URLClassLoader to load the class.
Throws:
MalformedURLException
URISyntaxException

loadAtmosphereHandlersFromPath

public void loadAtmosphereHandlersFromPath(URLClassLoader classloader,
                                           String realPath)

autoDetectWebSocketHandler

protected void autoDetectWebSocketHandler(javax.servlet.ServletContext servletContext,
                                          URLClassLoader classloader)
                                   throws MalformedURLException,
                                          URISyntaxException
Auto detect instance of WebSocketHandler in case META-INF/atmosphere.xml is missing.

Parameters:
servletContext - ServletContext
classloader - URLClassLoader to load the class.
Throws:
MalformedURLException
URISyntaxException

loadWebSocketFromPath

protected void loadWebSocketFromPath(URLClassLoader classloader,
                                     String realPath)

configureRequestResponse

public AtmosphereFramework configureRequestResponse(AtmosphereRequest req,
                                                    AtmosphereResponse res)
                                             throws UnsupportedEncodingException
Configure some attributes on the AtmosphereRequest.

Parameters:
req - AtmosphereRequest
Throws:
UnsupportedEncodingException

doCometSupport

public Action doCometSupport(AtmosphereRequest req,
                             AtmosphereResponse res)
                      throws IOException,
                             javax.servlet.ServletException
Invoke the proprietary AsyncSupport.

Parameters:
req -
res -
Returns:
an Action
Throws:
IOException
javax.servlet.ServletException

getDefaultBroadcasterClassName

public String getDefaultBroadcasterClassName()
Return the default Broadcaster class name.

Returns:
the broadcasterClassName

setDefaultBroadcasterClassName

public AtmosphereFramework setDefaultBroadcasterClassName(String bccn)
Set the default Broadcaster class name.

Parameters:
bccn - the broadcasterClassName to set

isUseStreamForFlushingComments

public boolean isUseStreamForFlushingComments()
true if Atmosphere uses AtmosphereResponse.getOutputStream() by default for write operation.

Returns:
the useStreamForFlushingComments

setUseStreamForFlushingComments

public AtmosphereFramework setUseStreamForFlushingComments(boolean useStreamForFlushingComments)
Set to true so Atmosphere uses AtmosphereResponse.getOutputStream() by default for write operation. Default is false.

Parameters:
useStreamForFlushingComments - the useStreamForFlushingComments to set

getBroadcasterFactory

public BroadcasterFactory getBroadcasterFactory()
Get the BroadcasterFactory which is used by Atmosphere to construct Broadcaster.

Returns:
BroadcasterFactory

setBroadcasterFactory

public AtmosphereFramework setBroadcasterFactory(BroadcasterFactory broadcasterFactory)
Set the BroadcasterFactory which is used by Atmosphere to construct Broadcaster.

Returns:
BroadcasterFactory

getBroadcasterCacheClassName

public String getBroadcasterCacheClassName()
Return the BroadcasterCache class name.

Returns:
the BroadcasterCache class name

setBroadcasterCacheClassName

public AtmosphereFramework setBroadcasterCacheClassName(String broadcasterCacheClassName)
Set the BroadcasterCache class name.

Parameters:
broadcasterCacheClassName -

addBroadcasterType

public AtmosphereFramework addBroadcasterType(String broadcasterTypeString)
Add a new Broadcaster class name that AtmosphereServlet can use when initializing requests, and when the atmosphere.xml broadcaster element is unspecified.

Parameters:
broadcasterTypeString -

getWebSocketProtocolClassName

public String getWebSocketProtocolClassName()

setWebSocketProtocolClassName

public AtmosphereFramework setWebSocketProtocolClassName(String webSocketProtocolClassName)

getAtmosphereHandlers

public Map<String,AtmosphereFramework.AtmosphereHandlerWrapper> getAtmosphereHandlers()

configureQueryStringAsRequest

protected Map<String,String> configureQueryStringAsRequest(AtmosphereRequest request)

getWebSocketProtocol

public WebSocketProtocol getWebSocketProtocol()

isUseNativeImplementation

public boolean isUseNativeImplementation()

setUseNativeImplementation

public AtmosphereFramework setUseNativeImplementation(boolean useNativeImplementation)

isUseBlockingImplementation

public boolean isUseBlockingImplementation()

setUseBlockingImplementation

public AtmosphereFramework setUseBlockingImplementation(boolean useBlockingImplementation)

getAtmosphereDotXmlPath

public String getAtmosphereDotXmlPath()

setAtmosphereDotXmlPath

public AtmosphereFramework setAtmosphereDotXmlPath(String atmosphereDotXmlPath)

getHandlersPath

public String getHandlersPath()

setHandlersPath

public AtmosphereFramework setHandlersPath(String handlersPath)

getLibPath

public String getLibPath()
Return the location of the JARs containing the application classes. Default is WEB-INF/lib.

Returns:
the location of the JARs containing the application classes. Default is WEB-INF/lib

setLibPath

public AtmosphereFramework setLibPath(String libPath)
Set the location of the JARs containing the application.

Parameters:
libPath - the location of the JARs containing the application.
Returns:
this

getWebSocketProcessorClassName

public String getWebSocketProcessorClassName()
The current WebSocketProcessor used to handle websocket requests.

Returns:
WebSocketProcessor

setWebsocketProcessorClassName

public AtmosphereFramework setWebsocketProcessorClassName(String webSocketProcessorClassName)
Set the WebSocketProcessor class name used to process WebSocket requests. Default is DefaultWebSocketProcessor

Parameters:
webSocketProcessorClassName - WebSocketProcessor
Returns:
this

interceptor

public AtmosphereFramework interceptor(AtmosphereInterceptor c)
Add an AtmosphereInterceptor implementation. The adding order of AtmosphereInterceptor will be used, e.g the first added AtmosphereInterceptor will always be called first.

Parameters:
c - AtmosphereInterceptor
Returns:
this

positionInterceptor

protected void positionInterceptor(InvokationOrder.PRIORITY p,
                                   AtmosphereInterceptor c)

interceptors

public LinkedList<AtmosphereInterceptor> interceptors()
Return the list of AtmosphereInterceptor.

Returns:
the list of AtmosphereInterceptor

annotationProcessorClassName

public AtmosphereFramework annotationProcessorClassName(String annotationProcessorClassName)
Set the AnnotationProcessor class name.

Parameters:
annotationProcessorClassName - the AnnotationProcessor class name.
Returns:
this

asyncSupportListener

public AtmosphereFramework asyncSupportListener(AsyncSupportListener asyncSupportListener)
Add an AsyncSupportListener.

Parameters:
asyncSupportListener - an AsyncSupportListener
Returns:
this;

asyncSupportListeners

public List<AsyncSupportListener> asyncSupportListeners()
Return the list of AsyncSupportListeners.

Returns:

addBroadcasterListener

public AtmosphereFramework addBroadcasterListener(BroadcasterListener b)
Add BroadcasterListener to all created Broadcasters.


addBroadcasterCacheInjector

public AtmosphereFramework addBroadcasterCacheInjector(BroadcasterCacheInspector b)
Add a BroadcasterCacheInspector which will be associated with the defined BroadcasterCache.

Parameters:
b - BroadcasterCacheInspector
Returns:
this;

inspectors

protected ConcurrentLinkedQueue<BroadcasterCacheInspector> inspectors()
Return the list of BroadcasterCacheInspectors.

Returns:
the list of BroadcasterCacheInspectors

getAtmosphereConfig

public AtmosphereConfig getAtmosphereConfig()
Return a configured instance of AtmosphereConfig.

Returns:
a configured instance of AtmosphereConfig

getServletContext

public javax.servlet.ServletContext getServletContext()
Specified by:
getServletContext in interface ServletContextProvider

getServletConfig

public javax.servlet.ServletConfig getServletConfig()

broadcasterFilters

public List<String> broadcasterFilters()
Return the list of BroadcastFilters.

Returns:
the list of BroadcastFilters

broadcasterFilters

public AtmosphereFramework broadcasterFilters(BroadcastFilter f)
Add a BroadcastFilter.

Returns:

isShareExecutorServices

public boolean isShareExecutorServices()
Returns true if ExecutorService is shared among all components.

Returns:
true if ExecutorService is shared amongst all components

shareExecutorServices

public AtmosphereFramework shareExecutorServices(boolean sharedThreadPools)
Set to true to have a ExecutorService shared among all components.

Parameters:
sharedThreadPools -
Returns:
this

autoConfigureService

protected void autoConfigureService(javax.servlet.ServletContext sc)
                             throws IOException
Throws:
IOException

endPointMapper

public EndpointMapper<AtmosphereFramework.AtmosphereHandlerWrapper> endPointMapper()
The current EndpointMapper used to map requests to AtmosphereHandler.

Returns:
EndpointMapper

endPointMapper

public AtmosphereFramework endPointMapper(EndpointMapper endpointMapper)
Set the EndpointMapper.

Parameters:
endpointMapper - EndpointMapper
Returns:
this

addAnnotationPackage

public AtmosphereFramework addAnnotationPackage(Class<?> clazz)
Add support for package detection of Atmosphere's Component.

Parameters:
clazz - a Class
Returns:
this.

notify

public void notify(Action.TYPE type,
                   AtmosphereRequest request,
                   AtmosphereResponse response)

addWebSocketHandler

public AtmosphereFramework addWebSocketHandler(WebSocketHandler handler)
Add an WebSocketHandler mapped to "/*". return this


addWebSocketHandler

public AtmosphereFramework addWebSocketHandler(String path,
                                               WebSocketHandler handler)
Add an WebSocketHandler mapped to the path. return this


addWebSocketHandler

public AtmosphereFramework addWebSocketHandler(String path,
                                               WebSocketHandler handler,
                                               AtmosphereHandler h)
Add an WebSocketHandler mapped to the path and the AtmosphereHandler in case Broadcaster are used.

Parameters:
path - a path
handler - a WebSocketHandler
h - an AtmosphereHandler
Returns:
this

addWebSocketHandler

public AtmosphereFramework addWebSocketHandler(String path,
                                               WebSocketHandler handler,
                                               AtmosphereHandler h,
                                               List<AtmosphereInterceptor> l)
Add an WebSocketHandler mapped to the path and the AtmosphereHandler in case Broadcaster are used.

Parameters:
path - a path
handler - a WebSocketHandler
h - an AtmosphereHandler
l - AtmosphereInterceptor
Returns:
this

annotationScanned

public AtmosphereFramework annotationScanned(boolean b)
Invoked when a AnnotationProcessor found an annotation.

Parameters:
b - true when found
Returns:
this

customAnnotationPackages

public List<String> customAnnotationPackages()
Return the list of packages the framework should look for AtmosphereAnnotation.

Returns:
the list of packages the framework should look for AtmosphereAnnotation

addCustomAnnotationPackage

public AtmosphereFramework addCustomAnnotationPackage(Class p)
Add a package containing classes annotated with AtmosphereAnnotation.

Parameters:
p - a package
Returns:
this;

externalizeDestroy

public AtmosphereFramework externalizeDestroy(boolean externalizeDestroy)
If set to true, the task of finishing the request/response lifecycle will not be handled by this class.

Parameters:
externalizeDestroy -
Returns:
this


Copyright © 2014. All Rights Reserved.