Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 69783 invoked from network); 17 Jul 2008 15:58:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Jul 2008 15:58:38 -0000 Received: (qmail 93977 invoked by uid 500); 17 Jul 2008 15:58:36 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 93907 invoked by uid 500); 17 Jul 2008 15:58:36 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@cocoon.apache.org List-Id: Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 93896 invoked by uid 99); 17 Jul 2008 15:58:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jul 2008 08:58:36 -0700 X-ASF-Spam-Status: No, hits=1.6 required=10.0 tests=RCVD_IN_DNSWL_LOW,RCVD_NUMERIC_HELO,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ap-cocoon-dev@m.gmane.org designates 80.91.229.2 as permitted sender) Received: from [80.91.229.2] (HELO ciao.gmane.org) (80.91.229.2) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jul 2008 15:57:41 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1KJVri-0006n3-9d for dev@cocoon.apache.org; Thu, 17 Jul 2008 15:57:58 +0000 Received: from 130.60.224.71 ([130.60.224.71]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 17 Jul 2008 15:57:58 +0000 Received: from andreas by 130.60.224.71 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 17 Jul 2008 15:57:58 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: dev@cocoon.apache.org From: Andreas Hartmann Subject: Re: [Corona] PIpeline API Date: Thu, 17 Jul 2008 17:57:46 +0200 Lines: 102 Message-ID: References: <48775DFE.7020903@apache.org> <487A10D8.3050908@apache.org> <487B03F4.8050901@apache.org> <487B1E49.5050008@apache.org> <487C7B91.2040306@apache.org> <487C7F12.2070101@apache.org> <487CD15E.5090809@apache.org> <487DE613.60208@apache.org> <487E0355.8010803@apache.org> <487E12B6.2050807@apache.org> <487F55A2.3040108@apache.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 130.60.224.71 User-Agent: Thunderbird 2.0.0.14 (Macintosh/20080421) In-Reply-To: <487F55A2.3040108@apache.org> Sender: news X-Virus-Checked: Checked by ClamAV on apache.org Carsten Ziegeler schrieb: […] >> Client code inside a web application: >> >> public void parameterizeComponents(Request req, Pipeline pipeline) { >> for (Iterator i = pipeline.getComponents().iterator(); … ) { >> PipelineComponent c = (PipelineComponent) i.next(); >> if (c instanceof WebappPipelineComponent) { >> WebappPipelineComponent wpc = (…) c; >> wpc.setRequest(req); >> } >> } >> } >> >> The pipeline is executed in a specific environment. The actual >> pipeline object itself is oblivious of the environment information, but >> the pipeline components are directly dependent on the environment. > > Hmm, yes this would work, but :) this would make it harder to have a > reusable pipeline implementation that frees my application from passing > the information to the components. Does it make a big difference if the information is passed to the pipeline or to the components? To get rid of the boilerplate loop above, the visitor pattern could be used: public class Webapp implements PipelineEnvironment { public void preparePipelineForExecution() { // let the pipeline visit its components this.pipeline.setEnvironment(this); } /** * @see PipelineEnvironment.environmentalize(…) */ public void environmentalize(PipelineComponent c) { if (c instanceof WebappPipelineComponent) { WebappPipelineComponent wpc = (…) c; wpc.setRequest(req); } } } > Currently the app creates a map, passed it to the pipeline > implementation and this implementation passes the map on to the components. > With the approach above, I would need a custom pipeline implementation > to do this. Hmm, why would you need a custom pipeline implementation? Wouldn't this be generic enough: public class PipelineImpl implements Pipeline { public void setEnvironment(PipelineEnvironment env) { for (Iterator i = getComponents().iterator(); … ) { PipelineComponent c = (…) i.next(); env.environmentalize(c); } } } > Furthermore there might be a lot of marker interfaces to test. The marker interfaces wouldn't be generic, but application-specific, so there would only be one needed per application. I imagine to use application-specific wrappers for "standard" pipeline components, e.g. public class WebappXsltTransformerWrapper implements Transformer, WebappPipelineComponent { private XsltTransformer delegate; public void setRequest(Request req) { if (this.useRequestParams()) { this.delegate.setXsltParams(req.getParameterMap()); } } } In this case the application can provide a layer of classes to adapt the standard pipeline components to the application-specific environment. The marker interface check would allow to use other components as well - they just wouldn't be "environmentalized". -- Andreas -- Andreas Hartmann, CTO BeCompany GmbH http://www.becompany.ch Tel.: +41 (0) 43 818 57 01