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

pack-priv Class DefaultTransportRequest

extends Object
implements TransportRequest
Class Inheritance
All Implemented Interfaces
org.springframework.web.socket.sockjs.client.TransportRequest
Imports
java.net.URI, java.security.Principal, java.time.Instant, java.time.temporal.ChronoUnit, java.util.ArrayList, .List, java.util.concurrent.CompletableFuture, java.util.concurrent.atomic.AtomicBoolean, java.util.function.BiConsumer, org.apache.commons.logging.Log, .LogFactory, org.springframework.http.HttpHeaders, org.springframework.lang.Nullable, org.springframework.scheduling.TaskScheduler, org.springframework.util.Assert, org.springframework.web.socket.WebSocketHandler, .WebSocketSession, org.springframework.web.socket.sockjs.SockJsTransportFailureException, org.springframework.web.socket.sockjs.frame.SockJsMessageCodec, org.springframework.web.socket.sockjs.transport.TransportType

A default implementation of TransportRequest.
Author
Rossen Stoyanchev
Since
4.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
DefaultTransportRequest.CompletableConnectCallback

Updates the given (global) future based success or failure to connect for the entire SockJS request regardless of which transport actually managed to connect.

private class
DefaultTransportRequest.ListenableConnectCallback

References Deprecated ListenableFutureCallback is deprecated or references (maybe indirectly) at least one deprecated element.
Updates the given (global) future based success or failure to connect for the entire SockJS request regardless of which transport actually managed to connect.

Field Summary

Modifier and TypeField and Description
private final SockJsMessageCodec
private DefaultTransportRequest
private final HttpHeaders
private final HttpHeaders
private static final Log
private final TransportType
private final SockJsUrlInfo
private TaskScheduler
private final List<Runnable>
private long
private final Transport
private Principal

Constructor Summary

AccessConstructor and Description
public
DefaultTransportRequest(SockJsUrlInfo sockJsUrlInfo, HttpHeaders handshakeHeaders, HttpHeaders httpRequestHeaders, Transport transport, TransportType serverTransportType, SockJsMessageCodec codec)

Method Summary

Modifier and TypeMethod and Description
public void
addTimeoutTask(Runnable runnable)

Implements org.springframework.web.socket.sockjs.client.TransportRequest.addTimeoutTask.

Register a timeout cleanup task to invoke if the SockJS session is not fully established within the calculated retransmission timeout period.

public void
public void
public HttpHeaders
getHandshakeHeaders()

Implements org.springframework.web.socket.sockjs.client.TransportRequest.getHandshakeHeaders.

Return the headers to send with the connect request.

public HttpHeaders
getHttpRequestHeaders()

Implements org.springframework.web.socket.sockjs.client.TransportRequest.getHttpRequestHeaders.

Return the headers to add to all other HTTP requests besides the handshake request such as XHR receive and send requests.

public SockJsMessageCodec
getMessageCodec()

Implements org.springframework.web.socket.sockjs.client.TransportRequest.getMessageCodec.

Return the message codec to use for encoding SockJS messages.

public SockJsUrlInfo
getSockJsUrlInfo()

Implements org.springframework.web.socket.sockjs.client.TransportRequest.getSockJsUrlInfo.

Return information about the SockJS URL including server and session ID.

public URI
getTransportUrl()

Implements org.springframework.web.socket.sockjs.client.TransportRequest.getTransportUrl.

Return the transport URL for the given transport.

public Principal
getUser()

Implements org.springframework.web.socket.sockjs.client.TransportRequest.getUser.

Return the user associated with the request, if any.

private void
scheduleConnectTimeoutTask(DefaultTransportRequest.ListenableConnectCallback connectHandler)
References Deprecated DefaultTransportRequest.ListenableConnectCallback is deprecated or references (maybe indirectly) at least one deprecated element.

private void
public void
public void
public void
setTimeoutValue(long timeoutValue)

public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

codecback to summary
private final SockJsMessageCodec codec
fallbackRequestback to summary
private DefaultTransportRequest fallbackRequest
Annotations
@Nullable
handshakeHeadersback to summary
private final HttpHeaders handshakeHeaders
httpRequestHeadersback to summary
private final HttpHeaders httpRequestHeaders
loggerback to summary
private static final Log logger
serverTransportTypeback to summary
private final TransportType serverTransportType
sockJsUrlInfoback to summary
private final SockJsUrlInfo sockJsUrlInfo
timeoutSchedulerback to summary
private TaskScheduler timeoutScheduler
Annotations
@Nullable
timeoutTasksback to summary
private final List<Runnable> timeoutTasks
timeoutValueback to summary
private long timeoutValue
transportback to summary
private final Transport transport
userback to summary
private Principal user
Annotations
@Nullable

