Top Description Inners Methods
org.springframework.messaging.rsocket

public Interface RSocketStrategies

Known Direct Implementers
org.springframework.messaging.rsocket.DefaultRSocketStrategies
Imports
java.util.List, java.util.function.Consumer, io.rsocket.Payload, org.springframework.core.ReactiveAdapterRegistry, .ResolvableType, org.springframework.core.codec.Decoder, .Encoder, org.springframework.core.io.buffer.DataBufferFactory, .DefaultDataBufferFactory, .NettyDataBufferFactory, org.springframework.lang.Nullable, org.springframework.util.AntPathMatcher, .MimeType, .RouteMatcher, .SimpleRouteMatcher

Access to strategies for use by RSocket requester and responder components.
Author
Rossen Stoyanchev
Since
5.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
RSocketStrategies.Builder

The builder options for creating RSocketStrategies.

Method Summary

Modifier and TypeMethod and Description
public static RSocketStrategies.Builder
builder()

Return a builder to prepare a new RSocketStrategies instance.

public static RSocketStrategies
create()

Create an RSocketStrategies instance with default settings.

public DataBufferFactory
dataBufferFactory()

Return the configured dataBufferFactory.

public default <
for casting the Decoder to the expected element type
T
>
Decoder<T>

Returns:

the matching Decoder
decoder
(ResolvableType
the element type to match
elementType
,
MimeType
the MimeType to match
mimeType
)

Find a compatible Decoder for the given element type.

public List<Decoder<?>>
decoders()

Return the configured decoders.

public default <
for casting the Encoder to the expected element type
T
>
Encoder<T>

Returns:

the matching Encoder
encoder
(ResolvableType
the element type to match
elementType
,
MimeType
the MimeType to match
mimeType
)

Find a compatible Encoder for the given element type.

public List<Encoder<?>>
encoders()

Return the configured encoders.

public MetadataExtractor
public default RSocketStrategies.Builder
mutate()

Return a builder to create a new RSocketStrategies instance replicated from the current instance.

public ReactiveAdapterRegistry
public RouteMatcher

Method Detail

builderback to summary
public static RSocketStrategies.Builder builder()

Return a builder to prepare a new RSocketStrategies instance. The builder applies default settings, see individual builder methods for details.

createback to summary
public static RSocketStrategies create()

Create an RSocketStrategies instance with default settings. Equivalent to RSocketStrategies.builder().build(). See individual builder methods for details on default settings.

dataBufferFactoryback to summary
public DataBufferFactory dataBufferFactory()

Return the configured dataBufferFactory.

decoderback to summary
public default <T> Decoder<T> decoder(ResolvableType elementType, MimeType mimeType)

Find a compatible Decoder for the given element type.

Parameters
<T>
for casting the Decoder to the expected element type
elementType:ResolvableType

the element type to match

mimeType:MimeType

the MimeType to match

Returns:Decoder<T>

the matching Decoder

Annotations
@SuppressWarnings:unchecked
Exceptions
IllegalArgumentException:
if no matching Decoder is found
decodersback to summary
public List<Decoder<?>> decoders()

Return the configured decoders.

See Also
decoder(ResolvableType, MimeType)
encoderback to summary
public default <T> Encoder<T> encoder(ResolvableType elementType, MimeType mimeType)

Find a compatible Encoder for the given element type.

Parameters
<T>
for casting the Encoder to the expected element type
elementType:ResolvableType

the element type to match

mimeType:MimeType

the MimeType to match

Returns:Encoder<T>

the matching Encoder

Annotations
@SuppressWarnings:unchecked
Exceptions
IllegalArgumentException:
if no matching Encoder is found
encodersback to summary
public List<Encoder<?>> encoders()

Return the configured encoders.

See Also
encoder(ResolvableType, MimeType)
metadataExtractorback to summary
public MetadataExtractor metadataExtractor()

Return the configured Builder#metadataExtractor(MetadataExtractor).

mutateback to summary
public default RSocketStrategies.Builder mutate()

Return a builder to create a new RSocketStrategies instance replicated from the current instance.

reactiveAdapterRegistryback to summary
public ReactiveAdapterRegistry reactiveAdapterRegistry()

Return the configured reactiveAdapterRegistry.

routeMatcherback to summary
public RouteMatcher routeMatcher()

Return the configured Builder#routeMatcher(RouteMatcher).

org.springframework.messaging.rsocket back to summary

public Interface RSocketStrategies.Builder

Known Direct Implementers
org.springframework.messaging.rsocket.DefaultRSocketStrategies.DefaultRSocketStrategiesBuilder

