You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Simone Tripodi <si...@apache.org> on 2011/07/06 14:43:33 UTC

Re: question regarding chainability of methods current API

Hi Robby!
that feature is already available, have a look at the cocoon-sax
'builder'[1] package!
Your first email was received, maybe there was just a minor async
issue on your provider.
HTH, have a nice day!
All the best,
Simo

[1] http://s.apache.org/dZm

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Wed, Jul 6, 2011 at 10:46 AM, Robby Pelssers
<ro...@ciber.com> wrote:
>
> Hi Simone,
>
> I have one question to the current interface of Pipeline.  I know you wrote a SAXPipelineBuilder to allow chaining.
>
> But it would have been much nicer if the Pipeline interface itself would have been chainable.
>
> void addComponent(T pipelineComponent);  -->     Pipeline<T> addComponent(T pipelineComponent);
>
> void setup(OutputStream outputStream);   -->     Pipeline<T> setup)(OutputStream outputStream);
>
> Same for other methods for which it makes sense to chain them.
>
> This would allow me to switch from
>
>        @Test
>        public void testXQuery1() throws Exception {
>            Map<String, Object> parameters = new HashMap<String, Object>();
>            parameters.put("sentence", "split words test");
>            XQJGenerator generator = new XQJGenerator(this.getClass().getResource("/xquery/stringtest.xquery"));
>            generator.setXQDataSource(xqds);
>            Pipeline<SAXPipelineComponent> pipeline = new NonCachingPipeline<SAXPipelineComponent>();
>            pipeline.addComponent(generator);
>            pipeline.addComponent(new XMLSerializer().setIndent(true));
>            pipeline.setup(System.out, parameters);
>            pipeline.execute();
>        }
>
> to
>
>        @Test
>        public void testXQuery1() throws Exception {
>            Map<String, Object> parameters = new HashMap<String, Object>();
>            parameters.put("sentence", "split words test");
>            XQJGenerator generator = new XQJGenerator(this.getClass().getResource("/xquery/stringtest.xquery"));
>            generator.setXQDataSource(xqds);
>            Pipeline<SAXPipelineComponent> pipeline =
>               new NonCachingPipeline<SAXPipelineComponent>()
>               .addComponent(generator)
>               .addComponent(new XMLSerializer().setIndent(true))
>               .setup(System.out, parameters)
>               .execute();
>        }
>
> which basically is what you intended to achieve if i'm correct.
>
> I know it's quite a big API change but designing the API with chainability in mind makes sense.
>
> Robby
>
>
>