Class ServerEndpointExporter
- java.lang.Object
- org.springframework.context.support.ApplicationObjectSupport
- org.springframework.web.context.support.WebApplicationObjectSupport
- org.springframework.web.socket.server.standard.ServerEndpointExporter
- All Implemented Interfaces:
Aware,InitializingBean,SmartInitializingSingleton,ApplicationContextAware,ServletContextAware
public class ServerEndpointExporter extends WebApplicationObjectSupport implements InitializingBean, SmartInitializingSingleton
Detects beans of typeServerEndpointConfigand registers with the standard Java WebSocket runtime. Also detects beans annotated withServerEndpointand registers them as well. Although not required, it is likely annotated endpoints should have theirconfiguratorproperty set toSpringConfigurator.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 inweb.xml.- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Juergen Hoeller
- See Also:
ServerEndpointRegistration,SpringConfigurator,ServletServerContainerFactoryBean
Field Summary
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
Constructor Summary
Constructors Constructor Description ServerEndpointExporter()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()Invoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.voidafterSingletonsInstantiated()Invoked right at the end of the singleton pre-instantiation phase, with a guarantee that all regular singleton beans have been created already.protected ServerContainergetServerContainer()Return the JSR-356ServerContainerto use for endpoint registration.protected voidinitServletContext(ServletContext servletContext)Subclasses may override this for custom initialization based on the ServletContext that this application object runs in.protected booleanisContextRequired()Overrides the base class behavior to enforce running in an ApplicationContext.protected voidregisterEndpoints()Actually register the endpoints.voidsetAnnotatedEndpointClasses(Class<?>... annotatedEndpointClasses)Explicitly list annotated endpoint types that should be registered on startup.voidsetServerContainer(ServerContainer serverContainer)Set the JSR-356ServerContainerto use for endpoint registration.Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, setServletContext
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
Constructor Detail
ServerEndpointExporter
public ServerEndpointExporter()
Method Detail
setAnnotatedEndpointClasses
public void setAnnotatedEndpointClasses(Class<?>... annotatedEndpointClasses)
Explicitly list annotated endpoint types that should be registered on startup. This can be done if you wish to turn off a Servlet container's scan for endpoints, which goes through all 3rd party jars in the, and rely on Spring configuration instead.- Parameters:
annotatedEndpointClasses-ServerEndpoint-annotated types
setServerContainer
public void setServerContainer(ServerContainer serverContainer)
Set the JSR-356ServerContainerto use for endpoint registration. If not set, the container is going to be retrieved via theServletContext.
getServerContainer
protected ServerContainer getServerContainer()
Return the JSR-356ServerContainerto use for endpoint registration.
initServletContext
protected void initServletContext(ServletContext servletContext)
Description copied from class:WebApplicationObjectSupportSubclasses may override this for custom initialization based on the ServletContext that this application object runs in.The default implementation is empty. Called by
WebApplicationObjectSupport.initApplicationContext(org.springframework.context.ApplicationContext)as well asWebApplicationObjectSupport.setServletContext(javax.servlet.ServletContext).- Overrides:
initServletContextin classWebApplicationObjectSupport- Parameters:
servletContext- the ServletContext that this application object runs in (nevernull)
isContextRequired
protected boolean isContextRequired()
Description copied from class:WebApplicationObjectSupportOverrides the base class behavior to enforce running in an ApplicationContext. All accessors will throw IllegalStateException if not running in a context.- Overrides:
isContextRequiredin classWebApplicationObjectSupport- See Also:
ApplicationObjectSupport.getApplicationContext(),ApplicationObjectSupport.getMessageSourceAccessor(),WebApplicationObjectSupport.getWebApplicationContext(),WebApplicationObjectSupport.getServletContext(),WebApplicationObjectSupport.getTempDir()
afterPropertiesSet
public void afterPropertiesSet()
Description copied from interface:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- Specified by:
afterPropertiesSetin interfaceInitializingBean
afterSingletonsInstantiated
public void afterSingletonsInstantiated()
Description copied from interface:SmartInitializingSingletonInvoked right at the end of the singleton pre-instantiation phase, with a guarantee that all regular singleton beans have been created already.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
BeanFactorybootstrap, and not for any other bean scope either. Carefully use it for beans with the intended bootstrap semantics only.- Specified by:
afterSingletonsInstantiatedin interfaceSmartInitializingSingleton
registerEndpoints
protected void registerEndpoints()
Actually register the endpoints. Called byafterSingletonsInstantiated().