public class JSR356WebsocketInitializer extends Object
Websocket specification says that initialization of websocket end points should be done in the servlet context initialization phase. Some servers implement this strictly so that end points cannot be registered after the context initialization phase.
Note that WebListener
is Servlet 3.0 API so this will not be run for
older servers (unless added to web.xml), but these servers do not support JSR
356 websockets either.
Modifier and Type | Class and Description |
---|---|
static class |
JSR356WebsocketInitializer.FakeServletConfig
"ServletConfig" which only provides information from a
ServletRegistration and its ServletContext . |
Constructor and Description |
---|
JSR356WebsocketInitializer() |
Modifier and Type | Method and Description |
---|---|
void |
contextDestroyed(ServletContextEvent sce) |
void |
contextInitialized(ServletContextEvent sce) |
static String |
getAttributeName(String servletName)
Returns the name of the attribute in the servlet context where the
pre-initialized Atmosphere object is stored.
|
void |
init(ServletContext servletContext)
Initializes Atmosphere for use with Vaadin servlets found in the given
context.
|
static void |
initAtmosphereForVaadinServlet(ServletRegistration servletRegistration,
ServletContext servletContext)
Initializes Atmosphere for use with the given Vaadin servlet
|
static boolean |
isAtmosphereAvailable()
Checks if Atmosphere is available on the classpath.
|
protected boolean |
isVaadinServlet(ServletRegistration servletRegistration,
ServletContext servletContext)
Tries to determine if the given servlet registration refers to a Vaadin
servlet.
|
public void contextInitialized(ServletContextEvent sce)
public void init(ServletContext servletContext)
For JSR 356 websockets to work properly, the initialization must be done in the servlet context initialization phase.
servletContext
- The servlet contextpublic static void initAtmosphereForVaadinServlet(ServletRegistration servletRegistration, ServletContext servletContext)
For JSR 356 websockets to work properly, the initialization must be done in the servlet context initialization phase.
servletRegistration
- The servlet registration info for the servletservletContext
- The servlet contextpublic static String getAttributeName(String servletName)
servletName
- The name of the servletprotected boolean isVaadinServlet(ServletRegistration servletRegistration, ServletContext servletContext)
servletRegistration
- The servlet registration info for the servletservletContext
- the context of the servletpublic void contextDestroyed(ServletContextEvent sce)
public static boolean isAtmosphereAvailable()
true
if Atmosphere is available, false
otherwiseCopyright © 2018. All rights reserved.