From d54466366bcb61d2680403da73e52ddb008e7c19 Mon Sep 17 00:00:00 2001 From: Thomas Diesler Date: Mon, 30 Jan 2012 15:50:29 +0100 Subject: [PATCH] Update to xerces-2.10.0 --- .gitignore | 4 +- .project | 17 - .settings/org.eclipse.jdt.core.prefs | 6 - .settings/org.maven.ide.eclipse.prefs | 9 - bundle/.classpath | 8 - bundle/.gitignore | 1 - bundle/.project | 23 - bundle/.settings/org.eclipse.jdt.core.prefs | 6 - bundle/.settings/org.maven.ide.eclipse.prefs | 9 - bundle/pom.xml | 209 ++++--- .../osgi/xml/DocumentBuilderFactoryImpl.java | 30 +- .../jboss/osgi/xml/SAXParserFactoryImpl.java | 27 +- .../jboss/osgi/xml/XMLParserCapability.java | 31 +- .../osgi/xml/internal/XMLParserActivator.java | 569 ------------------ .../xml/internal/XMLParserActivatorExt.java | 232 ++++--- itest/.classpath | 8 - itest/.gitignore | 1 - itest/.project | 23 - itest/.settings/org.eclipse.jdt.core.prefs | 6 - itest/.settings/org.maven.ide.eclipse.prefs | 9 - itest/pom.xml | 261 ++++---- .../test/osgi/xml/dom/DOMParserTestCase.java | 189 +++--- .../jaxp/DocumentParserFactoryTestCase.java | 136 ----- .../test/osgi/xml/sax/SAXParserTestCase.java | 198 +++--- .../resources/jboss-osgi-framework.properties | 18 +- itest/src/test/resources/log4j.xml | 50 -- itest/src/test/resources/logging.properties | 44 ++ pom.xml | 216 ++++--- 28 files changed, 684 insertions(+), 1656 deletions(-) delete mode 100644 .project delete mode 100644 .settings/org.eclipse.jdt.core.prefs delete mode 100644 .settings/org.maven.ide.eclipse.prefs delete mode 100644 bundle/.classpath delete mode 100644 bundle/.gitignore delete mode 100644 bundle/.project delete mode 100644 bundle/.settings/org.eclipse.jdt.core.prefs delete mode 100644 bundle/.settings/org.maven.ide.eclipse.prefs delete mode 100644 bundle/src/main/java/org/jboss/osgi/xml/internal/XMLParserActivator.java delete mode 100644 itest/.classpath delete mode 100644 itest/.gitignore delete mode 100644 itest/.project delete mode 100644 itest/.settings/org.eclipse.jdt.core.prefs delete mode 100644 itest/.settings/org.maven.ide.eclipse.prefs delete mode 100644 itest/src/test/java/org/jboss/test/osgi/xml/jaxp/DocumentParserFactoryTestCase.java delete mode 100644 itest/src/test/resources/log4j.xml create mode 100644 itest/src/test/resources/logging.properties diff --git a/.gitignore b/.gitignore index 19f2e00..26a9bfe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -/target -/target +*.iml +target diff --git a/.project b/.project deleted file mode 100644 index 8a2078d..0000000 --- a/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - jboss-osgi-xerces - - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.maven.ide.eclipse.maven2Nature - - diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 8e9e937..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,6 +0,0 @@ -#Sun Aug 01 11:40:32 EDT 2010 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/.settings/org.maven.ide.eclipse.prefs b/.settings/org.maven.ide.eclipse.prefs deleted file mode 100644 index 628739a..0000000 --- a/.settings/org.maven.ide.eclipse.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Sun Aug 01 11:40:31 EDT 2010 -activeProfiles= -eclipse.preferences.version=1 -fullBuildGoals=process-test-resources -includeModules=false -resolveWorkspaceProjects=true -resourceFilterGoals=process-resources resources\:testResources -skipCompilerPlugin=true -version=1 diff --git a/bundle/.classpath b/bundle/.classpath deleted file mode 100644 index fb2f7c1..0000000 --- a/bundle/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/bundle/.gitignore b/bundle/.gitignore deleted file mode 100644 index ea8c4bf..0000000 --- a/bundle/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/bundle/.project b/bundle/.project deleted file mode 100644 index e28aeed..0000000 --- a/bundle/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - jboss-osgi-xerces - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - diff --git a/bundle/.settings/org.eclipse.jdt.core.prefs b/bundle/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 6ccf48c..0000000 --- a/bundle/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,6 +0,0 @@ -#Tue Aug 03 03:41:31 EDT 2010 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/bundle/.settings/org.maven.ide.eclipse.prefs b/bundle/.settings/org.maven.ide.eclipse.prefs deleted file mode 100644 index dcb9d17..0000000 --- a/bundle/.settings/org.maven.ide.eclipse.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Aug 03 03:41:30 EDT 2010 -activeProfiles= -eclipse.preferences.version=1 -fullBuildGoals=process-test-resources -includeModules=false -resolveWorkspaceProjects=true -resourceFilterGoals=process-resources resources\:testResources -skipCompilerPlugin=true -version=1 diff --git a/bundle/pom.xml b/bundle/pom.xml index 1077189..532fe41 100644 --- a/bundle/pom.xml +++ b/bundle/pom.xml @@ -1,109 +1,122 @@ - - - - - - - - + + + + + + + + - - 4.0.0 + + 4.0.0 - JBossOSGi Xerces Bundle - - org.jboss.osgi.xerces - jboss-osgi-xerces - bundle + + org.jboss.osgi.xerces + jbosgi-xerces-parent + 2.10.0-SNAPSHOT + + + JBossOSGi Xerces Bundle - - org.jboss.osgi.xerces - jboss-osgi-xerces-parent - 2.9.1.SP8-SNAPSHOT - + jbosgi-xerces + bundle + + + + + xml-apis + xml-apis + + + xml-resolver + xml-resolver + + + xerces + xercesImpl + + + + org.jboss.logging + jboss-logging + provided + + + + + org.osgi + org.osgi.core + provided + + + org.osgi + org.osgi.enterprise + provided + + - - - - org.jboss.osgi - jboss-osgi-spi - - - xerces - xercesImpl - - - - xml-resolver - xml-resolver - + + + + org.apache.felix + maven-bundle-plugin + + + ${project.artifactId} + org.jboss.osgi.xml.internal.XMLParserActivatorExt + + org.jboss.osgi.xml.internal + + + org.jboss.osgi.xml;version=${project.version} + + + javax.xml.datatype, + javax.xml.namespace, + javax.xml.parsers, + javax.xml.stream;resolution:=optional, + javax.xml.stream.events;resolution:=optional, + javax.xml.transform;resolution:=optional, + javax.xml.transform.dom;resolution:=optional, + javax.xml.transform.sax;resolution:=optional, + javax.xml.transform.stax;resolution:=optional, + javax.xml.transform.stream;resolution:=optional, + javax.xml.validation;resolution:=optional, + org.apache.xml.resolver*;version="[1.2,2.0)", + org.w3c.dom, + org.w3c.dom.events, + org.w3c.dom.ls, + org.w3c.dom.ranges;resolution:=optional, + org.w3c.dom.traversal;resolution:=optional, + org.w3c.dom.views;resolution:=optional, + org.xml.sax, + org.xml.sax.ext, + org.xml.sax.helpers, - - - org.osgi - org.osgi.core - - - org.osgi - org.osgi.compendium - provided - - + + org.jboss.logging;version="[3.0,4.0)", + org.osgi.framework;version="[1.5,2.0)", + org.osgi.util.xml;version="[1.0,2.0)", - - - - org.apache.felix - maven-bundle-plugin - - - ${project.artifactId} - org.jboss.osgi.xml.internal.XMLParserActivatorExt - - org.jboss.osgi.xml.internal - - - org.jboss.osgi.xml;version=${project.version} - - - javax.xml.datatype, - javax.xml.namespace, - javax.xml.parsers, - javax.xml.transform*, - javax.xml.validation, - org.w3c.dom*, - org.xml.sax*, + + !sun.io + + + xercesImpl;inline=false, + xml-apis;inline=false, + xml-resolver;inline=false, + + <_exportcontents> + org.apache.xml.resolver*;version=1.2, + + + + + + - - org.jboss.logging;version="[3.0,4.0)", - org.jboss.osgi.spi.*;version="[1.0,2.0)", - org.osgi.framework;version="[1.5,2.0)", - org.osgi.util.xml;version="[1.0,2.0)", - - - !sun.io, - - - - xercesImpl;inline=false, - xml-resolver;inline=false, - - <_exportcontents> - - org.apache.xerces.*;version=${version.apache.xerces}, - - - - - - - diff --git a/bundle/src/main/java/org/jboss/osgi/xml/DocumentBuilderFactoryImpl.java b/bundle/src/main/java/org/jboss/osgi/xml/DocumentBuilderFactoryImpl.java index 2ac499a..cffe496 100644 --- a/bundle/src/main/java/org/jboss/osgi/xml/DocumentBuilderFactoryImpl.java +++ b/bundle/src/main/java/org/jboss/osgi/xml/DocumentBuilderFactoryImpl.java @@ -26,24 +26,20 @@ /** * A DocumentBuilderFactory that gets loaded from this bundle. - * + * * @author thomas.diesler@jboss.com * @since 21-Jul-2009 */ -public class DocumentBuilderFactoryImpl extends org.apache.xerces.jaxp.DocumentBuilderFactoryImpl -{ - @Override - public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException - { - ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader(); - try - { - Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); - return super.newDocumentBuilder(); - } - finally - { - Thread.currentThread().setContextClassLoader(ctxLoader); - } - } +public class DocumentBuilderFactoryImpl extends org.apache.xerces.jaxp.DocumentBuilderFactoryImpl { + @Override + public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException { + ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader(); + try { + Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); + DocumentBuilder domBuilder = super.newDocumentBuilder(); + return domBuilder; + } finally { + Thread.currentThread().setContextClassLoader(ctxLoader); + } + } } \ No newline at end of file diff --git a/bundle/src/main/java/org/jboss/osgi/xml/SAXParserFactoryImpl.java b/bundle/src/main/java/org/jboss/osgi/xml/SAXParserFactoryImpl.java index 798d2e9..72dfd28 100644 --- a/bundle/src/main/java/org/jboss/osgi/xml/SAXParserFactoryImpl.java +++ b/bundle/src/main/java/org/jboss/osgi/xml/SAXParserFactoryImpl.java @@ -30,20 +30,15 @@ * @author thomas.diesler@jboss.com * @since 21-Jul-2009 */ -public class SAXParserFactoryImpl extends org.apache.xerces.jaxp.SAXParserFactoryImpl -{ - @Override - public SAXParser newSAXParser() throws ParserConfigurationException - { - ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader(); - try - { - Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); - return super.newSAXParser(); - } - finally - { - Thread.currentThread().setContextClassLoader(ctxLoader); - } - } +public class SAXParserFactoryImpl extends org.apache.xerces.jaxp.SAXParserFactoryImpl { + @Override + public SAXParser newSAXParser() throws ParserConfigurationException { + ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader(); + try { + Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); + return super.newSAXParser(); + } finally { + Thread.currentThread().setContextClassLoader(ctxLoader); + } + } } \ No newline at end of file diff --git a/bundle/src/main/java/org/jboss/osgi/xml/XMLParserCapability.java b/bundle/src/main/java/org/jboss/osgi/xml/XMLParserCapability.java index 8cbf794..e48044c 100644 --- a/bundle/src/main/java/org/jboss/osgi/xml/XMLParserCapability.java +++ b/bundle/src/main/java/org/jboss/osgi/xml/XMLParserCapability.java @@ -23,43 +23,30 @@ import javax.xml.parsers.SAXParserFactory; -import org.jboss.osgi.spi.capability.Capability; -import org.jboss.osgi.spi.capability.CompendiumCapability; - /** * Adds the XML parser capability. - * + *

