Top Description Fields Constructors Methods
org.springframework.messaging.rsocket

pack-priv final Class DefaultRSocketRequesterBuilder

extends Object
implements Builder
Class Inheritance
All Implemented Interfaces
org.springframework.messaging.rsocket.RSocketRequester.Builder
Imports
java.net.URI, java.util.ArrayList, .Collections, .LinkedHashMap, .List, .Map, java.util.function.Consumer, io.rsocket.Payload, io.rsocket.core.RSocketClient, .RSocketConnector, io.rsocket.frame.decoder.PayloadDecoder, io.rsocket.loadbalance.LoadbalanceRSocketClient, .LoadbalanceStrategy, .LoadbalanceTarget, io.rsocket.metadata.WellKnownMimeType, io.rsocket.transport.ClientTransport, io.rsocket.transport.netty.client.TcpClientTransport, .WebsocketClientTransport, io.rsocket.util.DefaultPayload, org.reactivestreams.Publisher, reactor.core.publisher.Mono, org.springframework.core.ReactiveAdapter, .ResolvableType, org.springframework.core.codec.Decoder, .Encoder, .StringDecoder, org.springframework.core.io.buffer.DataBuffer, .DataBufferUtils, .NettyDataBufferFactory, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils, .MimeType, .MimeTypeUtils

Default implementation of RSocketRequester.Builder.
Authors
Brian Clozel, Rossen Stoyanchev
Since
5.2

Field Summary

Modifier and TypeField and Description
private MimeType
private static final byte[]
private static final Payload
private static final Map<String, Object>
private MimeType
private final List<RSocketConnectorConfigurer>
private Object
private Map<Object, MimeType>
private String
private Object[]
private RSocketStrategies
private final List<Consumer<RSocketStrategies.Builder>>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public RSocketRequester.Builder
apply(Consumer<RSocketRequester.Builder>
the configurer to apply
configurer
)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.apply.

Configure this builder through a Consumer.
public Mono<RSocketRequester>
connect(ClientTransport
the client transport to use
transport
)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.connect.

Connect to the server with the given ClientTransport.
public Mono<RSocketRequester>
connectTcp(String
the server host
host
,
int
the server port
port
)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.connectTcp.

Connect to the server over TCP.
public Mono<RSocketRequester>
connectWebSocket(URI
the RSocket server endpoint URI
uri
)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.connectWebSocket.

Connect to the server over WebSocket.
public RSocketRequester.Builder
dataMimeType(MimeType mimeType)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.dataMimeType.

Configure the payload data MimeType to specify on the SETUP frame that applies to the whole connection.
private MimeType
public MimeType
private static MimeType
getMimeType(Decoder<?> decoder)

private RSocketStrategies
private Mono<Payload>
getSetupPayload(MimeType dataMimeType, MimeType metaMimeType, RSocketStrategies strategies)

private RSocketConnector
initConnector(List<RSocketConnectorConfigurer> connectorConfigurers, MimeType metaMimeType, MimeType dataMimeType, RSocketStrategies rsocketStrategies)

private static boolean
public RSocketRequester.Builder
metadataMimeType(MimeType mimeType)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.metadataMimeType.

Configure the payload metadata MimeType to specify on the SETUP frame that applies to the whole connection.
public RSocketRequester.Builder
public RSocketRequester.Builder
public RSocketRequester.Builder
public RSocketRequester.Builder
public RSocketRequester.Builder
setupMetadata(Object metadata, MimeType mimeType)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.setupMetadata.

Add metadata entry to the setup payload.
public RSocketRequester.Builder
setupRoute(String route, Object... routeVars)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.setupRoute.

Set the route for the setup payload.
public RSocketRequester
tcp(String
the host to connect to
host
,
int
the port to connect to
port
)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.tcp.

Build an RSocketRequester with an io.rsocket.core.RSocketClient that connects over TCP to the given host and port.
public RSocketRequester
transport(ClientTransport
the transport to connect with
transport
)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.transport.

Variant of tcp(String, int) and websocket(URI) with an already initialized ClientTransport.
public RSocketRequester
transports(Publisher<List<LoadbalanceTarget>>
a Publisher that supplies a list of target transports to loadbalance against; the given list may be periodically updated by the Publisher.
targetPublisher
,
LoadbalanceStrategy
the strategy to use for selecting from the list of loadbalance targets.
loadbalanceStrategy
)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.transports.

Build an RSocketRequester with an io.rsocket.loadbalance.LoadbalanceRSocketClient that will connect to one of the given targets selected through the given io.rsocket.loadbalance.LoadbalanceRSocketClient.
public RSocketRequester
websocket(URI
the URL to connect to
uri
)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.websocket.

