001/* 002 * Copyright 2002-2017 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.messaging.handler.invocation.reactive; 018 019import reactor.core.publisher.Mono; 020 021import org.springframework.core.MethodParameter; 022import org.springframework.lang.Nullable; 023import org.springframework.messaging.Message; 024 025/** 026 * Handle the return value from the invocation of an annotated {@link Message} 027 * handling method. 028 * 029 * @author Rossen Stoyanchev 030 * @since 5.2 031 */ 032public interface HandlerMethodReturnValueHandler { 033 034 /** Header containing a DataBufferFactory for use in return value handling. */ 035 String DATA_BUFFER_FACTORY_HEADER = "dataBufferFactory"; 036 037 038 /** 039 * Whether the given {@linkplain MethodParameter method return type} is 040 * supported by this handler. 041 * @param returnType the method return type to check 042 * @return {@code true} if this handler supports the supplied return type; 043 * {@code false} otherwise 044 */ 045 boolean supportsReturnType(MethodParameter returnType); 046 047 /** 048 * Handle the given return value. 049 * @param returnValue the value returned from the handler method 050 * @param returnType the type of the return value. This type must have previously 051 * been passed to {@link #supportsReturnType(MethodParameter)} 052 * and it must have returned {@code true}. 053 * @return {@code Mono<Void>} to indicate when handling is complete. 054 */ 055 Mono<Void> handleReturnValue(@Nullable Object returnValue, MethodParameter returnType, Message<?> message); 056 057}