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:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.InitializingBean,org.springframework.beans.factory.SmartInitializingSingleton,org.springframework.context.ApplicationContextAware,org.springframework.web.context.ServletContextAware
public class ServerEndpointExporter
extends org.springframework.web.context.support.WebApplicationObjectSupport
implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.SmartInitializingSingleton
Detects beans of type
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 TypeMethodDescriptionvoidvoidprotected ServerContainerReturn the JSR-356ServerContainerto use for endpoint registration.protected voidinitServletContext(ServletContext servletContext) protected booleanprotected 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
- Overrides:
initServletContextin classorg.springframework.web.context.support.WebApplicationObjectSupport
-
isContextRequired
protected boolean isContextRequired()- Overrides:
isContextRequiredin classorg.springframework.web.context.support.WebApplicationObjectSupport
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
afterSingletonsInstantiated
public void afterSingletonsInstantiated()- Specified by:
afterSingletonsInstantiatedin interfaceorg.springframework.beans.factory.SmartInitializingSingleton
-
registerEndpoints
protected void registerEndpoints()Actually register the endpoints. Called byafterSingletonsInstantiated().
-