cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r712563 - /cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java
Date Sun, 09 Nov 2008 21:50:46 GMT
Author: reinhard
Date: Sun Nov  9 13:50:46 2008
New Revision: 712563

URL: http://svn.apache.org/viewvc?rev=712563&view=rev
Log:
throw exceptions if a pipeline isn't used correctly

Modified:
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java

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=712563&r1=712562&r2=712563&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
Sun Nov  9 13:50:46 2008
@@ -41,15 +41,23 @@
 
     private final LinkedList<PipelineComponent> components = new LinkedList<PipelineComponent>();
 
+    private boolean setupDone;
+
     /**
      * {@inheritDoc}
      * 
      * @see org.apache.cocoon.pipeline.Pipeline#addComponent(org.apache.cocoon.pipeline.component.PipelineComponent)
      */
     public void addComponent(PipelineComponent pipelineComponent) {
+        if (this.setupDone) {
+            throw new SetupException(new IllegalStateException(
+                    "Pass all pipeline components to the pipeline before calling this method."));
+        }
+
         if (this.logger.isDebugEnabled()) {
             this.logger.debug("Adding component " + pipelineComponent + " to pipeline ["
+ this + "].");
         }
+
         this.components.add(pipelineComponent);
     }
 
@@ -59,7 +67,7 @@
      * @see org.apache.cocoon.pipeline.Pipeline#setup(java.io.OutputStream, java.util.Map)
      */
     public void setup(OutputStream outputStream) {
-        this.setupComponents(outputStream, null);
+        this.setup(outputStream, null);
     }
 
     /**
@@ -68,7 +76,12 @@
      * @see org.apache.cocoon.pipeline.Pipeline#setup(java.io.OutputStream, java.util.Map)
      */
     public void setup(OutputStream outputStream, Map<String, Object> parameters) {
+        if (outputStream == null) {
+            throw new SetupException("An output stream must be passed.");
+        }
+
         this.setupComponents(outputStream, parameters);
+        this.setupDone = true;
     }
 
     /**
@@ -77,6 +90,11 @@
      * @see org.apache.cocoon.pipeline.Pipeline#execute()
      */
     public void execute() throws Exception {
+        if (!this.setupDone) {
+            throw new ProcessingException(new IllegalStateException(
+                    "The pipeline wasn't setup correctly. Call #setup() first."));
+        }
+
         this.invokeStarter();
     }
 



Mime
View raw message