Top Description Inners Fields Constructors Methods
org.springframework.web.socket.sockjs.client

public Class UndertowXhrTransport

extends AbstractXhrTransport
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .IOException, java.net.URI, java.nio.ByteBuffer, java.util.List, java.util.concurrent.CompletableFuture, .CopyOnWriteArrayList, .CountDownLatch, io.undertow.client.ClientCallback, .ClientConnection, .ClientExchange, .ClientRequest, .ClientResponse, .UndertowClient, io.undertow.connector.ByteBufferPool, .PooledByteBuffer, io.undertow.server.DefaultByteBufferPool, io.undertow.util.AttachmentKey, .HeaderMap, .HttpString, .Methods, .StringReadChannelListener, org.xnio.ChannelListener, .ChannelListeners, .IoUtils, .OptionMap, .Options, .Xnio, .XnioWorker, org.xnio.channels.StreamSinkChannel, .StreamSourceChannel, org.springframework.http.HttpHeaders, .HttpStatusCode, .ResponseEntity, org.springframework.lang.Nullable, org.springframework.util.Assert, .StreamUtils, .StringUtils, org.springframework.web.client.HttpServerErrorException, org.springframework.web.socket.CloseStatus, .TextMessage, .WebSocketHandler, .WebSocketSession, org.springframework.web.socket.sockjs.SockJsException, .SockJsTransportFailureException, org.springframework.web.socket.sockjs.frame.SockJsFrame

An XHR transport based on Undertow's io.undertow.client.UndertowClient. Requires Undertow 1.3 or 1.4, including XNIO, as of Spring Framework 5.0.

When used for testing purposes (e.g. load testing) or for specific use cases (like HTTPS configuration), a custom OptionMap should be provided:

OptionMap optionMap = OptionMap.builder()
  .set(Options.WORKER_IO_THREADS, 8)
  .set(Options.TCP_NODELAY, true)
  .set(Options.KEEP_ALIVE, true)
  .set(Options.WORKER_NAME, "SockJSClient")
  .getMap();

UndertowXhrTransport transport = new UndertowXhrTransport(optionMap);
Authors
Brian Clozel, Rossen Stoyanchev
Since
4.1.2
See Also
org.xnio.Options

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final ByteBufferPool
private final UndertowClient
private final OptionMap
private static final AttachmentKey<String>
private final XnioWorker
Inherited from org.springframework.web.socket.sockjs.client.AbstractXhrTransport:
loggerPRELUDE

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
private static void
protected void
private ClientCallback<ClientExchange>
createReceiveCallback(final TransportRequest transportRequest, final URI url, final HttpHeaders headers, final XhrClientSockJsSession sockJsSession, final CompletableFuture<WebSocketSession> connectFuture)

private ClientCallback<ClientExchange>
createRequestCallback(final String body, final List<ClientResponse> responses, final CountDownLatch latch)

protected ResponseEntity<String>
private void
executeReceiveRequest(final TransportRequest transportRequest, final URI url, final HttpHeaders headers, final XhrClientSockJsSession session, final CompletableFuture<WebSocketSession> connectFuture)

protected ResponseEntity<String>
executeRequest(URI url, HttpString method, HttpHeaders headers, String body)

protected ResponseEntity<String>
public UndertowClient
getHttpClient()

Return Undertow's native HTTP client.

public XnioWorker
getWorker()

Return the org.xnio.XnioWorker backing the I/O operations for Undertow's HTTP client.

private static HttpHeaders
Inherited from org.springframework.web.socket.sockjs.client.AbstractXhrTransport:
connectAsyncconnectInternalexecuteInfoRequestexecuteSendRequestgetTransportTypesisXhrStreamingDisabledsetXhrStreamingDisabled

Field Detail

bufferPoolback to summary
private final ByteBufferPool bufferPool
httpClientback to summary
private final UndertowClient httpClient
optionMapback to summary
private final OptionMap optionMap
RESPONSE_BODYback to summary
private static final AttachmentKey<String> RESPONSE_BODY
workerback to summary
private final XnioWorker worker

Constructor Detail

UndertowXhrTransportback to summary
public UndertowXhrTransport() throws IOException
UndertowXhrTransportback to summary
public UndertowXhrTransport(OptionMap optionMap) throws IOException

Method Detail

