cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r655336 - in /cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline: ./ caching/ component/ util/
Date Sun, 11 May 2008 16:39:17 GMT
Author: reinhard
Date: Sun May 11 09:39:17 2008
New Revision: 655336

URL: http://svn.apache.org/viewvc?rev=655336&view=rev
Log:
. javadocs
. logging

Added:
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/util/
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/util/StringRepresentation.java
  (with props)
Modified:
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/AbstractPipeline.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/AsyncCachePipeline.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/CachingPipeline.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/NonCachingPipeline.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/Pipeline.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CacheRefreshJob.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CacheRefreshManager.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CacheRefreshManagerImpl.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CompleteCacheValue.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CompoundCacheKey.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/SimpleCacheKey.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/SimplePipelineCache.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/TimestampCacheKey.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/AbstractXMLProducer.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/CleaningTransformer.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/FileGenerator.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/XMLSerializer.java
    cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/XSLTTransformer.java

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/AbstractPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/AbstractPipeline.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/AbstractPipeline.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/AbstractPipeline.java
Sun May 11 09:39:17 2008
@@ -30,12 +30,20 @@
 import org.apache.cocoon.corona.pipeline.component.PipelineComponent;
 import org.apache.cocoon.corona.pipeline.component.Producer;
 import org.apache.cocoon.corona.pipeline.component.Starter;
-
+import org.apache.cocoon.corona.pipeline.util.StringRepresentation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Basic pipeline implementation that collects the {@link PipelineComponent}s and connects
them with each other.
+ */
 public abstract class AbstractPipeline implements Pipeline {
 
-    private List<Action> actions = new LinkedList<Action>();
+    private final Log logger = LogFactory.getLog(this.getClass());
+
+    private final List<Action> actions = new LinkedList<Action>();
 
-    private LinkedList<PipelineComponent> components = new LinkedList<PipelineComponent>();
+    private final LinkedList<PipelineComponent> components = new LinkedList<PipelineComponent>();
 
     /**
      * {@inheritDoc}
@@ -52,6 +60,9 @@
      * @see org.apache.cocoon.corona.pipeline.Pipeline#addComponent(org.apache.cocoon.corona.pipeline.component.PipelineComponent)
      */
     public void addComponent(PipelineComponent pipelineComponent) {
+        if (this.logger.isDebugEnabled()) {
+            this.logger.debug("Adding component " + pipelineComponent + " to pipeline ["
+ this + "].");
+        }
         this.components.add(pipelineComponent);
     }
 
@@ -68,8 +79,13 @@
         this.invokeStarter();
     }
 
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.apache.cocoon.corona.pipeline.Pipeline#getContentType()
+     */
     public String getContentType() {
-        Finisher last = getFinisher();
+        Finisher last = this.getFinisher();
         return last.getContentType();
     }
 
@@ -88,6 +104,10 @@
     }
 
     protected void invokeStarter() {
+        if (this.logger.isDebugEnabled()) {
+            this.logger.debug("Invoking first component of " + this);
+        }
+
         Starter starter = (Starter) this.components.getFirst();
         starter.execute();
     }