Build an RSocketRequester with an io.rsocket.core.RSocketClient that connects over WebSocket to the given URL.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dataMimeTypeback to summary
private MimeType dataMimeType
Annotations
@Nullable
EMPTY_BYTE_ARRAYback to summary
private static final byte[] EMPTY_BYTE_ARRAY
EMPTY_SETUP_PAYLOADback to summary
private static final Payload EMPTY_SETUP_PAYLOAD
HINTSback to summary
private static final Map<String, Object> HINTS
metadataMimeTypeback to summary
private MimeType metadataMimeType
Annotations
@Nullable
rsocketConnectorConfigurersback to summary
private final List<RSocketConnectorConfigurer> rsocketConnectorConfigurers
setupDataback to summary
private Object setupData
Annotations
@Nullable
setupMetadataback to summary
private Map<Object, MimeType> setupMetadata
Annotations
@Nullable
setupRouteback to summary
private String setupRoute
Annotations
@Nullable
setupRouteVarsback to summary
private Object[] setupRouteVars
Annotations
@Nullable
strategiesback to summary
private RSocketStrategies strategies
Annotations
@Nullable
strategiesConfigurersback to summary
private final List<Consumer<RSocketStrategies.Builder>> strategiesConfigurers

Constructor Detail

DefaultRSocketRequesterBuilderback to summary
pack-priv DefaultRSocketRequesterBuilder()

Method Detail

applyback to summary
public RSocketRequester.Builder apply(Consumer<RSocketRequester.Builder> configurer)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.apply.

Doc from org.springframework.messaging.rsocket.RSocketRequester.Builder.apply.

Configure this builder through a Consumer. This enables libraries such as Spring Security to provide shortcuts for applying a set of related customizations.

Parameters
configurer:Consumer<RSocketRequester.Builder>

the configurer to apply

Annotations
@Override
connectback to summary
public Mono<RSocketRequester> connect(ClientTransport transport)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.connect.

Doc from org.springframework.messaging.rsocket.RSocketRequester.Builder.connect.

Connect to the server with the given ClientTransport.

Parameters
transport:ClientTransport

the client transport to use

Returns:Mono<RSocketRequester>

an RSocketRequester for the connection

Annotations
@Override
@SuppressWarnings:deprecation
connectTcpback to summary
public Mono<RSocketRequester> connectTcp(String host, int port)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.connectTcp.

Doc from org.springframework.messaging.rsocket.RSocketRequester.Builder.connectTcp.

Connect to the server over TCP.

Parameters
host:String

the server host

port:int

the server port

Returns:Mono<RSocketRequester>

an RSocketRequester for the connection

Annotations
@Override
@SuppressWarnings:deprecation
connectWebSocketback to summary
public Mono<RSocketRequester> connectWebSocket(URI uri)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.connectWebSocket.

Doc from org.springframework.messaging.rsocket.RSocketRequester.Builder.connectWebSocket.

Connect to the server over WebSocket.

Parameters
uri:URI

the RSocket server endpoint URI

Returns:Mono<RSocketRequester>

an RSocketRequester for the connection

Annotations
@Override
@SuppressWarnings:deprecation
dataMimeTypeback to summary
public RSocketRequester.Builder dataMimeType(MimeType mimeType)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.dataMimeType.

Doc from org.springframework.messaging.rsocket.RSocketRequester.Builder.dataMimeType.

Configure the payload data MimeType to specify on the SETUP frame that applies to the whole connection.

If not set, this will be initialized to the MimeType of the first non-default Decoder, or otherwise the MimeType of the first decoder.

Annotations
@Override
getDataMimeTypeback to summary
private MimeType getDataMimeType(RSocketStrategies strategies)
getMetadataMimeTypeback to summary
public MimeType getMetadataMimeType()
getMimeTypeback to summary
private static MimeType getMimeType(Decoder<?> decoder)
getRSocketStrategiesback to summary
private RSocketStrategies getRSocketStrategies()
getSetupPayloadback to summary
private Mono<Payload> getSetupPayload(MimeType dataMimeType, MimeType metaMimeType, RSocketStrategies strategies)
initConnectorback to summary
private RSocketConnector initConnector(List<RSocketConnectorConfigurer> connectorConfigurers, MimeType metaMimeType, MimeType dataMimeType, RSocketStrategies rsocketStrategies)
Annotations
@SuppressWarnings:deprecation
isCoreCodecback to summary
private static boolean isCoreCodec(Object codec)
metadataMimeTypeback to summary
public RSocketRequester.Builder metadataMimeType(MimeType mimeType)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.metadataMimeType.

Doc from org.springframework.messaging.rsocket.RSocketRequester.Builder.metadataMimeType.

Configure the payload metadata MimeType to specify on the SETUP frame that applies to the whole connection.

By default this is set to "message/x.rsocket.composite-metadata.v0" in which case the route, if provided, is encoded as a "message/x.rsocket.routing.v0" composite metadata entry. If this is set to any other MimeType, it is assumed that's the MimeType for the route, if provided.

