Class ServerEndpointRegistration

java.lang.Object
jakarta.websocket.server.ServerEndpointConfig.Configurator
org.springframework.web.socket.server.standard.ServerEndpointRegistration
All Implemented Interfaces:
jakarta.websocket.EndpointConfig, jakarta.websocket.server.ServerEndpointConfig, Aware, BeanFactoryAware

public class ServerEndpointRegistration extends jakarta.websocket.server.ServerEndpointConfig.Configurator implements jakarta.websocket.server.ServerEndpointConfig, BeanFactoryAware
An implementation of ServerEndpointConfig for use in Spring-based applications. A ServerEndpointRegistration bean is detected by ServerEndpointExporter and registered with a Jakarta WebSocket runtime at startup.

Class constructors accept a singleton Endpoint instance or an Endpoint specified by type Class. When specified by type, the endpoint will be instantiated and initialized through the Spring ApplicationContext before each client WebSocket connection.

This class also extends ServerEndpointConfig.Configurator to make it easier to override methods for customizing the handshake process.

Since:
4.0
Author:
Rossen Stoyanchev, Juergen Hoeller
See Also:
  • Constructor Details

    • ServerEndpointRegistration

      public ServerEndpointRegistration(String path, jakarta.websocket.Endpoint endpoint)
      Create a new ServerEndpointRegistration instance from an jakarta.websocket.Endpoint instance.
      Parameters:
      path - the endpoint path
      endpoint - the endpoint instance
    • ServerEndpointRegistration

      public ServerEndpointRegistration(String path, Class<? extends jakarta.websocket.Endpoint> endpointClass)
      Create a new ServerEndpointRegistration instance from an jakarta.websocket.Endpoint class.
      Parameters:
      path - the endpoint path
      endpointClass - the endpoint class
  • Method Details

    • getPath

      public String getPath()
      Specified by:
      getPath in interface jakarta.websocket.server.ServerEndpointConfig
    • getEndpointClass

      public Class<? extends jakarta.websocket.Endpoint> getEndpointClass()
      Specified by:
      getEndpointClass in interface jakarta.websocket.server.ServerEndpointConfig
    • getEndpoint

      public jakarta.websocket.Endpoint getEndpoint()
    • setSubprotocols

      public void setSubprotocols(List<String> subprotocols)
    • getSubprotocols

      public List<String> getSubprotocols()
      Specified by:
      getSubprotocols in interface jakarta.websocket.server.ServerEndpointConfig
    • setExtensions

      public void setExtensions(List<jakarta.websocket.Extension> extensions)
    • getExtensions

      public List<jakarta.websocket.Extension> getExtensions()
      Specified by:
      getExtensions in interface jakarta.websocket.server.ServerEndpointConfig
    • setEncoders

      public void setEncoders(List<Class<? extends jakarta.websocket.Encoder>> encoders)
    • getEncoders

      public List<Class<? extends jakarta.websocket.Encoder>> getEncoders()
      Specified by:
      getEncoders in interface jakarta.websocket.EndpointConfig
    • setDecoders

      public void setDecoders(List<Class<? extends jakarta.websocket.Decoder>> decoders)
    • getDecoders

      public List<Class<? extends jakarta.websocket.Decoder>> getDecoders()
      Specified by:
      getDecoders in interface jakarta.websocket.EndpointConfig
    • setUserProperties

      public void setUserProperties(Map<String,Object> userProperties)
    • getUserProperties

      public Map<String,Object> getUserProperties()
      Specified by:
      getUserProperties in interface jakarta.websocket.EndpointConfig
    • getConfigurator

      public jakarta.websocket.server.ServerEndpointConfig.Configurator getConfigurator()
      Specified by:
      getConfigurator in interface jakarta.websocket.server.ServerEndpointConfig
    • getEndpointInstance

      public final <T> T getEndpointInstance(Class<T> clazz) throws InstantiationException
      Overrides:
      getEndpointInstance in class jakarta.websocket.server.ServerEndpointConfig.Configurator
      Throws:
      InstantiationException
    • modifyHandshake

      public void modifyHandshake(jakarta.websocket.server.ServerEndpointConfig sec, jakarta.websocket.server.HandshakeRequest request, jakarta.websocket.HandshakeResponse response)
      Overrides:
      modifyHandshake in class jakarta.websocket.server.ServerEndpointConfig.Configurator
    • setBeanFactory

      public void setBeanFactory(BeanFactory beanFactory)
      Description copied from interface: BeanFactoryAware
      Callback that supplies the owning factory to a bean instance.

      Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean.afterPropertiesSet() or a custom init-method.

      Specified by:
      setBeanFactory in interface BeanFactoryAware
      Parameters:
      beanFactory - owning BeanFactory (never null). The bean can immediately call methods on the factory.
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object