@@ -97,13 +117,17 @@
 
         // first component must be a Starter
         if (!(first instanceof Starter)) {
-            throw new IllegalStateException("Cannot execute pipeline, first pipeline component
is no starter");
+            String msg = "Cannot execute pipeline, first pipeline component is no starter";
+            this.logger.error(msg);
+            throw new IllegalStateException(msg);
         }
 
         // last component must be a Finisher
         PipelineComponent last = this.components.getLast();
         if (!(last instanceof Finisher)) {
-            throw new IllegalStateException("Cannot execute pipeline, last pipeline component
is no finisher");
+            String msg = "Cannot execute pipeline, last pipeline component is no finisher";
+            this.logger.error(msg);
+            throw new IllegalStateException(msg);
         }
 
         // now try to link the components, always two components at a time
@@ -127,17 +151,28 @@
     }
 
     private void linkComponents(PipelineComponent firstComponent, PipelineComponent secondComponent)
{
+        if (this.logger.isDebugEnabled()) {
+            this.logger.debug("Going to link the component " + firstComponent + " with "
+ secondComponent + ".");
+        }
+
         // first component must be a Producer
         if (!(firstComponent instanceof Producer)) {
-            throw new IllegalStateException("Cannot link components: First component is no
producer.");
+            String msg = "Cannot link components: First component (" + firstComponent + ")
is no producer.";
+            throw new IllegalStateException(msg);
         }
 
         // second component must be a Consumer
         if (!(secondComponent instanceof Consumer)) {
-            throw new IllegalStateException("Cannot link components: Second component is
no consumer.");
+            String msg = "Cannot link components: Second component (" + secondComponent +
") is no consumer.";
+            throw new IllegalStateException(msg);
         }
 
         // let the Producer accept the Consumer (the Producer might reject it)
         ((Producer) firstComponent).setConsumer((Consumer) secondComponent);
     }
+
+    @Override
+    public String toString() {
+        return StringRepresentation.buildString(this, "components=" + this.getComponents());
+    }
 }

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/AsyncCachePipeline.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/AsyncCachePipeline.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/AsyncCachePipeline.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/AsyncCachePipeline.java
Sun May 11 09:39:17 2008
@@ -28,9 +28,25 @@
 import org.apache.cocoon.corona.pipeline.caching.CacheValue;
 import org.apache.cocoon.corona.pipeline.caching.CachingOutputStream;
 import org.apache.cocoon.corona.pipeline.caching.CompleteCacheValue;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
+/**
+ * <p>
+ * This {@link Pipeline} basically works like the {@link CachingPipeline}. The only difference
is that when the the
+ * cached result isn't valid anymore, the refresh is done in a separate thread. This means
that the re-production of the
+ * result doesn't block the initial request. The disadvantage of this approach is that until
the result is being
+ * reproduced, an out-dated result is being 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 {
 
+    private final Log logger = LogFactory.getLog(this.getClass());
+
+    /**
+     * The component that does the refresh in a separate thread.
+     */
     private CacheRefreshManager cacheRefreshManager;
 
     /**
@@ -40,6 +56,10 @@
      */
     @Override
     public void execute(Map<String, Object> parameters, OutputStream outputStream)
throws Exception {
+        if (this.logger.isDebugEnabled()) {
+            this.logger.debug("Used cache: " + this.pipelineCache);
+        }
+
         this.invokeActions(parameters);
 
         // create a caching output stream to intercept the result
@@ -48,13 +68,20 @@
 
         // construct the current cache key
         CacheKey cacheKey = this.constructCacheKey();
+
         // check for a cached value first
         CacheValue cachedValue = this.getCachedValue(cacheKey);
         if (cachedValue != null) {
             // cached value found -> write it
+            if (this.logger.isDebugEnabled()) {
+                this.logger.debug("Write cache value to output stream: " + cachedValue);
+            }
             cachedValue.writeTo(outputStream);
 
             if (!cachedValue.isValid(cacheKey)) {
+                if (this.logger.isDebugEnabled()) {
+                    this.logger.debug("Cached value is not up to date. Delegating to " +
this.cacheRefreshManager);
+                }
                 // the cached value is not valid -> refresh the value
                 this.cacheRefreshManager.refreshCacheValue(cacheKey, this);
             }

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/CachingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/CachingPipeline.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/CachingPipeline.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/CachingPipeline.java
Sun May 11 09:39:17 2008
@@ -29,13 +29,27 @@
 import org.apache.cocoon.corona.pipeline.caching.PipelineCache;
 import org.apache.cocoon.corona.pipeline.component.CachingPipelineComponent;
 import org.apache.cocoon.corona.pipeline.component.PipelineComponent;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
+/**
+ * <p>
+ * A {@link Pipeline} implementation that returns a cached result if, and only if all its
components support caching. A
+ * {@link PipelineComponent} is cacheable if it implements the interface {@link CachingPipelineComponent}.
+ * </p>
+ */
 public class CachingPipeline extends AbstractPipeline {
 
-    private PipelineCache pipelineCache;
+    private final Log logger = LogFactory.getLog(this.getClass());
+
+    protected PipelineCache pipelineCache;
 
     @Override
     public void execute(Map<String, Object> parameters, OutputStream outputStream)
throws Exception {
+        if (this.logger.isDebugEnabled()) {
+            this.logger.debug("Used cache: " + this.pipelineCache);
+        }
+
         this.invokeActions(parameters);
 
         // create a caching output stream to intercept the result
@@ -44,10 +58,15 @@
 
         // construct the current cache key
         CacheKey cacheKey = this.constructCacheKey();
+
         // checked for a cached value first
         CacheValue cachedValue = this.getCachedValue(cacheKey);
         if (cachedValue != null && cachedValue.isValid(cacheKey)) {
             // cached value found
+            if (this.logger.isDebugEnabled()) {
+                this.logger.debug("Write cache value to output stream: " + cachedValue);
+            }
+
             cachedValue.writeTo(outputStream);
             return;
         }
@@ -65,16 +84,28 @@
 
     protected CacheKey constructCacheKey() {
         CompoundCacheKey result = new CompoundCacheKey();
+        if (this.logger.isDebugEnabled()) {
+            this.logger.debug("Creating " + result + ": ");
+        }
 
         for (PipelineComponent pipelineComponent : this.getComponents()) {
             if (pipelineComponent instanceof CachingPipelineComponent) {
                 CachingPipelineComponent cachablePipelineComponent = (CachingPipelineComponent)
pipelineComponent;
 
-                result.addCacheKey(cachablePipelineComponent.constructCacheKey());
+                CacheKey cacheKey = cachablePipelineComponent.constructCacheKey();
+                result.addCacheKey(cacheKey);
+                if (this.logger.isDebugEnabled()) {
+                    this.logger.debug("  ~ adding " + cacheKey + " for component " + pipelineComponent);
+                }
+
                 continue;
             }
 
             // component does not support caching
+            if (this.logger.isDebugEnabled()) {
+                this.logger.debug("  ~ no caching: " + pipelineComponent);
+                this.logger.debug("Stop construction a cache key");
+            }
             return null;
         }
 
@@ -86,11 +117,22 @@
             return null;
         }
 
-        return this.pipelineCache.get(cacheKey);
+        CacheValue cacheValue = this.pipelineCache.get(cacheKey);
+        if (this.logger.isDebugEnabled()) {
+            if (cacheValue != null) {
+                this.logger.debug("Retrieved content from cache: " + cacheValue);
+            } else {
+                this.logger.debug("No cache value available for " + cacheKey);
+            }
+        }
+        return cacheValue;
     }
 
     protected void setCachedValue(CacheKey cacheKey, CacheValue cacheValue) {
         if (cacheKey != null) {
+            if (this.logger.isDebugEnabled()) {
+                this.logger.debug("Putting result into pipeline cache: " + cacheValue + ")");
+            }
             this.pipelineCache.put(cacheKey, cacheValue);
         }
     }

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/NonCachingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/NonCachingPipeline.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/NonCachingPipeline.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/NonCachingPipeline.java
Sun May 11 09:39:17 2008
@@ -18,6 +18,9 @@
  */
 package org.apache.cocoon.corona.pipeline;
 
+/**
+ * This {@link Pipeline} doesn't support caching at all. Whenever it is used, it will produce
a fresh result.
+ */
 public class NonCachingPipeline extends AbstractPipeline {
 
 }

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/Pipeline.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/Pipeline.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/Pipeline.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/Pipeline.java
Sun May 11 09:39:17 2008
@@ -22,14 +22,57 @@
 import java.util.Map;
 
 import org.apache.cocoon.corona.pipeline.action.Action;
+import org.apache.cocoon.corona.pipeline.component.Consumer;
+import org.apache.cocoon.corona.pipeline.component.Finisher;
 import org.apache.cocoon.corona.pipeline.component.PipelineComponent;
+import org.apache.cocoon.corona.pipeline.component.Producer;
+import org.apache.cocoon.corona.pipeline.component.Starter;
 
+/**
+ * <p>
+ * A pipeline expects one or more {@link PipelineComponent}s that passed by using
+ * {@link #addComponent(PipelineComponent)}. Then these components linked with each other
in the order they were passed
+ * and the {@link #execute(Map, OutputStream)} method finally produces an {@link OutputStream}
as result.
+ * </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
+ * responsibility of the {@link Producer} to decide whether a specific {@link Consumer} can
be linked to it or not (that
+ * is, whether it can produce output in the desired format of the {@link Consumer} or not).
It is also conceivable that
+ * a {@link Producer} is capable of accepting different types of {@link Consumer}s and adjust
the output format
+ * according to the actual {@link Consumer}.
+ * </p>
+ */
 public interface Pipeline {
 
     void addAction(Action action);
 
+    /**
+     * 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);
 
+    /**
+     * After the pipeline has been prepared ({@link #addComponent(PipelineComponent)}, this
method can be invoked in
+     * order to produce the result.
+     * 
+     * @param parameters A {@link Map} of parameters that are available to all {@link PipelineComponent}s.
+     * @param outputStream The processing result.
+     * @throws Exception Any problem that might occur while processing the pipeline.
+     */
     void execute(Map<String, Object> parameters, OutputStream outputStream) throws
Exception;
 
     String getContentType();

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CacheRefreshJob.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CacheRefreshJob.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CacheRefreshJob.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CacheRefreshJob.java
Sun May 11 09:39:17 2008
@@ -18,7 +18,6 @@
  */
 package org.apache.cocoon.corona.pipeline.caching;
 
-
 public interface CacheRefreshJob {
 
     void refresh(CacheKey cacheKey);

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CacheRefreshManager.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CacheRefreshManager.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CacheRefreshManager.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CacheRefreshManager.java
Sun May 11 09:39:17 2008
@@ -18,7 +18,6 @@
  */
 package org.apache.cocoon.corona.pipeline.caching;
 
-
 public interface CacheRefreshManager {
 
     void refreshCacheValue(CacheKey cacheKey, CacheRefreshJob cacheRefreshJob);

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CacheRefreshManagerImpl.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CacheRefreshManagerImpl.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CacheRefreshManagerImpl.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CacheRefreshManagerImpl.java
Sun May 11 09:39:17 2008
@@ -24,10 +24,19 @@
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
+import org.apache.cocoon.corona.pipeline.util.StringRepresentation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 public class CacheRefreshManagerImpl implements CacheRefreshManager {
 
-    private ExecutorService executorService = Executors.newFixedThreadPool(50);
-    private List<CacheKey> pendingCacheKeys = Collections.synchronizedList(new LinkedList<CacheKey>());
+    private final Log logger = LogFactory.getLog(this.getClass());
+
+    private static final int threadPoolSize = 50;
+
+    private final ExecutorService executorService = Executors.newFixedThreadPool(threadPoolSize);
+
+    private final List<CacheKey> pendingCacheKeys = Collections.synchronizedList(new
LinkedList<CacheKey>());
 
     /**
      * {@inheritDoc}
@@ -38,6 +47,10 @@
     public void refreshCacheValue(CacheKey cacheKey, CacheRefreshJob cacheRefreshJob) {
         if (this.pendingCacheKeys.contains(cacheKey)) {
             // the refresh of this cache key is already scheduled
+            if (this.logger.isDebugEnabled()) {
+                this.logger.debug("Refreshing of this cache key is already scheduled: " +
cacheKey);
+            }
+
             return;
         }
 
@@ -46,6 +59,10 @@
     }
 
     protected void executeCacheRefreshJob(CacheRefreshJob cacheRefreshJob, CacheKey cacheKey)
{
+        if (this.logger.isDebugEnabled()) {
+            this.logger.debug("Execute cache refresh job for " + cacheRefreshJob);
+        }
+
         cacheRefreshJob.refresh(cacheKey);
         this.pendingCacheKeys.remove(cacheKey);
     }
@@ -64,4 +81,11 @@
             CacheRefreshManagerImpl.this.executeCacheRefreshJob(this.cacheRefreshJob, this.cacheKey);
         }
     }
+
+    @Override
+    public String toString() {
+        // TODO Auto-generated method stub
+        return StringRepresentation.buildString(this, "executerService=" + this.executorService,
"threadPoolSize="
+                + threadPoolSize);
+    }
 }

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CompleteCacheValue.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CompleteCacheValue.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CompleteCacheValue.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CompleteCacheValue.java
Sun May 11 09:39:17 2008
@@ -21,6 +21,8 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
+import org.apache.cocoon.corona.pipeline.util.StringRepresentation;
+
 public class CompleteCacheValue implements CacheValue {
 
     private final byte[] content;
@@ -50,4 +52,10 @@
     public void writeTo(OutputStream outputStream) throws IOException {
         outputStream.write(this.content);
     }
+
+    @Override
+    public String toString() {
+        return StringRepresentation.buildString(this, "content.length=" + this.content.length,
"cacheKey="
+                + this.cacheKey);
+    }
 }

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CompoundCacheKey.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CompoundCacheKey.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CompoundCacheKey.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/CompoundCacheKey.java
Sun May 11 09:39:17 2008
@@ -22,9 +22,15 @@
 import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.cocoon.corona.pipeline.util.StringRepresentation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 public class CompoundCacheKey implements CacheKey {
 
-    private List<CacheKey> cacheKeys = new LinkedList<CacheKey>();
+    private final Log logger = LogFactory.getLog(this.getClass());
+
+    private final List<CacheKey> cacheKeys = new LinkedList<CacheKey>();
 
     public void addCacheKey(CacheKey cacheKey) {
         this.cacheKeys.add(cacheKey);
@@ -32,6 +38,12 @@
 
     @Override
     public boolean equals(Object obj) {
+        if (this.logger.isDebugEnabled()) {
+            this.logger.debug("Comparing two cache keys: ");
+            this.logger.debug("  this=" + this);
+            this.logger.debug("  other=" + obj);
+        }
+
         if (!(obj instanceof CompoundCacheKey)) {
             return false;
         }
@@ -49,6 +61,11 @@
             CacheKey otherCacheKey = otherIterator.next();
 
             if (myCacheKey == null || !myCacheKey.equals(otherCacheKey)) {
+                if (this.logger.isDebugEnabled()) {
+                    this.logger.debug("Cache keys are not equal: ");
+                    this.logger.debug("  myCacheKey=" + myCacheKey);
+                    this.logger.debug("  otherCacheKey=" + otherCacheKey);
+                }
                 return false;
             }
         }
@@ -86,10 +103,21 @@
             CacheKey otherCacheKey = otherIterator.next();
 
             if (!myCacheKey.isValid(otherCacheKey)) {
+                if (this.logger.isDebugEnabled()) {
+                    this.logger.debug("Cache key is not valid: ");
+                    this.logger.debug("  myCacheKey=" + myCacheKey);
+                    this.logger.debug("  otherCacheKey=" + otherCacheKey);
+                }
+
                 return false;
             }
         }
 
         return true;
     }
+
+    @Override
+    public String toString() {
+        return StringRepresentation.buildString(this, "key=" + this.cacheKeys);
+    }
 }

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/SimpleCacheKey.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/SimpleCacheKey.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/SimpleCacheKey.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/SimpleCacheKey.java
Sun May 11 09:39:17 2008
@@ -18,6 +18,8 @@
  */
 package org.apache.cocoon.corona.pipeline.caching;
 
+import org.apache.cocoon.corona.pipeline.util.StringRepresentation;
+
 public class SimpleCacheKey implements CacheKey {
 
     @Override
@@ -33,4 +35,9 @@
     public boolean isValid(CacheKey cacheKey) {
         return true;
     }
+
+    @Override
+    public String toString() {
+        return StringRepresentation.buildString(this);
+    }
 }

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/SimplePipelineCache.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/SimplePipelineCache.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/SimplePipelineCache.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/SimplePipelineCache.java
Sun May 11 09:39:17 2008
@@ -21,9 +21,11 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.cocoon.corona.pipeline.util.StringRepresentation;
+
 public class SimplePipelineCache implements PipelineCache {
 
-    private Map<CacheKey, CacheValue> map = new HashMap<CacheKey, CacheValue>();
+    private final Map<CacheKey, CacheValue> map = new HashMap<CacheKey, CacheValue>();
 
     public CacheValue get(CacheKey pipelineCacheKey) {
         return this.map.get(pipelineCacheKey);
@@ -32,4 +34,9 @@
     public void put(CacheKey pipelineCacheKey, CacheValue pipelineCacheValue) {
         this.map.put(pipelineCacheKey, pipelineCacheValue);
     }
+
+    @Override
+    public String toString() {
+        return StringRepresentation.buildString(this);
+    }
 }

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/TimestampCacheKey.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/TimestampCacheKey.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/TimestampCacheKey.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/caching/TimestampCacheKey.java
Sun May 11 09:39:17 2008
@@ -19,6 +19,10 @@
 package org.apache.cocoon.corona.pipeline.caching;
 
 import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.cocoon.corona.pipeline.util.StringRepresentation;
 
 public class TimestampCacheKey implements CacheKey {
 
@@ -59,4 +63,11 @@
         TimestampCacheKey other = (TimestampCacheKey) cacheKey;
         return this.timestamp == other.timestamp;
     }
+
+    @Override
+    public String toString() {
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
+        return StringRepresentation.buildString(this, "url=" + this.url, "timestamp=" + this.timestamp
+ " ("
+                + dateFormat.format(new Date(this.timestamp)) + ")");
+    }
 }

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/AbstractXMLProducer.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/AbstractXMLProducer.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/AbstractXMLProducer.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/AbstractXMLProducer.java
Sun May 11 09:39:17 2008
@@ -20,6 +20,8 @@
 
 import java.util.Map;
 
+import org.apache.cocoon.corona.pipeline.util.StringRepresentation;
+
 public abstract class AbstractXMLProducer implements XMLProducer {
 
     private XMLConsumer xmlConsumer;
@@ -61,4 +63,8 @@
         this.xmlConsumer = xmlConsumer;
     }
 
+    @Override
+    public String toString() {
+        return StringRepresentation.buildString(this);
+    }
 }

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/CleaningTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/CleaningTransformer.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/CleaningTransformer.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/CleaningTransformer.java
Sun May 11 09:39:17 2008
@@ -18,10 +18,12 @@
  */
 package org.apache.cocoon.corona.pipeline.component;
 
+import org.apache.cocoon.corona.pipeline.caching.CacheKey;
+import org.apache.cocoon.corona.pipeline.caching.SimpleCacheKey;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 
-public class CleaningTransformer extends AbstractTransformer {
+public class CleaningTransformer extends AbstractTransformer implements CachingPipelineComponent
{
 
     private static final String EMPTY_NS = "";
 
@@ -92,4 +94,8 @@
         this.position = 0;
     }
 
+    public CacheKey constructCacheKey() {
+        return new SimpleCacheKey();
+    }
+
 }

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/FileGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/FileGenerator.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/FileGenerator.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/FileGenerator.java
Sun May 11 09:39:17 2008
@@ -26,6 +26,7 @@
 
 import org.apache.cocoon.corona.pipeline.caching.CacheKey;
 import org.apache.cocoon.corona.pipeline.caching.TimestampCacheKey;
+import org.apache.cocoon.corona.pipeline.util.StringRepresentation;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
 import org.xml.sax.helpers.XMLReaderFactory;
@@ -102,4 +103,9 @@
     public void setSource(URL source) {
         this.source = source;
     }
+
+    @Override
+    public String toString() {
+        return StringRepresentation.buildString(this, "source=" + this.source);
+    }
 }

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/XMLSerializer.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/XMLSerializer.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/XMLSerializer.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/XMLSerializer.java
Sun May 11 09:39:17 2008
@@ -30,13 +30,15 @@
 
 import org.apache.cocoon.corona.pipeline.caching.CacheKey;
 import org.apache.cocoon.corona.pipeline.caching.SimpleCacheKey;
+import org.apache.cocoon.corona.pipeline.util.StringRepresentation;
 import org.xml.sax.Attributes;
 import org.xml.sax.Locator;
 import org.xml.sax.SAXException;
 
 public class XMLSerializer implements XMLConsumer, Finisher, CachingPipelineComponent {
 
-    private static final SAXTransformerFactory SAX_TRANSFORMER_FACTORY = (SAXTransformerFactory)
TransformerFactory.newInstance();
+    private static final SAXTransformerFactory SAX_TRANSFORMER_FACTORY = (SAXTransformerFactory)
TransformerFactory
+            .newInstance();
 
     private String contentType;
     private Properties format = new Properties();
@@ -149,4 +151,9 @@
     public void startPrefixMapping(String prefix, String uri) throws SAXException {
         this.transformerHandler.startPrefixMapping(prefix, uri);
     }
+
+    @Override
+    public String toString() {
+        return StringRepresentation.buildString(this);
+    }
 }

Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/XSLTTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/XSLTTransformer.java?rev=655336&r1=655335&r2=655336&view=diff
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/XSLTTransformer.java
(original)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/component/XSLTTransformer.java
Sun May 11 09:39:17 2008
@@ -28,6 +28,7 @@
 import javax.xml.transform.sax.TemplatesHandler;
 import javax.xml.transform.sax.TransformerHandler;
 
+import org.apache.cocoon.corona.pipeline.util.StringRepresentation;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.xml.sax.InputSource;
@@ -94,7 +95,8 @@
 
         // Create transformer handler
         final TransformerHandler handler = transformerFactory.newTransformerHandler(templatesHandler.getTemplates());
-        handler.getTransformer().setErrorListener(new XSLTProcessorErrorListener(this.log,
this.source.toExternalForm()));
+        handler.getTransformer().setErrorListener(
+                new XSLTProcessorErrorListener(this.log, this.source.toExternalForm()));
         // TODO: apparently this is currently not needed
         // handler.getTransformer().setURIResolver(this);
 
@@ -118,4 +120,9 @@
 
         return result;
     }
+
+    @Override
+    public String toString() {
+        return StringRepresentation.buildString(this, "src=" + this.source);
+    }
 }

Added: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/util/StringRepresentation.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/util/StringRepresentation.java?rev=655336&view=auto
==============================================================================
--- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/util/StringRepresentation.java
(added)
+++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/util/StringRepresentation.java
Sun May 11 09:39:17 2008
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.corona.pipeline.util;
+
+/**
+ * Helper class to create the {@link String} for {@link Object#toString()}.
+ */
+public abstract class StringRepresentation {
+
+    public static String buildString(Object instance, String... additionalOutputStrings)
{
+        StringBuilder sb = new StringBuilder();
+        sb.append(instance.getClass().getSimpleName());
+        sb.append("(hashCode=");
+        sb.append(instance.hashCode());
+        if (additionalOutputStrings != null) {
+            for (String outputString : additionalOutputStrings) {
+                sb.append(" ").append(outputString);
+            }
+        }
+        sb.append(")");
+        return sb.toString();
+    }
+
+}

Propchange: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/util/StringRepresentation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/util/StringRepresentation.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/util/StringRepresentation.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message