Class ServerEndpointExporter
- All Implemented Interfaces:
Aware,InitializingBean,SmartInitializingSingleton,ApplicationContextAware,ServletContextAware
ServerEndpointConfig and registers
with the standard Jakarta 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.
- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.voidInvoked right at the end of the singleton pre-instantiation phase, with a guarantee that all regular singleton beans have been created already.protected ServerContainerReturn 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 booleanOverrides the base class behavior to enforce running in an ApplicationContext.protected voidActually 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, setServletContextMethods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContext
-
Constructor Details
-
ServerEndpointExporter
public ServerEndpointExporter()
-
-
Method Details
-
setAnnotatedEndpointClasses
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 classpath, and rely on Spring configuration instead.- Parameters:
annotatedEndpointClasses-ServerEndpoint-annotated types
-
setServerContainer
Set the JSR-356ServerContainerto use for endpoint registration. If not set, the container is going to be retrieved via theServletContext. -
getServerContainer
Return the JSR-356ServerContainerto use for endpoint registration. -
initServletContext
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(jakarta.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:
-
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().
-