Class DefaultMetadataExtractor
- java.lang.Object
- org.springframework.messaging.rsocket.DefaultMetadataExtractor
- All Implemented Interfaces:
MetadataExtractor
,MetadataExtractorRegistry
public class DefaultMetadataExtractor extends Object implements MetadataExtractor, MetadataExtractorRegistry
DefaultMetadataExtractor
implementation that relies onDecoder
s to deserialize the content of metadata entries.By default only
"message/x.rsocket.routing.v0""
is extracted and saved underMetadataExtractor.ROUTE_KEY
. UsemetadataToExtract
methods to specify other metadata mime types of interest to extract.- Since:
- 5.2
- Author:
- Rossen Stoyanchev
Field Summary
Fields inherited from interface org.springframework.messaging.rsocket.MetadataExtractor
ROUTE_KEY
Constructor Summary
Constructors Constructor Description DefaultMetadataExtractor(List<Decoder<?>> decoders)
Constructor with list of decoders for de-serializing metadata entries.DefaultMetadataExtractor(Decoder<?>... decoders)
Constructor with decoders for de-serializing metadata entries.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Object>
extract(io.rsocket.Payload payload, MimeType metadataMimeType)
Extract a map of values from the givenPayload
metadata.List<? extends Decoder<?>>
getDecoders()
Return a read-only list with the configured decoders.<T> void
metadataToExtract(MimeType mimeType, Class<T> targetType, BiConsumer<T,Map<String,Object>> mapper)
Variant ofMetadataExtractorRegistry.metadataToExtract(MimeType, Class, String)
that allows custom logic to be used to map the decoded value to any number of values in the output map.<T> void
metadataToExtract(MimeType mimeType, ParameterizedTypeReference<T> type, BiConsumer<T,Map<String,Object>> mapper)
Variant ofMetadataExtractorRegistry.metadataToExtract(MimeType, Class, BiConsumer)
that acceptsParameterizedTypeReference
instead ofClass
for specifying a target type with generic parameters.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.messaging.rsocket.MetadataExtractorRegistry
metadataToExtract, metadataToExtract
Constructor Detail
DefaultMetadataExtractor
public DefaultMetadataExtractor(Decoder<?>... decoders)
Constructor with decoders for de-serializing metadata entries.
DefaultMetadataExtractor
public DefaultMetadataExtractor(List<Decoder<?>> decoders)
Constructor with list of decoders for de-serializing metadata entries.
Method Detail
getDecoders
public List<? extends Decoder<?>> getDecoders()
Return a read-only list with the configured decoders.
metadataToExtract
public <T> void metadataToExtract(MimeType mimeType, Class<T> targetType, BiConsumer<T,Map<String,Object>> mapper)
Description copied from interface:MetadataExtractorRegistry
Variant ofMetadataExtractorRegistry.metadataToExtract(MimeType, Class, String)
that allows custom logic to be used to map the decoded value to any number of values in the output map.- Specified by:
metadataToExtract
in interfaceMetadataExtractorRegistry
- Type Parameters:
T
- the target value type- Parameters:
mimeType
- the mime type of metadata entries to extracttargetType
- the target value type to decode tomapper
- custom logic to add the decoded value to the output map
metadataToExtract
public <T> void metadataToExtract(MimeType mimeType, ParameterizedTypeReference<T> type, BiConsumer<T,Map<String,Object>> mapper)
Description copied from interface:MetadataExtractorRegistry
Variant ofMetadataExtractorRegistry.metadataToExtract(MimeType, Class, BiConsumer)
that acceptsParameterizedTypeReference
instead ofClass
for specifying a target type with generic parameters.- Specified by:
metadataToExtract
in interfaceMetadataExtractorRegistry
- Type Parameters:
T
- the target value type- Parameters:
mimeType
- the mime type of metadata entries to extracttype
- the target value type to decode tomapper
- custom logic to add the decoded value to the output map
extract
public Map<String,Object> extract(io.rsocket.Payload payload, MimeType metadataMimeType)
Description copied from interface:MetadataExtractor
Extract a map of values from the givenPayload
metadata. The Payload "route", if present, should be saved underMetadataExtractor.ROUTE_KEY
.- Specified by:
extract
in interfaceMetadataExtractor
- Parameters:
payload
- the payload whose metadata should be readmetadataMimeType
- the metadata MimeType for the connection.- Returns:
- name values pairs extracted from the metadata