org.atmosphere.cpr
Class AtmosphereFramework

java.lang.Object
  extended by org.atmosphere.cpr.AtmosphereFramework

public class AtmosphereFramework
extends Object

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
           
static class AtmosphereFramework.DefaultAtmosphereObjectFactory
           
static class AtmosphereFramework.MetaServiceAction
           This enumeration represents all possible actions to specify in a meta service file.
 
Field Summary
protected  boolean allowAllClassesScan
           
protected  boolean annotationFound
           
protected  LinkedList<String> annotationPackages
           
protected  AnnotationProcessor annotationProcessor
           
protected  String annotationProcessorClassName
           
protected  AtmosphereResourceFactory arFactory
           
protected  AsyncSupport asyncSupport
           
protected  List<AsyncSupportListener> asyncSupportListeners
           
protected  String atmosphereDotXmlPath
           
protected  Map<String,AtmosphereFramework.AtmosphereHandlerWrapper> atmosphereHandlers
           
protected  boolean autoDetectHandlers
           
protected  String broadcasterCacheClassName
           
protected  LinkedList<BroadcasterCacheListener> broadcasterCacheListeners
           
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  List<String> excludedInterceptors
           
protected  boolean executeFirstSet
           
protected  boolean externalizeDestroy
           
protected  List<BroadcasterConfig.FilterManipulator> filterManipulators
           
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  AtomicBoolean 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  MetaBroadcaster metaBroadcaster
           
protected  AtmosphereObjectFactory objectFactory
           
protected  ConcurrentLinkedQueue<String> objectFactoryType
           
protected  List<String> packages
           
protected  ArrayList<String> possibleComponentsCandidate
           
static AtmosphereHandler REFLECTOR_ATMOSPHEREHANDLER
          An implementation of AbstractReflectorAtmosphereHandler.
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 addBroadcasterCacheListener(BroadcasterCacheListener b)
          Add BroadcasterCacheListener to the 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 "/*".
 boolean allowAllClassesScan()
           
 AtmosphereFramework allowAllClassesScan(boolean allowAllClassesScan)
           
protected  void analytics()
           
 AnnotationProcessor annotationProcessor()
          Return the AnnotationProcessor
 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.
 AtmosphereResourceFactory atmosphereFactory()
           
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<BroadcasterCacheListener> broadcasterCacheListeners()
           
 List<String> broadcasterFilters()
          Return the list of BroadcastFilters.
 AtmosphereFramework broadcasterFilters(BroadcastFilter f)
          Add a BroadcastFilter.
 String broadcasterLifeCyclePolicy()
           
 AtmosphereFramework broadcasterLifeCyclePolicy(String broadcasterLifeCyclePolicy)
           
 List<BroadcasterListener> broadcasterListeners()
           
 ConcurrentLinkedQueue<String> broadcasterTypes()
           
protected  void configureAtmosphereInterceptor(javax.servlet.ServletConfig sc)
          Configure the list of AtmosphereInterceptor.
protected  void configureBroadcaster()
           
 void configureBroadcasterFactory()
           
protected  void configureDetectedFramework(ReflectorServletProcessor rsp, boolean isJersey)
           
protected  void configureObjectFactory()
           
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.
 Class<? extends AtmosphereInterceptor>[] defaultInterceptors()
           
protected  void defaultPackagesToScan()
           
 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 doInitParams(javax.servlet.ServletConfig sc, boolean reconfigure)
          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.
 List<String> excludedInterceptors()
           
 AtmosphereFramework excludeInterceptor(String interceptor)
          Exclude an AtmosphereInterceptor from being added, at startup, by Atmosphere.
 boolean externalizeDestroy()
           
 AtmosphereFramework externalizeDestroy(boolean externalizeDestroy)
          If set to true, the task of finishing the request/response lifecycle will not be handled by this class.
 AtmosphereFramework filterManipulator(BroadcasterConfig.FilterManipulator m)
           
 List<BroadcasterConfig.FilterManipulator> filterManipulators()
           
 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()
          Return the ServletContext
 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()
           
 void initHandlerInterceptors(LinkedList<AtmosphereInterceptor> l)
           
 boolean initialized()
          Return true if the init() has been sucessfully executed.
