public class JettyRequestUpgradeStrategy extends Object implements RequestUpgradeStrategy, org.springframework.web.context.ServletContextAware, org.springframework.context.Lifecycle
RequestUpgradeStrategy for use with Jetty 9.4. Based on Jetty's
internal org.eclipse.jetty.websocket.server.WebSocketHandler class.| Constructor and Description |
|---|
JettyRequestUpgradeStrategy()
Default constructor that creates
WebSocketServerFactory through
its default constructor thus using a default WebSocketPolicy. |
JettyRequestUpgradeStrategy(org.eclipse.jetty.websocket.api.WebSocketPolicy policy)
A constructor accepting a
WebSocketPolicy to be used when
creating the WebSocketServerFactory instance. |
JettyRequestUpgradeStrategy(org.eclipse.jetty.websocket.server.WebSocketServerFactory factory)
A constructor accepting a
WebSocketServerFactory. |
| Modifier and Type | Method and Description |
|---|---|
List<WebSocketExtension> |
getSupportedExtensions(org.springframework.http.server.ServerHttpRequest request)
Return the WebSocket protocol extensions supported by the underlying WebSocket server.
|
String[] |
getSupportedVersions()
Return the supported WebSocket protocol versions.
|
boolean |
isRunning() |
void |
setServletContext(ServletContext servletContext) |
void |
start() |
void |
stop() |
void |
upgrade(org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response,
String selectedProtocol,
List<WebSocketExtension> selectedExtensions,
Principal user,
WebSocketHandler wsHandler,
Map<String,Object> attributes)
Perform runtime specific steps to complete the upgrade.
|
public JettyRequestUpgradeStrategy()
WebSocketServerFactory through
its default constructor thus using a default WebSocketPolicy.public JettyRequestUpgradeStrategy(org.eclipse.jetty.websocket.api.WebSocketPolicy policy)
WebSocketPolicy to be used when
creating the WebSocketServerFactory instance.policy - the policy to usepublic JettyRequestUpgradeStrategy(org.eclipse.jetty.websocket.server.WebSocketServerFactory factory)
WebSocketServerFactory.factory - the pre-configured factory to usepublic void setServletContext(ServletContext servletContext)
setServletContext in interface org.springframework.web.context.ServletContextAwarepublic void start()
start in interface org.springframework.context.Lifecyclepublic void stop()
stop in interface org.springframework.context.Lifecyclepublic boolean isRunning()
isRunning in interface org.springframework.context.Lifecyclepublic String[] getSupportedVersions()
RequestUpgradeStrategygetSupportedVersions in interface RequestUpgradeStrategypublic List<WebSocketExtension> getSupportedExtensions(org.springframework.http.server.ServerHttpRequest request)
RequestUpgradeStrategygetSupportedExtensions in interface RequestUpgradeStrategypublic void upgrade(org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response,
@Nullable
String selectedProtocol,
List<WebSocketExtension> selectedExtensions,
@Nullable
Principal user,
WebSocketHandler wsHandler,
Map<String,Object> attributes)
throws HandshakeFailureException
RequestUpgradeStrategyupgrade in interface RequestUpgradeStrategyrequest - 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 messagesattributes - handshake request specific attributes to be set on the WebSocket
session via HandshakeInterceptor and
thus made available to the WebSocketHandlerHandshakeFailureException - 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.