Class PayloadMethodArgumentResolver
- java.lang.Object
- org.springframework.messaging.handler.annotation.reactive.PayloadMethodArgumentResolver
- All Implemented Interfaces:
HandlerMethodArgumentResolver
public class PayloadMethodArgumentResolver extends Object implements HandlerMethodArgumentResolver
A resolver to extract and decode the payload of a message using aDecoder, where the payload is expected to be aPublisherofDataBuffer.Validation is applied if the method argument is annotated with
@javax.validation.ValidorValidated. Validation failure results in anMethodArgumentNotValidException.This resolver should be ordered last if
useDefaultResolutionis set totruesince in that case it supports all types and does not require the presence ofPayload.- Since:
- 5.2
- Author:
- Rossen Stoyanchev
Constructor Summary
Constructors Constructor Description PayloadMethodArgumentResolver(List<? extends Decoder<?>> decoders, Validator validator, ReactiveAdapterRegistry registry, boolean useDefaultResolution)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReactiveAdapterRegistrygetAdapterRegistry()Return the configuredReactiveAdapterRegistry.List<Decoder<?>>getDecoders()Return a read-only list of the configured decoders.protected MimeTypegetMimeType(Message<?> message)Return the mime type for the content.ValidatorgetValidator()Return the configured validator, if any.booleanisUseDefaultResolution()Whether this resolver is configured to use default resolution, i.e.reactor.core.publisher.Mono<Object>resolveArgument(MethodParameter parameter, Message<?> message)Decode the content of the given message payload through a compatibleDecoder.booleansupportsParameter(MethodParameter parameter)Whether the given method parameter is supported by this resolver.
Constructor Detail
PayloadMethodArgumentResolver
public PayloadMethodArgumentResolver(List<? extends Decoder<?>> decoders, @Nullable Validator validator, @Nullable ReactiveAdapterRegistry registry, boolean useDefaultResolution)
Method Detail
getDecoders
public List<Decoder<?>> getDecoders()
Return a read-only list of the configured decoders.
getValidator
@Nullable public Validator getValidator()
Return the configured validator, if any.
getAdapterRegistry
public ReactiveAdapterRegistry getAdapterRegistry()
Return the configuredReactiveAdapterRegistry.
isUseDefaultResolution
public boolean isUseDefaultResolution()
Whether this resolver is configured to use default resolution, i.e. works for any argument type regardless of whether@Payloadis present or not.
supportsParameter
public boolean supportsParameter(MethodParameter parameter)
Description copied from interface:HandlerMethodArgumentResolverWhether the given method parameter is supported by this resolver.- Specified by:
supportsParameterin interfaceHandlerMethodArgumentResolver- Parameters:
parameter- the method parameter to check- Returns:
trueif this resolver supports the supplied parameter;falseotherwise
resolveArgument
public final reactor.core.publisher.Mono<Object> resolveArgument(MethodParameter parameter, Message<?> message)
Decode the content of the given message payload through a compatibleDecoder.Validation is applied if the method argument is annotated with
@javax.validation.ValidorValidated. Validation failure results in anMethodArgumentNotValidException.- Specified by:
resolveArgumentin interfaceHandlerMethodArgumentResolver- Parameters:
parameter- the target method argument that we are decoding tomessage- the message from which the content was extracted- Returns:
- a Mono with the result of argument resolution
- See Also:
extractContent(MethodParameter, Message),getMimeType(Message)
getMimeType
@Nullable protected MimeType getMimeType(Message<?> message)
Return the mime type for the content. By default this method checks theMessageHeaders.CONTENT_TYPEheader expecting to find aMimeTypevalue or a String to parse to aMimeType.- Parameters:
message- the input message