A base class for HandshakeHandler implementations, independent from the Servlet API.
Performs initial validation of the WebSocket handshake request - possibly rejecting it
through the appropriate HTTP status code - while also allowing its subclasses to override
various parts of the negotiation process (e.g. origin validation, sub-protocol negotiation,
extensions negotiation, etc).
If the negotiation succeeds, the actual upgrade is delegated to a server-specific
RequestUpgradeStrategy, which will update
the response as necessary and initialize the WebSocket. Currently supported servers are
Jetty 9.0-9.3, Tomcat 7.0.47+ and 8.x, Undertow 1.0-1.3, GlassFish 4.1+, WebLogic 12.1.3+.
public void setSupportedProtocols(java.lang.String... protocols)
Use this property to configure the list of supported sub-protocols.
The first configured sub-protocol that matches a client-requested sub-protocol
is accepted. If there are no matches the response will not contain a
Note that if the WebSocketHandler passed in at runtime is an instance of
SubProtocolCapable then there is not need to explicitly configure
this property. That is certainly the case with the built-in STOMP over
WebSocket support. Therefore this property should be configured explicitly
only if the WebSocketHandler does not implement SubProtocolCapable.
Stop this component, typically in a synchronous fashion, such that the component is
fully stopped upon return of this method. Consider implementing SmartLifecycle
and its stop(Runnable) variant when asynchronous stop behavior is necessary.
Note that this stop notification is not guaranteed to come before destruction:
On regular shutdown, Lifecycle beans will first receive a stop notification
before the general destruction callbacks are being propagated; however, on hot
refresh during a context's lifetime or on aborted refresh attempts, a given bean's
destroy method will be called without any consideration of stop signals upfront.
Should not throw an exception if the component is not running (not started yet).
In the case of a container, this will propagate the stop signal to all components
attributes - attributes from the HTTP handshake to associate with the WebSocket
session; the provided attributes are copied, the original map is not used.
whether the handshake negotiation was successful or not. In either case the
response status, headers, and body will have been updated to reflect the
result of the negotiation
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 handshake.
Perform the sub-protocol negotiation based on requested and supported sub-protocols.
For the list of supported sub-protocols, this method first checks if the target
WebSocketHandler is a SubProtocolCapable and then also checks if any
sub-protocols have been explicitly configured with
requestedProtocols - the requested sub-protocols
webSocketHandler - the WebSocketHandler that will be used