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
,
ServletServerContainerFactoryBean
logger
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 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, setServletContext
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
public 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)
WebApplicationObjectSupport
The default implementation is empty. Called by
WebApplicationObjectSupport.initApplicationContext(org.springframework.context.ApplicationContext)
as well as WebApplicationObjectSupport.setServletContext(javax.servlet.ServletContext)
.
initServletContext
in class WebApplicationObjectSupport
servletContext
- the ServletContext that this application object runs in
(never null
)protected boolean isContextRequired()
WebApplicationObjectSupport
isContextRequired
in class WebApplicationObjectSupport
ApplicationObjectSupport.getApplicationContext()
,
ApplicationObjectSupport.getMessageSourceAccessor()
,
WebApplicationObjectSupport.getWebApplicationContext()
,
WebApplicationObjectSupport.getServletContext()
,
WebApplicationObjectSupport.getTempDir()
public void afterPropertiesSet()
InitializingBean
BeanFactory
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 InitializingBean
public void afterSingletonsInstantiated()
SmartInitializingSingleton
ListableBeanFactory.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 SmartInitializingSingleton
protected void registerEndpoints()
afterSingletonsInstantiated()
.