geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aaron Mulder" <ammul...@alumni.princeton.edu>
Subject Re: svn commit: r428843 - in /geronimo/trunk: applications/console/console-standard/src/java/org/apache/geronimo/console/car/ applications/console/console-standard/src/java/org/apache/geronimo/console/configmanager/ applications/console/console-stand
Date Fri, 04 Aug 2006 19:15:17 GMT
Never mind -- I misunderstood the usage of the new option.  I'm OK
with the patch.

Thanks,
    Aaron

On 8/4/06, Aaron Mulder <ammulder@alumni.princeton.edu> wrote:
> I think this is going to cause problems.
>
> The plugin installer uses various attributes to configure the XSD
> files to validate and so on.  Those attributes are not parser
> independent, so if someone changes the implementation, I think that's
> going to break.  We also use other attributes to control the output
> formatting (indentation and such) for the XSLT engine.
>
> Thanks,
>      Aaron
>
> On 8/4/06, dain@apache.org <dain@apache.org> wrote:
> > Author: dain
> > Date: Fri Aug  4 11:43:59 2006
> > New Revision: 428843
> >
> > URL: http://svn.apache.org/viewvc?rev=428843&view=rev
> > Log:
> > GERONIMO-2224 Add a geronimo specific system property for controlling dom, sax, and transformer creation
> >
> > Added:
> >     geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/util/XmlUtil.java
> >     geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/util/
> >     geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/util/XmlUtilTest.java
> > Modified:
> >     geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java
> >     geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java
> >     geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java
> >     geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/JMSProviderData.java
> >     geronimo/trunk/modules/converter/src/java/org/apache/geronimo/converter/bea/WebLogic81DatabaseConverter.java
> >     geronimo/trunk/modules/converter/src/java/org/apache/geronimo/converter/jboss/JBoss4DatabaseConverter.java
> >     geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java
> >     geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/xml/ParserFactoryImpl.java
> >     geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/xstream/DomConverter.java
> >     geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/xstream/XStreamGBeanState.java
> >     geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
> >     geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
> >     geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java
> >     geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/util/PluginRepositoryExporter.java
> >     geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/configuration/ServerOverrideTest.java
> >
> > Modified: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java?rev=428843&r1=428842&r2=428843&view=diff
> > ==============================================================================
> > --- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java (original)
> > +++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/car/GeronimoAsMavenServlet.java Fri Aug  4 11:43:59 2006
> > @@ -46,6 +46,7 @@
> >  import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
> >  import org.apache.geronimo.kernel.Kernel;
> >  import org.apache.geronimo.kernel.KernelRegistry;
> > +import org.apache.geronimo.kernel.util.XmlUtil;
> >  import org.apache.geronimo.kernel.config.ConfigurationInfo;
> >  import org.apache.geronimo.kernel.config.ConfigurationManager;
> >  import org.apache.geronimo.kernel.config.ConfigurationStore;
> > @@ -198,7 +199,7 @@
> >      private void generateConfigFile(HttpServletRequest request, Kernel kernel, PrintWriter out) throws ParserConfigurationException, NoSuchStoreException, TransformerException {
> >          ConfigurationManager mgr = ConfigurationUtil.getConfigurationManager(kernel);
> >          PluginInstaller installer = getInstaller(kernel);
> > -        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
> > +        DocumentBuilderFactory factory = XmlUtil.newDocumentBuilderFactory();
> >          factory.setNamespaceAware(true);
> >          DocumentBuilder builder = factory.newDocumentBuilder();
> >          Document doc = builder.newDocument();
> > @@ -260,7 +261,7 @@
> >          String repo = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+request.getServletPath();
> >          if(!repo.endsWith("/")) repo += "/";
> >          createText(doc, root, "default-repository", repo);
> > -        TransformerFactory xfactory = TransformerFactory.newInstance();
> > +        TransformerFactory xfactory = XmlUtil.newTransformerFactory();
> >          Transformer xform = xfactory.newTransformer();
> >          xform.setOutputProperty(OutputKeys.INDENT, "yes");
> >          xform.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
> > @@ -282,7 +283,7 @@
> >              return;
> >          }
> >
> > -        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
> > +        DocumentBuilderFactory factory = XmlUtil.newDocumentBuilderFactory();
> >          DocumentBuilder builder = factory.newDocumentBuilder();
> >          Document doc = builder.newDocument();
> >          Element root = doc.createElement("metadata");
> > @@ -300,7 +301,7 @@
> >              Artifact artifact = artifacts[i];
> >              createText(doc, versions, "version", artifact.getVersion().toString());
> >          }
> > -        TransformerFactory xfactory = TransformerFactory.newInstance();
> > +        TransformerFactory xfactory = XmlUtil.newTransformerFactory();
> >          Transformer xform = xfactory.newTransformer();
> >          xform.setOutputProperty(OutputKeys.INDENT, "yes");
> >          xform.transform(new DOMSource(doc), new StreamResult(writer));
> >
> > Modified: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java?rev=428843&r1=428842&r2=428843&view=diff
> > ==============================================================================
> > --- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java (original)
> > +++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java Fri Aug  4 11:43:59 2006
> > @@ -38,7 +38,6 @@
> >  import javax.portlet.RenderRequest;
> >  import javax.portlet.RenderResponse;
> >  import javax.xml.parsers.DocumentBuilder;
> > -import javax.xml.parsers.DocumentBuilderFactory;
> >
> >  import org.apache.commons.fileupload.FileItem;
> >  import org.apache.commons.fileupload.FileUploadException;
> > @@ -49,6 +48,7 @@
> >  import org.apache.geronimo.deployment.plugin.ConfigIDExtractor;
> >  import org.apache.geronimo.common.DeploymentException;
> >  import org.apache.geronimo.kernel.repository.Artifact;
> > +import org.apache.geronimo.kernel.util.XmlUtil;
> >  import org.apache.geronimo.upgrade.Upgrade1_0To1_1;
> >  import org.w3c.dom.Document;
> >
> > @@ -164,7 +164,7 @@
> >                              byte[] plan = new byte[(int) planFile.length()];
> >                              fis = new FileInputStream(planFile);
> >                              fis.read(plan);
> > -                            DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
> > +                            DocumentBuilder documentBuilder = XmlUtil.newDocumentBuilderFactory().newDocumentBuilder();
> >                              Document doc = documentBuilder.parse(new ByteArrayInputStream(plan));
> >                              // v1.1 switched from configId to moduleId
> >                              String configId = doc.getDocumentElement().getAttribute("configId");
> >
> > Modified: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java?rev=428843&r1=428842&r2=428843&view=diff
> > ==============================================================================
> > --- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java (original)
> > +++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java Fri Aug  4 11:43:59 2006
> > @@ -96,6 +96,7 @@
> >  import org.apache.geronimo.kernel.repository.ListableRepository;
> >  import org.apache.geronimo.kernel.repository.Repository;
> >  import org.apache.geronimo.kernel.repository.WriteableRepository;
> > +import org.apache.geronimo.kernel.util.XmlUtil;
> >  import org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory;
> >  import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
> >  import org.w3c.dom.Document;
> > @@ -551,7 +552,7 @@
> >      private ResourceAdapterParams loadConfigPropertiesByAbstractName(PortletRequest request, String abstractName) {
> >          ResourceAdapterModule module = (ResourceAdapterModule) PortletManager.getManagedBean(request, new AbstractName(URI.create(abstractName)));
> >          String dd = module.getDeploymentDescriptor();
> > -        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
> > +        DocumentBuilderFactory factory = XmlUtil.newDocumentBuilderFactory();
> >          factory.setValidating(false);
> >          factory.setNamespaceAware(true);
> >          try {
> >
> > Modified: geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/JMSProviderData.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/JMSProviderData.java?rev=428843&r1=428842&r2=428843&view=diff
> > ==============================================================================
> > --- geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/JMSProviderData.java (original)
> > +++ geronimo/trunk/applications/console/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/JMSProviderData.java Fri Aug  4 11:43:59 2006
> > @@ -36,6 +36,7 @@
> >  import org.apache.commons.logging.Log;
> >  import org.apache.commons.logging.LogFactory;
> >  import org.apache.geronimo.console.util.PortletManager;
> > +import org.apache.geronimo.kernel.util.XmlUtil;
> >  import org.w3c.dom.Document;
> >  import org.w3c.dom.Element;
> >  import org.w3c.dom.Node;
> > @@ -218,7 +219,7 @@
> >          try {
> >              while((entry = in.getNextEntry()) != null) {
> >                  if(entry.getName().equals("META-INF/ra.xml")) {
> > -                    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
> > +                    DocumentBuilderFactory factory = XmlUtil.newDocumentBuilderFactory();
> >                      factory.setValidating(false);
> >                      DocumentBuilder builder = factory.newDocumentBuilder();
> >                      doc = builder.parse(in);
> >
> > Modified: geronimo/trunk/modules/converter/src/java/org/apache/geronimo/converter/bea/WebLogic81DatabaseConverter.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/converter/src/java/org/apache/geronimo/converter/bea/WebLogic81DatabaseConverter.java?rev=428843&r1=428842&r2=428843&view=diff
> > ==============================================================================
> > --- geronimo/trunk/modules/converter/src/java/org/apache/geronimo/converter/bea/WebLogic81DatabaseConverter.java (original)
> > +++ geronimo/trunk/modules/converter/src/java/org/apache/geronimo/converter/bea/WebLogic81DatabaseConverter.java Fri Aug  4 11:43:59 2006
> > @@ -33,6 +33,7 @@
> >  import org.apache.geronimo.converter.JDBCPool;
> >  import org.apache.geronimo.converter.XADatabasePool;
> >  import org.apache.geronimo.converter.AbstractDatabasePool;
> > +import org.apache.geronimo.kernel.util.XmlUtil;
> >  import org.w3c.dom.Document;
> >  import org.w3c.dom.Element;
> >  import org.w3c.dom.NodeList;
> > @@ -58,7 +59,7 @@
> >          List local = new ArrayList();
> >          List xa = new ArrayList();
> >
> > -        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
> > +        DocumentBuilderFactory factory = XmlUtil.newDocumentBuilderFactory();
> >          factory.setValidating(false);
> >          try {
> >              DocumentBuilder builder = factory.newDocumentBuilder();
> >
> > Modified: geronimo/trunk/modules/converter/src/java/org/apache/geronimo/converter/jboss/JBoss4DatabaseConverter.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/converter/src/java/org/apache/geronimo/converter/jboss/JBoss4DatabaseConverter.java?rev=428843&r1=428842&r2=428843&view=diff
> > ==============================================================================
> > --- geronimo/trunk/modules/converter/src/java/org/apache/geronimo/converter/jboss/JBoss4DatabaseConverter.java (original)
> > +++ geronimo/trunk/modules/converter/src/java/org/apache/geronimo/converter/jboss/JBoss4DatabaseConverter.java Fri Aug  4 11:43:59 2006
> > @@ -28,6 +28,7 @@
> >  import org.apache.geronimo.converter.XADatabasePool;
> >  import org.apache.geronimo.converter.AbstractDatabasePool;
> >  import org.apache.geronimo.converter.DOMUtils;
> > +import org.apache.geronimo.kernel.util.XmlUtil;
> >  import org.w3c.dom.Document;
> >  import org.w3c.dom.Element;
> >  import org.w3c.dom.NodeList;
> > @@ -47,7 +48,7 @@
> >          List local = new ArrayList();
> >          List xa = new ArrayList();
> >
> > -        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
> > +        DocumentBuilderFactory factory = XmlUtil.newDocumentBuilderFactory();
> >          factory.setValidating(false);
> >          try {
> >              DocumentBuilder builder = factory.newDocumentBuilder();
> >
> > Modified: geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java?rev=428843&r1=428842&r2=428843&view=diff
> > ==============================================================================
> > --- geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java (original)
> > +++ geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java Fri Aug  4 11:43:59 2006
> > @@ -36,6 +36,7 @@
> >  import org.apache.geronimo.common.FileUtils;
> >  import org.apache.geronimo.kernel.repository.Artifact;
> >  import org.apache.geronimo.kernel.repository.Version;
> > +import org.apache.geronimo.kernel.util.XmlUtil;
> >  import org.xml.sax.Attributes;
> >  import org.xml.sax.InputSource;
> >  import org.xml.sax.SAXException;
> > @@ -207,7 +208,7 @@
> >      }
> >
> >      private static String extractModuleIdFromPlan(Reader plan) throws IOException {
> > -        SAXParserFactory factory = SAXParserFactory.newInstance();
> > +        SAXParserFactory factory = XmlUtil.newSAXParserFactory();
> >          factory.setNamespaceAware(true);
> >          factory.setValidating(false);
> >          try {
> >
> > Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/xml/ParserFactoryImpl.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/xml/ParserFactoryImpl.java?rev=428843&r1=428842&r2=428843&view=diff
> > ==============================================================================
> > --- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/xml/ParserFactoryImpl.java (original)
> > +++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/xml/ParserFactoryImpl.java Fri Aug  4 11:43:59 2006
> > @@ -25,6 +25,7 @@
> >  import org.apache.commons.logging.LogFactory;
> >  import org.apache.geronimo.gbean.GBeanInfo;
> >  import org.apache.geronimo.gbean.GBeanInfoBuilder;
> > +import org.apache.geronimo.kernel.util.XmlUtil;
> >  import org.xml.sax.EntityResolver;
> >  import org.xml.sax.ErrorHandler;
> >  import org.xml.sax.SAXParseException;
> > @@ -44,7 +45,7 @@
> >
> >      public ParserFactoryImpl(EntityResolver entityResolver) {
> >          this.entityResolver = entityResolver;
> > -        factory = DocumentBuilderFactory.newInstance();
> > +        factory = XmlUtil.newDocumentBuilderFactory();
> >          //sets "http://xml.org/sax/features/namespaces"
> >          factory.setNamespaceAware(true);
> >          //sets "http://xml.org/sax/features/validation"
> >
> > Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/xstream/DomConverter.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/xstream/DomConverter.java?rev=428843&r1=428842&r2=428843&view=diff
> > ==============================================================================
> > --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/xstream/DomConverter.java (original)
> > +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/xstream/DomConverter.java Fri Aug  4 11:43:59 2006
> > @@ -30,6 +30,7 @@
> >  import com.thoughtworks.xstream.io.xml.DomWriter;
> >  import org.w3c.dom.Document;
> >  import org.w3c.dom.Element;
> > +import org.apache.geronimo.kernel.util.XmlUtil;
> >
> >  /**
> >   * @version $Rev$ $Date$
> > @@ -53,7 +54,7 @@
> >      }
> >
> >      public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext unmarshallingContext) {
> > -        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
> > +        DocumentBuilderFactory documentBuilderFactory = XmlUtil.newDocumentBuilderFactory();
> >          DocumentBuilder documentBuilder = null;
> >          try {
> >              documentBuilder = documentBuilderFactory.newDocumentBuilder();
> >
> > Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/xstream/XStreamGBeanState.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/xstream/XStreamGBeanState.java?rev=428843&r1=428842&r2=428843&view=diff
> > ==============================================================================
> > --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/xstream/XStreamGBeanState.java (original)
> > +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/xstream/XStreamGBeanState.java Fri Aug  4 11:43:59 2006
> > @@ -33,6 +33,7 @@
> >  import org.apache.geronimo.gbean.GBeanData;
> >  import org.apache.geronimo.gbean.GBeanInfo;
> >  import org.apache.geronimo.kernel.Naming;
> > +import org.apache.geronimo.kernel.util.XmlUtil;
> >  import org.apache.geronimo.kernel.config.InvalidConfigException;
> >  import org.apache.geronimo.kernel.config.GBeanState;
> >  import org.apache.geronimo.kernel.repository.Environment;
> > @@ -125,7 +126,7 @@
> >      private static Element storeGBeans(List gbeans) throws IOException {
> >          GBeanData[] gbeanDatas = (GBeanData[]) gbeans.toArray(new GBeanData[gbeans.size()]);
> >
> > -        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
> > +        DocumentBuilderFactory documentBuilderFactory = XmlUtil.newDocumentBuilderFactory();
> >          DocumentBuilder documentBuilder = null;
> >          try {
> >              documentBuilder = documentBuilderFactory.newDocumentBuilder();
> >
> > Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/util/XmlUtil.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/util/XmlUtil.java?rev=428843&view=auto
> > ==============================================================================
> > --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/util/XmlUtil.java (added)
> > +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/util/XmlUtil.java Fri Aug  4 11:43:59 2006
> > @@ -0,0 +1,112 @@
> > +/**
> > + *
> > + * Copyright 2006 The Apache Software Foundation
> > + *
> > + *  Licensed under the Apache License, Version 2.0 (the "License");
> > + *  you may not use this file except in compliance with the License.
> > + *  You may obtain a copy of the License at
> > + *
> > + *     http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + *  Unless required by applicable law or agreed to in writing, software
> > + *  distributed under the License is distributed on an "AS IS" BASIS,
> > + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> > + *  See the License for the specific language governing permissions and
> > + *  limitations under the License.
> > + */
> > +package org.apache.geronimo.kernel.util;
> > +
> > +import javax.xml.parsers.SAXParserFactory;
> > +import javax.xml.parsers.DocumentBuilderFactory;
> > +import javax.xml.parsers.FactoryConfigurationError;
> > +import javax.xml.transform.TransformerFactory;
> > +import javax.xml.transform.TransformerFactoryConfigurationError;
> > +
> > +import org.apache.geronimo.kernel.ClassLoading;
> > +
> > +/**
> > + * @version $Rev$ $Date$
> > + */
> > +public final class XmlUtil {
> > +    public static final String DOCUMENT_BUILDER_FACTORY = "geronimo.xml.parsers.DocumentBuilderFactory";
> > +    public static final String SAX_PARSER_FACTORY = "geronimo.xml.parsers.SAXParserFactory";
> > +    public static final String TRANSFORMER_FACTORY = "geronimo.xml.transform.TransformerFactory";
> > +
> > +    private XmlUtil() {
> > +    }
> > +
> > +    public static DocumentBuilderFactory newDocumentBuilderFactory() {
> > +        return newDocumentBuilderFactory(getClassLoader());
> > +    }
> > +
> > +    public static DocumentBuilderFactory newDocumentBuilderFactory(ClassLoader classLoader) {
> > +        String documentBuilderName = getSystemProperty(DOCUMENT_BUILDER_FACTORY);
> > +        if (documentBuilderName != null && documentBuilderName.length() != 0) {
> > +            try {
> > +                Class documentBuilderClass = ClassLoading.loadClass(documentBuilderName, classLoader);
> > +                DocumentBuilderFactory documentBuilderFactory = (DocumentBuilderFactory) documentBuilderClass.newInstance();
> > +                return documentBuilderFactory;
> > +            } catch (Exception e) {
> > +                throw new FactoryConfigurationError(e, "Unable to create DocumentBuilderFactory " +
> > +                        documentBuilderName + ", which was specified in the " + DOCUMENT_BUILDER_FACTORY + " system property");
> > +            }
> > +        }
> > +
> > +        return DocumentBuilderFactory.newInstance();
> > +    }
> > +
> > +    public static SAXParserFactory newSAXParserFactory() {
> > +        return newSAXParserFactory(getClassLoader());
> > +    }
> > +
> > +    public static SAXParserFactory newSAXParserFactory(ClassLoader classLoader) {
> > +        String saxParserName = getSystemProperty(SAX_PARSER_FACTORY);
> > +        if (saxParserName != null && saxParserName.length() != 0) {
> > +            try {
> > +                Class saxParserClass = ClassLoading.loadClass(saxParserName, classLoader);
> > +                SAXParserFactory saxParserFactory = (SAXParserFactory) saxParserClass.newInstance();
> > +                return saxParserFactory;
> > +            } catch (Exception e) {
> > +                throw new FactoryConfigurationError(e, "Unable to create SAXParserFactory " +
> > +                        saxParserName + ", which was specified in the " + SAX_PARSER_FACTORY + " system property");
> > +            }
> > +        }
> > +
> > +        return SAXParserFactory.newInstance();
> > +    }
> > +
> > +    public static TransformerFactory newTransformerFactory() {
> > +        return newTransformerFactory(getClassLoader());
> > +    }
> > +
> > +    public static TransformerFactory newTransformerFactory(ClassLoader classLoader) {
> > +        String transformerName = getSystemProperty(TRANSFORMER_FACTORY);
> > +        if (transformerName != null && transformerName.length() != 0) {
> > +            try {
> > +                Class transformerClass = ClassLoading.loadClass(transformerName, classLoader);
> > +                TransformerFactory transformerFactory = (TransformerFactory) transformerClass.newInstance();
> > +                return transformerFactory;
> > +            } catch (Exception e) {
> > +                throw new TransformerFactoryConfigurationError(e, "Unable to create TransformerFactory " +
> > +                        transformerName + ", which was specified in the " + TRANSFORMER_FACTORY + " system property");
> > +            }
> > +        }
> > +
> > +        return TransformerFactory.newInstance();
> > +    }
> > +
> > +    private static ClassLoader getClassLoader() {
> > +        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
> > +        if (classLoader != null) {
> > +            return classLoader;
> > +        } else {
> > +            return XmlUtil.class.getClassLoader();
> > +        }
> > +    }
> > +
> > +    private static String getSystemProperty(String key) {
> > +        String value = System.getProperty(key);
> > +        if (value != null) value = value.trim();
> > +        return value;
> > +    }
> > +}
> >
> > Added: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/util/XmlUtilTest.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/util/XmlUtilTest.java?rev=428843&view=auto
> > ==============================================================================
> > --- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/util/XmlUtilTest.java (added)
> > +++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/util/XmlUtilTest.java Fri Aug  4 11:43:59 2006
> > @@ -0,0 +1,93 @@
> > +/**
> > + *
> > + * Copyright 2006 The Apache Software Foundation
> > + *
> > + *  Licensed under the Apache License, Version 2.0 (the "License");
> > + *  you may not use this file except in compliance with the License.
> > + *  You may obtain a copy of the License at
> > + *
> > + *     http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + *  Unless required by applicable law or agreed to in writing, software
> > + *  distributed under the License is distributed on an "AS IS" BASIS,
> > + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> > + *  See the License for the specific language governing permissions and
> > + *  limitations under the License.
> > + */
> > +package org.apache.geronimo.kernel.util;
> > +
> > +import javax.xml.parsers.DocumentBuilderFactory;
> > +import javax.xml.parsers.SAXParserFactory;
> > +import javax.xml.transform.TransformerFactory;
> > +
> > +import junit.framework.TestCase;
> > +
> > +/**
> > + * @version $Rev$ $Date$
> > + */
> > +public class XmlUtilTest extends TestCase {
> > +    private String documentBuilderClassName;
> > +    private String saxParserClassName;
> > +    private String transformerClassName;
> > +
> > +    public void testDocumentBuilderDefault() {
> > +        System.getProperties().remove(XmlUtil.DOCUMENT_BUILDER_FACTORY);
> > +        assertNull(System.getProperty(XmlUtil.DOCUMENT_BUILDER_FACTORY));
> > +
> > +        DocumentBuilderFactory documentBuilderFactory = XmlUtil.newDocumentBuilderFactory();
> > +        String className = documentBuilderFactory.getClass().getName();
> > +        assertEquals(documentBuilderClassName, className);
> > +    }
> > +
> > +    public void testDocumentBuilderOverride() {
> > +        System.setProperty(XmlUtil.DOCUMENT_BUILDER_FACTORY, documentBuilderClassName);
> > +        assertEquals(documentBuilderClassName, System.getProperty(XmlUtil.DOCUMENT_BUILDER_FACTORY));
> > +
> > +        DocumentBuilderFactory documentBuilderFactory = XmlUtil.newDocumentBuilderFactory();
> > +        String className = documentBuilderFactory.getClass().getName();
> > +        assertEquals(documentBuilderClassName, className);
> > +    }
> > +
> > +    public void testSaxparserDefault() {
> > +        System.getProperties().remove(XmlUtil.SAX_PARSER_FACTORY);
> > +        assertNull(System.getProperty(XmlUtil.SAX_PARSER_FACTORY));
> > +
> > +        SAXParserFactory saxParserFactory = XmlUtil.newSAXParserFactory();
> > +        String className = saxParserFactory.getClass().getName();
> > +        assertEquals(saxParserClassName, className);
> > +    }
> > +
> > +    public void testSAXParserOverride() {
> > +        System.setProperty(XmlUtil.SAX_PARSER_FACTORY, saxParserClassName);
> > +        assertEquals(saxParserClassName, System.getProperty(XmlUtil.SAX_PARSER_FACTORY));
> > +
> > +        SAXParserFactory saxParserFactory = XmlUtil.newSAXParserFactory();
> > +        String className = saxParserFactory.getClass().getName();
> > +        assertEquals(saxParserClassName, className);
> > +    }
> > +
> > +    public void testTransformerDefault() {
> > +        System.getProperties().remove(XmlUtil.TRANSFORMER_FACTORY);
> > +        assertNull(System.getProperty(XmlUtil.TRANSFORMER_FACTORY));
> > +
> > +        TransformerFactory transformerFactory = XmlUtil.newTransformerFactory();
> > +        String className = transformerFactory.getClass().getName();
> > +        assertEquals(transformerClassName, className);
> > +    }
> > +
> > +    public void testTransformerOverride() {
> > +        System.setProperty(XmlUtil.TRANSFORMER_FACTORY, transformerClassName);
> > +        assertEquals(transformerClassName, System.getProperty(XmlUtil.TRANSFORMER_FACTORY));
> > +
> > +        TransformerFactory transformerFactory = XmlUtil.newTransformerFactory();
> > +        String className = transformerFactory.getClass().getName();
> > +        assertEquals(transformerClassName, className);
> > +    }
> > +
> > +    protected void setUp() throws Exception {
> > +        super.setUp();
> > +        documentBuilderClassName = DocumentBuilderFactory.newInstance().getClass().getName();
> > +        saxParserClassName = SAXParserFactory.newInstance().getClass().getName();
> > +        transformerClassName = TransformerFactory.newInstance().getClass().getName();
> > +    }
> > +}
> >
> > Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java?rev=428843&r1=428842&r2=428843&view=diff
> > ==============================================================================
> > --- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java (original)
> > +++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java Fri Aug  4 11:43:59 2006
> > @@ -33,6 +33,7 @@
> >  import org.apache.geronimo.kernel.config.Configuration;
> >  import org.apache.geronimo.kernel.repository.Artifact;
> >  import org.apache.geronimo.kernel.InvalidGBeanException;
> > +import org.apache.geronimo.kernel.util.XmlUtil;
> >  import org.apache.geronimo.system.serverinfo.ServerInfo;
> >  import org.w3c.dom.Document;
> >  import org.w3c.dom.Element;
> > @@ -365,7 +366,7 @@
> >          FileInputStream fis = new FileInputStream(attributeFile);
> >          InputSource in = new InputSource(fis);
> >          in.setSystemId(attributeFile.toString());
> > -        DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
> > +        DocumentBuilderFactory dFactory = XmlUtil.newDocumentBuilderFactory();
> >          try {
> >              dFactory.setValidating(true);
> >              dFactory.setNamespaceAware(true);
> > @@ -453,7 +454,7 @@
> >      }
> >
> >      private static void saveXmlToFile(File file, ServerOverride serverOverride) {
> > -        DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
> > +        DocumentBuilderFactory dFactory = XmlUtil.newDocumentBuilderFactory();
> >          dFactory.setValidating(true);
> >          dFactory.setNamespaceAware(true);
> >          dFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
> > @@ -464,7 +465,7 @@
> >          try {
> >              Document doc = dFactory.newDocumentBuilder().newDocument();
> >              serverOverride.writeXml(doc);
> > -            TransformerFactory xfactory = TransformerFactory.newInstance();
> > +            TransformerFactory xfactory = XmlUtil.newTransformerFactory();
> >              Transformer xform = xfactory.newTransformer();
> >              xform.setOutputProperty(OutputKeys.INDENT, "yes");
> >              xform.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
> >
> > Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java?rev=428843&r1=428842&r2=428843&view=diff
> > ==============================================================================
> > --- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java (original)
> > +++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java Fri Aug  4 11:43:59 2006
> > @@ -75,6 +75,7 @@
> >  import org.apache.geronimo.kernel.repository.Version;
> >  import org.apache.geronimo.kernel.repository.WritableListableRepository;
> >  import org.apache.geronimo.kernel.InvalidGBeanException;
> > +import org.apache.geronimo.kernel.util.XmlUtil;
> >  import org.apache.geronimo.system.configuration.ConfigurationStoreUtil;
> >  import org.apache.geronimo.system.configuration.GBeanOverride;
> >  import org.apache.geronimo.system.configuration.PluginAttributeStore;
> > @@ -269,7 +270,7 @@
> >                          entry = new JarEntry(entry.getName());
> >                          out.putNextEntry(entry);
> >                          Document doc = writePluginMetadata(metadata);
> > -                        TransformerFactory xfactory = TransformerFactory.newInstance();
> > +                        TransformerFactory xfactory = XmlUtil.newTransformerFactory();
> >                          Transformer xform = xfactory.newTransformer();
> >                          xform.setOutputProperty(OutputKeys.INDENT, "yes");
> >                          xform.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
> > @@ -313,7 +314,7 @@
> >                      }
> >                  }
> >                  Document doc = writePluginMetadata(metadata);
> > -                TransformerFactory xfactory = TransformerFactory.newInstance();
> > +                TransformerFactory xfactory = XmlUtil.newTransformerFactory();
> >                  Transformer xform = xfactory.newTransformer();
> >                  xform.setOutputProperty(OutputKeys.INDENT, "yes");
> >                  xform.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
> > @@ -1055,7 +1056,7 @@
> >              return null;
> >          }
> >          // Don't use the validating parser that we normally do
> > -        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
> > +        DocumentBuilder builder = XmlUtil.newDocumentBuilderFactory().newDocumentBuilder();
> >          Document doc = builder.parse(in);
> >          Element root = doc.getDocumentElement();
> >          NodeList list = root.getElementsByTagName("versions");
> > @@ -1091,7 +1092,7 @@
> >       */
> >      private void readNameAndID(File xml, Map plugins) {
> >          try {
> > -            SAXParserFactory factory = SAXParserFactory.newInstance();
> > +            SAXParserFactory factory = XmlUtil.newSAXParserFactory();
> >              SAXParser parser = factory.newSAXParser();
> >              PluginNameIDHandler handler = new PluginNameIDHandler();
> >              parser.parse(xml, handler);
> > @@ -1112,7 +1113,7 @@
> >       */
> >      private void readNameAndID(InputStream xml, Map plugins) {
> >          try {
> > -            SAXParserFactory factory = SAXParserFactory.newInstance();
> > +            SAXParserFactory factory = XmlUtil.newSAXParserFactory();
> >              SAXParser parser = factory.newSAXParser();
> >              PluginNameIDHandler handler = new PluginNameIDHandler();
> >              parser.parse(xml, handler);
> > @@ -1243,7 +1244,7 @@
> >       * @throws ParserConfigurationException
> >       */
> >      private static DocumentBuilder createDocumentBuilder() throws ParserConfigurationException {
> > -        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
> > +        DocumentBuilderFactory factory = XmlUtil.newDocumentBuilderFactory();
> >          factory.setValidating(true);
> >          factory.setNamespaceAware(true);
> >          factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
> >
> > Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java?rev=428843&r1=428842&r2=428843&view=diff
> > ==============================================================================
> > --- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java (original)
> > +++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java Fri Aug  4 11:43:59 2006
> > @@ -41,6 +41,7 @@
> >  import org.apache.geronimo.kernel.repository.ArtifactTypeHandler;
> >  import org.apache.geronimo.kernel.repository.FileWriteMonitor;
> >  import org.apache.geronimo.kernel.repository.WriteableRepository;
> > +import org.apache.geronimo.kernel.util.XmlUtil;
> >  import org.apache.geronimo.system.serverinfo.ServerInfo;
> >  import org.w3c.dom.Document;
> >  import org.w3c.dom.Element;
> > @@ -125,7 +126,7 @@
> >          try {
> >              if (is != null) {
> >                  InputSource in = new InputSource(is);
> > -                DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
> > +                DocumentBuilderFactory dfactory = XmlUtil.newDocumentBuilderFactory();
> >                  dfactory.setNamespaceAware(true);
> >                  try {
> >                      Document doc = dfactory.newDocumentBuilder().parse(in);
> >
> > Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/util/PluginRepositoryExporter.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/util/PluginRepositoryExporter.java?rev=428843&r1=428842&r2=428843&view=diff
> > ==============================================================================
> > --- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/util/PluginRepositoryExporter.java (original)
> > +++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/util/PluginRepositoryExporter.java Fri Aug  4 11:43:59 2006
> > @@ -40,6 +40,7 @@
> >  import org.apache.geronimo.kernel.config.IOUtil;
> >  import org.apache.geronimo.kernel.repository.Artifact;
> >  import org.apache.geronimo.kernel.repository.Version;
> > +import org.apache.geronimo.kernel.util.XmlUtil;
> >  import org.apache.geronimo.system.configuration.RepositoryConfigurationStore;
> >  import org.apache.geronimo.system.configuration.ConfigurationStoreUtil;
> >  import org.apache.geronimo.system.configuration.GBeanOverride;
> > @@ -237,7 +238,7 @@
> >              }
> >              Map plugins = installer.getInstalledPlugins();
> >              Document doc = generateConfigFile(installer, plugins.values());
> > -            TransformerFactory xfactory = TransformerFactory.newInstance();
> > +            TransformerFactory xfactory = XmlUtil.newTransformerFactory();
> >              Transformer xform = xfactory.newTransformer();
> >              xform.setOutputProperty(OutputKeys.INDENT, "yes");
> >              xform.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
> > @@ -291,7 +292,7 @@
> >
> >      private void updateMavenMetadata(File dir, Artifact artifact) throws TransformerException, IOException, SAXException, ParserConfigurationException {
> >          File mavenFile = new File(dir, "maven-metadata.xml");
> > -        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
> > +        DocumentBuilderFactory factory = XmlUtil.newDocumentBuilderFactory();
> >          DocumentBuilder builder = factory.newDocumentBuilder();
> >          Document doc;
> >          if(mavenFile.exists()) {
> > @@ -323,7 +324,7 @@
> >              newVersion.appendChild(doc.createTextNode(artifact.getVersion().toString()));
> >              versionsElement.appendChild(newVersion);
> >          }
> > -        TransformerFactory xfactory = TransformerFactory.newInstance();
> > +        TransformerFactory xfactory = XmlUtil.newTransformerFactory();
> >          Transformer xform = xfactory.newTransformer();
> >          xform.setOutputProperty(OutputKeys.INDENT, "yes");
> >          xform.transform(new DOMSource(doc), new StreamResult(mavenFile));
> > @@ -344,7 +345,7 @@
> >
> >
> >      private Document generateConfigFile(PluginInstaller installer, Collection plugins) throws ParserConfigurationException {
> > -        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
> > +        DocumentBuilderFactory factory = XmlUtil.newDocumentBuilderFactory();
> >          factory.setNamespaceAware(true);
> >          factory.setValidating(true);
> >          factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
> >
> > Modified: geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/configuration/ServerOverrideTest.java
> > URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/configuration/ServerOverrideTest.java?rev=428843&r1=428842&r2=428843&view=diff
> > ==============================================================================
> > --- geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/configuration/ServerOverrideTest.java (original)
> > +++ geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/configuration/ServerOverrideTest.java Fri Aug  4 11:43:59 2006
> > @@ -20,6 +20,7 @@
> >  import org.apache.geronimo.gbean.AbstractNameQuery;
> >  import org.apache.geronimo.gbean.ReferencePatterns;
> >  import org.apache.geronimo.kernel.repository.Artifact;
> > +import org.apache.geronimo.kernel.util.XmlUtil;
> >  import org.w3c.dom.Document;
> >  import org.w3c.dom.Element;
> >  import org.w3c.dom.NodeList;
> > @@ -31,13 +32,11 @@
> >  import javax.xml.transform.TransformerFactory;
> >  import javax.xml.transform.Transformer;
> >  import javax.xml.transform.OutputKeys;
> > -import javax.xml.transform.TransformerException;
> >  import javax.xml.transform.stream.StreamResult;
> >  import javax.xml.transform.dom.DOMSource;
> >  import java.io.ByteArrayInputStream;
> >  import java.io.ByteArrayOutputStream;
> >  import java.io.InputStream;
> > -import java.io.PrintWriter;
> >  import java.util.Arrays;
> >  import java.util.Collections;
> >  import java.util.Iterator;
> > @@ -282,7 +281,7 @@
> >      }
> >
> >      private Element parseXml(InputStream in, String name) throws Exception {
> > -        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
> > +        DocumentBuilderFactory documentBuilderFactory = XmlUtil.newDocumentBuilderFactory();
> >          Document doc = documentBuilderFactory.newDocumentBuilder().parse(in);
> >          Element elem = doc.getDocumentElement();
> >          if(elem.getNodeName().equals(name)) {
> > @@ -293,14 +292,14 @@
> >      }
> >
> >      private Document createDocument() throws ParserConfigurationException {
> > -        DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
> > +        DocumentBuilderFactory dFactory = XmlUtil.newDocumentBuilderFactory();
> >          dFactory.setValidating(false);
> >          return dFactory.newDocumentBuilder().newDocument();
> >      }
> >
> >      private Element readElement(Element e, String name) throws Exception {
> >          ByteArrayOutputStream out = new ByteArrayOutputStream();
> > -        TransformerFactory xfactory = TransformerFactory.newInstance();
> > +        TransformerFactory xfactory = XmlUtil.newTransformerFactory();
> >          Transformer xform = xfactory.newTransformer();
> >          xform.setOutputProperty(OutputKeys.INDENT, "yes");
> >          xform.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
> >
> >
> >
>

Mime
View raw message