org.springframework.web.socket.server.support

## Class WebSocketHttpRequestHandler

- java.lang.Object
- - org.springframework.web.socket.server.support.WebSocketHttpRequestHandler

All Implemented Interfaces:
  org.springframework.beans.factory.Aware, org.springframework.context.Lifecycle, org.springframework.web.context.ServletContextAware, org.springframework.web.HttpRequestHandler

    public class WebSocketHttpRequestHandler
    extends Object
    implements org.springframework.web.HttpRequestHandler, org.springframework.context.Lifecycle, org.springframework.web.context.ServletContextAware

A `HttpRequestHandler` for processing WebSocket handshake requests.

This is the main class to use when configuring a server WebSocket at a specific URL. It is a very thin wrapper around a `WebSocketHandler` and a `HandshakeHandler`, also adapting the `HttpServletRequest` and `HttpServletResponse` to `ServerHttpRequest` and `ServerHttpResponse`, respectively.

Since:
  4.0
Author:
  Rossen Stoyanchev

### Constructor Summary

Constructors
Constructor and Description
`WebSocketHttpRequestHandler(WebSocketHandler wsHandler)`
`WebSocketHttpRequestHandler(WebSocketHandler wsHandler, HandshakeHandler handshakeHandler)`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected WebSocketHandler` `decorate(WebSocketHandler handler)` Decorate the `WebSocketHandler` passed into the constructor.
`HandshakeHandler` `getHandshakeHandler()` Return the HandshakeHandler.
`List<HandshakeInterceptor>` `getHandshakeInterceptors()` Return the configured WebSocket handshake request interceptors.
`WebSocketHandler` `getWebSocketHandler()` Return the WebSocketHandler.
`void` `handleRequest(HttpServletRequest servletRequest, HttpServletResponse servletResponse)`
`boolean` `isRunning()`
`void` `setHandshakeInterceptors(List<HandshakeInterceptor> interceptors)` Configure one or more WebSocket handshake request interceptors.
`void` `setServletContext(ServletContext servletContext)`
`void` `start()`
`void` `stop()`

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

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

### Constructor Detail

#### WebSocketHttpRequestHandler

    public WebSocketHttpRequestHandler(WebSocketHandler wsHandler)

#### WebSocketHttpRequestHandler

    public WebSocketHttpRequestHandler(WebSocketHandler wsHandler,
                                       HandshakeHandler handshakeHandler)

### Method Detail

#### decorate

    protected WebSocketHandler decorate(WebSocketHandler handler)

Decorate the `WebSocketHandler` passed into the constructor.

By default, `LoggingWebSocketHandlerDecorator` and `ExceptionWebSocketHandlerDecorator` are added.

Since:
  5.2.2

#### getWebSocketHandler

    public WebSocketHandler getWebSocketHandler()

Return the WebSocketHandler.

#### getHandshakeHandler

    public HandshakeHandler getHandshakeHandler()

Return the HandshakeHandler.

#### setHandshakeInterceptors

    public void setHandshakeInterceptors(@Nullable
                                         List<HandshakeInterceptor> interceptors)

Configure one or more WebSocket handshake request interceptors.

#### getHandshakeInterceptors

    public List<HandshakeInterceptor> getHandshakeInterceptors()

Return the configured WebSocket handshake request interceptors.

#### setServletContext

    public void setServletContext(ServletContext servletContext)

Specified by:
  `setServletContext` in interface `org.springframework.web.context.ServletContextAware`

#### start

    public void start()

Specified by:
  `start` in interface `org.springframework.context.Lifecycle`

#### stop

    public void stop()

Specified by:
  `stop` in interface `org.springframework.context.Lifecycle`

#### isRunning

    public boolean isRunning()

Specified by:
  `isRunning` in interface `org.springframework.context.Lifecycle`

#### handleRequest

    public void handleRequest(HttpServletRequest servletRequest,
                              HttpServletResponse servletResponse)
                       throws ServletException,
                              IOException

Specified by:
  `handleRequest` in interface `org.springframework.web.HttpRequestHandler`
Throws:
  `ServletException`
  `IOException`