protected  void initInterceptors()
           
 void initWebSocket()
           
 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 isAServletFilter()
           
 boolean isBroadcasterSpecified()
          Was a Broadcaster defined in web.xml or programmatically added.
 boolean isShareExecutorServices()
          Returns true if ExecutorService is shared among all components.
 boolean isUseBlockingImplementation()
           
 boolean isUseNativeImplementation()
           
 boolean isUseServlet30()
           
 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 loadMetaService()
           
protected  void loadWebSocketFromPath(URLClassLoader classloader, String realPath)
           
protected  String lookupDefaultBroadcasterType(String defaultB)
           
protected  AtmosphereObjectFactory lookupDefaultObjectFactoryType()
           
 String mappingRegex()
           
 AtmosphereFramework mappingRegex(String mappingRegex)
           
 MetaBroadcaster metaBroadcaster()
           
protected  AtmosphereInterceptor newAInterceptor(Class<? extends AtmosphereInterceptor> a)
           
<T,U extends T>
T
newClassInstance(Class<T> classType, Class<U> defaultType)
          Instantiate a class
 void notify(Action.TYPE type, AtmosphereRequest request, AtmosphereResponse response)
           
 AtmosphereObjectFactory objectFactory()
           
 void objectFactory(AtmosphereObjectFactory objectFactory)
          Set an object used for class instantiation.
 ConcurrentLinkedQueue<String> objectFactoryType()
           
 List<String> packages()
           
 void patchContainer()
          Path specific container using their own property.
protected  void positionInterceptor(InvokationOrder.PRIORITY p, AtmosphereInterceptor c, LinkedList<AtmosphereInterceptor> interceptors)
           
protected  void preventOOM()
          Prevent Atmosphere from scanning the entire class path.
protected  void readSystemProperties()
           
 void reconfigureInitParams(boolean reconfigureInitParams)
           
 AtmosphereFramework removeAllAtmosphereHandler()
          Remove all AtmosphereHandlers.
 AtmosphereFramework removeAllInitParams()
          Remove all init parameters.
 AtmosphereFramework removeAtmosphereHandler(String mapping)
          Remove an AtmosphereHandler.
 AtmosphereFramework resetStates()
           
 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)
           
 void setUseServlet30(boolean useServlet30)
           
 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)
           
 boolean sharedThreadPools()
           
 AtmosphereFramework sharedThreadPools(boolean sharedThreadPools)
           
 AtmosphereFramework shareExecutorServices(boolean sharedThreadPools)
          Set to true to have a ExecutorService shared among all components.
 boolean webSocketEnabled()
           
 AtmosphereFramework webSocketEnabled(boolean webSocketEnabled)
           
 
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

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

objectFactoryType

protected final ConcurrentLinkedQueue<String> objectFactoryType

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

objectFactory

protected AtmosphereObjectFactory objectFactory

isDestroyed

protected final AtomicBoolean isDestroyed

externalizeDestroy

protected boolean externalizeDestroy

annotationProcessor

protected AnnotationProcessor annotationProcessor

excludedInterceptors

protected final List<String> excludedInterceptors

broadcasterCacheListeners

protected final LinkedList<BroadcasterCacheListener> broadcasterCacheListeners

filterManipulators

protected final List<BroadcasterConfig.FilterManipulator> filterManipulators

arFactory

protected AtmosphereResourceFactory arFactory

metaBroadcaster

protected MetaBroadcaster metaBroadcaster

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

reconfigureInitParams

public void reconfigureInitParams(boolean reconfigureInitParams)

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

public void initHandlerInterceptors(LinkedList<AtmosphereInterceptor> l)

initInterceptors

protected void initInterceptors()

configureWebDotXmlAtmosphereHandler

protected void configureWebDotXmlAtmosphereHandler(javax.servlet.ServletConfig sc)

configureScanningPackage

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

defaultPackagesToScan

protected void defaultPackagesToScan()

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

doInitParams

protected void doInitParams(javax.servlet.ServletConfig sc,
                            boolean reconfigure)
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 Exception
Auto-detect Jersey when no atmosphere.xml file is specified.

Parameters:
sc - ServletConfig
Returns:
true if Jersey classes are detected
Throws:
ClassNotFoundException
Exception

configureDetectedFramework

protected void configureDetectedFramework(ReflectorServletProcessor rsp,
                                          boolean isJersey)