Annotations
@Override
rsocketConnectorback to summary
public RSocketRequester.Builder rsocketConnector(RSocketConnectorConfigurer configurer)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.rsocketConnector.

Doc from org.springframework.messaging.rsocket.RSocketRequester.Builder.rsocketConnector.

Callback to configure the RSocketConnector directly.

Annotations
@Override
rsocketStrategiesback to summary
public RSocketRequester.Builder rsocketStrategies(RSocketStrategies strategies)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.rsocketStrategies.

Doc from org.springframework.messaging.rsocket.RSocketRequester.Builder.rsocketStrategies.

Provide the RSocketStrategies to use.

This is useful for changing the default settings, yet still allowing further customizations via rsocketStrategies(Consumer). If not set, defaults are obtained from RSocketStrategies#builder().

Parameters
strategies:RSocketStrategies

the strategies to use

Annotations
@Override
rsocketStrategiesback to summary
public RSocketRequester.Builder rsocketStrategies(Consumer<RSocketStrategies.Builder> configurer)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.rsocketStrategies.

Doc from org.springframework.messaging.rsocket.RSocketRequester.Builder.rsocketStrategies.

Customize the RSocketStrategies.

Allows further customization on RSocketStrategies, mutating them if they were set, or starting from RSocketStrategies#builder() defaults}.

Annotations
@Override
setupDataback to summary
public RSocketRequester.Builder setupData(Object data)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.setupData.

Doc from org.springframework.messaging.rsocket.RSocketRequester.Builder.setupData.

Set the data for the setup payload. The data will be encoded according to the configured dataMimeType(MimeType). The data be a concrete value or any producer of a single value that can be adapted to a Publisher via ReactiveAdapterRegistry.

By default this is not set.

Annotations
@Override
setupMetadataback to summary
public RSocketRequester.Builder setupMetadata(Object metadata, MimeType mimeType)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.setupMetadata.

Doc from org.springframework.messaging.rsocket.RSocketRequester.Builder.setupMetadata.

Add metadata entry to the setup payload. Composite metadata must be in use if this is called more than once or in addition to setupRoute(String, Object...). The metadata value be a concrete value or any producer of a single value that can be adapted to a Publisher via ReactiveAdapterRegistry.

Annotations
@Override
setupRouteback to summary
public RSocketRequester.Builder setupRoute(String route, Object... routeVars)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.setupRoute.

Doc from org.springframework.messaging.rsocket.RSocketRequester.Builder.setupRoute.

Set the route for the setup payload. The rules for formatting and encoding the route are the same as those for a request route as described in route(String, Object...).

By default this is not set.

Annotations
@Override
tcpback to summary
public RSocketRequester tcp(String host, int port)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.tcp.

Doc from org.springframework.messaging.rsocket.RSocketRequester.Builder.tcp.

Build an RSocketRequester with an io.rsocket.core.RSocketClient that connects over TCP to the given host and port. The requester can be used to make requests concurrently. Requests are made over a shared connection that is also re-established as needed when further requests are made.

Parameters
host:String

the host to connect to

port:int

the port to connect to

Returns:RSocketRequester

the created RSocketRequester

Annotations
@Override
transportback to summary
public RSocketRequester transport(ClientTransport transport)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.transport.

Doc from org.springframework.messaging.rsocket.RSocketRequester.Builder.transport.

Variant of tcp(String, int) and websocket(URI) with an already initialized ClientTransport.

Parameters
transport:ClientTransport

the transport to connect with

Returns:RSocketRequester

the created RSocketRequester

Annotations
@Override
transportsback to summary
public RSocketRequester transports(Publisher<List<LoadbalanceTarget>> targetPublisher, LoadbalanceStrategy loadbalanceStrategy)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.transports.

Doc from org.springframework.messaging.rsocket.RSocketRequester.Builder.transports.

Build an RSocketRequester with an io.rsocket.loadbalance.LoadbalanceRSocketClient that will connect to one of the given targets selected through the given io.rsocket.loadbalance.LoadbalanceRSocketClient.

Parameters
targetPublisher:Publisher<List<LoadbalanceTarget>>

a Publisher that supplies a list of target transports to loadbalance against; the given list may be periodically updated by the Publisher.

loadbalanceStrategy:LoadbalanceStrategy

the strategy to use for selecting from the list of loadbalance targets.

Returns:RSocketRequester

the created RSocketRequester

Annotations
@Override
websocketback to summary
public RSocketRequester websocket(URI uri)

Implements org.springframework.messaging.rsocket.RSocketRequester.Builder.websocket.

Doc from org.springframework.messaging.rsocket.RSocketRequester.Builder.websocket.

Build an RSocketRequester with an io.rsocket.core.RSocketClient that connects over WebSocket to the given URL. The requester can be used to make requests concurrently. Requests are made over a shared connection that is also re-established as needed when further requests are made.

Parameters
uri:URI

the URL to connect to

Returns:RSocketRequester

the created RSocketRequester

Annotations
@Override