cziegeler 02/01/10 07:32:24 Modified: src/java/org/apache/cocoon/components/parser JaxpParser.java Log: Cleaning up lifecycle interfaces and using Parameterizable instead of Configurable Revision Changes Path 1.2 +22 -25 xml-cocoon2/src/java/org/apache/cocoon/components/parser/JaxpParser.java Index: JaxpParser.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/parser/JaxpParser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JaxpParser.java 3 Jan 2002 12:31:12 -0000 1.1 +++ JaxpParser.java 10 Jan 2002 15:32:24 -0000 1.2 @@ -11,10 +11,9 @@ 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.configuration.Configurable; -import org.apache.avalon.framework.configuration.Configuration; -import org.apache.avalon.framework.configuration.ConfigurationException; +import org.apache.avalon.framework.parameters.Parameterizable; import org.apache.avalon.framework.parameters.Parameters; +import org.apache.avalon.framework.parameters.ParameterException; import org.apache.cocoon.components.resolver.Resolver; import org.apache.cocoon.util.ClassUtils; import org.apache.cocoon.xml.AbstractXMLProducer; @@ -59,10 +58,10 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a> * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:12 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/01/10 15:32:24 $ */ public class JaxpParser extends AbstractXMLProducer -implements Parser, ErrorHandler, Composable, Configurable, Poolable { +implements Parser, ErrorHandler, Composable, Parameterizable, Poolable { /** the SAX Parser factory */ protected SAXParserFactory factory; @@ -73,20 +72,20 @@ /** The SAX reader. It is created lazily by {@link #setupXMLReader()} and cleared if a parsing error occurs. */ protected XMLReader reader; - + /** The DOM builder. It is created lazily by {@link #setupDocumentBuilder()} and cleared if a parsing error occurs. */ protected DocumentBuilder docBuilder; - + /** the component manager */ protected ComponentManager manager; /** the Entity Resolver */ protected Resolver resolver; - + /** do we want namespaces also as attributes ? */ protected boolean nsPrefixes; - + /** do we want to reuse parsers ? */ protected boolean reuseParsers; @@ -108,15 +107,13 @@ /** * Configure */ - public void configure(Configuration config) - throws ConfigurationException { - Parameters params = Parameters.fromConfiguration(config); - + public void parameterize(Parameters params) + throws ParameterException { // Validation and namespace prefixes parameters boolean validate = params.getParameterAsBoolean("validate", false); this.nsPrefixes = params.getParameterAsBoolean("namespace-prefixes", false); this.reuseParsers = params.getParameterAsBoolean("reuse-parsers", true); - + // Get the SAXFactory String className = params.getParameter("sax-parser-factory", null); if (className == null) { @@ -127,14 +124,14 @@ Class factoryClass = ClassUtils.loadClass(className); factory = (SAXParserFactory)factoryClass.newInstance(); } catch(Exception e) { - throw new ConfigurationException("Cannot load SAXParserFactory class " + className, e); + throw new ParameterException("Cannot load SAXParserFactory class " + className, e); } } getLogger().debug("SAXParserFactory: " + ClassUtils.which(factory.getClass())); factory.setNamespaceAware(true); factory.setValidating(validate); - - + + // Get the DocumentFactory className = params.getParameter("document-builder-factory", null); if (className == null) { @@ -145,7 +142,7 @@ Class factoryClass = ClassUtils.loadClass(className); this.docFactory = (DocumentBuilderFactory)factoryClass.newInstance(); } catch(Exception e) { - throw new ConfigurationException("Cannot load DocumentBuilderFactory class " + className, e); + throw new ParameterException("Cannot load DocumentBuilderFactory class " + className, e); } } getLogger().debug("DocumentBuilderFactory: " + ClassUtils.which(docFactory.getClass())); @@ -169,13 +166,13 @@ if(this.resolver != null) { reader.setEntityResolver(this.resolver); } - + // Ensure we will use a fresh new parser at next parse in case of failure XMLReader tmpReader = this.reader; this.reader = null; tmpReader.parse(in); - + // Here, parsing was successful : restore this.reader if (this.reuseParsers) this.reader = tmpReader; @@ -210,7 +207,7 @@ impl.createDocumentType(name, publicId, systemId) ); } - + /** * Parses a new Document object from the given InputSource. */ @@ -222,14 +219,14 @@ this.docBuilder = null; Document result = tmpBuilder.parse(input); - + // Here, parsing was successful : restore this.builder if (this.reuseParsers) this.docBuilder = tmpBuilder; - + return result; } - + /** * Creates a new <code>XMLReader</code> if needed. */ @@ -245,7 +242,7 @@ } } } - + /** * Creates a new <code>DocumentBuilder</code> if needed. */
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]