lookupDefaultBroadcasterType

protected String lookupDefaultBroadcasterType(String defaultB)

lookupDefaultObjectFactoryType

protected AtmosphereObjectFactory lookupDefaultObjectFactoryType()

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()

resetStates

public AtmosphereFramework resetStates()

loadMetaService

protected void loadMetaService()

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

isUseServlet30

public boolean isUseServlet30()

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 -

broadcasterTypes

public ConcurrentLinkedQueue<String> broadcasterTypes()

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,
                                   LinkedList<AtmosphereInterceptor> interceptors)

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.


addBroadcasterCacheListener

public AtmosphereFramework addBroadcasterCacheListener(BroadcasterCacheListener b)
Add BroadcasterCacheListener to the BroadcasterCache.


broadcasterCacheListeners

public List<BroadcasterCacheListener> broadcasterCacheListeners()

addBroadcasterCacheInjector

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

Parameters:
b - BroadcasterCacheInspector
Returns:
this;

inspectors

public 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()
Return the ServletContext

Returns:
the ServletContext

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

initialized

public boolean initialized()
Return true if the init() has been sucessfully executed.

Returns:
true if the init() has been sucessfully executed.

packages

public List<String> packages()

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;

newClassInstance

public <T,U extends T> T newClassInstance(Class<T> classType,
                                          Class<U> defaultType)
                   throws InstantiationException,
                          IllegalAccessException
Instantiate a class

Parameters:
classType - The Required Class's Type
defaultType - The default implementation of the Class's Type.
Returns:
the an instance of defaultType
Throws:
InstantiationException
IllegalAccessException

objectFactory

public void objectFactory(AtmosphereObjectFactory objectFactory)
Set an object used for class instantiation. Allows for integration with dependency injection frameworks.

Parameters:
objectFactory -

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

annotationProcessor

public AnnotationProcessor annotationProcessor()
Return the AnnotationProcessor

Returns:
the AnnotationProcessor

isBroadcasterSpecified

public boolean isBroadcasterSpecified()
Was a Broadcaster defined in web.xml or programmatically added.

Returns:
true is defined.

configureObjectFactory

protected void configureObjectFactory()

excludeInterceptor

public AtmosphereFramework excludeInterceptor(String interceptor)
Exclude an AtmosphereInterceptor from being added, at startup, by Atmosphere. The default's defaultInterceptors are candidates for being excluded.

Parameters:
interceptor - an AtmosphereInterceptor class name
Returns:
this

filterManipulator

public AtmosphereFramework filterManipulator(BroadcasterConfig.FilterManipulator m)

filterManipulators

public List<BroadcasterConfig.FilterManipulator> filterManipulators()

isAServletFilter

public boolean isAServletFilter()

objectFactoryType

public ConcurrentLinkedQueue<String> objectFactoryType()

mappingRegex

public String mappingRegex()

mappingRegex

public AtmosphereFramework mappingRegex(String mappingRegex)

setUseServlet30

public void setUseServlet30(boolean useServlet30)

webSocketEnabled

public boolean webSocketEnabled()

webSocketEnabled

public AtmosphereFramework webSocketEnabled(boolean webSocketEnabled)

broadcasterLifeCyclePolicy

public String broadcasterLifeCyclePolicy()

broadcasterLifeCyclePolicy

public AtmosphereFramework broadcasterLifeCyclePolicy(String broadcasterLifeCyclePolicy)

broadcasterListeners

public List<BroadcasterListener> broadcasterListeners()

sharedThreadPools

public boolean sharedThreadPools()

sharedThreadPools

public AtmosphereFramework sharedThreadPools(boolean sharedThreadPools)

allowAllClassesScan

public boolean allowAllClassesScan()

allowAllClassesScan

public AtmosphereFramework allowAllClassesScan(boolean allowAllClassesScan)

objectFactory

public AtmosphereObjectFactory objectFactory()

externalizeDestroy

public boolean externalizeDestroy()

excludedInterceptors

public List<String> excludedInterceptors()

defaultInterceptors

public Class<? extends AtmosphereInterceptor>[] defaultInterceptors()

atmosphereFactory

public AtmosphereResourceFactory atmosphereFactory()

metaBroadcaster

public MetaBroadcaster metaBroadcaster()


Copyright © 2014. All Rights Reserved.