Class StandardWebSocketUpgradeStrategy

java.lang.Object
org.springframework.web.socket.server.standard.StandardWebSocketUpgradeStrategy
All Implemented Interfaces:
RequestUpgradeStrategy

public class StandardWebSocketUpgradeStrategy extends Object implements RequestUpgradeStrategy
A WebSocket RequestUpgradeStrategy for the Jakarta WebSocket API 2.1+.

To modify properties of the underlying ServerContainer you can use ServletServerContainerFactoryBean in XML configuration or, when using Java configuration, access the container instance through the "jakarta.websocket.server.ServerContainer" ServletContext attribute.

Since:
6.0
Author:
Juergen Hoeller, Rossen Stoyanchev
See Also:
  • ServerContainer.upgradeHttpToWebSocket(Object, Object, ServerEndpointConfig, Map)
  • Constructor Details

    • StandardWebSocketUpgradeStrategy

      public StandardWebSocketUpgradeStrategy()
  • Method Details

    • getSupportedVersions

      public String[] getSupportedVersions()
      Description copied from interface: RequestUpgradeStrategy
      Return the supported WebSocket protocol versions.
      Specified by:
      getSupportedVersions in interface RequestUpgradeStrategy
    • getSupportedExtensions

      public List<WebSocketExtension> getSupportedExtensions(org.springframework.http.server.ServerHttpRequest request)
      Description copied from interface: RequestUpgradeStrategy
      Return the WebSocket protocol extensions supported by the underlying WebSocket server.
      Specified by:
      getSupportedExtensions in interface RequestUpgradeStrategy
    • getInstalledExtensions

      protected List<WebSocketExtension> getInstalledExtensions(jakarta.websocket.WebSocketContainer container)
    • upgrade

      public void upgrade(org.springframework.http.server.ServerHttpRequest request, org.springframework.http.server.ServerHttpResponse response, @Nullable String selectedProtocol, List<WebSocketExtension> selectedExtensions, @Nullable Principal user, WebSocketHandler wsHandler, Map<String,Object> attrs) throws HandshakeFailureException
      Description copied from interface: RequestUpgradeStrategy
      Perform runtime specific steps to complete the upgrade. Invoked after successful negotiation of the handshake request.
      Specified by:
      upgrade in interface RequestUpgradeStrategy
      Parameters:
      request - the current request
      response - the current response
      selectedProtocol - the selected sub-protocol, if any
      selectedExtensions - the selected WebSocket protocol extensions
      user - the user to associate with the WebSocket session
      wsHandler - the handler for WebSocket messages
      attrs - handshake request specific attributes to be set on the WebSocket session via HandshakeInterceptor and thus made available to the WebSocketHandler
      Throws:
      HandshakeFailureException - thrown when handshake processing failed to complete due to an internal, unrecoverable error, i.e. a server error as opposed to a failure to successfully negotiate the requirements of the handshake request.
    • getContainer

      protected jakarta.websocket.server.ServerContainer getContainer(jakarta.servlet.http.HttpServletRequest request)
    • getHttpServletRequest

      protected final jakarta.servlet.http.HttpServletRequest getHttpServletRequest(org.springframework.http.server.ServerHttpRequest request)
    • getHttpServletResponse

      protected final jakarta.servlet.http.HttpServletResponse getHttpServletResponse(org.springframework.http.server.ServerHttpResponse response)