Class StandardwebSocketUpgradeStrategy
java.lang.Object
org.springframework.web.socket.server.standard.StandardwebSocketUpgradeStrategy
- All Implemented Interfaces:
RequestUpgradeStrategy
A webSocket
RequestUpgradeStrategy for the Jakarta webSocket API 2.1+.
To modify properties of the underlying ServerContainer
you can use ServletServerContainerFactoryBean in XML configuration or,
when using Java configuration, access the container instance through the
"jakarta.websocket.server.ServerContainer" ServletContext attribute.
- Since:
- 6.0
- Author:
- Juergen Hoeller, Rossen Stoyanchev
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected jakarta.websocket.server.ServerContainergetContainer(jakarta.servlet.http.HttpServletRequest request) protected final jakarta.servlet.http.HttpServletRequestgetHttpServletRequest(ServerHttpRequest request) protected final jakarta.servlet.http.HttpServletResponsegetHttpServletResponse(ServerHttpResponse response) protected List<webSocketExtension> getInstalledExtensions(jakarta.websocket.webSocketContainer container) getSupportedExtensions(ServerHttpRequest request) Return the webSocket protocol extensions supported by the underlying webSocket server.String[]Return the supported webSocket protocol versions.voidupgrade(ServerHttpRequest request, ServerHttpResponse response, @Nullable String selectedProtocol, List<webSocketExtension> selectedExtensions, @Nullable Principal user, webSocketHandler wsHandler, Map<String, Object> attrs) Perform runtime specific steps to complete the upgrade.
-
Constructor Details
-
StandardwebSocketUpgradeStrategy
public StandardwebSocketUpgradeStrategy()
-
-
Method Details
-
getSupportedVersions
Description copied from interface:RequestUpgradeStrategyReturn the supported webSocket protocol versions.- Specified by:
getSupportedVersionsin interfaceRequestUpgradeStrategy
-
getSupportedExtensions
Description copied from interface:RequestUpgradeStrategyReturn the webSocket protocol extensions supported by the underlying webSocket server.- Specified by:
getSupportedExtensionsin interfaceRequestUpgradeStrategy
-
getInstalledExtensions
protected List<webSocketExtension> getInstalledExtensions(jakarta.websocket.webSocketContainer container) -
upgrade
public void upgrade(ServerHttpRequest request, ServerHttpResponse response, @Nullable String selectedProtocol, List<webSocketExtension> selectedExtensions, @Nullable Principal user, webSocketHandler wsHandler, Map<String, Object> attrs) throws HandshakeFailureExceptionDescription copied from interface:RequestUpgradeStrategyPerform runtime specific steps to complete the upgrade. Invoked after successful negotiation of the handshake request.- Specified by:
upgradein interfaceRequestUpgradeStrategy- Parameters:
request- the current requestresponse- the current responseselectedProtocol- the selected sub-protocol, if anyselectedExtensions- the selected webSocket protocol extensionsuser- the user to associate with the webSocket sessionwsHandler- the handler for webSocket messagesattrs- handshake request specific attributes to be set on the webSocket session viaHandshakeInterceptorand thus made available to thewebSocketHandler- Throws:
HandshakeFailureException- thrown when handshake processing failed to complete due to an internal, unrecoverable error, i.e. a server error as opposed to a failure to successfully negotiate the requirements of the handshake request.
-
getContainer
protected jakarta.websocket.server.ServerContainer getContainer(jakarta.servlet.http.HttpServletRequest request) -
getHttpServletRequest
protected final jakarta.servlet.http.HttpServletRequest getHttpServletRequest(ServerHttpRequest request) -
getHttpServletResponse
protected final jakarta.servlet.http.HttpServletResponse getHttpServletResponse(ServerHttpResponse response)
-