svn commit: r1354095 - in /cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline: AbstractPipeline.java AsyncCachePipeline.java CachingPipeline.java Pipeline.java

[email protected]
Newsgroups gmane.text.xml.cocoon.cvs
Message-ID <[email protected]>
Author: reinhard
Date: Tue Jun 26 16:23:16 2012
New Revision: 1354095

URL: http://svn.apache.org/viewvc?rev=1354095&view=rev
Log:
remove 'throws Exception' from the pipeline API
get rid of some warnings

Modified:
    cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java
    cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AsyncCachePipeline.java
    cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java
    cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/Pipeline.java

Modified: cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java?rev=1354095&r1=1354094&r2=1354095&view=diff
==============================================================================
--- cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java (original)
+++ cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AbstractPipeline.java Tue Jun 26 16:23:16 2012
@@ -43,7 +43,7 @@ public abstract class AbstractPipeline<T
      */
     private static final Logger LOG =
             LoggerFactory.getLogger(AbstractPipeline.class);
-    
+
     private final LinkedList<T> components = new LinkedList<T>();
 
     private boolean setupDone;
@@ -53,6 +53,7 @@ public abstract class AbstractPipeline<T
      *
      * @see org.apache.cocoon.pipeline.Pipeline#addComponent(org.apache.cocoon.pipeline.component.PipelineComponent)
      */
