public class ServerEndpointExporter extends WebApplicationObjectSupport implements InitializingBean, SmartInitializingSingleton
ServerEndpointConfig and registers
with the standard Java WebSocket runtime. Also detects beans annotated with
ServerEndpoint and registers them as well. Although not required, it is likely
annotated endpoints should have their configurator property set to
SpringConfigurator.
When this class is used, by declaring it in Spring configuration, it should be
possible to turn off a Servlet container's scan for WebSocket endpoints. This can be
done with the help of the <absolute-ordering> element in web.xml.
ServerEndpointRegistration,
SpringConfigurator,
ServletServerContainerFactoryBeanlogger| Constructor and Description |
|---|
ServerEndpointExporter() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
|
void |
afterSingletonsInstantiated()
Invoked right at the end of the singleton pre-instantiation phase,
with a guarantee that all regular singleton beans have been created
already.
|
protected javax.websocket.server.ServerContainer |
getServerContainer()
Return the JSR-356
ServerContainer to use for endpoint registration. |
protected void |
initServletContext(ServletContext servletContext)
Subclasses may override this for custom initialization based
on the ServletContext that this application object runs in.
|
protected boolean |
isContextRequired()
Overrides the base class behavior to enforce running in an ApplicationContext.
|
protected void |
registerEndpoints()
Actually register the endpoints.
|
void |
setAnnotatedEndpointClasses(java.lang.Class<?>... annotatedEndpointClasses)
Explicitly list annotated endpoint types that should be registered on startup.
|
void |
setServerContainer(javax.websocket.server.ServerContainer serverContainer)
Set the JSR-356
ServerContainer to use for endpoint registration. |
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, setServletContextgetApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContextpublic void setAnnotatedEndpointClasses(java.lang.Class<?>... annotatedEndpointClasses)
annotatedEndpointClasses - ServerEndpoint-annotated typespublic void setServerContainer(javax.websocket.server.ServerContainer serverContainer)
ServerContainer to use for endpoint registration.
If not set, the container is going to be retrieved via the ServletContext.protected javax.websocket.server.ServerContainer getServerContainer()
ServerContainer to use for endpoint registration.protected void initServletContext(ServletContext servletContext)
WebApplicationObjectSupportThe default implementation is empty. Called by
WebApplicationObjectSupport.initApplicationContext(org.springframework.context.ApplicationContext)
as well as WebApplicationObjectSupport.setServletContext(javax.servlet.ServletContext).
initServletContext in class WebApplicationObjectSupportservletContext - the ServletContext that this application object runs in
(never null)protected boolean isContextRequired()
WebApplicationObjectSupportisContextRequired in class WebApplicationObjectSupportApplicationObjectSupport.getApplicationContext(),
ApplicationObjectSupport.getMessageSourceAccessor(),
WebApplicationObjectSupport.getWebApplicationContext(),
WebApplicationObjectSupport.getServletContext(),
WebApplicationObjectSupport.getTempDir()public void afterPropertiesSet()
InitializingBeanThis method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
afterPropertiesSet in interface InitializingBeanpublic void afterSingletonsInstantiated()
SmartInitializingSingletonListableBeanFactory.getBeansOfType(java.lang.Class<T>) calls within
this method won't trigger accidental side effects during bootstrap.
NOTE: This callback won't be triggered for singleton beans
lazily initialized on demand after BeanFactory bootstrap,
and not for any other bean scope either. Carefully use it for beans
with the intended bootstrap semantics only.
afterSingletonsInstantiated in interface SmartInitializingSingletonprotected void registerEndpoints()
afterSingletonsInstantiated().