changeset 31:c4d85a8532d1

Artifact.out() is now called with an java.io.Outpustream instead of producing bytes. artifacts/trunk@77 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sat, 12 Sep 2009 10:45:28 +0000
parents 88972c6daa4f
children c2d53bd30ab8
files Changelog artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java artifact-database/src/main/java/de/intevation/artifactdatabase/rest/OutRepresentation.java artifacts/src/main/java/de/intevation/artifacts/Artifact.java
diffstat 5 files changed, 38 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/Changelog	Thu Sep 10 23:16:18 2009 +0000
+++ b/Changelog	Sat Sep 12 10:45:28 2009 +0000
@@ -1,3 +1,14 @@
+2009-09-12	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* artifacts/src/main/java/de/intevation/artifacts/Artifact.java(out):
+	out() is now called with an java.io.Outputstream to place
+	the output.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java,
+	artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java,
+	artifact-database/src/main/java/de/intevation/artifactdatabase/rest/OutRepresentation.java:
+	Adjusted.
+
 2009-09-11	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* artifact-database/doc/example-conf/conf.xml: Added
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Thu Sep 10 23:16:18 2009 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Sat Sep 12 10:45:28 2009 +0000
@@ -17,6 +17,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.ObjectOutputStream;
 import java.io.ObjectInputStream;
+import java.io.OutputStream;
 
 import java.util.zip.GZIPOutputStream;
 import java.util.zip.GZIPInputStream;
@@ -116,9 +117,15 @@
             }
         }
 
-        public byte [] out(Document format, Object context) {
+        public void out(
+            Document     format, 
+            OutputStream output,
+            Object       context
+        ) 
+        throws IOException
+        {
             try {
-                return original.out(format, context);
+                original.out(format, output, context);
             }
             finally {
                 touch(this);
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java	Thu Sep 10 23:16:18 2009 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java	Sat Sep 12 10:45:28 2009 +0000
@@ -7,6 +7,9 @@
 
 import org.apache.log4j.Logger;
 
+import java.io.IOException;
+import java.io.OutputStream;
+
 /**
  * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
  */
@@ -40,8 +43,13 @@
         return XMLUtils.newDocument();
     }
 
-    public byte [] out(Document format, Object context) {
-        return new byte[0];
+    public void out(
+        Document     format,
+        OutputStream out,
+        Object       context
+    )
+    throws IOException
+    {
     }
 
     public void setup(String identifier, ArtifactFactory factory, Object context) {
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/OutRepresentation.java	Thu Sep 10 23:16:18 2009 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/OutRepresentation.java	Sat Sep 12 10:45:28 2009 +0000
@@ -34,8 +34,7 @@
     }
 
     public void write(OutputStream outputStream) throws IOException {
-        byte [] bytes = artifact.out(document, context);
-        outputStream.write(bytes);
+        artifact.out(document, outputStream, context);
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
--- a/artifacts/src/main/java/de/intevation/artifacts/Artifact.java	Thu Sep 10 23:16:18 2009 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/Artifact.java	Sat Sep 12 10:45:28 2009 +0000
@@ -3,6 +3,8 @@
 import org.w3c.dom.Document;
 
 import java.io.Serializable;
+import java.io.OutputStream;
+import java.io.IOException;
 
 /**
  * Interface of the core component of the artifact system: <strong>The artifact</strong>.
@@ -76,9 +78,12 @@
      * Produce output from this artifact.
      * @param format Specifies the format of the output.
      * @param context The global context of the runtime system.
-     * @return a byte representation of the output.
      */
-    public byte [] out(Document format, Object context);
+    public void out(
+        Document     format,
+        OutputStream out, 
+        Object       context)
+    throws IOException;
 
     /**
      * When created by a factory this method is called to

http://dive4elements.wald.intevation.org