cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r697370 - in /cocoon/cocoon3/trunk: cocoon-docs/src/site/apt/ cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/ cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/ cocoon-pipeline/src/main/java/org/apache/cocoon/...
Date Sat, 20 Sep 2008 14:36:57 GMT
Author: reinhard
Date: Sat Sep 20 07:36:56 2008
New Revision: 697370

URL: http://svn.apache.org/viewvc?rev=697370&view=rev
Log:
allow pipeline setup without passing parameters

Modified:
    cocoon/cocoon3/trunk/cocoon-docs/src/site/apt/index.apt
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/Pipeline.java
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/XSLTTransformer.java
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/TransformationUtils.java
    cocoon/cocoon3/trunk/cocoon-pipeline/src/test/java/org/apache/cocoon/pipeline/PipelineTest.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java

Modified: cocoon/cocoon3/trunk/cocoon-docs/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-docs/src/site/apt/index.apt?rev=697370&r1=697369&r2=697370&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-docs/src/site/apt/index.apt (original)
+++ cocoon/cocoon3/trunk/cocoon-docs/src/site/apt/index.apt Sat Sep 20 07:36:56 2008
@@ -19,12 +19,12 @@
 +------------------------------------------+
 Pipeline pipeline = new NonCachingPipeline();
 pipeline.addComponent(new StringGenerator("<x></x>"));
-pipeline.addComponent(new XSLTTransformer(PipelineTest.class.getClassLoader().getResource("test1.xslt")));
-pipeline.addComponent(new XSLTTransformer(PipelineTest.class.getClassLoader().getResource("test2.xslt")));
+pipeline.addComponent(new XSLTTransformer(this.getClass().getResource("test1.xslt")));
+pipeline.addComponent(new XSLTTransformer(this.getClass().getResource("test2.xslt")));
 pipeline.addComponent(new XMLSerializer());
 
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
-pipeline.setup(null, baos);
+pipeline.setup(baos);
 pipeline.execute();
 +------------------------------------------+     
 

Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java?rev=697370&r1=697369&r2=697370&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java
Sat Sep 20 07:36:56 2008
@@ -56,10 +56,19 @@
     /**
      * {@inheritDoc}
      * 
-     * @see org.apache.cocoon.pipeline.Pipeline#setup(java.util.Map, java.io.OutputStream)
+     * @see org.apache.cocoon.pipeline.Pipeline#setup(java.io.OutputStream, java.util.Map)
      */