* It is ignored if the {@link SAXParserFactory} is already registered. - * + *

* Installed bundles: jboss-osgi-xerces.jar * * @author thomas.diesler@jboss.com * @since 05-May-2009 */ -public class XMLParserCapability extends Capability -{ - /* +public class XMLParserCapability { + /* * Service property key for the 'provider' of this service. */ - public static final String PARSER_PROVIDER = "provider"; - /* + public static final String PARSER_PROVIDER = "provider"; + /* * Service property value for the 'provider' of this service. * The value is jboss.osgi. */ - public static final String PROVIDER_JBOSS_OSGI = "jboss"; - /* + public static final String PROVIDER_JBOSS_OSGI = "jboss"; + /* * Service property specifying if factory is configured to support XInclude aware parsers. * The value is of type Boolean. */ - public static final String PARSER_XINCLUDEAWARE = "parser.xincludeAware"; - - public XMLParserCapability() - { - super(SAXParserFactory.class.getName()); - setFilter("(" + PARSER_PROVIDER + "=" + PROVIDER_JBOSS_OSGI + ")"); - - addDependency(new CompendiumCapability()); + public static final String PARSER_XINCLUDEAWARE = "parser.xincludeAware"; - addBundle("bundles/jboss-osgi-xerces.jar"); - } } \ No newline at end of file diff --git a/bundle/src/main/java/org/jboss/osgi/xml/internal/XMLParserActivator.java b/bundle/src/main/java/org/jboss/osgi/xml/internal/XMLParserActivator.java deleted file mode 100644 index bdb7132..0000000 --- a/bundle/src/main/java/org/jboss/osgi/xml/internal/XMLParserActivator.java +++ /dev/null @@ -1,569 +0,0 @@ -/* - * $Header: /cvshome/build/org.osgi.util.xml/src/org/osgi/util/xml/XMLParserActivator.java,v 1.11 2006/10/27 18:17:06 hargrave Exp $ - * - * Copyright (c) OSGi Alliance (2002, 2006). All Rights Reserved. - * - * 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.jboss.osgi.xml.internal; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.FactoryConfigurationError; -import javax.xml.parsers.SAXParserFactory; - -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.ServiceFactory; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; - -/** - * This is a copy of the original XMLParserActivator, because we cannot use the one - * from the Apache Felix org.osgi.compendium-1.2.0.jar - * - * [JBOSGI-92] Class.forName issue with XMLParserActivator - * https://jira.jboss.org/jira/browse/JBOSGI-92 - */ - -/** - * A BundleActivator class that allows any JAXP compliant XML Parser to register - * itself as an OSGi parser service. - * - * Multiple JAXP compliant parsers can concurrently register by using this - * BundleActivator class. Bundles who wish to use an XML parser can then use the - * framework's service registry to locate available XML Parsers with the desired - * characteristics such as validating and namespace-aware. - * - *

- * The services that this bundle activator enables a bundle to provide are: - *

- * - *

- * The algorithm to find the implementations of the abstract parsers is derived - * from the JAR file specifications, specifically the Services API. - *

- * An XMLParserActivator assumes that it can find the class file names of the - * factory classes in the following files: - *

- *

- * If either of the files does not exist, XMLParserActivator - * assumes that the parser does not support that parser type. - * - *

- * XMLParserActivator attempts to instantiate both the - * SAXParserFactory and the DocumentBuilderFactory. - * It registers each factory with the framework along with service properties: - *

- *

- * Individual parser implementations may have additional features, properties, - * or attributes which could be used to select a parser with a filter. These can - * be added by extending this class and overriding the - * setSAXProperties and setDOMProperties methods. - */ -@SuppressWarnings({ "rawtypes", "unchecked" }) -public class XMLParserActivator implements BundleActivator, ServiceFactory -{ - /** Context of this bundle */ - private BundleContext context; - /** - * Filename containing the SAX Parser Factory Class name. Also used as the - * basis for the SERVICE_PID registration property. - */ - public static final String SAXFACTORYNAME = "javax.xml.parsers.SAXParserFactory"; - /** - * Filename containing the DOM Parser Factory Class name. Also used as the - * basis for the SERVICE_PID registration property. - */ - public static final String DOMFACTORYNAME = "javax.xml.parsers.DocumentBuilderFactory"; - /** Path to the factory class name files */ - private static final String PARSERCLASSFILEPATH = "/META-INF/services/"; - /** Fully qualified path name of SAX Parser Factory Class Name file */ - public static final String SAXCLASSFILE = PARSERCLASSFILEPATH + SAXFACTORYNAME; - /** Fully qualified path name of DOM Parser Factory Class Name file */ - public static final String DOMCLASSFILE = PARSERCLASSFILEPATH + DOMFACTORYNAME; - /** SAX Factory Service Description */ - private static final String SAXFACTORYDESCRIPTION = "A JAXP Compliant SAX Parser"; - /** DOM Factory Service Description */ - private static final String DOMFACTORYDESCRIPTION = "A JAXP Compliant DOM Parser"; - /** - * Service property specifying if factory is configured to support - * validating parsers. The value is of type Boolean. - */ - public static final String PARSER_VALIDATING = "parser.validating"; - /** - * Service property specifying if factory is configured to support namespace - * aware parsers. The value is of type Boolean. - */ - public static final String PARSER_NAMESPACEAWARE = "parser.namespaceAware"; - /** - * Key for parser factory name property - this must be saved in the parsers - * properties hashtable so that the parser factory can be instantiated from - * a ServiceReference - */ - private static final String FACTORYNAMEKEY = "parser.factoryname"; - - /** - * Called when this bundle is started so the Framework can perform the - * bundle-specific activities necessary to start this bundle. This method - * can be used to register services or to allocate any resources that this - * bundle needs. - * - *

- * This method must complete and return to its caller in a timely manner. - * - *

- * This method attempts to register a SAX and DOM parser with the - * Framework's service registry. - * - * @param context The execution context of the bundle being started. - * @throws java.lang.Exception If this method throws an exception, this - * bundle is marked as stopped and the Framework will remove this - * bundle's listeners, unregister all services registered by this - * bundle, and release all services used by this bundle. - */ - public void start(BundleContext context) throws Exception - { - this.context = context; - Bundle parserBundle = context.getBundle(); - try - { - // check for sax parsers - registerSAXParsers(getParserFactoryClassNames(parserBundle.getResource(SAXCLASSFILE))); - // check for dom parsers - registerDOMParsers(getParserFactoryClassNames(parserBundle.getResource(DOMCLASSFILE))); - } - catch (IOException ioe) - { - // if there were any IO errors accessing the resource files - // containing the class names - ioe.printStackTrace(); - throw new FactoryConfigurationError(ioe); - } - } - - /** - * This method has nothing to do as all active service registrations will - * automatically get unregistered when the bundle stops. - * - * @param context The execution context of the bundle being stopped. - * @throws java.lang.Exception If this method throws an exception, the - * bundle is still marked as stopped, and the Framework will remove - * the bundle's listeners, unregister all services registered by the - * bundle, and release all services used by the bundle. - */ - public void stop(BundleContext context) throws Exception - { - } - - /** - * Given the URL for a file, reads and returns the parser class names. There - * may be multiple classes specified in this file, one per line. There may - * also be comment lines in the file, which begin with "#". - * - * @param parserUrl The URL of the service file containing the parser class - * names - * @return A vector of strings containing the parser class names or null if - * parserUrl is null - * @throws IOException if there is a problem reading the URL input stream - */ - private Vector getParserFactoryClassNames(URL parserUrl) throws IOException - { - Vector v = new Vector(1); - if (parserUrl != null) - { - String parserFactoryClassName = null; - InputStream is = parserUrl.openStream(); - BufferedReader br = new BufferedReader(new InputStreamReader(is)); - while (true) - { - parserFactoryClassName = br.readLine(); - if (parserFactoryClassName == null) - { - break; // end of file reached - } - String pfcName = parserFactoryClassName.trim(); - if (pfcName.length() == 0) - { - continue; // blank line - } - int commentIdx = pfcName.indexOf("#"); - if (commentIdx == 0) - { // comment line - continue; - } - else if (commentIdx < 0) - { // no comment on this line - v.addElement(pfcName); - } - else - { - v.addElement(pfcName.substring(0, commentIdx).trim()); - } - } - return v; - } - else - { - return null; - } - } - - /** - * Register SAX Parser Factory Services with the framework. - * - * @param parserFactoryClassNames - a Vector of - * String objects containing the names of the parser - * Factory Classes - * @throws FactoryConfigurationError if thrown from getFactory - */ - private void registerSAXParsers(Vector parserFactoryClassNames) throws FactoryConfigurationError - { - if (parserFactoryClassNames != null) - { - Enumeration e = parserFactoryClassNames.elements(); - int index = 0; - while (e.hasMoreElements()) - { - String parserFactoryClassName = (String)e.nextElement(); - // create a sax parser factory just to get it's default - // properties. It will never be used since - // this class will operate as a service factory and give each - // service requestor it's own SaxParserFactory - SAXParserFactory factory = (SAXParserFactory)getFactory(parserFactoryClassName); - Hashtable properties = new Hashtable(7); - // figure out the default properties of the parser - setDefaultSAXProperties(factory, properties, index); - // store the parser factory class name in the properties so that - // it can be retrieved when getService is called - // to return a parser factory - properties.put(FACTORYNAMEKEY, parserFactoryClassName); - // release the factory - factory = null; - // register the factory as a service - context.registerService(SAXFACTORYNAME, this, properties); - index++; - } - } - } - - /** - *

- * Set the SAX Parser Service Properties. By default, the following - * properties are set: - *