Example usage for org.springframework.messaging.handler.invocation.reactive HandlerMethodReturnValueHandler DATA_BUFFER_FACTORY_HEADER

List of usage examples for org.springframework.messaging.handler.invocation.reactive HandlerMethodReturnValueHandler DATA_BUFFER_FACTORY_HEADER

Introduction

In this page you can find the example usage for org.springframework.messaging.handler.invocation.reactive HandlerMethodReturnValueHandler DATA_BUFFER_FACTORY_HEADER.

Prototype

String DATA_BUFFER_FACTORY_HEADER

To view the source code for org.springframework.messaging.handler.invocation.reactive HandlerMethodReturnValueHandler DATA_BUFFER_FACTORY_HEADER.

Click Source Link

Document

Header containing a DataBufferFactory for use in return value handling.

Usage

From source file:org.springframework.messaging.handler.invocation.reactive.AbstractEncoderMethodReturnValueHandler.java

@Override
public Mono<Void> handleReturnValue(@Nullable Object returnValue, MethodParameter returnType,
        Message<?> message) {/*  w  ww. ja  v  a  2 s  .  c o  m*/

    if (returnValue == null) {
        return handleNoContent(returnType, message);
    }

    DataBufferFactory bufferFactory = (DataBufferFactory) message.getHeaders().getOrDefault(
            HandlerMethodReturnValueHandler.DATA_BUFFER_FACTORY_HEADER, this.defaultBufferFactory);

    MimeType mimeType = (MimeType) message.getHeaders().get(MessageHeaders.CONTENT_TYPE);
    Flux<DataBuffer> encodedContent = encodeContent(returnValue, returnType, bufferFactory, mimeType,
            Collections.emptyMap());

    return new ChannelSendOperator<>(encodedContent,
            publisher -> handleEncodedContent(Flux.from(publisher), returnType, message));
}