Constructor Detail

DefaultTransportRequestback to summary
public DefaultTransportRequest(SockJsUrlInfo sockJsUrlInfo, HttpHeaders handshakeHeaders, HttpHeaders httpRequestHeaders, Transport transport, TransportType serverTransportType, SockJsMessageCodec codec)

Method Detail

addTimeoutTaskback to summary
public void addTimeoutTask(Runnable runnable)

Implements org.springframework.web.socket.sockjs.client.TransportRequest.addTimeoutTask.

Doc from org.springframework.web.socket.sockjs.client.TransportRequest.addTimeoutTask.

Register a timeout cleanup task to invoke if the SockJS session is not fully established within the calculated retransmission timeout period.

Annotations
@Override
connectback to summary
public void connect(WebSocketHandler handler, SettableListenableFuture<WebSocketSession> future)

Deprecated

Annotations
@Deprecated
connectback to summary
public void connect(WebSocketHandler handler, CompletableFuture<WebSocketSession> future)
getHandshakeHeadersback to summary
public HttpHeaders getHandshakeHeaders()

Implements org.springframework.web.socket.sockjs.client.TransportRequest.getHandshakeHeaders.

Doc from org.springframework.web.socket.sockjs.client.TransportRequest.getHandshakeHeaders.

Return the headers to send with the connect request.

Annotations
@Override
getHttpRequestHeadersback to summary
public HttpHeaders getHttpRequestHeaders()

Implements org.springframework.web.socket.sockjs.client.TransportRequest.getHttpRequestHeaders.

Doc from org.springframework.web.socket.sockjs.client.TransportRequest.getHttpRequestHeaders.

Return the headers to add to all other HTTP requests besides the handshake request such as XHR receive and send requests.

Annotations
@Override
getMessageCodecback to summary
public SockJsMessageCodec getMessageCodec()

Implements org.springframework.web.socket.sockjs.client.TransportRequest.getMessageCodec.

Doc from org.springframework.web.socket.sockjs.client.TransportRequest.getMessageCodec.

Return the message codec to use for encoding SockJS messages.

Annotations
@Override
getSockJsUrlInfoback to summary
public SockJsUrlInfo getSockJsUrlInfo()

Implements org.springframework.web.socket.sockjs.client.TransportRequest.getSockJsUrlInfo.

Doc from org.springframework.web.socket.sockjs.client.TransportRequest.getSockJsUrlInfo.

Return information about the SockJS URL including server and session ID.

Annotations
@Override
getTransportUrlback to summary
public URI getTransportUrl()

Implements org.springframework.web.socket.sockjs.client.TransportRequest.getTransportUrl.

Doc from org.springframework.web.socket.sockjs.client.TransportRequest.getTransportUrl.

Return the transport URL for the given transport.

For an XhrTransport this is the URL for receiving messages.

Annotations
@Override
getUserback to summary
public Principal getUser()

Implements org.springframework.web.socket.sockjs.client.TransportRequest.getUser.

Doc from org.springframework.web.socket.sockjs.client.TransportRequest.getUser.

Return the user associated with the request, if any.

Annotations
@Override
@Nullable
scheduleConnectTimeoutTaskback to summary
private void scheduleConnectTimeoutTask(DefaultTransportRequest.ListenableConnectCallback connectHandler)

References Deprecated

DefaultTransportRequest.ListenableConnectCallback is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

scheduleConnectTimeoutTaskback to summary
private void scheduleConnectTimeoutTask(DefaultTransportRequest.CompletableConnectCallback connectHandler)
setFallbackRequestback to summary
public void setFallbackRequest(DefaultTransportRequest fallbackRequest)
setTimeoutSchedulerback to summary
public void setTimeoutScheduler(TaskScheduler scheduler)
setTimeoutValueback to summary
public void setTimeoutValue(long timeoutValue)
setUserback to summary
public void setUser(Principal user)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.springframework.web.socket.sockjs.client back to summary

private Class DefaultTransportRequest.CompletableConnectCallback

extends Object
implements Runnable, BiConsumer<WebSocketSession, Throwable>
Class Inheritance
  • java.lang.Object
  • org.springframework.web.socket.sockjs.client.DefaultTransportRequest.CompletableConnectCallback
All Implemented Interfaces
java.util.function.BiConsumer, java.lang.Runnable

