ingo@100: /* ingo@100: * Copyright (c) 2010 by Intevation GmbH ingo@100: * ingo@100: * This program is free software under the LGPL (>=v2.1) ingo@100: * Read the file LGPL.txt coming with the software for details ingo@100: * or visit http://www.gnu.org/licenses/ if it does not exist. ingo@100: */ ingo@100: teichmann@475: package org.dive4elements.artifactdatabase.rest; sascha@29: teichmann@475: import org.dive4elements.artifacts.ArtifactDatabase.DeferredOutput; sascha@32: sascha@29: import java.io.IOException; sascha@32: import java.io.OutputStream; sascha@29: sascha@93: import org.restlet.data.MediaType; sascha@93: sascha@93: import org.restlet.representation.OutputRepresentation; sascha@93: sascha@29: /** sascha@88: * Special representation to serve the out()-outputs sascha@88: * via DeferredOutput efficently . sascha@77: * @author Sascha L. Teichmann sascha@29: */ sascha@29: public class OutRepresentation sascha@29: extends OutputRepresentation sascha@29: { sascha@88: /** sascha@88: * The deferred output fetched from ArtifactDatabase.out(). sascha@88: */ sascha@32: protected DeferredOutput out; sascha@29: sascha@88: /** sascha@88: * Constructor to create representation with a given MIME type and sascha@88: * a deferred output. sascha@88: * @param mediaType The MIME type of this representation. sascha@88: * @param out The deferred output from the ArtifactDatabase.out() call. sascha@88: */ sascha@32: public OutRepresentation(MediaType mediaType, DeferredOutput out) { sascha@29: super(mediaType); sascha@32: this.out = out; sascha@29: } sascha@29: sascha@88: /** sascha@88: * Overwrites the write(OutputStream) of OutRepresentation to serve sascha@88: * the data from the deferred output. sascha@88: * @param output the stream where to write the data into. sascha@88: * @throws IOException Thrown if an exception occurred while writing sascha@88: * the data to the output stream. sascha@88: */ sascha@32: public void write(OutputStream output) throws IOException { sascha@32: out.write(output); sascha@29: } sascha@29: } sascha@88: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :