Class SockJsHttpRequestHandler
java.lang.Object
org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler
- All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.Lifecycle, org.springframework.web.context.ServletContextAware, org.springframework.web.cors.CorsConfigurationSource, org.springframework.web.HttpRequestHandler
public class SockJsHttpRequestHandler
extends Object
implements org.springframework.web.HttpRequestHandler, org.springframework.web.cors.CorsConfigurationSource, org.springframework.context.Lifecycle, org.springframework.web.context.ServletContextAware
An
HttpRequestHandler that allows mapping a SockJsService to requests
in a Servlet container.- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Sebastien Deleuze
-
Constructor Summary
ConstructorsConstructorDescriptionSockJsHttpRequestHandler(SockJsService sockJsService, WebSocketHandler webSocketHandler) Create a new SockJsHttpRequestHandler. -
Method Summary
Modifier and TypeMethodDescription@Nullable org.springframework.web.cors.CorsConfigurationgetCorsConfiguration(jakarta.servlet.http.HttpServletRequest request) Return theSockJsService.Return theWebSocketHandler.voidhandleRequest(jakarta.servlet.http.HttpServletRequest servletRequest, jakarta.servlet.http.HttpServletResponse servletResponse) booleanvoidsetServletContext(jakarta.servlet.ServletContext servletContext) voidstart()voidstop()
-
Constructor Details
-
SockJsHttpRequestHandler
Create a new SockJsHttpRequestHandler.- Parameters:
sockJsService- the SockJS servicewebSocketHandler- the websocket handler
-
-
Method Details
-
getSockJsService
Return theSockJsService. -
getWebSocketHandler
Return theWebSocketHandler. -
setServletContext
public void setServletContext(jakarta.servlet.ServletContext servletContext) - 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(jakarta.servlet.http.HttpServletRequest servletRequest, jakarta.servlet.http.HttpServletResponse servletResponse) throws jakarta.servlet.ServletException, IOException - Specified by:
handleRequestin interfaceorg.springframework.web.HttpRequestHandler- Throws:
jakarta.servlet.ServletExceptionIOException
-
getCorsConfiguration
public @Nullable org.springframework.web.cors.CorsConfiguration getCorsConfiguration(jakarta.servlet.http.HttpServletRequest request) - Specified by:
getCorsConfigurationin interfaceorg.springframework.web.cors.CorsConfigurationSource
-