-    public void setup(Map<String, Object> parameters, OutputStream outputStream) {
-        this.setupComponents(parameters, outputStream);
+    public void setup(OutputStream outputStream) {
+        this.setupComponents(outputStream, null);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.apache.cocoon.pipeline.Pipeline#setup(java.io.OutputStream, java.util.Map)
+     */
+    public void setup(OutputStream outputStream, Map<String, Object> parameters) {
+        this.setupComponents(outputStream, parameters);
     }
 
     /**
@@ -108,7 +117,7 @@
         }
     }
 
-    protected void setupComponents(Map<String, Object> parameters, OutputStream outputStream)
{
+    protected void setupComponents(OutputStream outputStream, Map<String, Object> parameters)
{
         PipelineComponent first = this.components.getFirst();
 
         // first component must be a Starter

Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java?rev=697370&r1=697369&r2=697370&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java
Sat Sep 20 07:36:56 2008
@@ -49,11 +49,16 @@
     protected CachingOutputStream cachingOutputStream;
 
     @Override
-    public void setup(Map<String, Object> parameters, OutputStream outputStream) {
+    public void setup(OutputStream outputStream) {
+        this.setup(outputStream);
+    }
+
+    @Override
+    public void setup(OutputStream outputStream, Map<String, Object> parameters) {
         // create a caching output stream to intercept the result
         this.cachingOutputStream = new CachingOutputStream(outputStream);
 
-        super.setup(parameters, cachingOutputStream);
+        super.setup(this.cachingOutputStream, parameters);
     }
 
     @Override
@@ -71,7 +76,7 @@
                 this.logger.debug("Write cache value to output stream: " + cachedValue);
             }
 
-            cachedValue.writeTo(cachingOutputStream.getOutputStream());
+            cachedValue.writeTo(this.cachingOutputStream.getOutputStream());
             return;
         }
 
@@ -79,7 +84,9 @@
         this.invokeStarter();
 
         // cache the result
-        this.setCachedValue(this.cacheKey, new CompleteCacheValue(cachingOutputStream.getContent(),
this.cacheKey));
+        this
+                .setCachedValue(this.cacheKey, new CompleteCacheValue(this.cachingOutputStream.getContent(),
+                        this.cacheKey));
     }
 
     public void setPipelineCache(PipelineCache pipelineCache) {

Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/Pipeline.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/Pipeline.java?rev=697370&r1=697369&r2=697370&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/Pipeline.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/Pipeline.java
Sat Sep 20 07:36:56 2008
@@ -31,9 +31,9 @@
  * <p>
  * A pipeline expects one or more {@link PipelineComponent}s that passed by using
  * {@link #addComponent(PipelineComponent)}. Then these components get linked with each other
in the order they were
- * added. The {@link #setup(Map, OutputStream)} method, calls the setup method on all pipeline
components and assembles
+ * added. The {@link #setup(OutputStream, Map)} method, calls the setup method on all pipeline
components and assembles
  * the pipeline. Finally the {@link #execute()} method produces the result and writes it
to the {@link OutputStream}
- * which has been passed to the {@link #setup(Map, OutputStream)} method.
+ * which has been passed to the {@link #setup(OutputStream, Map)} method.
  * </p>
  * 
  * <p>
@@ -68,12 +68,20 @@
      * After the pipeline has been prepared ({@link #addComponent(PipelineComponent)}, this
method can be invoked in
      * order to setup and initialize the pipeline and its components.
      * 
+     * @param outputStream An {@link OutputStream} where the pipeline execution result is
written.
+     */
+    void setup(OutputStream outputStream);
+
+    /**
+     * The same as {@link #setup(OutputStream)} but also allows passing parameters to the
pipeline components.
+     * 
+     * @param outputStream An {@link OutputStream} where the pipeline execution result is
written.
      * @param parameters A {@link Map} of parameters that are available to all {@link PipelineComponent}s.
      */
-    void setup(Map<String, Object> parameters, OutputStream outputStream);
+    void setup(OutputStream outputStream, Map<String, Object> parameters);
 
     /**
-     * After the pipeline has been setup ({@link #setup(Map, OutputStream)}, this method
can be invoked in order to
+     * After the pipeline has been setup ({@link #setup(OutputStream, Map)}, this method
can be invoked in order to
      * produce the result.
      * 
      * @throws Exception Any problem that might occur while processing the pipeline.

Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/XSLTTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/XSLTTransformer.java?rev=697370&r1=697369&r2=697370&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/XSLTTransformer.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/component/sax/XSLTTransformer.java
Sat Sep 20 07:36:56 2008
@@ -46,12 +46,15 @@
     }
 
     public XSLTTransformer(URL source) {
-        super();
-        this.source = source;
+        this(source, null);
     }
 
     public XSLTTransformer(URL source, Map<String, Object> parameters) {
         super();
+        if (source == null) {
+            throw new IllegalArgumentException("The parameter 'source' mustn't be null.");
+        }
+
         this.parameters = parameters;
         this.source = source;
     }

Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/TransformationUtils.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/TransformationUtils.java?rev=697370&r1=697369&r2=697370&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/TransformationUtils.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/TransformationUtils.java
Sat Sep 20 07:36:56 2008
@@ -166,7 +166,7 @@
         }
         pipeline.addComponent(new XMLSerializer(outputProperties));
 
-        pipeline.setup(null, outputStream);
+        pipeline.setup(outputStream, null);
         pipeline.execute();
     }
 }
\ No newline at end of file

Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/test/java/org/apache/cocoon/pipeline/PipelineTest.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/test/java/org/apache/cocoon/pipeline/PipelineTest.java?rev=697370&r1=697369&r2=697370&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/test/java/org/apache/cocoon/pipeline/PipelineTest.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/test/java/org/apache/cocoon/pipeline/PipelineTest.java
Sat Sep 20 07:36:56 2008
@@ -22,8 +22,6 @@
 
 import junit.framework.TestCase;
 
-import org.apache.cocoon.pipeline.NonCachingPipeline;
-import org.apache.cocoon.pipeline.Pipeline;
 import org.apache.cocoon.pipeline.component.sax.FileReaderComponent;
 import org.apache.cocoon.pipeline.component.sax.StringGenerator;
 import org.apache.cocoon.pipeline.component.sax.XMLSerializer;
@@ -37,8 +35,8 @@
      */
     public void testPipelineWithReader() throws Exception {
         Pipeline pipeline = new NonCachingPipeline();
-        pipeline.addComponent(new FileReaderComponent(PipelineTest.class.getResource("/test.xml")));
-        pipeline.setup(null, System.out);
+        pipeline.addComponent(new FileReaderComponent(this.getClass().getResource("/test.xml")));
+        pipeline.setup(System.out);
         pipeline.execute();
     }
 
@@ -48,11 +46,11 @@
     public void testPipelineWithTransformer() throws Exception {
         Pipeline pipeline = new NonCachingPipeline();
         pipeline.addComponent(new StringGenerator("<x></x>"));
-        pipeline.addComponent(new XSLTTransformer(PipelineTest.class.getClassLoader().getResource("test.xslt")));
+        pipeline.addComponent(new XSLTTransformer(this.getClass().getResource("/test.xslt")));
         pipeline.addComponent(new XMLSerializer());
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        pipeline.setup(null, baos);
+        pipeline.setup(baos);
         pipeline.execute();
 
         Diff diff = new Diff("<?xml version=\"1.0\" encoding=\"UTF-8\"?><p></p>",
new String(baos.toByteArray()));

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java?rev=697370&r1=697369&r2=697370&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java
Sat Sep 20 07:36:56 2008
@@ -126,7 +126,7 @@
         for (final Action action : this.actions) {
             action.setup(this.parameters);
         }
-        this.pipeline.setup(this.parameters, this.outputStream);
+        this.pipeline.setup(this.outputStream, this.parameters);
 
         // then execute
         for (final Action action : this.actions) {



Mime
View raw message