stephan 2002/08/21 08:37:58 Modified: src/java/org/apache/cocoon/components/profiler ProfilerData.java ProfilingCachingProcessingPipeline.java ProfilingNonCachingProcessingPipeline.java Log: Solved Exception from pipelines with readers. The profiles profiles now pipeling with readers. Revision Changes Path 1.8 +6 -8 xml-cocoon2/src/java/org/apache/cocoon/components/profiler/ProfilerData.java Index: ProfilerData.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/profiler/ProfilerData.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ProfilerData.java 20 Aug 2002 16:15:27 -0000 1.7 +++ ProfilerData.java 21 Aug 2002 15:37:58 -0000 1.8 @@ -82,16 +82,13 @@ private long totaltime = 0; - public ProfilerData() - { + public ProfilerData() { a = new ArrayList(); - a.add(null); - } - - public void setGenerator(Object generator, String role, String source) { - a.set(0, new Entry(generator, role, source)); } + /** + * Add new component from the pipeling, which should be measured. + */ public void addComponent(Object component, String role, String source) { a.add(new Entry(component, role, source)); } @@ -122,6 +119,7 @@ StringBuffer key = new StringBuffer(uri); for(int i=0; i<a.size(); i++){ Entry entry = (Entry)a.get(i); + key.append(':'); key.append(entry.role); key.append(':'); 1.5 +68 -14 xml-cocoon2/src/java/org/apache/cocoon/components/profiler/ProfilingCachingProcessingPipeline.java Index: ProfilingCachingProcessingPipeline.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/profiler/ProfilingCachingProcessingPipeline.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ProfilingCachingProcessingPipeline.java 20 Aug 2002 16:15:27 -0000 1.4 +++ ProfilingCachingProcessingPipeline.java 21 Aug 2002 15:37:58 -0000 1.5 @@ -64,6 +64,7 @@ /** * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> + * @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a> * @version CVS $Id$ */ public class ProfilingCachingProcessingPipeline @@ -79,7 +80,8 @@ * Composable */ public void compose(ComponentManager manager) - throws ComponentException { + throws ComponentException { + super.compose(manager); this.profiler = (Profiler)manager.lookup(Profiler.ROLE); } @@ -103,17 +105,43 @@ super.recycle(); } + /** + * Set the generator that will be used as the initial step in the pipeline. + * The generator role is given : the actual <code>Generator</code> is fetched + * from the latest <code>ComponentManager</code> given by <code>compose()</code> + * or <code>recompose()</code>. + * + * @param role the generator role in the component manager. + * @param source the source where to produce XML from, or <code>null</code> if no + * source is given. + * @param param the parameters for the generator. + * @throws ProcessingException if the generator couldn't be obtained. + */ public void setGenerator (String role, String source, Parameters param) - throws ProcessingException { + throws ProcessingException { + super.setGenerator(role, source, param); if(this.data == null) this.data = new ProfilerData(); - this.data.setGenerator(super.generator, role, source); + this.data.addComponent(super.generator, role, source); } + /** + * Add a transformer at the end of the pipeline. + * The transformer role is given : the actual <code>Transformer</code> is fetched + * from the latest <code>ComponentManager</code> given by <code>compose()</code> + * or <code>recompose()</code>. + * + * @param role the transformer role in the component manager. + * @param source the source used to setup the transformer (e.g. XSL file), or + * <code>null</code> if no source is given. + * @param param the parameters for the transfomer. + * @throws ProcessingException if the generator couldn't be obtained. + */ public void addTransformer (String role, String source, Parameters param) - throws ProcessingException { + throws ProcessingException { + super.addTransformer(role, source, param); if(this.data == null) @@ -121,11 +149,42 @@ this.data.addComponent(super.transformers.get(super.transformers.size()-1), role, source); } + /** + * Set the serializer for this pipeline + * @param mimeType Can be null + */ + public void setSerializer (String role, String source, Parameters param, String mimeType) + throws ProcessingException { + + super.setSerializer(role, source, param, mimeType); + + if(this.data == null) + this.data = new ProfilerData(); + this.data.addComponent(super.serializer, role, source); + } + + /** + * Set the reader for this pipeline + * @param mimeType Can be null + */ + public void setReader (String role, String source, Parameters param, String mimeType) + throws ProcessingException { + + super.setReader(role, source, param, mimeType); + + if(this.data == null) + this.data = new ProfilerData(); + this.data.addComponent(super.reader, role, source); + } + + /** + * Process the given <code>Environment</code>, producing the output. + */ public boolean process(Environment environment) - throws ProcessingException { + throws ProcessingException { + this.index = 0; if (this.data != null) { - this.data.addComponent(super.lastConsumer, null, null); // Execute pipeline long time = System.currentTimeMillis(); @@ -136,14 +195,9 @@ profiler.addResult(environment.getURI(), data); return result; } else { - this.data = new ProfilerData(); - long time = System.currentTimeMillis(); - boolean result = super.process( environment ); - this.data.setTotalTime(System.currentTimeMillis() - time); - // Report - profiler.addResult(environment.getURI(), data); - return result; + getLogger().warn("Profiler Data havn't any components to measure"); + return super.process( environment ); } } 1.5 +72 -18 xml-cocoon2/src/java/org/apache/cocoon/components/profiler/ProfilingNonCachingProcessingPipeline.java Index: ProfilingNonCachingProcessingPipeline.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/profiler/ProfilingNonCachingProcessingPipeline.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ProfilingNonCachingProcessingPipeline.java 20 Aug 2002 16:15:27 -0000 1.4 +++ ProfilingNonCachingProcessingPipeline.java 21 Aug 2002 15:37:58 -0000 1.5 @@ -64,6 +64,7 @@ /** * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> + * @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a> * @version CVS $Id$ */ public class ProfilingNonCachingProcessingPipeline @@ -80,7 +81,8 @@ * Composable */ public void compose(ComponentManager manager) - throws ComponentException { + throws ComponentException { + super.compose(manager); this.profiler = (Profiler)manager.lookup(Profiler.ROLE); } @@ -103,29 +105,86 @@ super.recycle(); } + /** + * Set the generator that will be used as the initial step in the pipeline. + * The generator role is given : the actual <code>Generator</code> is fetched + * from the latest <code>ComponentManager</code> given by <code>compose()</code> + * or <code>recompose()</code>. + * + * @param role the generator role in the component manager. + * @param source the source where to produce XML from, or <code>null</code> if no + * source is given. + * @param param the parameters for the generator. + * @throws ProcessingException if the generator couldn't be obtained. + */ public void setGenerator (String role, String source, Parameters param) - throws ProcessingException { + throws ProcessingException { + super.setGenerator(role, source, param); - if (this.data == null) + if(this.data == null) this.data = new ProfilerData(); - this.data.setGenerator(super.generator, role, source); + this.data.addComponent(super.generator, role, source); } - + + /** + * Add a transformer at the end of the pipeline. + * The transformer role is given : the actual <code>Transformer</code> is fetched + * from the latest <code>ComponentManager</code> given by <code>compose()</code> + * or <code>recompose()</code>. + * + * @param role the transformer role in the component manager. + * @param source the source used to setup the transformer (e.g. XSL file), or + * <code>null</code> if no source is given. + * @param param the parameters for the transfomer. + * @throws ProcessingException if the generator couldn't be obtained. + */ public void addTransformer (String role, String source, Parameters param) - throws ProcessingException { + throws ProcessingException { + super.addTransformer(role, source, param); - if (this.data == null) + if(this.data == null) this.data = new ProfilerData(); this.data.addComponent(super.transformers.get(super.transformers.size()-1), role, source); } + /** + * Set the serializer for this pipeline + * @param mimeType Can be null + */ + public void setSerializer (String role, String source, Parameters param, String mimeType) + throws ProcessingException { + + super.setSerializer(role, source, param, mimeType); + + if(this.data == null) + this.data = new ProfilerData(); + this.data.addComponent(super.serializer, role, source); + } + + /** + * Set the reader for this pipeline + * @param mimeType Can be null + */ + public void setReader (String role, String source, Parameters param, String mimeType) + throws ProcessingException { + + super.setReader(role, source, param, mimeType); + + if(this.data == null) + this.data = new ProfilerData(); + this.data.addComponent(super.reader, role, source); + } + + /** + * Process the given <code>Environment</code>, producing the output. + */ public boolean process(Environment environment) - throws ProcessingException { + throws ProcessingException { + this.index = 0; if (this.data != null) { - this.data.addComponent(super.lastConsumer, null, null); // Execute pipeline long time = System.currentTimeMillis(); @@ -136,14 +195,9 @@ profiler.addResult(environment.getURI(), data); return result; } else { - this.data = new ProfilerData(); - long time = System.currentTimeMillis(); - boolean result = super.process( environment ); - this.data.setTotalTime(System.currentTimeMillis() - time); - // Report - profiler.addResult(environment.getURI(), data); - return result; + getLogger().warn("Profiler Data havn't any components to measure"); + return super.process( environment ); } } @@ -154,7 +208,7 @@ XMLProducer producer, XMLConsumer consumer) throws ProcessingException { - ProfilingSAXBufferConnector connector = new ProfilingSAXBufferConnector(); + ProfilingXMLPipe connector = this.profiler.createConnector(); connector.setup(this.index, this.data); this.index++; super.connect(environment, producer, connector);
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]