Class DefaultMetadataExtractor
java.lang.Object
org.springframework.messaging.rsocket.DefaultMetadataExtractor
- All Implemented Interfaces:
MetadataExtractor, MetadataExtractorRegistry
public class DefaultMetadataExtractor
extends Object
implements MetadataExtractor, MetadataExtractorRegistry
Default
MetadataExtractor implementation that relies on
Decoders 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.
- since:
- 5.2
- Author:
- Rossen stoyanchev
-
Field summary
Fields inherited from interface MetadataExtractor
ROUTE_KEY -
Constructor summary
ConstructorsConstructorDescriptionDefaultMetadataExtractor(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
Modifier and TypeMethodDescriptionExtract a map of values from the givenPayloadmetadata.Return a read-only list with the configured decoders.<T> voidmetadataToExtract(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> voidmetadataToExtract(MimeType mimeType, ParameterizedTypeReference<T> type, BiConsumer<T, Map<string, Object>> mapper) Variant ofMetadataExtractorRegistry.metadataToExtract(MimeType, Class, BiConsumer)that acceptsParameterizedTypeReferenceinstead ofClassfor specifying a target type with generic parameters.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, tostring, wait, wait, waitMethods inherited from interface MetadataExtractorRegistry
metadataToExtract, metadataToExtract
-
Constructor Details
-
DefaultMetadataExtractor
Constructor with decoders for de-serializing metadata entries. -
DefaultMetadataExtractor
-
-
Method Details
-
getDecoders
-
metadataToExtract
public <T> void metadataToExtract(MimeType mimeType, Class<T> targetType, BiConsumer<T, Map<string, Object>> mapper) Description copied from interface: MetadataExtractorRegistryVariant 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 interface MetadataExtractorRegistry- 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: MetadataExtractorRegistryVariant ofMetadataExtractorRegistry.metadataToExtract(MimeType, Class, BiConsumer)that acceptsParameterizedTypeReferenceinstead ofClassfor specifying a target type with generic parameters.- specified by:
metadataToExtract in interface MetadataExtractorRegistry- 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: MetadataExtractorExtract a map of values from the givenPayloadmetadata. The Payload "route", if present, should be saved underMetadataExtractor.ROUTE_KEY.- specified by:
extract in interface MetadataExtractor- Parameters:
payload- the payload whose metadata should be readmetadataMimeType- the metadata MimeType for the connection.- Returns:
- name values pairs extracted from the metadata
-