Top Description Fields Constructors Methods
org.springframework.web.socket.server.jetty

public Class JettyRequestUpgradeStrategy

extends Object
implements RequestUpgradeStrategy, ServletContextAware
Class Inheritance
All Implemented Interfaces
org.springframework.web.context.ServletContextAware, org.springframework.beans.factory.Aware, org.springframework.web.socket.server.RequestUpgradeStrategy
Imports
java.lang.reflect.UndeclaredThrowableException, java.security.Principal, java.util.Collections, .List, .Map, java.util.function.Consumer, jakarta.servlet.ServletContext, jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, org.eclipse.jetty.ee10.websocket.server.JettyWebSocketCreator, .JettyWebSocketServerContainer, org.eclipse.jetty.websocket.api.Configurable, org.springframework.http.server.ServerHttpRequest, .ServerHttpResponse, .ServletServerHttpRequest, .ServletServerHttpResponse, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.web.context.ServletContextAware, org.springframework.web.socket.WebSocketExtension, .WebSocketHandler, org.springframework.web.socket.adapter.jetty.JettyWebSocketHandlerAdapter, .JettyWebSocketSession, org.springframework.web.socket.server.HandshakeFailureException, .RequestUpgradeStrategy

A RequestUpgradeStrategy for Jetty 11.
Author
Rossen Stoyanchev
Since
5.3.4

Field Summary

Modifier and TypeField and Description
private static final String[]
private Consumer<Configurable>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addWebSocketConfigurer(Consumer<Configurable> webSocketConfigurer)

Add a callback to configure WebSocket server parameters on JettyWebSocketServerContainer.

public List<WebSocketExtension>
getSupportedExtensions(ServerHttpRequest request)

Implements org.springframework.web.socket.server.RequestUpgradeStrategy.getSupportedExtensions.

Return the WebSocket protocol extensions supported by the underlying WebSocket server.

public String[]
public void
setServletContext(ServletContext
the ServletContext object to be used by this object
servletContext
)

Implements org.springframework.web.context.ServletContextAware.setServletContext.

Set the ServletContext that this object runs in.

Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method.

public void
upgrade(ServerHttpRequest
the current request
request
,
ServerHttpResponse
the current response
response
,
String
the selected sub-protocol, if any
selectedProtocol
,
List<WebSocketExtension>
the selected WebSocket protocol extensions
selectedExtensions
,
Principal
the user to associate with the WebSocket session
user
,
WebSocketHandler
the handler for WebSocket messages
handler
,
Map<String, Object>
handshake request specific attributes to be set on the WebSocket session via org.springframework.web.socket.server.HandshakeInterceptor and thus made available to the org.springframework.web.socket.WebSocketHandler
attributes
)

Implements org.springframework.web.socket.server.RequestUpgradeStrategy.upgrade.

Perform runtime specific steps to complete the upgrade.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

SUPPORTED_VERSIONSback to summary
private static final String[] SUPPORTED_VERSIONS
webSocketConfigurerback to summary
private Consumer<Configurable> webSocketConfigurer
Annotations
@Nullable

Constructor Detail

JettyRequestUpgradeStrategyback to summary
public JettyRequestUpgradeStrategy()

Method Detail

addWebSocketConfigurerback to summary
public void addWebSocketConfigurer(Consumer<Configurable> webSocketConfigurer)

Add a callback to configure WebSocket server parameters on JettyWebSocketServerContainer.

Since
6.1
getSupportedExtensionsback to summary
public List<WebSocketExtension> getSupportedExtensions(ServerHttpRequest request)

Implements org.springframework.web.socket.server.RequestUpgradeStrategy.getSupportedExtensions.

Doc from org.springframework.web.socket.server.RequestUpgradeStrategy.getSupportedExtensions.

Return the WebSocket protocol extensions supported by the underlying WebSocket server.

Annotations
@Override
getSupportedVersionsback to summary
public String[] getSupportedVersions()

Implements org.springframework.web.socket.server.RequestUpgradeStrategy.getSupportedVersions.

Doc from org.springframework.web.socket.server.RequestUpgradeStrategy.getSupportedVersions.

Return the supported WebSocket protocol versions.

Annotations
@Override
setServletContextback to summary
public void setServletContext(ServletContext servletContext)

Implements org.springframework.web.context.ServletContextAware.setServletContext.

Doc from org.springframework.web.context.ServletContextAware.setServletContext.

Set the ServletContext that this object runs in.

Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked after ApplicationContextAware's setApplicationContext.

Parameters
servletContext:ServletContext

the ServletContext object to be used by this object

Annotations
@Override
upgradeback to summary
public void upgrade(ServerHttpRequest request, ServerHttpResponse response, String selectedProtocol, List<WebSocketExtension> selectedExtensions, Principal user, WebSocketHandler handler, Map<String, Object> attributes) throws HandshakeFailureException

Implements org.springframework.web.socket.server.RequestUpgradeStrategy.upgrade.

Doc from org.springframework.web.socket.server.RequestUpgradeStrategy.upgrade.

Perform runtime specific steps to complete the upgrade. Invoked after successful negotiation of the handshake request.

Parameters
request:ServerHttpRequest

the current request

response:ServerHttpResponse

the current response

selectedProtocol:String

the selected sub-protocol, if any

selectedExtensions:List<WebSocketExtension>

the selected WebSocket protocol extensions

user:Principal

the user to associate with the WebSocket session

handler:WebSocketHandler

the handler for WebSocket messages

attributes:Map<String, Object>

handshake request specific attributes to be set on the WebSocket session via org.springframework.web.socket.server.HandshakeInterceptor and thus made available to the org.springframework.web.socket.WebSocketHandler

Annotations
@Override
Exceptions
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.