+    @Override
     public void addComponent(T pipelineComponent) {
         if (this.setupDone) {
             throw new SetupException(new IllegalStateException(
@@ -71,7 +72,8 @@ public abstract class AbstractPipeline<T
      *
      * @see org.apache.cocoon.pipeline.Pipeline#execute()
      */
-    public void execute() throws Exception {
+    @Override
+    public void execute() {
         if (!this.setupDone) {
             throw new ProcessingException(new IllegalStateException(
                     "The pipeline wasn't setup correctly. Call #setup() first."));
@@ -85,10 +87,12 @@ public abstract class AbstractPipeline<T
      *
      * @see org.apache.cocoon.pipeline.Pipeline#getContentType()
      */
+    @Override
     public String getContentType() {
         return this.getFinisher().getContentType();
     }
 
+    @Override
     public long getLastModified() {
         return -1;
     }
@@ -98,6 +102,7 @@ public abstract class AbstractPipeline<T
      *
      * @see org.apache.cocoon.pipeline.Pipeline#setConfiguration(java.util.Map)
      */
+    @Override
     public void setConfiguration(Map<String, ? extends Object> parameters) {
         // do nothing
     }
@@ -108,6 +113,7 @@ public abstract class AbstractPipeline<T
      * @see org.apache.cocoon.pipeline.Pipeline#setup(java.io.OutputStream,
      *      java.util.Map)
      */
+    @Override
     public void setup(OutputStream outputStream) {
         this.setup(outputStream, null);
     }
@@ -118,6 +124,7 @@ public abstract class AbstractPipeline<T
      * @see org.apache.cocoon.pipeline.Pipeline#setup(java.io.OutputStream,
      *      java.util.Map)
      */
+    @Override
     public void setup(OutputStream outputStream, Map<String, Object> parameters) {
         if (outputStream == null) {
             throw new SetupException("An output stream must be passed.");

Modified: cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AsyncCachePipeline.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AsyncCachePipeline.java?rev=1354095&r1=1354094&r2=1354095&view=diff
==============================================================================
--- cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AsyncCachePipeline.java (original)
+++ cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/AsyncCachePipeline.java Tue Jun 26 16:23:16 2012
@@ -19,6 +19,7 @@
 package org.apache.cocoon.pipeline;
 
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 
 import org.apache.cocoon.pipeline.caching.CacheKey;
 import org.apache.cocoon.pipeline.caching.CacheRefreshJob;
@@ -39,11 +40,7 @@ import org.slf4j.LoggerFactory;
  */
 public class AsyncCachePipeline<T extends PipelineComponent> extends CachingPipeline<T> implements CacheRefreshJob {
 
-    /**
-     * Logger.
-     */
-    private static final Logger LOG =
-            LoggerFactory.getLogger(AsyncCachePipeline.class);
+    private static final Logger LOG = LoggerFactory.getLogger(AsyncCachePipeline.class);
 
     /**
      * The component that does the refresh in a separate thread.
@@ -52,33 +49,38 @@ public class AsyncCachePipeline<T extend
 
     /**
      * {@inheritDoc}
+     * @throws IOException
      *
      * @see org.apache.cocoon.pipeline.CachingPipeline#execute()
      */
     @Override
-    public void execute() throws Exception {
+    public void execute() {
         if (LOG.isDebugEnabled()) {
             LOG.debug("Used cache: " + this.cache);
         }
 
         // construct the current cache key
-        this.cacheKey = this.constructCacheKey();
+        this.pipelineCacheKey = this.constructCacheKey();
 
         // check for a cached value first
-        CacheValue cachedValue = this.getCachedValue(this.cacheKey);
+        CacheValue cachedValue = this.getCachedValue(this.pipelineCacheKey);
         if (cachedValue != null) {
             // cached value found -> write it
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Write cache value to output stream: " + cachedValue);
             }
-            cachedValue.writeTo(this.cachingOutputStream.getOutputStream());
+            try {
+                cachedValue.writeTo(this.cachingOutputStream.getOutputStream());
+            } catch (IOException e) {
+                throw new ProcessingException("Error while writing the cached value to the output stream.", e);
+            }
 
             if (!this.isCacheKeyValid(cachedValue)) {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("Cached value is not up to date. Delegating to " + this.cacheRefreshManager);
                 }
                 // the cached value is not valid -> refresh the value
-                this.cacheRefreshManager.refreshCacheValue(this.cacheKey, this);
+                this.cacheRefreshManager.refreshCacheValue(this.pipelineCacheKey, this);
             }
             // stop here
             return;
@@ -87,8 +89,8 @@ public class AsyncCachePipeline<T extend
         // no cached value (not even an invalid one) was present -> execute the pipeline
         this.invokeStarter();
         // cache the result
-        CompleteCacheValue cacheValue = new CompleteCacheValue(this.cachingOutputStream.getContent(), this.cacheKey);
-        this.setCachedValue(this.cacheKey, cacheValue);
+        CompleteCacheValue cacheValue = new CompleteCacheValue(this.cachingOutputStream.getContent(), this.pipelineCacheKey);
+        this.setCachedValue(this.pipelineCacheKey, cacheValue);
     }
 
     public CacheRefreshManager getCacheRefreshManager() {
@@ -100,6 +102,7 @@ public class AsyncCachePipeline<T extend
      *
      * @see org.apache.cocoon.pipeline.caching.CacheRefreshJob#refresh(org.apache.cocoon.pipeline.caching.CacheKey)
      */
+    @Override
     public void refresh(CacheKey cacheKey) {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         this.getFinisher().setOutputStream(baos);

Modified: cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java?rev=1354095&r1=1354094&r2=1354095&view=diff
==============================================================================
--- cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java (original)
+++ cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/CachingPipeline.java Tue Jun 26 16:23:16 2012
@@ -18,6 +18,7 @@
  */
 package org.apache.cocoon.pipeline;
 
+import java.io.IOException;
 import java.io.OutputStream;
 import java.io.Serializable;
 import java.util.Map;
@@ -43,15 +44,11 @@ import org.slf4j.LoggerFactory;
  */
 public class CachingPipeline<T extends PipelineComponent> extends AbstractPipeline<T> {
 
-    /**
-     * Logger.
-     */
-    private static final Logger LOG =
-            LoggerFactory.getLogger(CachingPipeline.class);
-    
+    private static final Logger LOG = LoggerFactory.getLogger(CachingPipeline.class);
+
     protected Cache cache;
 
-    protected CacheKey cacheKey;
+    protected CacheKey pipelineCacheKey;
 
     protected CachingOutputStream cachingOutputStream;
 
@@ -62,7 +59,7 @@ public class CachingPipeline<T extends P
      * Expires pipelines that have non-cacheable pipeline components require an
      * explicit cache key
      */
-    private Serializable expiresCacheKey;
+    private Serializable pipelineExpiresCacheKey;
 
     private String jmxGroupName;
 
@@ -95,7 +92,7 @@ public class CachingPipeline<T extends P
                             + "but expires caching is activated)");
                 }
 
-                return new ExpiresCacheKey(new InvalidCacheKey(this.expiresCacheKey), this.expires);
+                return new ExpiresCacheKey(new InvalidCacheKey(this.pipelineExpiresCacheKey), this.expires);
             }
 
             // component does not support caching
@@ -125,20 +122,24 @@ public class CachingPipeline<T extends P
     }
 
     @Override
-    public void execute() throws Exception {
+    public void execute() {
         if (LOG.isDebugEnabled()) {
             LOG.debug("Used cache: " + this.cache);
         }
 
         // checked for a cached value first
-        CacheValue cachedValue = this.getCachedValue(this.cacheKey);
+        CacheValue cachedValue = this.getCachedValue(this.pipelineCacheKey);
         if (this.isCacheKeyValid(cachedValue)) {
             // cached value found
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Write cache value to output stream: " + cachedValue);
             }
 
-            cachedValue.writeTo(this.cachingOutputStream.getOutputStream());
+            try {
+                cachedValue.writeTo(this.cachingOutputStream.getOutputStream());
+            } catch (IOException e) {
+                throw new ProcessingException("Error while writing the cached value to the output stream.", e);
+            }
             return;
         }
 
@@ -146,12 +147,12 @@ public class CachingPipeline<T extends P
         this.invokeStarter();
 
         // cache the result
-        CompleteCacheValue cacheValue = new CompleteCacheValue(this.cachingOutputStream.getContent(), this.cacheKey);
-        this.setCachedValue(this.cacheKey, cacheValue);
+        CompleteCacheValue cacheValue = new CompleteCacheValue(this.cachingOutputStream.getContent(), this.pipelineCacheKey);
+        this.setCachedValue(this.pipelineCacheKey, cacheValue);
     }
 
     public CacheKey getCacheKey() {
-        return this.cacheKey;
+        return this.pipelineCacheKey;
     }
 
     public String getExpires() {
@@ -160,11 +161,11 @@ public class CachingPipeline<T extends P
 
     @Override
     public long getLastModified() {
-        if (this.cacheKey == null) {
+        if (this.pipelineCacheKey == null) {
             return -1;
         }
 
-        return this.cacheKey.getLastModified();
+        return this.pipelineCacheKey.getLastModified();
     }
 
     public void setCache(Cache cache) {
@@ -179,7 +180,7 @@ public class CachingPipeline<T extends P
     @Override
     public void setConfiguration(Map<String, ? extends Object> parameters) {
         this.expires = (String) parameters.get("expires");
-        this.expiresCacheKey = (Serializable) parameters.get("expires-cache-key");
+        this.pipelineExpiresCacheKey = (Serializable) parameters.get("expires-cache-key");
         this.jmxGroupName = (String) parameters.get("jmx-group-name");
 
         super.setConfiguration(parameters);
@@ -190,7 +191,7 @@ public class CachingPipeline<T extends P
     }
 
     public void setExpiresCacheKey(Serializable expiresCacheKey) {
-        this.expiresCacheKey = expiresCacheKey;
+        this.pipelineExpiresCacheKey = expiresCacheKey;
     }
 
     @Override
@@ -200,7 +201,7 @@ public class CachingPipeline<T extends P
 
         super.setup(this.cachingOutputStream, parameters);
 
-        this.cacheKey = this.constructCacheKey();
+        this.pipelineCacheKey = this.constructCacheKey();
     }
 
     protected CacheValue getCachedValue(CacheKey cacheKey) {
@@ -225,7 +226,7 @@ public class CachingPipeline<T extends P
     }
 
     protected boolean isCacheKeyValid(CacheValue cachedValue) {
-        return cachedValue != null && cachedValue.isValid(this.cacheKey);
+        return cachedValue != null && cachedValue.isValid(this.pipelineCacheKey);
     }
 
     protected void setCachedValue(CacheKey cacheKey, CacheValue cacheValue) {

Modified: cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/Pipeline.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/Pipeline.java?rev=1354095&r1=1354094&r2=1354095&view=diff
==============================================================================
--- cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/Pipeline.java (original)
+++ cocoon/whiteboard/c3-pipeline-api-refactoring/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/Pipeline.java Tue Jun 26 16:23:16 2012
@@ -78,7 +78,7 @@ public interface Pipeline<T extends Pipe
      * @throws Exception Any problem that might occur while processing the
      *             pipeline.
      */
-    void execute() throws Exception;
+    void execute();
 
     /**
      * Get the mime-type {@linkref http://tools.ietf.org/html/rfc2046} of the
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.