The builder options for creating RSocketStrategies.

Method Summary

Modifier and TypeMethod and Description
public RSocketStrategies
build()

Build the RSocketStrategies instance.

public RSocketStrategies.Builder
dataBufferFactory(DataBufferFactory bufferFactory)

Configure the DataBufferFactory to use for allocating buffers when preparing requests or creating responses.

public RSocketStrategies.Builder
decoder(Decoder<?>... decoder)

Append to the list of decoders to use for de-serializing Objects from the data or metadata of a Payload.

public RSocketStrategies.Builder
decoders(Consumer<List<Decoder<?>>> consumer)

Apply the consumer to the list of configured decoders, immediately.

public RSocketStrategies.Builder
encoder(Encoder<?>... encoder)

Append to the list of encoders to use for serializing Objects to the data or metadata of a Payload.

public RSocketStrategies.Builder
encoders(Consumer<List<Encoder<?>>> consumer)

Apply the consumer to the list of configured encoders, immediately.

public RSocketStrategies.Builder
metadataExtractor(MetadataExtractor metadataExtractor)

Configure a MetadataExtractor to extract the route along with other metadata.

public RSocketStrategies.Builder
metadataExtractorRegistry(Consumer<MetadataExtractorRegistry> consumer)

Apply the consumer to the MetadataExtractorRegistry in order to register extra metadata entry extractors.

public RSocketStrategies.Builder
reactiveAdapterStrategy(ReactiveAdapterRegistry registry)

Configure the registry for reactive type support.

public RSocketStrategies.Builder
routeMatcher(RouteMatcher routeMatcher)

Configure a RouteMatcher for matching routes to message handlers based on route patterns.

Method Detail

buildback to summary
public RSocketStrategies build()

Build the RSocketStrategies instance.

dataBufferFactoryback to summary
public RSocketStrategies.Builder dataBufferFactory(DataBufferFactory bufferFactory)

Configure the DataBufferFactory to use for allocating buffers when preparing requests or creating responses.

By default this is set to NettyDataBufferFactory with pooled, allocated buffers for zero copy. RSocket must also be configured for zero copy. For client setup, RSocketRequester.Builder adapts automatically to the DataBufferFactory configured here, and sets the frame decoder in RSocketConnector accordingly. For server setup, the RSocketServer must be configured accordingly for zero copy too.

If using DefaultDataBufferFactory instead, there is no need for related config changes in RSocket.

decoderback to summary
public RSocketStrategies.Builder decoder(Decoder<?>... decoder)

Append to the list of decoders to use for de-serializing Objects from the data or metadata of a Payload.

By default this is initialized with decoders for String, byte[], ByteBuffer, and DataBuffer.

decodersback to summary
public RSocketStrategies.Builder decoders(Consumer<List<Decoder<?>>> consumer)

Apply the consumer to the list of configured decoders, immediately.

encoderback to summary
public RSocketStrategies.Builder encoder(Encoder<?>... encoder)

Append to the list of encoders to use for serializing Objects to the data or metadata of a Payload.

By default this is initialized with encoders for String, byte[], ByteBuffer, and DataBuffer.

encodersback to summary
public RSocketStrategies.Builder encoders(Consumer<List<Encoder<?>>> consumer)

Apply the consumer to the list of configured encoders, immediately.

metadataExtractorback to summary
public RSocketStrategies.Builder metadataExtractor(MetadataExtractor metadataExtractor)

Configure a MetadataExtractor to extract the route along with other metadata. This option is applicable to client or server responders.

By default this is DefaultMetadataExtractor created with the configured decoders and extracting a route from "message/x.rsocket.routing.v0" metadata.

metadataExtractorRegistryback to summary
public RSocketStrategies.Builder metadataExtractorRegistry(Consumer<MetadataExtractorRegistry> consumer)

Apply the consumer to the MetadataExtractorRegistry in order to register extra metadata entry extractors.

reactiveAdapterStrategyback to summary
public RSocketStrategies.Builder reactiveAdapterStrategy(ReactiveAdapterRegistry registry)

Configure the registry for reactive type support. This can be used to adapt to, and/or determine the semantics of a given Publisher.

By default this ReactiveAdapterRegistry#getSharedInstance().

routeMatcherback to summary
public RSocketStrategies.Builder routeMatcher(RouteMatcher routeMatcher)

Configure a RouteMatcher for matching routes to message handlers based on route patterns. This option is applicable to client or server responders.

By default, SimpleRouteMatcher is used, backed by AntPathMatcher with "." as separator. For better efficiency consider switching to PathPatternRouteMatcher from spring-web instead.