public class WebSocketHandlerAdapter extends Object implements HandlerAdapter, Ordered
DispatcherHandlerto support handlers of type
WebSocketHandlerwith such handlers mapped to URL patterns via
Requests are handled by delegating to a
WebSocketService, by default
which checks the WebSocket handshake request parameters, upgrades to a
WebSocket interaction, and uses the
WebSocketHandler to handle it.
As of 5.3 the WebFlux Java configuration, imported via
@EnableWebFlux, includes a declaration of this adapter and therefore
it no longer needs to be present in application configuration.
|Constructor and Description|
Default constructor that creates and uses a
Alternative constructor with the
|Modifier and Type||Method and Description|
Return the configured
Handle the request with the given handler.
Set the order value for this adapter.
public void setOrder(int order)
By default this is set to 2.
order- the value to set to
public int getOrder()
configuredorder for this instance.
public WebSocketService getWebSocketService()
WebSocketServiceto handle requests.
public boolean supports(Object handler)
HandlerAdaptersupports the given
public reactor.core.publisher.Mono<HandlerResult> handle(ServerWebExchange exchange, Object handler)
Implementations are encouraged to handle exceptions resulting from the invocation of a handler in order and if necessary to return an alternate result that represents an error response.
Furthermore since an async
HandlerResult may produce an error
later during result handling implementations are also encouraged to
set an exception
handler on the
HandlerResult so that may also be applied later
after result handling.
exchange- current server exchange
handler- the selected handler which must have been previously checked via
Monothat emits a single
HandlerResultor none if the request has been fully handled and doesn't require further handling.