cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robby Pelssers" <robby.pelss...@ciber.com>
Subject FW: question regarding chainability of methods current API
Date Wed, 06 Jul 2011 11:40:58 GMT
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


Mime
View raw message