cziegeler 01/10/29 04:22:01 Modified: . changes.xml src/org/apache/cocoon Cocoon.java src/org/apache/cocoon/components/parser JaxpParser.java Log: The JAXPParser is now Poolable and Configurable. It is theoretically possible to turn on validation now. Revision Changes Path 1.46 +4 -1 xml-cocoon2/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/changes.xml,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- changes.xml 2001/10/25 10:34:00 1.45 +++ changes.xml 2001/10/29 12:22:01 1.46 @@ -4,7 +4,7 @@ <!-- History of Cocoon changes - $Id: changes.xml,v 1.45 2001/10/25 10:34:00 sylvain Exp $ + $Id: changes.xml,v 1.46 2001/10/29 12:22:01 cziegeler Exp $ --> <changes title="History of Changes"> @@ -26,6 +26,9 @@ </devs> <release version="2.1-dev" date="@date@"> + <action dev="CZ" type="update"> + The JaxpParser is now poolable and configurable. + </action> <action dev="SW" type="update"> The sitemap engine is now a regular component available through Processor.ROLE. This allows alternative implementations of Processors (e.g. interpreted sitemap, flowmap, statemap) to 1.32 +10 -10 xml-cocoon2/src/org/apache/cocoon/Cocoon.java Index: Cocoon.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Cocoon.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- Cocoon.java 2001/10/25 10:34:00 1.31 +++ Cocoon.java 2001/10/29 12:22:01 1.32 @@ -56,7 +56,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a> (Apache Software Foundation, Exoffice Technologies) * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a> * @author <a href="mailto:[EMAIL PROTECTED]">Leo Sutic</a> - * @version CVS $Revision: 1.31 $ $Date: 2001/10/25 10:34:00 $ + * @version CVS $Revision: 1.32 $ $Date: 2001/10/29 12:22:01 $ */ public class Cocoon extends AbstractLoggable @@ -101,7 +101,7 @@ /** maximum request count */ private static int maxRequestCount = 0; - + /** the Processor if it is ThreadSafe */ private Processor threadSafeProcessor = null; @@ -163,7 +163,7 @@ startupManager.setLogKitManager(this.logKitManager); try { - startupManager.addComponent(Parser.ROLE, ClassUtils.loadClass(parser), null); + startupManager.addComponent(Parser.ROLE, ClassUtils.loadClass(parser), new org.apache.avalon.framework.configuration.DefaultConfiguration("", "empty")); } catch (Exception e) { getLogger().error("Could not load parser, Cocoon object not created.", e); throw new ConfigurationException("Could not load parser " + parser, e); @@ -216,7 +216,7 @@ } finally { this.componentManager.release(server); } - + } /** Dump System Properties */ @@ -464,10 +464,10 @@ incRequestCount(); this.debug(environment, null, null); } - + if (this.threadSafeProcessor != null) { return this.threadSafeProcessor.process(environment); - } else { + } else { Processor processor = (Processor)this.componentManager.lookup(Processor.ROLE); try { return processor.process(environment); @@ -496,7 +496,7 @@ incRequestCount(); this.debug(environment, pipeline, eventPipeline); } - + if (this.threadSafeProcessor != null) { return this.threadSafeProcessor.process(environment, pipeline, eventPipeline); } else { @@ -568,15 +568,15 @@ * result if it's the maximum. */ private static synchronized void incRequestCount() { - if (++activeRequestCount > maxRequestCount) - maxRequestCount = activeRequestCount; + if (++activeRequestCount > maxRequestCount) + maxRequestCount = activeRequestCount; } /** * Decrement active request count. */ private static synchronized void decRequestCount() { - --activeRequestCount; + --activeRequestCount; } } 1.11 +35 -34 xml-cocoon2/src/org/apache/cocoon/components/parser/JaxpParser.java Index: JaxpParser.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/parser/JaxpParser.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- JaxpParser.java 2001/10/10 09:18:28 1.10 +++ JaxpParser.java 2001/10/29 12:22:01 1.11 @@ -7,30 +7,22 @@ *****************************************************************************/ package org.apache.cocoon.components.parser; +import org.apache.avalon.excalibur.pool.Recyclable; import org.apache.avalon.framework.component.ComponentException; - import org.apache.avalon.framework.component.ComponentManager; - import org.apache.avalon.framework.component.Composable; - -import org.apache.avalon.framework.thread.SingleThreaded; - +import org.apache.avalon.framework.configuration.Configurable; +import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.configuration.ConfigurationException; +import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.components.resolver.Resolver; - import org.apache.cocoon.util.ClassUtils; - import org.apache.cocoon.xml.AbstractXMLProducer; - import org.w3c.dom.DOMImplementation; - import org.w3c.dom.Document; - import org.xml.sax.*; - - import javax.xml.parsers.*; - import java.io.IOException; /** @@ -38,43 +30,52 @@ * If only we can get rid of the need for the Document... * * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a> - * @version CVS $Revision: 1.10 $ $Date: 2001/10/10 09:18:28 $ + * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> + * @version CVS $Revision: 1.11 $ $Date: 2001/10/29 12:22:01 $ */ public class JaxpParser extends AbstractXMLProducer -implements Parser, ErrorHandler, Composable, SingleThreaded { +implements Parser, ErrorHandler, Composable, Configurable, Recyclable { /** the SAX Parser factory */ - final SAXParserFactory factory = SAXParserFactory.newInstance(); + protected SAXParserFactory factory; /** the Document Builder factory */ - final DocumentBuilderFactory docfactory = DocumentBuilderFactory.newInstance(); + protected DocumentBuilderFactory docfactory; /** the component manager */ protected ComponentManager manager; /** the Entity Resolver */ - protected Resolver resolver = null; + protected Resolver resolver; - public JaxpParser () - throws SAXException, ParserConfigurationException { - this.factory.setNamespaceAware(true); - this.factory.setValidating(false); - this.docfactory.setNamespaceAware(true); - this.docfactory.setValidating(false); + /** + * Get the Entity Resolver from the component manager + */ + public void compose(ComponentManager manager) + throws ComponentException { + try { + this.manager = manager; + getLogger().debug("Looking up " + Resolver.ROLE); + this.resolver = (Resolver)manager.lookup(Resolver.ROLE); + } catch(ComponentException e) { + // This exception is ok during initialization/startup. + getLogger().debug("Error in JaxpParser: Cannot find " + Resolver.ROLE); + } } /** - * Get the Entity Resolver from the component manager + * Configure */ - public void compose(ComponentManager manager) throws ComponentException { - try { - this.manager = manager; - getLogger().debug("Looking up " + Resolver.ROLE); - this.resolver = (Resolver)manager.lookup(Resolver.ROLE); - } catch(ComponentException e) { - // This exception is ok during initialization/startup. - getLogger().debug("Error in JaxpParser: Cannot find " + Resolver.ROLE); - } + public void configure(Configuration config) + throws ConfigurationException { + Parameters params = Parameters.fromConfiguration(config); + boolean validate = params.getParameterAsBoolean("validate", false); + this.factory = SAXParserFactory.newInstance(); + this.docfactory = DocumentBuilderFactory.newInstance(); + this.factory.setNamespaceAware(true); + this.factory.setValidating(validate); + this.docfactory.setNamespaceAware(true); + this.docfactory.setValidating(validate); } public void parse(InputSource in)
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]