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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
protected ServerContainer
Return the JSR-356ServerContainer
to use for endpoint registration.protected void
initServletContext
(ServletContext servletContext) protected boolean
protected void
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-356ServerContainer
to 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, 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-356ServerContainer
to use for endpoint registration. If not set, the container is going to be retrieved via theServletContext
. -
getServerContainer
Return the JSR-356ServerContainer
to use for endpoint registration. -
initServletContext
- Overrides:
initServletContext
in classorg.springframework.web.context.support.WebApplicationObjectSupport
-
isContextRequired
protected boolean isContextRequired()- Overrides:
isContextRequired
in classorg.springframework.web.context.support.WebApplicationObjectSupport
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
afterSingletonsInstantiated
public void afterSingletonsInstantiated()- Specified by:
afterSingletonsInstantiated
in interfaceorg.springframework.beans.factory.SmartInitializingSingleton
-
registerEndpoints
protected void registerEndpoints()Actually register the endpoints. Called byafterSingletonsInstantiated()
.
-