类 PayloadMethodArgumentResolver
- java.lang.Object
- org.springframework.messaging.handler.annotation.reactive.PayloadMethodArgumentResolver
- 所有已实现的接口:
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 aPublisher
ofDataBuffer
.Validation is applied if the method argument is annotated with
@javax.validation.Valid
orValidated
. Validation failure results in anMethodArgumentNotValidException
.This resolver should be ordered last if
useDefaultResolution
is set totrue
since in that case it supports all types and does not require the presence ofPayload
.- 从以下版本开始:
- 5.2
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 PayloadMethodArgumentResolver(List<? extends Decoder<?>> decoders, Validator validator, ReactiveAdapterRegistry registry, boolean useDefaultResolution)
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 ReactiveAdapterRegistry
getAdapterRegistry()
Return the configuredReactiveAdapterRegistry
.List<Decoder<?>>
getDecoders()
Return a read-only list of the configured decoders.protected MimeType
getMimeType(Message<?> message)
Return the mime type for the content.Validator
getValidator()
Return the configured validator, if any.boolean
isUseDefaultResolution()
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
.boolean
supportsParameter(MethodParameter parameter)
Whether the given method parameter is supported by this resolver.
构造器详细资料
PayloadMethodArgumentResolver
public PayloadMethodArgumentResolver(List<? extends Decoder<?>> decoders, @Nullable Validator validator, @Nullable ReactiveAdapterRegistry registry, boolean useDefaultResolution)
方法详细资料
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@Payload
is present or not.
supportsParameter
public boolean supportsParameter(MethodParameter parameter)
从接口复制的说明:HandlerMethodArgumentResolver
Whether the given method parameter is supported by this resolver.- 指定者:
supportsParameter
在接口中HandlerMethodArgumentResolver
- 参数:
parameter
- the method parameter to check- 返回:
true
if this resolver supports the supplied parameter;false
otherwise
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.Valid
orValidated
. Validation failure results in anMethodArgumentNotValidException
.- 指定者:
resolveArgument
在接口中HandlerMethodArgumentResolver
- 参数:
parameter
- the target method argument that we are decoding tomessage
- the message from which the content was extracted- 返回:
- a Mono with the result of argument resolution
- 另请参阅:
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_TYPE
header expecting to find aMimeType
value or a String to parse to aMimeType
.- 参数:
message
- the input message