public class DefaultMetadataExtractor extends Object implements MetadataExtractor, MetadataExtractorRegistry
MetadataExtractor
implementation that relies on
Decoder
s to deserialize the content of metadata entries.
By default only "message/x.rsocket.routing.v0""
is extracted and
saved under MetadataExtractor.ROUTE_KEY
. Use metadataToExtract
methods to specify other metadata mime types of interest to extract.
ROUTE_KEY
Constructor and Description |
---|
DefaultMetadataExtractor(Decoder<?>... decoders)
Constructor with decoders for de-serializing metadata entries.
|
DefaultMetadataExtractor(List<Decoder<?>> decoders)
Constructor with list of decoders for de-serializing metadata entries.
|
Modifier and Type | Method and Description |
---|---|
Map<String,Object> |
extract(io.rsocket.Payload payload,
MimeType metadataMimeType)
Extract a map of values from the given
Payload 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 of
MetadataExtractorRegistry.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 of
MetadataExtractorRegistry.metadataToExtract(MimeType, Class, BiConsumer) that
accepts ParameterizedTypeReference instead of Class for
specifying a target type with generic parameters. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
metadataToExtract, metadataToExtract
public DefaultMetadataExtractor(Decoder<?>... decoders)
public List<? extends Decoder<?>> getDecoders()
public <T> void metadataToExtract(MimeType mimeType, Class<T> targetType, BiConsumer<T,Map<String,Object>> mapper)
MetadataExtractorRegistry
MetadataExtractorRegistry.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.metadataToExtract
in interface MetadataExtractorRegistry
T
- the target value typemimeType
- 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 mappublic <T> void metadataToExtract(MimeType mimeType, ParameterizedTypeReference<T> type, BiConsumer<T,Map<String,Object>> mapper)
MetadataExtractorRegistry
MetadataExtractorRegistry.metadataToExtract(MimeType, Class, BiConsumer)
that
accepts ParameterizedTypeReference
instead of Class
for
specifying a target type with generic parameters.metadataToExtract
in interface MetadataExtractorRegistry
T
- the target value typemimeType
- 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 mappublic Map<String,Object> extract(io.rsocket.Payload payload, MimeType metadataMimeType)
MetadataExtractor
Payload
metadata.
The Payload "route", if present, should be saved under MetadataExtractor.ROUTE_KEY
.extract
in interface MetadataExtractor
payload
- the payload whose metadata should be readmetadataMimeType
- the metadata MimeType for the connection.