You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Robby Pelssers <ro...@ciber.com> on 2011/07/06 13:40:58 UTC

FW: question regarding chainability of methods current API

My mail to @dev did  not reach the mailinglist so trying again.


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




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org