Carsten Ziegeler schrieb:
> Bertrand Delacretaz wrote:
>> On Wed, Jul 16, 2008 at 5:14 AM, Sylvain Wallez <sylvain@apache.org>
>> wrote:
>>
>>> ...Can't we just give the parameters they need
>>> individually to every pipeline component, thus allowing per-component
>>> strongly typed and well defined contracts?..
>>
>> I'm also catching up on this thread but I tend to agree with the above
>> suggestion, i.e. something like
>>
>> Transformer t = new XsltTransformer();
>> t.setXslt("cocoon:/mytransform.xsl");
>> t.setRequestParameters(request.getParameterMap());
>> ...
>>
> Ok, in this case you can't use "Transformer" as the class type. This
> would be:
> XsltTransformer t = ...
>
> Now, it seems that we are still mixing up things here. As I said, I'm
> not talking about configuration of the components. The stylesheet from
> above is a configuration.
> We're talking about information about the current environment for
> executing the already configured pipeline.
IIUC the request parameters in the above example would belong to the
execution environment, wouldn't they?
I'd imagine something like this:
public void parameterizeTransformers(Request req, Pipeline pipeline) {
for (Iterator i = pipeline.getTransformers().iterator(); … ) {
Transformer t = (Transformer) i.next();
if (t instanceof WebappXsltTransformer) {
WebappXsltTransformer xsltTr = (WebappXsltTransformer) t;
if (xsltTr.useRequestParameters()) {
xsltTr.setXsltParams(req.getParameterMap());
}
}
}
}
IMO passing the execution environment to a pipeline component depends
very much on the nature of the environment, and also on the nature of
the individual components. I'm not sure if it should be attempted to
find a generic API for this. Wouldn't it be sufficient to let the client
code handle this? I guess this is what Torsten and Jörg had in mind when
they suggested a callback mechanism:
public class ServletPipelineInvoker {
protected Pipeline createPipeline() {
Pipeline pipeline = new NonCachingPipeline();
pipeline.addListener(this);
return pipeline;
}
/**
* Called before pipeline execution.
* @see PipelineListener.contextualizePipeline(Pipeline)
*/
public void contextualizePipeline(Pipeline pipeline) {
parameterizeTransformers(this.request, pipeline);
}
}
-- Andreas
--
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01
|