Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/org/dive4elements/artifactdatabase/rest/OutRepresentation.java @ 473:d0ac790a6c89 dive4elements-move
Moved directories to org.dive4elements
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 10:57:18 +0200 |
parents | artifact-database/src/main/java/de/intevation/artifactdatabase/rest/OutRepresentation.java@933bbc9fc11f |
children | 415df0fc4fa1 |
comparison
equal
deleted
inserted
replaced
472:783cc1b6b615 | 473:d0ac790a6c89 |
---|---|
1 /* | |
2 * Copyright (c) 2010 by Intevation GmbH | |
3 * | |
4 * This program is free software under the LGPL (>=v2.1) | |
5 * Read the file LGPL.txt coming with the software for details | |
6 * or visit http://www.gnu.org/licenses/ if it does not exist. | |
7 */ | |
8 | |
9 package de.intevation.artifactdatabase.rest; | |
10 | |
11 import de.intevation.artifacts.ArtifactDatabase.DeferredOutput; | |
12 | |
13 import java.io.IOException; | |
14 import java.io.OutputStream; | |
15 | |
16 import org.restlet.data.MediaType; | |
17 | |
18 import org.restlet.representation.OutputRepresentation; | |
19 | |
20 /** | |
21 * Special representation to serve the out()-outputs | |
22 * via DeferredOutput efficently . | |
23 * @author <a href="mailto:sascha.teichmann@intevation">Sascha L. Teichmann</a> | |
24 */ | |
25 public class OutRepresentation | |
26 extends OutputRepresentation | |
27 { | |
28 /** | |
29 * The deferred output fetched from ArtifactDatabase.out(). | |
30 */ | |
31 protected DeferredOutput out; | |
32 | |
33 /** | |
34 * Constructor to create representation with a given MIME type and | |
35 * a deferred output. | |
36 * @param mediaType The MIME type of this representation. | |
37 * @param out The deferred output from the ArtifactDatabase.out() call. | |
38 */ | |
39 public OutRepresentation(MediaType mediaType, DeferredOutput out) { | |
40 super(mediaType); | |
41 this.out = out; | |
42 } | |
43 | |
44 /** | |
45 * Overwrites the write(OutputStream) of OutRepresentation to serve | |
46 * the data from the deferred output. | |
47 * @param output the stream where to write the data into. | |
48 * @throws IOException Thrown if an exception occurred while writing | |
49 * the data to the output stream. | |
50 */ | |
51 public void write(OutputStream output) throws IOException { | |
52 out.write(output); | |
53 } | |
54 } | |
55 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |