On Tue, 2011-08-16 at 10:08 +0200, Thorsten Scherler wrote: > On Tue, 2011-08-16 at 09:25 +0200, Steven Dolg wrote: > > Am 14.08.2011 14:18, schrieb Sylvain Wallez: > > >.... > > >> I mean > > >> > > >> Pipeline<StAXPipelineComponent> pipeStAX = new > > >> NonCachingPipeline<StAXPipelineComponent>(); > > >> pipeStAX.addComponent(new XMLGenerator(input)); > > >> ... > > >> pipeStAX.setup(System.out); > > >> pipeStAX.execute(); > > >> > > >> Now my question is how people feel about: > > >> a) Making java based pipes resettable pipeStAX.reset() > > >> b) Adding a method like pipeStAX.getComonponet(int i) to retrieve the > > >> component x in position i. > > > > > > > a) What exactly should Pipeline.reset() do? (Besides calling reset on > > each component) > > And what should a component do during a reset? > > I think components can be configured/set up as often as you like. > > > > b) If you construct the components directly, can't you keep a reference > > to them and just call the setters/methods directly when needed? > > Yes, but only if I can execute the pipe x times. > > > I guess I don't understand why the pipeline is not reusable in your case > > or what you need to reconfigure between the runs. > > Maybe you need x different pipelines for x different configurations? > > If you see above example you cannot do > > // first time works fine > pipeStAX.setup(System.out); > pipeStAX.execute(); > // the next time it is doing nothing > pipeStAX.setup(System.out); > pipeStAX.execute(); > > The second call of execute() will not do anything. The reset() or > redeploy() would refactor the pipeline to be usable again. > > Then I can configure the different pipes again tu use it x times.
Actually I did some more testing and it is quite curious (and annoying): I am creating now a new pipeline due to the limitation I mentioned early that you cannot execute two times the same pipe. While I am doing this I am using: @Autowired private SummaryStAXTransformer summaryTransformer; ... private void invokePipe(FileInputStream input, FileOutputStream output) throws Exception { ... // prepare summary transformer summaryTransformer.setup(bean,dispoNumber); Pipeline<StAXPipelineComponent> pipeStAX = new NonCachingPipeline<StAXPipelineComponent>(); pipeStAX.addComponent(generator); pipeStAX.addComponent(new SAXForStAXPipelineWrapper(saxSummaryCleaner)); pipeStAX.addComponent(summaryTransformer); pipeStAX.addComponent(new XMLSerializer()); pipeStAX.setup(output); pipeStAX.execute(); } Now everything is working fine for the first time I use the pipeline. However the second time it is not working anymore. I am using this.addEventToQueue(event) in the transformer to add the events to the queue. However the second time I am calling the transformer I get "org.apache.cocoon.pipeline.ProcessingException: Error during writing output elements." Whiles debug I found that the summaryTransformer is adding correctly the "StartDocument"/"EndDocument" however in the second call the XMLSerializer is getting in initiatePullProcessing() as first event a START_DOCUMENT (which is expected), however resulting in "javax.xml.stream.XMLStreamException: Can not output XML declaration, after other output has already been done." I debugged summaryTransformer.setup(...) and I figured that StAXConsumer consumer = this.getConsumer(); the first time is null, but the second time is the "old" consumer. Can it be related? Any help appreciated. salu2 -- Thorsten Scherler <thorsten.at.apache.org> codeBusters S.L. - web based systems <consulting, training and solutions> http://www.codebusters.es/