From cvs-return-33430-apmail-cocoon-cvs-archive=cocoon.apache.org@cocoon.apache.org Tue Jul 15 10:21:54 2008 Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 21502 invoked from network); 15 Jul 2008 10:21:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Jul 2008 10:21:53 -0000 Received: (qmail 74286 invoked by uid 500); 15 Jul 2008 10:21:53 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 74174 invoked by uid 500); 15 Jul 2008 10:21:52 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 74165 invoked by uid 99); 15 Jul 2008 10:21:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Jul 2008 03:21:52 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Jul 2008 10:21:07 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BB7BD2388A04; Tue, 15 Jul 2008 03:21:01 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r676859 - in /cocoon/whiteboard/corona/trunk: corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/ corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/action/ corona-pipeline/src/main/java/org/apache/cocoon/corona/pi... Date: Tue, 15 Jul 2008 10:21:00 -0000 To: cvs@cocoon.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080715102101.BB7BD2388A04@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: cziegeler Date: Tue Jul 15 03:20:59 2008 New Revision: 676859 URL: http://svn.apache.org/viewvc?rev=676859&view=rev Log: Separate setup and execution in pipeline and action interface. Removed: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/action/ 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/Pipeline.java cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/util/StringTransformation.java cocoon/whiteboard/corona/trunk/corona-pipeline/src/test/java/org/apache/cocoon/corona/pipeline/PipelineTest.java cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/InvocationImpl.java cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/action/Action.java cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/action/ErrorThrowingAction.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=676859&r1=676858&r2=676859&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 Tue Jul 15 03:20:59 2008 @@ -56,11 +56,19 @@ /** * {@inheritDoc} * - * @see org.apache.cocoon.corona.pipeline.Pipeline#execute(OutputStream) + * @see org.apache.cocoon.corona.pipeline.Pipeline#setup(java.util.Map, java.io.OutputStream) */ - public void execute(Map parameters, OutputStream outputStream) throws Exception { + public void setup(Map parameters, OutputStream outputStream) + throws Exception { this.setupComponents(parameters, outputStream); + } + /** + * {@inheritDoc} + * + * @see org.apache.cocoon.corona.pipeline.Pipeline#execute() + */ + public void execute() throws Exception { this.invokeStarter(); } 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=676859&r1=676858&r2=676859&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 Tue Jul 15 03:20:59 2008 @@ -19,14 +19,11 @@ package org.apache.cocoon.corona.pipeline; import java.io.ByteArrayOutputStream; -import java.io.OutputStream; -import java.util.Map; import org.apache.cocoon.corona.pipeline.caching.CacheKey; import org.apache.cocoon.corona.pipeline.caching.CacheRefreshJob; import org.apache.cocoon.corona.pipeline.caching.CacheRefreshManager; 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; @@ -52,18 +49,14 @@ /** * {@inheritDoc} * - * @see org.apache.cocoon.corona.pipeline.CachingPipeline#execute(java.util.Map, java.io.OutputStream) + * @see org.apache.cocoon.corona.pipeline.CachingPipeline#execute() */ @Override - public void execute(Map parameters, OutputStream outputStream) throws Exception { + public void execute() throws Exception { if (this.logger.isDebugEnabled()) { this.logger.debug("Used cache: " + this.pipelineCache); } - // create a caching output stream to intercept the result - CachingOutputStream cachingOutputStream = new CachingOutputStream(outputStream); - this.setupComponents(parameters, cachingOutputStream); - // construct the current cache key this.cacheKey = this.constructCacheKey(); @@ -74,7 +67,7 @@ if (this.logger.isDebugEnabled()) { this.logger.debug("Write cache value to output stream: " + cachedValue); } - cachedValue.writeTo(outputStream); + cachedValue.writeTo(this.cachingOutputStream.getOutputStream()); if (!cachedValue.isValid(this.cacheKey)) { if (this.logger.isDebugEnabled()) { 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=676859&r1=676858&r2=676859&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 Tue Jul 15 03:20:59 2008 @@ -46,16 +46,23 @@ protected CacheKey cacheKey; + protected CachingOutputStream cachingOutputStream; + + @Override + public void setup(Map parameters, OutputStream outputStream) + throws Exception { + // create a caching output stream to intercept the result + this.cachingOutputStream = new CachingOutputStream(outputStream); + + super.setup(parameters, cachingOutputStream); + } + @Override - public void execute(Map parameters, OutputStream outputStream) throws Exception { + public void execute() throws Exception { if (this.logger.isDebugEnabled()) { this.logger.debug("Used cache: " + this.pipelineCache); } - // create a caching output stream to intercept the result - CachingOutputStream cachingOutputStream = new CachingOutputStream(outputStream); - this.setupComponents(parameters, cachingOutputStream); - this.cacheKey = this.constructCacheKey(); // checked for a cached value first CacheValue cachedValue = this.getCachedValue(this.cacheKey); @@ -65,7 +72,7 @@ this.logger.debug("Write cache value to output stream: " + cachedValue); } - cachedValue.writeTo(outputStream); + cachedValue.writeTo(cachingOutputStream.getOutputStream()); return; } 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=676859&r1=676858&r2=676859&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 Tue Jul 15 03:20:59 2008 @@ -64,13 +64,20 @@ /** * After the pipeline has been prepared ({@link #addComponent(PipelineComponent)}, this method can be invoked in - * order to produce the result. + * order to setup and initialize the pipeline and its components. * * @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 setting up the pipeline. + */ + void setup(Map parameters, OutputStream outputStream) throws Exception; + + /** + * After the pipeline has been setup ({@link #setup(Map, OutputStream)}, this method can be invoked in + * order to produce the result. + * * @throws Exception Any problem that might occur while processing the pipeline. */ - void execute(Map parameters, OutputStream outputStream) throws Exception; + void execute() throws Exception; String getContentType(); Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/util/StringTransformation.java URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/util/StringTransformation.java?rev=676859&r1=676858&r2=676859&view=diff ============================================================================== --- cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/util/StringTransformation.java (original) +++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/main/java/org/apache/cocoon/corona/pipeline/util/StringTransformation.java Tue Jul 15 03:20:59 2008 @@ -32,19 +32,19 @@ * This class contains utility methods to transform an XML string by using XSLT. It hides all the details of the Java * TRaX API by using SAX pipeline components that are linked to each other. This means that the SAX events stream * through through the pipeline and are serialized at the end. - * + * * NOTE: Exception handling needs to be discussed and will probably change. */ public abstract class StringTransformation { /** * Transform an XML string by using XSLT. - * + * * @param xmlString The String to be transformed. * @param xsltUrls The {@link URL}s of all XSLT stylesheets that are used in the order they are passed to transform * the passed XML string. * @return The transformed result as {@link String}. - * + * * @throws Exception */ public static String transform(String xmlString, URL... xsltUrls) throws Exception { @@ -53,7 +53,7 @@ /** * Transform an XML string by using XSLT. This method also allows passing parameters to the stylesheets. - * + * * @param xmlString The String to be transformed. * @param xsltParameters Parameters that are available in all XSLT stylesheets. * @param xsltUrls The {@link URL}s of all XSLT stylesheets that are used in the order they are passed to transform @@ -68,7 +68,7 @@ /** * Transform an XML string by using XSLT. This method allows defining the output properties. - * + * * @param xmlString The String to be transformed. * @param outputProperties XML output properties. See {@link http://www.w3.org/TR/xslt#output}. * @param xsltUrls The {@link URL}s of all XSLT stylesheets that are used in the order they are passed to transform @@ -83,7 +83,7 @@ /** * Transform an XML string by using XSLT. This method allows defining the output properties and also allows passing * parameters to the stylesheets. - * + * * @param xmlString The String to be transformed. * @param xsltParameters Parameters that are available in all XSLT stylesheets. * @param outputProperties XML output properties. See {@link http://www.w3.org/TR/xslt#output}. @@ -101,7 +101,7 @@ /** * Transform an XML string by using XSLT and write the result into an {@link OutputStream}. - * + * * @param xmlString The String to be transformed. * @param outputStream The result is written into this {@link OutputStream}. * @param xsltUrls The {@link URL}s of all XSLT stylesheets that are used in the order they are passed to transform @@ -115,7 +115,7 @@ /** * Transform an XML string by using XSLT and write the result into an {@link OutputStream}. This method also allows * passing parameters to the stylesheets. - * + * * @param xmlString The String to be transformed. * @param outputStream The result is written into this {@link OutputStream}. * @param xsltParameters Parameters that are available in all XSLT stylesheets. @@ -131,7 +131,7 @@ /** * Transform an XML string by using XSLT and write the result into an {@link OutputStream}. This method allows * defining the output properties. - * + * * @param xmlString The String to be transformed. * @param outputStream The result is written into this {@link OutputStream}. * @param outputProperties XML output properties. See {@link http://www.w3.org/TR/xslt#output}. @@ -146,14 +146,14 @@ /** * Transform an XML string and write the result into an {@link OutputStream}. - * + * * @param xmlString The String to be transformed. * @param xsltParameters Parameters that are available in all XSLT stylesheets. * @param outputProperties XML output properties. See {@link http://www.w3.org/TR/xslt#output}. * @param outputStream The result is written into this {@link OutputStream}. * @param xsltUrls The {@link URL}s of all XSLT stylesheets that are used in the order they are passed to transform * the passed XML string. - * + * * @throws Exception */ public static void transform(String xmlString, Map xsltParameters, Properties outputProperties, @@ -173,6 +173,7 @@ xmlSerializer.init(); pipeline.addComponent(xmlSerializer); - pipeline.execute(null, outputStream); + pipeline.setup(null, outputStream); + pipeline.execute(); } } \ No newline at end of file Modified: cocoon/whiteboard/corona/trunk/corona-pipeline/src/test/java/org/apache/cocoon/corona/pipeline/PipelineTest.java URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-pipeline/src/test/java/org/apache/cocoon/corona/pipeline/PipelineTest.java?rev=676859&r1=676858&r2=676859&view=diff ============================================================================== --- cocoon/whiteboard/corona/trunk/corona-pipeline/src/test/java/org/apache/cocoon/corona/pipeline/PipelineTest.java (original) +++ cocoon/whiteboard/corona/trunk/corona-pipeline/src/test/java/org/apache/cocoon/corona/pipeline/PipelineTest.java Tue Jul 15 03:20:59 2008 @@ -37,7 +37,8 @@ Pipeline pipeline = new NonCachingPipeline(); pipeline.addComponent(new FileReaderComponent(PipelineTest.class.getResource("/test.xml"))); - pipeline.execute(null, System.out); + pipeline.setup(null, System.out); + pipeline.execute(); } public void testStringTransformation() throws Exception { Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/InvocationImpl.java URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/InvocationImpl.java?rev=676859&r1=676858&r2=676859&view=diff ============================================================================== --- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/InvocationImpl.java (original) +++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/InvocationImpl.java Tue Jul 15 03:20:59 2008 @@ -103,10 +103,17 @@ throw new IllegalStateException("InvocationImpl has been executed without having a pipeline."); } + // first setup everything for(final Action action : this.actions) { - action.execute(this.parameters); + action.setup(this.parameters); } - this.pipeline.execute(this.parameters, this.outputStream); + this.pipeline.setup(this.parameters, this.outputStream); + + // then execute + for(final Action action : this.actions) { + action.execute(); + } + this.pipeline.execute(); } /** Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/action/Action.java URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/action/Action.java?rev=676859&r1=676858&r2=676859&view=diff ============================================================================== --- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/action/Action.java (original) +++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/action/Action.java Tue Jul 15 03:20:59 2008 @@ -23,5 +23,7 @@ public interface Action { - void execute(Map parameters) throws Exception; + void setup(Map parameters) throws Exception; + + void execute() throws Exception; } Modified: cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/action/ErrorThrowingAction.java URL: http://svn.apache.org/viewvc/cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/action/ErrorThrowingAction.java?rev=676859&r1=676858&r2=676859&view=diff ============================================================================== --- cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/action/ErrorThrowingAction.java (original) +++ cocoon/whiteboard/corona/trunk/corona-sitemap/src/main/java/org/apache/cocoon/corona/sitemap/action/ErrorThrowingAction.java Tue Jul 15 03:20:59 2008 @@ -22,12 +22,22 @@ public class ErrorThrowingAction implements Action { + + /** + * {@inheritDoc} + * + * @see org.apache.cocoon.corona.sitemap.action.Action#setup(java.util.Map) + */ + public void setup(Map parameters) throws Exception { + // nothing to do + } + /** * {@inheritDoc} * - * @see org.apache.cocoon.corona.sitemap.action.Action#execute(Map) + * @see org.apache.cocoon.corona.sitemap.action.Action#execute() */ - public void execute(Map parameters) throws Exception { + public void execute() throws Exception { throw new CustomException(); }