public class AtmosphereFramework extends Object
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();
| Modifier and Type | Class and Description |
|---|---|
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.
|
| Constructor and Description |
|---|
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). |
public static final String DEFAULT_ATMOSPHERE_CONFIG_PATH
public static final String DEFAULT_LIB_PATH
public static final String DEFAULT_HANDLER_PATH
public static final String META_SERVICE
public static final String MAPPING_REGEX
protected static final org.slf4j.Logger logger
protected final List<AsyncSupportListener> asyncSupportListeners
protected final List<AtmosphereResourceListener> atmosphereResourceListeners
protected final AtmosphereConfig config
protected final AtomicBoolean isCometSupportConfigured
protected final boolean isFilter
protected final Map<String,AtmosphereFramework.AtmosphereHandlerWrapper> atmosphereHandlers
protected final ConcurrentLinkedQueue<String> broadcasterTypes
protected final ConcurrentLinkedQueue<String> objectFactoryType
protected final ConcurrentLinkedQueue<BroadcasterCacheInspector> inspectors
protected String mappingRegex
protected boolean useNativeImplementation
protected boolean useBlockingImplementation
protected boolean useStreamForFlushingComments
protected boolean useServlet30
protected AsyncSupport asyncSupport
protected String broadcasterClassName
protected boolean isCometSupportSpecified
protected boolean isBroadcasterSpecified
protected boolean isSessionSupportSpecified
protected boolean isThrowExceptionOnClonedRequestSpecified
protected BroadcasterFactory broadcasterFactory
protected String broadcasterFactoryClassName
protected String broadcasterCacheClassName
protected boolean webSocketEnabled
protected String broadcasterLifeCyclePolicy
protected String webSocketProtocolClassName
protected WebSocketProtocol webSocketProtocol
protected String handlersPath
protected javax.servlet.ServletConfig servletConfig
protected boolean autoDetectHandlers
protected String atmosphereDotXmlPath
protected String metaServicePath
protected final LinkedList<AtmosphereInterceptor> interceptors
protected boolean scanDone
protected String annotationProcessorClassName
protected final List<BroadcasterListener> broadcasterListeners
protected String webSocketProcessorClassName
protected boolean webSocketProtocolInitialized
protected EndpointMapper<AtmosphereFramework.AtmosphereHandlerWrapper> endpointMapper
protected String libPath
protected boolean isInit
protected boolean sharedThreadPools
protected final LinkedList<String> annotationPackages
protected boolean allowAllClassesScan
protected boolean annotationFound
protected boolean executeFirstSet
protected AtmosphereObjectFactory<?> objectFactory
protected final AtomicBoolean isDestroyed
protected boolean externalizeDestroy
protected AnnotationProcessor annotationProcessor
protected final LinkedList<BroadcasterCacheListener> broadcasterCacheListeners
protected final List<BroadcasterConfig.FilterManipulator> filterManipulators
protected AtmosphereResourceFactory arFactory
protected MetaBroadcaster metaBroadcaster
protected AtmosphereResourceSessionFactory sessionFactory
protected String defaultSerializerClassName
protected Class<Serializer> defaultSerializerClass
protected final List<AtmosphereFrameworkListener> frameworkListeners
protected Thread shutdownHook
public static final List<Class<? extends AtmosphereInterceptor>> DEFAULT_ATMOSPHERE_INTERCEPTORS
public static final AtmosphereHandler REFLECTOR_ATMOSPHEREHANDLER
AbstractReflectorAtmosphereHandler.public AtmosphereFramework()
public AtmosphereFramework(javax.servlet.ServletConfig sc)
throws javax.servlet.ServletException
init(javax.servlet.ServletConfig).javax.servlet.ServletExceptionpublic AtmosphereFramework(boolean isFilter,
boolean autoDetectHandlers)
isFilter - true if this instance is used as an AtmosphereFilterpublic void setAndConfigureAtmosphereResourceFactory(AtmosphereResourceFactory arFactory)
protected AtmosphereConfig newAtmosphereConfig()
AtmosphereConfigpublic AtmosphereFramework addAtmosphereHandler(String mapping, AtmosphereHandler h, List<AtmosphereInterceptor> l)
AtmosphereHandler serviced by the Servlet
This API is exposed to allow embedding an Atmosphere application.mapping - The servlet mapping (servlet path)h - implementation of an AtmosphereHandlerl - An array of AtmosphereInterceptor.public AtmosphereFramework addAtmosphereHandler(String mapping, AtmosphereHandler h, Broadcaster broadcaster, List<AtmosphereInterceptor> l)
AtmosphereHandler serviced by the Servlet.
This API is exposed to allow embedding an Atmosphere application.mapping - The servlet mapping (servlet path)h - implementation of an AtmosphereHandlerbroadcaster - The Broadcaster associated with AtmosphereHandlerl - A list of AtmosphereInterceptorspublic AtmosphereFramework addAtmosphereHandler(String mapping, AtmosphereHandler h, String broadcasterId, List<AtmosphereInterceptor> l)
AtmosphereHandler serviced by the Servlet.
This API is exposed to allow embedding an Atmosphere application.mapping - The servlet mapping (servlet path)h - implementation of an AtmosphereHandlerbroadcasterId - The Broadcaster.getID() value.l - A list of AtmosphereInterceptorprotected AtmosphereFramework.AtmosphereHandlerWrapper createWrapperAndConfigureHandler(AtmosphereHandler h, String mapping, List<AtmosphereInterceptor> l)
public AtmosphereFramework addAtmosphereHandler(String mapping, AtmosphereHandler h)
AtmosphereHandler serviced by the Servlet
This API is exposed to allow embedding an Atmosphere application.mapping - The servlet mapping (servlet path)h - implementation of an AtmosphereHandlerpublic AtmosphereFramework addAtmosphereHandler(String mapping, AtmosphereHandler h, String broadcasterId)
AtmosphereHandler serviced by the Servlet.
This API is exposed to allow embedding an Atmosphere application.mapping - The servlet mapping (servlet path)h - implementation of an AtmosphereHandlerbroadcasterId - The Broadcaster.getID() valuepublic AtmosphereFramework addAtmosphereHandler(String mapping, AtmosphereHandler h, Broadcaster broadcaster)
AtmosphereHandler serviced by the Servlet.
This API is exposed to allow embedding an Atmosphere application.mapping - The servlet mapping (servlet path)h - implementation of an AtmosphereHandlerbroadcaster - The Broadcaster associated with AtmosphereHandler.public AtmosphereFramework removeAtmosphereHandler(String mapping)
AtmosphereHandler.mapping - the mapping used when invoking addAtmosphereHandler(String, AtmosphereHandler);public AtmosphereFramework removeAllAtmosphereHandler()
AtmosphereHandlers.public AtmosphereFramework removeAllInitParams()
public AtmosphereFramework addInitParameter(String name, String value)
name - The namevalue - The valueprotected void readSystemProperties()
public void patchContainer()
public AtmosphereFramework init()
public AtmosphereFramework init(javax.servlet.ServletConfig sc) throws javax.servlet.ServletException
ServletContext.sc - the ServletContextjavax.servlet.ServletExceptionprotected void preventOOM()
public AtmosphereFramework init(javax.servlet.ServletConfig sc, boolean wrap) throws javax.servlet.ServletException
ServletContext.sc - the ServletContextjavax.servlet.ServletExceptionprotected void servletConfig(javax.servlet.ServletConfig sc,
boolean wrap)
public void reconfigureInitParams(boolean reconfigureInitParams)
protected void universe()
protected void analytics()
protected void configureAtmosphereInterceptor(javax.servlet.ServletConfig sc)
AtmosphereInterceptor.sc - a ServletConfigprotected AtmosphereInterceptor newAInterceptor(Class<? extends AtmosphereInterceptor> a)
protected void configureWebDotXmlAtmosphereHandler(javax.servlet.ServletConfig sc)
protected void configureScanningPackage(javax.servlet.ServletConfig sc,
String value)
protected void defaultPackagesToScan()
public void configureBroadcasterFactory()
protected void configureBroadcaster()
protected void installAnnotationProcessor(javax.servlet.ServletConfig sc)
protected void doInitParamsForWebSocket(javax.servlet.ServletConfig sc)
protected void doInitParams(javax.servlet.ServletConfig sc)
sc - ServletConfigprotected void doInitParams(javax.servlet.ServletConfig sc,
boolean reconfigure)
sc - ServletConfigpublic void loadConfiguration(javax.servlet.ServletConfig sc)
throws javax.servlet.ServletException
javax.servlet.ServletExceptionprotected boolean detectSupportedFramework(javax.servlet.ServletConfig sc)
throws Exception
sc - ServletConfigClassNotFoundExceptionExceptionprotected void configureDetectedFramework(ReflectorServletProcessor rsp, boolean isJersey)
protected AtmosphereObjectFactory lookupDefaultObjectFactoryType()
public void sessionSupport(boolean sessionSupport)
public void initAtmosphereHandler(javax.servlet.ServletConfig sc)
throws javax.servlet.ServletException
AtmosphereServletProcessor.sc - the ServletConfigjavax.servlet.ServletExceptionpublic void initAtmosphereHandler()
throws javax.servlet.ServletException
javax.servlet.ServletExceptionpublic void checkWebSocketSupportState()
public void initWebSocket()
public void initEndpointMapper()
protected void closeAtmosphereResource()
public AtmosphereFramework destroy()
protected void destroyInterceptors()
public AtmosphereFramework resetStates()
protected void loadMetaService()
protected void loadAtmosphereDotXml(InputStream stream, URLClassLoader c) throws IOException, javax.servlet.ServletException
stream - The input stream we read from.c - The classloaderIOExceptionjavax.servlet.ServletExceptionpublic AtmosphereFramework setAsyncSupport(AsyncSupport asyncSupport)
AsyncSupport implementation. Make sure you don't set an implementation that only works on
some container. See BlockingIOCometSupport for an example.asyncSupport - public AtmosphereFramework setCometSupport(AsyncSupport asyncSupport)
asyncSupport - public AsyncSupport getAsyncSupport()
AsyncSupport.AsyncSupportpublic AsyncSupport getCometSupport()
AsyncSupport.AsyncSupportprotected AsyncSupportResolver createAsyncSupportResolver()
AsyncSupportResolver.protected void autoDetectContainer()
public void autoDetectAtmosphereHandlers(javax.servlet.ServletContext servletContext,
URLClassLoader classloader)
throws MalformedURLException,
URISyntaxException
AtmosphereHandler in case META-INF/atmosphere.xml
is missing.servletContext - ServletContextclassloader - URLClassLoader to load the class.MalformedURLExceptionURISyntaxExceptionpublic void loadAtmosphereHandlersFromPath(URLClassLoader classloader, String realPath)
protected void autoDetectWebSocketHandler(javax.servlet.ServletContext servletContext,
URLClassLoader classloader)
throws MalformedURLException,
URISyntaxException
WebSocketHandler in case META-INF/atmosphere.xml
is missing.servletContext - ServletContextclassloader - URLClassLoader to load the class.MalformedURLExceptionURISyntaxExceptionprotected void loadWebSocketFromPath(URLClassLoader classloader, String realPath)
public AtmosphereFramework configureRequestResponse(AtmosphereRequest req, AtmosphereResponse res) throws UnsupportedEncodingException
AtmosphereRequest.req - AtmosphereRequestUnsupportedEncodingExceptionpublic Action doCometSupport(AtmosphereRequest req, AtmosphereResponse res) throws IOException, javax.servlet.ServletException
AsyncSupport.req - res - ActionIOExceptionjavax.servlet.ServletExceptionpublic String getDefaultBroadcasterClassName()
Broadcaster class name.public AtmosphereFramework setDefaultBroadcasterClassName(String bccn)
Broadcaster class name.bccn - the broadcasterClassName to setpublic boolean isUseStreamForFlushingComments()
AtmosphereResponseImpl.getOutputStream()
by default for write operation.public boolean isUseServlet30()
public AtmosphereFramework setUseStreamForFlushingComments(boolean useStreamForFlushingComments)
AtmosphereResponseImpl.getOutputStream()
by default for write operation. Default is false.useStreamForFlushingComments - the useStreamForFlushingComments to setpublic BroadcasterFactory getBroadcasterFactory()
BroadcasterFactory which is used by Atmosphere to construct
Broadcaster.BroadcasterFactorypublic AtmosphereFramework setBroadcasterFactory(BroadcasterFactory broadcasterFactory)
BroadcasterFactory which is used by Atmosphere to construct
Broadcaster.BroadcasterFactorypublic String getBroadcasterCacheClassName()
BroadcasterCache class name.BroadcasterCache class namepublic AtmosphereFramework setBroadcasterCacheClassName(String broadcasterCacheClassName)
BroadcasterCache class name.broadcasterCacheClassName - public AtmosphereFramework addBroadcasterType(String broadcasterTypeString)
broadcasterTypeString - public ConcurrentLinkedQueue<String> broadcasterTypes()
public String getWebSocketProtocolClassName()
public AtmosphereFramework setWebSocketProtocolClassName(String webSocketProtocolClassName)
public Map<String,AtmosphereFramework.AtmosphereHandlerWrapper> getAtmosphereHandlers()
protected Map<String,String> configureQueryStringAsRequest(AtmosphereRequest request)
public WebSocketProtocol getWebSocketProtocol()
public boolean isUseNativeImplementation()
public AtmosphereFramework setUseNativeImplementation(boolean useNativeImplementation)
public boolean isUseBlockingImplementation()
public AtmosphereFramework setUseBlockingImplementation(boolean useBlockingImplementation)
public String getAtmosphereDotXmlPath()
public AtmosphereFramework setAtmosphereDotXmlPath(String atmosphereDotXmlPath)
public String getHandlersPath()
public AtmosphereFramework setHandlersPath(String handlersPath)
public String getLibPath()
public AtmosphereFramework setLibPath(String libPath)
libPath - the location of the JARs containing the application.public String getWebSocketProcessorClassName()
WebSocketProcessor used to handle websocket requests.WebSocketProcessorpublic AtmosphereFramework setWebsocketProcessorClassName(String webSocketProcessorClassName)
WebSocketProcessor class name used to process WebSocket requests. Default is
DefaultWebSocketProcessorwebSocketProcessorClassName - WebSocketProcessorpublic AtmosphereFramework interceptor(AtmosphereInterceptor c)
AtmosphereInterceptor implementation. The adding order of AtmosphereInterceptor will be used, e.g
the first added AtmosphereInterceptor will always be called first.c - AtmosphereInterceptorprotected void addDefaultOrAppInterceptors()
protected void addInterceptorToAllWrappers(AtmosphereInterceptor c)
protected void addInterceptorToWrapper(AtmosphereFramework.AtmosphereHandlerWrapper wrapper, AtmosphereInterceptor c)
protected void addInterceptorToWrapper(AtmosphereFramework.AtmosphereHandlerWrapper wrapper, List<AtmosphereInterceptor> interceptors)
public LinkedList<AtmosphereInterceptor> interceptors()
AtmosphereInterceptor.AtmosphereInterceptorpublic AtmosphereFramework annotationProcessorClassName(String annotationProcessorClassName)
AnnotationProcessor class name.annotationProcessorClassName - the AnnotationProcessor class name.public AtmosphereFramework asyncSupportListener(AsyncSupportListener asyncSupportListener)
AsyncSupportListener.asyncSupportListener - an AsyncSupportListenerpublic List<AsyncSupportListener> asyncSupportListeners()
AsyncSupportListeners.public AtmosphereFramework addBroadcasterListener(BroadcasterListener b)
BroadcasterListener to all created Broadcasters.public AtmosphereFramework addBroadcasterCacheListener(BroadcasterCacheListener b)
BroadcasterCacheListener to the BroadcasterCache.public List<BroadcasterCacheListener> broadcasterCacheListeners()
public AtmosphereFramework addBroadcasterCacheInjector(BroadcasterCacheInspector b)
BroadcasterCacheInspector which will be associated with the defined BroadcasterCache.b - BroadcasterCacheInspectorpublic ConcurrentLinkedQueue<BroadcasterCacheInspector> inspectors()
BroadcasterCacheInspectors.BroadcasterCacheInspectorspublic AtmosphereConfig getAtmosphereConfig()
AtmosphereConfig.AtmosphereConfigpublic javax.servlet.ServletContext getServletContext()
ServletContextServletContextpublic javax.servlet.ServletConfig getServletConfig()
public List<String> broadcasterFilters()
BroadcastFilters.BroadcastFilterspublic AtmosphereFramework broadcasterFilters(BroadcastFilter f)
BroadcastFilter.public boolean isShareExecutorServices()
ExecutorService is shared among all components.ExecutorService is shared amongst all componentspublic AtmosphereFramework shareExecutorServices(boolean sharedThreadPools)
ExecutorService shared among all components.sharedThreadPools - protected void autoConfigureService(javax.servlet.ServletContext sc)
throws IOException
IOExceptionpublic EndpointMapper<AtmosphereFramework.AtmosphereHandlerWrapper> endPointMapper()
EndpointMapper used to map requests to AtmosphereHandler.EndpointMapperpublic AtmosphereFramework endPointMapper(EndpointMapper endpointMapper)
EndpointMapper.endpointMapper - EndpointMapperpublic AtmosphereFramework addAnnotationPackage(Class<?> clazz)
clazz - a Classpublic AtmosphereFramework notify(Action.TYPE type, AtmosphereRequest request, AtmosphereResponse response)
public AtmosphereFramework notifyDestroyed(String uuid)
public AtmosphereFramework notifySuspended(String uuid)
public AtmosphereFramework addWebSocketHandler(WebSocketHandler handler)
WebSocketHandler mapped to "/*".
return thispublic AtmosphereFramework addWebSocketHandler(String path, WebSocketHandler handler)
WebSocketHandler mapped to the path.
return thispublic AtmosphereFramework addWebSocketHandler(String path, WebSocketHandler handler, AtmosphereHandler h)
path - a pathhandler - a WebSocketHandlerh - an AtmosphereHandlerpublic AtmosphereFramework addWebSocketHandler(String path, WebSocketHandler handler, AtmosphereHandler h, List<AtmosphereInterceptor> l)
path - a pathhandler - a WebSocketHandlerh - an AtmosphereHandlerl - AtmosphereInterceptorpublic AtmosphereFramework annotationScanned(boolean b)
AnnotationProcessor found an annotation.b - true when foundpublic boolean initialized()
init() has been sucessfully executed.init() has been sucessfully executed.public List<String> customAnnotationPackages()
AtmosphereAnnotation.AtmosphereAnnotationpublic AtmosphereFramework addCustomAnnotationPackage(Class p)
AtmosphereAnnotation.p - a packagepublic <T,U extends T> T newClassInstance(Class<T> classType, Class<U> defaultType) throws InstantiationException, IllegalAccessException
classType - The Required Class's TypedefaultType - The default implementation of the Class's Type.InstantiationExceptionIllegalAccessExceptionpublic void objectFactory(AtmosphereObjectFactory objectFactory)
objectFactory - public AtmosphereFramework externalizeDestroy(boolean externalizeDestroy)
externalizeDestroy - public AnnotationProcessor annotationProcessor()
AnnotationProcessorAnnotationProcessorpublic boolean isBroadcasterSpecified()
Broadcaster defined in web.xml or programmatically added.protected void configureObjectFactory()
public AtmosphereFramework excludeInterceptor(String interceptor)
AtmosphereInterceptor from being added, at startup, by Atmosphere. The default's DEFAULT_ATMOSPHERE_INTERCEPTORS
are candidates for being excluded.interceptor - an AtmosphereInterceptor class namepublic AtmosphereFramework filterManipulator(BroadcasterConfig.FilterManipulator m)
public List<BroadcasterConfig.FilterManipulator> filterManipulators()
public boolean isAServletFilter()
public ConcurrentLinkedQueue<String> objectFactoryType()
public String mappingRegex()
public AtmosphereFramework mappingRegex(String mappingRegex)
public void setUseServlet30(boolean useServlet30)
public boolean webSocketEnabled()
public AtmosphereFramework webSocketEnabled(boolean webSocketEnabled)
public String broadcasterLifeCyclePolicy()
public AtmosphereFramework broadcasterLifeCyclePolicy(String broadcasterLifeCyclePolicy)
public List<BroadcasterListener> broadcasterListeners()
public boolean sharedThreadPools()
public AtmosphereFramework sharedThreadPools(boolean sharedThreadPools)
public boolean allowAllClassesScan()
public AtmosphereFramework allowAllClassesScan(boolean allowAllClassesScan)
public AtmosphereObjectFactory objectFactory()
public boolean externalizeDestroy()
public Class<? extends AtmosphereInterceptor>[] defaultInterceptors()
public AtmosphereResourceFactory atmosphereFactory()
public MetaBroadcaster metaBroadcaster()
public String getDefaultSerializerClassName()
Serializer class name to use for AtmosphereResources.public Class<Serializer> getDefaultSerializerClass()
Serializer class to use for AtmosphereResources.public AtmosphereFramework setDefaultSerializerClassName(String defaultSerializerClassName)
Serializer class name to use for AtmosphereResources.defaultSerializerClassName - the class name to usepublic AtmosphereResourceSessionFactory sessionFactory()
AtmosphereResourceSessionFactorypublic boolean isDestroyed()
destroy() method has been invoked.destroy() method has been invoked.public AtmosphereFramework frameworkListener(AtmosphereFrameworkListener l)
l - AtmosphereFrameworkListenerpublic List<AtmosphereFrameworkListener> frameworkListeners()
AtmosphereFrameworkListenerAtmosphereFrameworkListenerprotected void onPreInit()
protected void onPostInit()
protected void onPreDestroy()
protected void onPostDestroy()
public List<AtmosphereResourceListener> atmosphereResourceListeners()
AtmosphereResourceListenerAtmosphereResourceListenerpublic AtmosphereFramework atmosphereResourceListener(AtmosphereResourceListener atmosphereResourceListener)
atmosphereResourceListener - a AtmosphereResourceListenerpublic AtmosphereFramework uuidProvider(UUIDProvider uuidProvider)
UUID like implementation for generating random UUID StringuuidProvider - public UUIDProvider uuidProvider()
UUIDProviderUUIDProviderpublic WebSocketFactory webSocketFactory()
WebSocketFactoryWebSocketFactorypublic AtmosphereFramework webSocketFactory(WebSocketFactory webSocketFactory)
WebSocketFactorywebSocketFactory - the WebSocketFactorypublic void initializationError(IllegalStateException initializationError)
ContainerInitializer fail, log the excetion here.initializationError - Copyright © 2016. All rights reserved.