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 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 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, setServletContext
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
public void setAnnotatedEndpointClasses(Class<?>... annotatedEndpointClasses)
annotatedEndpointClasses
- ServerEndpoint
-annotated typespublic void setServerContainer(ServerContainer serverContainer)
ServerContainer
to use for endpoint registration.
If not set, the container is going to be retrieved via the ServletContext
.protected 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
This 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 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()
.