You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2009/01/26 20:57:41 UTC

svn commit: r737805 - in /cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline: AbstractPipeline.java AsyncCachePipeline.java CachingPipeline.java NonCachingPipeline.java Pipeline.java

Author: cziegeler
Date: Mon Jan 26 19:57:41 2009
New Revision: 737805

URL: http://svn.apache.org/viewvc?rev=737805&view=rev
Log:
COCOON3-14 : Add support for generics to a pipeline.

Modified:
    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/AsyncCachePipeline.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/NonCachingPipeline.java
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/Pipeline.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=737805&r1=737804&r2=737805&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 Mon Jan 26 19:57:41 2009
@@ -35,9 +35,9 @@
 /**
  * Basic pipeline implementation that collects the {@link PipelineComponent}s and connects them with each other.
  */
-public abstract class AbstractPipeline implements Pipeline {
+public abstract class AbstractPipeline<T extends PipelineComponent> implements Pipeline<T> {
 
-    private final LinkedList<PipelineComponent> components = new LinkedList<PipelineComponent>();
+    private final LinkedList<T> components = new LinkedList<T>();
 
     private final Log logger = LogFactory.getLog(this.getClass());
 
@@ -45,10 +45,10 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.pipeline.Pipeline#addComponent(org.apache.cocoon.pipeline.component.PipelineComponent)
      */
-    public void addComponent(PipelineComponent pipelineComponent) {
+    public void addComponent(T pipelineComponent) {
         if (this.setupDone) {
             throw new SetupException(new IllegalStateException(
                     "Pass all pipeline components to the pipeline before calling this method."));
@@ -63,7 +63,7 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.pipeline.Pipeline#execute()
      */
     public void execute() throws Exception {
@@ -77,7 +77,7 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.pipeline.Pipeline#getContentType()
      */
     public String getContentType() {
@@ -91,7 +91,7 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.pipeline.Pipeline#setConfiguration(java.util.Map)
      */
     public void setConfiguration(Map<String, ? extends Object> parameters) {
@@ -100,7 +100,7 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.pipeline.Pipeline#setup(java.io.OutputStream, java.util.Map)
      */
     public void setup(OutputStream outputStream) {
@@ -109,7 +109,7 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.pipeline.Pipeline#setup(java.io.OutputStream, java.util.Map)
      */
     public void setup(OutputStream outputStream, Map<String, Object> parameters) {
@@ -126,7 +126,7 @@
         return StringRepresentation.buildString(this, "components=" + this.getComponents());
     }
 
-    protected LinkedList<PipelineComponent> getComponents() {
+    protected LinkedList<T> getComponents() {
         return this.components;
     }
 
@@ -177,7 +177,7 @@
         first.setup(parameters);
 
         // next component to link is the second in the list
-        for (ListIterator<PipelineComponent> i = this.components.listIterator(1); i.hasNext();) {
+        for (ListIterator<T> i = this.components.listIterator(1); i.hasNext();) {
             // link the current with the next component
             PipelineComponent nextComponent = i.next();
             this.linkComponents(currentComponent, nextComponent);

Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AsyncCachePipeline.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AsyncCachePipeline.java?rev=737805&r1=737804&r2=737805&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AsyncCachePipeline.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AsyncCachePipeline.java Mon Jan 26 19:57:41 2009
@@ -25,6 +25,7 @@
 import org.apache.cocoon.pipeline.caching.CacheRefreshManager;
 import org.apache.cocoon.pipeline.caching.CacheValue;
 import org.apache.cocoon.pipeline.caching.CompleteCacheValue;
+import org.apache.cocoon.pipeline.component.PipelineComponent;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -36,7 +37,7 @@
  * out-dated result is returned. If this is out of question for a use case, the {@link CachingPipeline} has to be used.
  * </p>
  */
-public class AsyncCachePipeline extends CachingPipeline implements CacheRefreshJob {
+public class AsyncCachePipeline<T extends PipelineComponent> extends CachingPipeline<T> implements CacheRefreshJob {
 
     private final Log logger = LogFactory.getLog(this.getClass());
 
@@ -47,7 +48,7 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.pipeline.CachingPipeline#execute()
      */
     @Override
@@ -92,7 +93,7 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.pipeline.caching.CacheRefreshJob#refresh(org.apache.cocoon.pipeline.caching.CacheKey)
      */
     public void refresh(CacheKey cacheKey) {

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=737805&r1=737804&r2=737805&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 Mon Jan 26 19:57:41 2009
@@ -42,7 +42,7 @@
  * {@link CachingPipelineComponent}.
  * </p>
  */
-public class CachingPipeline extends AbstractPipeline {
+public class CachingPipeline<T extends PipelineComponent> extends AbstractPipeline<T> {
 
     protected CacheKey cacheKey;
 
@@ -139,7 +139,7 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.pipeline.AbstractPipeline#setConfiguration(java.util.Map)
      */
     @Override

Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/NonCachingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/NonCachingPipeline.java?rev=737805&r1=737804&r2=737805&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/NonCachingPipeline.java (original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/NonCachingPipeline.java Mon Jan 26 19:57:41 2009
@@ -18,9 +18,11 @@
  */
 package org.apache.cocoon.pipeline;
 
+import org.apache.cocoon.pipeline.component.PipelineComponent;
+
 /**
  * This {@link Pipeline} doesn't support caching at all. Whenever it is used, it will produce a fresh result.
  */
-public class NonCachingPipeline extends AbstractPipeline {
+public class NonCachingPipeline<T extends PipelineComponent> extends AbstractPipeline<T> {
 
 }

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=737805&r1=737804&r2=737805&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 Mon Jan 26 19:57:41 2009
@@ -35,17 +35,17 @@
  * 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(OutputStream, Map)} method.
  * </p>
- * 
+ *
  * <p>
  * A pipeline works based on two fundamental concepts:
- * 
+ *
  * <ul>
  * <li>The first component of a pipeline is of type {@link Starter}. The last component is of type {@link Finisher}.
  * </li>
  * <li>In order to link components with each other, the first has to be a {@link Producer}, the latter
  * {@link Consumer}. </li>
  * </ul>
- * 
+ *
  * <p>
  * When the pipeline links the components, it merely checks whether the above mentioned interfaces are present. So the
  * pipeline does not know about the specific capabilities or the compatibility of the components. It is the
@@ -55,33 +55,33 @@
  * according to the actual {@link Consumer}.
  * </p>
  */
-public interface Pipeline {
+public interface Pipeline<T extends PipelineComponent>{
 
     /**
      * Add a {@link PipelineComponent} to the pipeline. The order of when the components are passed is significant.
-     * 
+     *
      * @param pipelineComponent The {@link PipelineComponent}.
      */
-    void addComponent(PipelineComponent pipelineComponent);
+    void addComponent(T pipelineComponent);
 
     /**
      * 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.
      */
     void execute() throws Exception;
 
     /**
-     * Get the mime-type {@link http://tools.ietf.org/html/rfc2046} of the content produced by the pipeline.
-     * 
+     * Get the mime-type {@linkref http://tools.ietf.org/html/rfc2046} of the content produced by the pipeline.
+     *
      * @return The mime-type of the content.
      */
     String getContentType();
 
     /**
      * Get the time of the last modification.
-     * 
+     *
      * @return The last modification date
      */
     long getLastModified();
@@ -89,14 +89,14 @@
     /**
      * 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.
      */