public abstract class AbstractEncoderMethodReturnValueHandler extends Object implements HandlerMethodReturnValueHandler
Flux<DataBuffer>
through the configured Encoder
s.
Subclasses must implement the abstract method
handleEncodedContent(reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer>, org.springframework.core.MethodParameter, org.springframework.messaging.Message<?>)
to handle the resulting encoded content.
This handler should be ordered last since its supportsReturnType(org.springframework.core.MethodParameter)
returns true
for any method parameter type.
Modifier and Type | Field and Description |
---|---|
protected Log |
logger |
DATA_BUFFER_FACTORY_HEADER
Modifier | Constructor and Description |
---|---|
protected |
AbstractEncoderMethodReturnValueHandler(List<Encoder<?>> encoders,
ReactiveAdapterRegistry registry) |
Modifier and Type | Method and Description |
---|---|
ReactiveAdapterRegistry |
getAdapterRegistry()
The configured adapter registry.
|
List<Encoder<?>> |
getEncoders()
The configured encoders.
|
protected abstract reactor.core.publisher.Mono<Void> |
handleEncodedContent(reactor.core.publisher.Flux<DataBuffer> encodedContent,
MethodParameter returnType,
Message<?> message)
Subclasses implement this method to handle encoded values in some way
such as creating and sending messages.
|
protected abstract reactor.core.publisher.Mono<Void> |
handleNoContent(MethodParameter returnType,
Message<?> message)
Invoked for a
null return value, which could mean a void method
or method returning an async type parameterized by void. |
reactor.core.publisher.Mono<Void> |
handleReturnValue(Object returnValue,
MethodParameter returnType,
Message<?> message)
Handle the given return value.
|
boolean |
supportsReturnType(MethodParameter returnType)
Whether the given method return type is
supported by this handler.
|
protected final Log logger
protected AbstractEncoderMethodReturnValueHandler(List<Encoder<?>> encoders, ReactiveAdapterRegistry registry)
public ReactiveAdapterRegistry getAdapterRegistry()
public boolean supportsReturnType(MethodParameter returnType)
HandlerMethodReturnValueHandler
supportsReturnType
in interface HandlerMethodReturnValueHandler
returnType
- the method return type to checktrue
if this handler supports the supplied return type;
false
otherwisepublic reactor.core.publisher.Mono<Void> handleReturnValue(@Nullable Object returnValue, MethodParameter returnType, Message<?> message)
HandlerMethodReturnValueHandler
handleReturnValue
in interface HandlerMethodReturnValueHandler
returnValue
- the value returned from the handler methodreturnType
- the type of the return value. This type must have previously
been passed to HandlerMethodReturnValueHandler.supportsReturnType(MethodParameter)
and it must have returned true
.Mono<Void>
to indicate when handling is complete.protected abstract reactor.core.publisher.Mono<Void> handleEncodedContent(reactor.core.publisher.Flux<DataBuffer> encodedContent, MethodParameter returnType, Message<?> message)
encodedContent
- the encoded content; each DataBuffer
represents the fully-aggregated, encoded content for one value
(i.e. payload) returned from the HandlerMethod.returnType
- return type of the handler method that produced the datamessage
- the input message handled by the handler methodMono<Void>
for the handlingprotected abstract reactor.core.publisher.Mono<Void> handleNoContent(MethodParameter returnType, Message<?> message)
null
return value, which could mean a void method
or method returning an async type parameterized by void.returnType
- return type of the handler method that produced the datamessage
- the input message handled by the handler methodMono<Void>
for the handling