addHttpHeadersback to summary
private static void addHttpHeaders(ClientRequest request, HttpHeaders headers)
connectInternalback to summary
protected void connectInternal(TransportRequest request, WebSocketHandler handler, URI receiveUrl, HttpHeaders handshakeHeaders, XhrClientSockJsSession session, CompletableFuture<WebSocketSession> connectFuture)

Implements abstract org.springframework.web.socket.sockjs.client.AbstractXhrTransport.connectInternal.

Annotations
@Override
createReceiveCallbackback to summary
private ClientCallback<ClientExchange> createReceiveCallback(final TransportRequest transportRequest, final URI url, final HttpHeaders headers, final XhrClientSockJsSession sockJsSession, final CompletableFuture<WebSocketSession> connectFuture)
createRequestCallbackback to summary
private ClientCallback<ClientExchange> createRequestCallback(final String body, final List<ClientResponse> responses, final CountDownLatch latch)
executeInfoRequestInternalback to summary
protected ResponseEntity<String> executeInfoRequestInternal(URI infoUrl, HttpHeaders headers)

Implements abstract org.springframework.web.socket.sockjs.client.AbstractXhrTransport.executeInfoRequestInternal.

Annotations
@Override
executeReceiveRequestback to summary
private void executeReceiveRequest(final TransportRequest transportRequest, final URI url, final HttpHeaders headers, final XhrClientSockJsSession session, final CompletableFuture<WebSocketSession> connectFuture)
executeRequestback to summary
protected ResponseEntity<String> executeRequest(URI url, HttpString method, HttpHeaders headers, String body)
executeSendRequestInternalback to summary
protected ResponseEntity<String> executeSendRequestInternal(URI url, HttpHeaders headers, TextMessage message)

Implements abstract org.springframework.web.socket.sockjs.client.AbstractXhrTransport.executeSendRequestInternal.

Annotations
@Override
getHttpClientback to summary
public UndertowClient getHttpClient()

Return Undertow's native HTTP client.

getWorkerback to summary
public XnioWorker getWorker()

Return the org.xnio.XnioWorker backing the I/O operations for Undertow's HTTP client.

See Also
org.xnio.Xnio
toHttpHeadersback to summary
private static HttpHeaders toHttpHeaders(HeaderMap headerMap)
org.springframework.web.socket.sockjs.client back to summary

private Class UndertowXhrTransport.SockJsResponseListener

extends Object
implements ChannelListener<StreamSourceChannel>
Class Inheritance
  • java.lang.Object
  • org.springframework.web.socket.sockjs.client.UndertowXhrTransport.SockJsResponseListener
All Implemented Interfaces
org.xnio.ChannelListener, java.util.EventListener

Field Summary

Modifier and TypeField and Description
private final CompletableFuture<WebSocketSession>
private final ClientConnection
private final HttpHeaders
private final ByteArrayOutputStream
private final TransportRequest
private final XhrClientSockJsSession
private final URI

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
handleEvent(StreamSourceChannel
the channel event
channel
)

Implements org.xnio.ChannelListener.handleEvent.

Handle the event on this channel.

private void
public void
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectFutureback to summary
private final CompletableFuture<WebSocketSession> connectFuture
connectionback to summary
private final ClientConnection connection
headersback to summary
private final HttpHeaders headers
outputStreamback to summary
private final ByteArrayOutputStream outputStream
requestback to summary
private final TransportRequest request
sessionback to summary
private final XhrClientSockJsSession session
urlback to summary
private final URI url

Constructor Detail

SockJsResponseListenerback to summary
public SockJsResponseListener(TransportRequest request, ClientConnection connection, URI url, HttpHeaders headers, XhrClientSockJsSession sockJsSession, CompletableFuture<WebSocketSession> connectFuture)

Method Detail

handleEventback to summary
public void handleEvent(StreamSourceChannel channel)

Implements org.xnio.ChannelListener.handleEvent.

Doc from org.xnio.ChannelListener.handleEvent.

Handle the event on this channel.

Parameters
channel:StreamSourceChannel

the channel event

Annotations
@Override
handleFrameback to summary
private void handleFrame()
onFailureback to summary
public void onFailure(Throwable failure)
onSuccessback to summary
public void onSuccess()
setupback to summary
public void setup(StreamSourceChannel channel)