@WebListener public class JSR356WebsocketInitializer extends Object implements javax.servlet.ServletContextListener
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(javax.servlet.ServletContextEvent sce) |
void |
contextInitialized(javax.servlet.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
|
static void |
initAtmosphereForVaadinServlet(javax.servlet.ServletRegistration servletRegistration,
javax.servlet.ServletContext servletContext)
Initializes Atmosphere for use with the given Vaadin servlet
|
protected boolean |
isVaadinServlet(javax.servlet.ServletRegistration servletRegistration,
javax.servlet.ServletContext servletContext)
Tries to determine if the given servlet registration refers to a Vaadin
servlet.
|
public void contextInitialized(javax.servlet.ServletContextEvent sce)
contextInitialized
in interface javax.servlet.ServletContextListener
public static void initAtmosphereForVaadinServlet(javax.servlet.ServletRegistration servletRegistration, javax.servlet.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
- public static String getAttributeName(String servletName)
servletName
- The name of the servletprotected boolean isVaadinServlet(javax.servlet.ServletRegistration servletRegistration, javax.servlet.ServletContext servletContext)
servletRegistration
- The servlet registration info for the servletpublic void contextDestroyed(javax.servlet.ServletContextEvent sce)
contextDestroyed
in interface javax.servlet.ServletContextListener
Copyright © 2021 Vaadin Ltd. All rights reserved.