Updates the given (global) future based success or failure to connect for the entire SockJS request regardless of which transport actually managed to connect. Also implements Runnable to handle a scheduled timeout callback.

Field Summary

Modifier and TypeField and Description
private final CompletableFuture<WebSocketSession>
private final AtomicBoolean
private final WebSocketHandler

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
accept(WebSocketSession
the first input argument
session
,
Throwable
the second input argument
throwable
)

Implements java.util.function.BiConsumer.accept.

Performs this operation on the given arguments.

private void
handleFailure(Throwable ex, boolean isTimeoutFailure)

public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

futureback to summary
private final CompletableFuture<WebSocketSession> future
handledback to summary
private final AtomicBoolean handled
handlerback to summary
private final WebSocketHandler handler

Constructor Detail

CompletableConnectCallbackback to summary
public CompletableConnectCallback(WebSocketHandler handler, CompletableFuture<WebSocketSession> future)

Method Detail

acceptback to summary
public void accept(WebSocketSession session, Throwable throwable)

Implements java.util.function.BiConsumer.accept.

Doc from java.util.function.BiConsumer.accept.

Performs this operation on the given arguments.

Parameters
session:WebSocketSession

the first input argument

throwable:Throwable

the second input argument

Annotations
@Override
handleFailureback to summary
private void handleFailure(Throwable ex, boolean isTimeoutFailure)
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
org.springframework.web.socket.sockjs.client back to summary

private Class DefaultTransportRequest.ListenableConnectCallback

extends Object
implements ListenableFutureCallback<WebSocketSession>, Runnable
Class Inheritance
  • java.lang.Object
  • org.springframework.web.socket.sockjs.client.DefaultTransportRequest.ListenableConnectCallback
All Implemented Interfaces
java.lang.Runnable, org.springframework.util.concurrent.ListenableFutureCallback, org.springframework.util.concurrent.FailureCallback, org.springframework.util.concurrent.SuccessCallback
Annotations
@SuppressWarnings:deprecation

References Deprecated

ListenableFutureCallback is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Updates the given (global) future based success or failure to connect for the entire SockJS request regardless of which transport actually managed to connect. Also implements Runnable to handle a scheduled timeout callback.

Field Summary

Modifier and TypeField and Description
private final SettableListenableFuture<WebSocketSession>
future

References Deprecated SettableListenableFuture is deprecated or references (maybe indirectly) at least one deprecated element.
private final AtomicBoolean
private final WebSocketHandler

Constructor Summary

AccessConstructor and Description
public
ListenableConnectCallback(WebSocketHandler handler, SettableListenableFuture<WebSocketSession> future)
References Deprecated SettableListenableFuture is deprecated or references (maybe indirectly) at least one deprecated element.

Method Summary

Modifier and TypeMethod and Description
private void
handleFailure(Throwable ex, boolean isTimeoutFailure)

public void
onFailure(Throwable
the failure
ex
)

Implements org.springframework.util.concurrent.FailureCallback.onFailure.

Called when the ListenableFuture completes with failure.

public void
onSuccess(WebSocketSession
the result
session
)

Implements org.springframework.util.concurrent.SuccessCallback.onSuccess.

Called when the ListenableFuture completes with success.

public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

futureback to summary
private final SettableListenableFuture<WebSocketSession> future

References Deprecated

SettableListenableFuture is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

handledback to summary
private final AtomicBoolean handled
handlerback to summary
private final WebSocketHandler handler

Constructor Detail

ListenableConnectCallbackback to summary
public ListenableConnectCallback(WebSocketHandler handler, SettableListenableFuture<WebSocketSession> future)

References Deprecated

SettableListenableFuture is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Method Detail

handleFailureback to summary
private void handleFailure(Throwable ex, boolean isTimeoutFailure)
onFailureback to summary
public void onFailure(Throwable ex)

Implements org.springframework.util.concurrent.FailureCallback.onFailure.

Doc from org.springframework.util.concurrent.FailureCallback.onFailure.

Called when the ListenableFuture completes with failure.

Note that Exceptions raised by this method are ignored.

Parameters
ex:Throwable

the failure

Annotations
@Override
onSuccessback to summary
public void onSuccess(WebSocketSession session)

Implements org.springframework.util.concurrent.SuccessCallback.onSuccess.

Doc from org.springframework.util.concurrent.SuccessCallback.onSuccess.

Called when the ListenableFuture completes with success.

Note that Exceptions raised by this method are ignored.

Parameters
session:WebSocketSession

the result

Annotations
@Override
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override