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:
  • Constructor Details

    • ServerEndpointExporter

      public ServerEndpointExporter()
  • Method Details

    • 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 classpath, and rely on Spring configuration instead.
      Parameters:
      annotatedEndpointClasses - ServerEndpoint-annotated types
    • setServerContainer

      public void setServerContainer(@Nullable ServerContainer serverContainer)
      Set the JSR-356 ServerContainer to use for endpoint registration. If not set, the container is going to be retrieved via the ServletContext.
    • getServerContainer

      @Nullable protected ServerContainer getServerContainer()
      Return the JSR-356 ServerContainer to use for endpoint registration.
    • initServletContext

      protected void initServletContext(ServletContext servletContext)
      Overrides:
      initServletContext in class org.springframework.web.context.support.WebApplicationObjectSupport
    • isContextRequired

      protected boolean isContextRequired()
      Overrides:
      isContextRequired in class org.springframework.web.context.support.WebApplicationObjectSupport
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • afterSingletonsInstantiated

      public void afterSingletonsInstantiated()
      Specified by:
      afterSingletonsInstantiated in interface org.springframework.beans.factory.SmartInitializingSingleton
    • registerEndpoints

      protected void registerEndpoints()
      Actually register the endpoints. Called by afterSingletonsInstantiated().