001/* 002 * Copyright 2002-2015 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 */ 016package org.springframework.web.servlet.mvc.method.annotation; 017 018 019import java.io.IOException; 020import java.io.OutputStream; 021 022/** 023 * A controller method return value type for asynchronous request processing 024 * where the application can write directly to the response {@code OutputStream} 025 * without holding up the Servlet container thread. 026 * 027 * <p><strong>Note:</strong> when using this option it is highly recommended to 028 * configure explicitly the TaskExecutor used in Spring MVC for executing 029 * asynchronous requests. Both the MVC Java config and the MVC namespaces provide 030 * options to configure asynchronous handling. If not using those, an application 031 * can set the {@code taskExecutor} property of 032 * {@link org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter 033 * RequestMappingHandlerAdapter}. 034 * 035 * @author Rossen Stoyanchev 036 * @since 4.2 037 */ 038public interface StreamingResponseBody { 039 040 /** 041 * A callback for writing to the response body. 042 * @param outputStream the stream for the response body 043 * @throws IOException an exception while writing 044 */ 045 void writeTo(OutputStream outputStream) throws IOException; 046 047}