org.springframework.web.socket.server.standard

## Class AbstractStandardUpgradeStrategy

- java.lang.Object
- - org.springframework.web.socket.server.standard.AbstractStandardUpgradeStrategy

- All Implemented Interfaces:
    RequestUpgradeStrategy
  Direct Known Subclasses:
    GlassFishRequestUpgradeStrategy, TomcatRequestUpgradeStrategy, UndertowRequestUpgradeStrategy

      public abstract class AbstractStandardUpgradeStrategy
      extends Object
      implements RequestUpgradeStrategy

  A base class for `RequestUpgradeStrategy` implementations that build on the standard WebSocket API for Java (JSR-356).
  Since:
    4.0
  Author:
    Rossen Stoyanchev

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Log` | `logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractStandardUpgradeStrategy()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected javax.websocket.server.ServerContainer` | `getContainer(HttpServletRequest request)`
    `protected HttpServletRequest` | `getHttpServletRequest(ServerHttpRequest request)`
    `protected HttpServletResponse` | `getHttpServletResponse(ServerHttpResponse response)`
    `protected List<WebSocketExtension>` | `getInstalledExtensions(javax.websocket.WebSocketContainer container)`
    `List<WebSocketExtension>` | `getSupportedExtensions(ServerHttpRequest request)`
    `void` | `upgrade(ServerHttpRequest request, ServerHttpResponse response, String selectedProtocol, List<WebSocketExtension> selectedExtensions, Principal user, WebSocketHandler wsHandler, Map<String,Object> attrs)` Perform runtime specific steps to complete the upgrade.
    `protected abstract void` | `upgradeInternal(ServerHttpRequest request, ServerHttpResponse response, String selectedProtocol, List<javax.websocket.Extension> selectedExtensions, javax.websocket.Endpoint endpoint)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.springframework.web.socket.server.RequestUpgradeStrategy

      `getSupportedVersions`

- - ### Field Detail

    - #### logger

          protected final Log logger

  - ### Constructor Detail

    - #### AbstractStandardUpgradeStrategy

          public AbstractStandardUpgradeStrategy()

  - ### Method Detail

    - #### getContainer

          protected javax.websocket.server.ServerContainer getContainer(HttpServletRequest request)

    - #### getHttpServletRequest

          protected final HttpServletRequest getHttpServletRequest(ServerHttpRequest request)

    - #### getHttpServletResponse

          protected final HttpServletResponse getHttpServletResponse(ServerHttpResponse response)

    - #### getSupportedExtensions

          public List<WebSocketExtension> getSupportedExtensions(ServerHttpRequest request)

      Specified by:
        `getSupportedExtensions` in interface `RequestUpgradeStrategy`
      Returns:
        the WebSocket protocol extensions supported by the underlying WebSocket server.

    - #### getInstalledExtensions

          protected List<WebSocketExtension> getInstalledExtensions(javax.websocket.WebSocketContainer container)

    - #### upgrade

          public void upgrade(ServerHttpRequest request,
                              ServerHttpResponse response,
                              String selectedProtocol,
                              List<WebSocketExtension> selectedExtensions,
                              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.

    - #### upgradeInternal

          protected abstract void upgradeInternal(ServerHttpRequest request,
                                                  ServerHttpResponse response,
                                                  String selectedProtocol,
                                                  List<javax.websocket.Extension> selectedExtensions,
                                                  javax.websocket.Endpoint endpoint)
                                           throws HandshakeFailureException

      Throws:
        `HandshakeFailureException`