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 the containing
BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware, ApplicationContextAware etc. |
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 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(Class<?>... annotatedEndpointClasses)
Explicitly list annotated endpoint types that should be registered on startup.
|
void |
setServerContainer(ServerContainer serverContainer)
Set the JSR-356
ServerContainer to use for endpoint registration. |
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, setServletContextgetApplicationContext, getMessageSourceAccessor, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContextpublic void setAnnotatedEndpointClasses(Class<?>... annotatedEndpointClasses)
annotatedEndpointClasses - ServerEndpoint-annotated typespublic void setServerContainer(@Nullable ServerContainer serverContainer)
ServerContainer to use for endpoint registration.
If not set, the container is going to be retrieved via the ServletContext.@Nullable protected 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()
InitializingBeanBeanFactory after it has set all bean properties
and satisfied BeanFactoryAware, ApplicationContextAware etc.
This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
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().