001 /*
002 * The contents of this file are subject to the terms
003 * of the Common Development and Distribution License
004 * (the "License"). You may not use this file except
005 * in compliance with the License.
006 *
007 * You can obtain a copy of the license at
008 * http://www.opensource.org/licenses/cddl1.php
009 * See the License for the specific language governing
010 * permissions and limitations under the License.
011 */
012
013 /*
014 * StreamingOutput.java
015 *
016 * Created on March 3, 2008, 4:00 PM
017 *
018 */
019
020 package javax.ws.rs.core;
021
022 import java.io.IOException;
023 import java.io.OutputStream;
024 import javax.ws.rs.WebApplicationException;
025
026 /**
027 * A type that may be used as a resource method return value or as the entity
028 * in a {@link Response} when the application wishes to stream the output.
029 * This is a lightweight alternative to a
030 * {@link javax.ws.rs.ext.MessageBodyWriter}.
031 *
032 * @see javax.ws.rs.ext.MessageBodyWriter
033 * @see javax.ws.rs.core.Response
034 */
035 public interface StreamingOutput {
036 /**
037 * Called to write the message body.
038 * @param output the OutputStream to write to.
039 * @throws java.io.IOException if an IO error is encountered
040 * @throws javax.ws.rs.WebApplicationException if a specific
041 * HTTP error response needs to be produced. Only effective if thrown prior
042 * to any bytes being written to output.
043 */
044 void write(OutputStream output) throws IOException, WebApplicationException;
045 }