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 Details

  • Method Details

    • 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