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
ConstructorDescriptionWebSocketHttpRequestHandler
(WebSocketHandler wsHandler) WebSocketHttpRequestHandler
(WebSocketHandler wsHandler, HandshakeHandler handshakeHandler) -
Method Summary
Modifier and TypeMethodDescriptionprotected WebSocketHandler
decorate
(WebSocketHandler handler) Decorate theWebSocketHandler
passed into the constructor.Return the HandshakeHandler.Return the configured WebSocket handshake request interceptors.Return the WebSocketHandler.void
handleRequest
(HttpServletRequest servletRequest, HttpServletResponse servletResponse) boolean
void
setHandshakeInterceptors
(List<HandshakeInterceptor> interceptors) Configure one or more WebSocket handshake request interceptors.void
setServletContext
(ServletContext servletContext) void
start()
void
stop()
-
Constructor Details
-
WebSocketHttpRequestHandler
-
WebSocketHttpRequestHandler
-
-
Method Details
-
decorate
Decorate theWebSocketHandler
passed into the constructor.By default,
LoggingWebSocketHandlerDecorator
andExceptionWebSocketHandlerDecorator
are 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:
setServletContext
in interfaceorg.springframework.web.context.ServletContextAware
-
start
public void start()- Specified by:
start
in interfaceorg.springframework.context.Lifecycle
-
stop
public void stop()- Specified by:
stop
in interfaceorg.springframework.context.Lifecycle
-
isRunning
public boolean isRunning()- Specified by:
isRunning
in interfaceorg.springframework.context.Lifecycle
-
handleRequest
public void handleRequest(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException - Specified by:
handleRequest
in interfaceorg.springframework.web.HttpRequestHandler
- Throws:
ServletException
IOException
-