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
ConstructorsConstructorDescriptionWebSocketHttpRequestHandler(WebSocketHandler wsHandler) WebSocketHttpRequestHandler(WebSocketHandler wsHandler, HandshakeHandler handshakeHandler) -
Method Summary
Modifier and TypeMethodDescriptionprotected WebSocketHandlerdecorate(WebSocketHandler handler) Decorate theWebSocketHandlerpassed into the constructor.Return the HandshakeHandler.Return the configured WebSocket handshake request interceptors.Return the WebSocketHandler.voidhandleRequest(HttpServletRequest servletRequest, HttpServletResponse servletResponse) booleanvoidsetHandshakeInterceptors(List<HandshakeInterceptor> interceptors) Configure one or more WebSocket handshake request interceptors.voidsetServletContext(ServletContext servletContext) voidstart()voidstop()
-
Constructor Details
-
WebSocketHttpRequestHandler
-
WebSocketHttpRequestHandler
-
-
Method Details
-
decorate
Decorate theWebSocketHandlerpassed into the constructor.By default,
LoggingWebSocketHandlerDecoratorandExceptionWebSocketHandlerDecoratorare added.- Since:
- 5.2.2
-
getWebSocketHandler
Return the WebSocketHandler. -
getHandshakeHandler
Return the HandshakeHandler. -
setHandshakeInterceptors
Configure one or more WebSocket handshake request interceptors. -
getHandshakeInterceptors
Return the configured WebSocket handshake request interceptors. -
setServletContext
- Specified by:
setServletContextin interfaceorg.springframework.web.context.ServletContextAware
-
start
public void start()- Specified by:
startin interfaceorg.springframework.context.Lifecycle
-
stop
public void stop()- Specified by:
stopin interfaceorg.springframework.context.Lifecycle
-
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceorg.springframework.context.Lifecycle
-
handleRequest
public void handleRequest(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException - Specified by:
handleRequestin interfaceorg.springframework.web.HttpRequestHandler- Throws:
ServletExceptionIOException
-