) c::getClassLoader);
- Package pkg = c.getPackage();
- if(pkg==null)
- continue; // this is possible for primitives, arrays, and classes that are loaded by poorly implemented ClassLoaders
- String packageName = pkg.getName().replace('.', '/');
-
- // TODO: do we want to optimize away searching the same package? org.Foo, org.Bar, com.Baz
- // classes from the same package might come from different class loades, so it might be a bad idea
-
- // TODO: it's easier to look things up from the class
- // c.getResourceAsStream("jaxb.properties");
-
- // build the resource name and use the property loader code
- String resourceName = packageName+"/jaxb.properties";
- logger.fine("Trying to locate "+resourceName);
- Properties props = loadJAXBProperties(classLoader, resourceName);
- if (props == null) {
- logger.fine(" not found");
- } else {
- logger.fine(" found");
- if (props.containsKey(JAXB_CONTEXT_FACTORY)) {
- // trim() seems redundant, but adding to satisfy customer complaint
- factoryClassName = props.getProperty(JAXB_CONTEXT_FACTORY).trim();
- return newInstance(classes, properties, factoryClassName);
- } else {
- throw new JAXBException(Messages.format(Messages.MISSING_PROPERTY, packageName, JAXB_CONTEXT_FACTORY));
- }
- }
- }
-
- // search for a system property second (javax.xml.bind.JAXBContext)
- logger.fine("Checking system property "+jaxbContextFQCN);
- factoryClassName = AccessController.doPrivileged(new GetPropertyAction(jaxbContextFQCN));
- if( factoryClassName != null ) {
- logger.fine(" found "+factoryClassName);
- return newInstance( classes, properties, factoryClassName );
- }
- logger.fine(" not found");
-
- // search META-INF services next
- logger.fine("Checking META-INF/services");
- BufferedReader r;
- try {
- final String resource = "META-INF/services/" + jaxbContextFQCN;
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- URL resourceURL;
- if(classLoader==null)
- resourceURL = ClassLoader.getSystemResource(resource);
- else
- resourceURL = classLoader.getResource(resource);
-
- if (resourceURL != null) {
- logger.fine("Reading "+resourceURL);
- r = new BufferedReader(new InputStreamReader(resourceURL.openStream(), StandardCharsets.UTF_8));
- factoryClassName = r.readLine().trim();
- return newInstance(classes, properties, factoryClassName);
- } else {
- logger.fine("Unable to find: " + resource);
- }
- } catch (IOException e) {
- throw new JAXBException(e);
- }
-
- // else no provider found
- logger.fine("Trying to create the platform default provider");
- return newInstance(classes, properties, PLATFORM_DEFAULT_FACTORY_CLASS);
- }
-
-
- private static Properties loadJAXBProperties( ClassLoader classLoader,
- String propFileName )
- throws JAXBException {
-
- Properties props = null;
-
- try {
- URL url;
- if(classLoader==null)
- url = ClassLoader.getSystemResource(propFileName);
- else
- url = classLoader.getResource( propFileName );
-
- if( url != null ) {
- logger.fine("loading props from "+url);
- props = new Properties();
- InputStream is = url.openStream();
- props.load( is );
- is.close();
- }
- } catch( IOException ioe ) {
- logger.log(Level.FINE,"Unable to load "+propFileName,ioe);
- throw new JAXBException( ioe.toString(), ioe );
- }
-
- return props;
- }
-
-
- /**
- * Search the given ClassLoader for an instance of the specified class and
- * return a string representation of the URL that points to the resource.
- *
- * @param clazz
- * The class to search for
- * @param loader
- * The ClassLoader to search. If this parameter is null, then the
- * system class loader will be searched
- * @return
- * the URL for the class or null if it wasn't found
- */
- static URL which(Class clazz, ClassLoader loader) {
-
- String classnameAsResource = clazz.getName().replace('.', '/') + ".class";
-
- if(loader == null) {
- loader = ClassLoader.getSystemClassLoader();
- }
-
- return loader.getResource(classnameAsResource);
- }
-
- /**
- * Get the URL for the Class from it's ClassLoader.
- *
- * Convenience method for {@link #which(Class, ClassLoader)}.
- *
- * Equivalent to calling: which(clazz, clazz.getClassLoader())
- *
- * @param clazz
- * The class to search for
- * @return
- * the URL for the class or null if it wasn't found
- */
- static URL which(Class clazz) {
- return which(clazz, clazz.getClassLoader());
- }
-
- /**
- * When JAXB is in J2SE, rt.jar has to have a JAXB implementation.
- * However, rt.jar cannot have META-INF/services/javax.xml.bind.JAXBContext
- * because if it has, it will take precedence over any file that applications have
- * in their jar files.
- *
- *
- * When the user bundles his own JAXB implementation, we'd like to use it, and we
- * want the platform default to be used only when there's no other JAXB provider.
- *
- *
- * For this reason, we have to hard-code the class name into the API.
- */
- private static final String PLATFORM_DEFAULT_FACTORY_CLASS = "com.sun.xml.internal.bind.v2.ContextFactory";
-
- /**
- * Loads the class, provided that the calling thread has an access to the class being loaded.
- */
- private static Class safeLoadClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
- // using Osig locator to load the spi class
- try {
- Class spiClass = org.apache.karaf.specs.locator.OsgiLocator.locate(JAXBContext.class);
- if (spiClass != null) {
- return spiClass;
- }
- } catch (Throwable t) {
- }
- logger.fine("Trying to load "+className);
- try {
- // make sure that the current thread has an access to the package of the given name.
- SecurityManager s = System.getSecurityManager();
- if (s != null) {
- int i = className.lastIndexOf('.');
- if (i != -1) {
- s.checkPackageAccess(className.substring(0,i));
- }
- }
-
- if (classLoader == null) {
- return Class.forName(className);
- } else {
- return classLoader.loadClass(className);
- }
- } catch (SecurityException se) {
- // anyone can access the platform default factory class without permission
- if (PLATFORM_DEFAULT_FACTORY_CLASS.equals(className)) {
- return Class.forName(className);
- }
- throw se;
- }
- }
-
-}
diff --git a/specs/java.xml.ws/src/main/java/javax/xml/soap/$FactoryFinder.java b/specs/java.xml.ws/src/main/java/javax/xml/soap/$FactoryFinder.java
deleted file mode 100644
index 65938dd9f79..00000000000
--- a/specs/java.xml.ws/src/main/java/javax/xml/soap/$FactoryFinder.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.soap;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Properties;
-import java.util.ServiceLoader;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-class $FactoryFinder {
-
- private static final Logger LOGGER = Logger.getLogger("javax.xml.soap");
-
- @SuppressWarnings("unchecked")
- static T find(Class factoryClass, String defaultClassName, boolean tryFallback, String deprecatedFactoryId) throws SOAPException {
- ClassLoader tccl = contextClassLoader();
-
- String factoryId = factoryClass.getName();
- String className = fromSystemProperty(factoryId, deprecatedFactoryId);
- if (className != null) {
- Object result = newInstance(className, defaultClassName, tccl);
- return (T) result;
- }
-
- className = fromJDKProperties(factoryId, deprecatedFactoryId);
- if (className != null) {
- Object result = newInstance(className, defaultClassName, tccl);
- return (T) result;
- }
-
- try {
- Class spiClass = org.apache.karaf.specs.locator.OsgiLocator.locate(factoryClass);
- if (spiClass != null) {
- return spiClass.getConstructor().newInstance();
- }
- } catch (Throwable t) {
- }
-
- T factory = firstByServiceLoader(factoryClass);
- if (factory != null) {
- return factory;
- }
-
- className = fromMetaInfServices(deprecatedFactoryId, tccl);
- if (className != null) {
- LOGGER.log(Level.WARNING,
- "Using deprecated META-INF/services mechanism with non-standard property: {0}. " +
- "Property {1} should be used instead.",
- new Object[]{deprecatedFactoryId, factoryId});
- Object result = newInstance(className, defaultClassName, tccl);
- return (T) result;
- }
-
- if (!tryFallback)
- return null;
-
- if (defaultClassName == null) {
- throw new SOAPException("Provider for " + factoryId + " cannot be found", null);
- }
- return (T) newInstance(defaultClassName, defaultClassName, tccl);
- }
-
- static T find(Class factoryClass, String defaultClassName, boolean tryFallback) throws SOAPException {
- return find(factoryClass, defaultClassName, tryFallback, null);
- }
-
- private static String fromMetaInfServices(String deprecatedFactoryId, ClassLoader tccl) {
- String serviceId = "META-INF/services/" + deprecatedFactoryId;
- LOGGER.log(Level.FINE, "Checking deprecated {0} resource", serviceId);
-
- try (InputStream is =
- tccl == null
- ? ClassLoader.getSystemResourceAsStream(serviceId)
- : tccl.getResourceAsStream(serviceId)) {
-
- if (is != null) {
- String factoryClassName;
- try (InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);
- BufferedReader rd = new BufferedReader(isr)) {
- factoryClassName = rd.readLine();
- }
-
- logFound(factoryClassName);
- if (factoryClassName != null && !"".equals(factoryClassName)) {
- return factoryClassName;
- }
- }
- } catch (IOException e) {
- }
- return null;
- }
-
- private static String fromJDKProperties(String factoryId, String deprecatedFactoryId) {
- Path path = null;
- try {
- String JAVA_HOME = getSystemProperty("java.home");
- path = Paths.get(JAVA_HOME, "conf", "jaxm.properties");
- LOGGER.log(Level.FINE, "Checking configuration in {0}", path);
-
- if (!Files.exists(path)) {
- path = Paths.get(JAVA_HOME, "lib", "jaxm.properties");
- }
-
- LOGGER.log(Level.FINE, "Checking configuration in {0}", path);
- if (Files.exists(path)) {
- Properties props = new Properties();
- try (InputStream inputStream = Files.newInputStream(path)) {
- props.load(inputStream);
- }
-
- LOGGER.log(Level.FINE, "Checking property {0}", factoryId);
- String factoryClassName = props.getProperty(factoryId);
- logFound(factoryClassName);
- if (factoryClassName != null) {
- return factoryClassName;
- }
-
- if (deprecatedFactoryId != null) {
- LOGGER.log(Level.FINE, "Checking deprecated property {0}", deprecatedFactoryId);
- factoryClassName = props.getProperty(deprecatedFactoryId);
- logFound(factoryClassName);
- if (factoryClassName != null) {
- LOGGER.log(Level.WARNING,
- "Using non-standard property: {0}. Property {1} should be used instead.",
- new Object[]{deprecatedFactoryId, factoryId});
- return factoryClassName;
- }
- }
- }
- } catch (Exception ignored) {
- LOGGER.log(Level.SEVERE, "Error reading SAAJ configuration from [" + path +
- "] file. Check it is accessible and has correct format.", ignored);
- }
- return null;
- }
-
- private static String fromSystemProperty(String factoryId, String deprecatedFactoryId) {
- String systemProp = getSystemProperty(factoryId);
- if (systemProp != null) {
- return systemProp;
- }
- if (deprecatedFactoryId != null) {
- systemProp = getSystemProperty(deprecatedFactoryId);
- if (systemProp != null) {
- LOGGER.log(Level.WARNING,
- "Using non-standard property: {0}. Property {1} should be used instead.",
- new Object[] {deprecatedFactoryId, factoryId});
- return systemProp;
- }
- }
- return null;
- }
-
- private static String getSystemProperty(final String property) {
- LOGGER.log(Level.FINE, "Checking system property {0}", property);
- String value = AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty(property));
- logFound(value);
- return value;
- }
-
- private static void logFound(String value) {
- if (value != null) {
- LOGGER.log(Level.FINE, " found {0}", value);
- } else {
- LOGGER.log(Level.FINE, " not found");
- }
- }
-
- private static T firstByServiceLoader(Class spiClass) throws SOAPException {
- LOGGER.log(Level.FINE, "Using java.util.ServiceLoader to find {0}", spiClass.getName());
- try {
- ServiceLoader serviceLoader = ServiceLoader.load(spiClass);
- for (T impl : serviceLoader) {
- LOGGER.fine("ServiceProvider loading Facility used; returning object [" + impl.getClass().getName() + "]");
- return impl;
- }
- } catch (Throwable t) {
- throw new SOAPException("Error while searching for service [" + spiClass.getName() + "]", t);
- }
- return null;
- }
-
- private static void checkPackageAccess(String className) {
- SecurityManager s = System.getSecurityManager();
- if (s != null) {
- int i = className.lastIndexOf('.');
- if (i != -1) {
- s.checkPackageAccess(className.substring(0, i));
- }
- }
- }
-
- private static Class nullSafeLoadClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
- if (classLoader == null) {
- return Class.forName(className);
- } else {
- return classLoader.loadClass(className);
- }
- }
-
- static Object newInstance(String className, String defaultImplClassName, ClassLoader classLoader) throws SOAPException {
- try {
- return safeLoadClass(className, defaultImplClassName, classLoader).getConstructor().newInstance();
- } catch (ClassNotFoundException x) {
- throw new SOAPException("Provider " + className + " not found", x);
- } catch (Exception x) {
- throw new SOAPException("Provider " + className + " could not be instantiated: " + x, x);
- }
- }
-
- private static Class> safeLoadClass(String className, String defaultImplClassName, ClassLoader classLoader) throws ClassNotFoundException {
- try {
- checkPackageAccess(className);
- } catch (SecurityException se) {
- if (defaultImplClassName != null && defaultImplClassName.equals(className)) {
- return Class.forName(className);
- }
- throw se;
- }
- return nullSafeLoadClass(className, classLoader);
- }
-
- private static ClassLoader contextClassLoader() throws SOAPException {
- try {
- return Thread.currentThread().getContextClassLoader();
- } catch (Exception x) {
- throw new SOAPException(x.toString(), x);
- }
- }
-
-}
diff --git a/specs/java.xml.ws/src/main/java/javax/xml/soap/MessageFactory.java b/specs/java.xml.ws/src/main/java/javax/xml/soap/MessageFactory.java
deleted file mode 100644
index 6f0686a68b4..00000000000
--- a/specs/java.xml.ws/src/main/java/javax/xml/soap/MessageFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.soap;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-public abstract class MessageFactory {
-
- private static final String DEFAULT_MESSAGE_FACTORY = "com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl";
-
- public static MessageFactory newInstance() throws SOAPException {
- try {
- MessageFactory factory = $FactoryFinder.find(MessageFactory.class, DEFAULT_MESSAGE_FACTORY, false);
- if (factory != null) {
- return factory;
- }
- return newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
- } catch (Exception ex) {
- throw new SOAPException("Unable to create message factory for SOAP: " + ex.getMessage(), ex);
- }
-
- }
-
- public static MessageFactory newInstance(String protocol) throws SOAPException {
- return SAAJMetaFactory.getInstance().newMessageFactory(protocol);
- }
-
- public abstract SOAPMessage createMessage() throws SOAPException;
-
- public abstract SOAPMessage createMessage(MimeHeaders headers, InputStream in) throws IOException, SOAPException;
-}
diff --git a/specs/java.xml.ws/src/main/java/javax/xml/soap/SAAJMetaFactory.java b/specs/java.xml.ws/src/main/java/javax/xml/soap/SAAJMetaFactory.java
deleted file mode 100644
index cf83c554a16..00000000000
--- a/specs/java.xml.ws/src/main/java/javax/xml/soap/SAAJMetaFactory.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.soap;
-
-public abstract class SAAJMetaFactory {
-
- private static final String META_FACTORY_DEPRECATED_CLASS_PROPERTY = "javax.xml.soap.MetaFactory";
-
- private static final String DEFAULT_META_FACTORY_CLASS = "com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl";
-
- static SAAJMetaFactory getInstance() throws SOAPException {
- try {
- return $FactoryFinder.find(SAAJMetaFactory.class, DEFAULT_META_FACTORY_CLASS, true, META_FACTORY_DEPRECATED_CLASS_PROPERTY);
- } catch (Exception e) {
- throw new SOAPException("Unable to create SAAJ meta-factory: " + e.getMessage(), e);
- }
- }
-
- protected SAAJMetaFactory() { }
-
- protected abstract MessageFactory newMessageFactory(String protocol) throws SOAPException;
-
- protected abstract SOAPFactory newSOAPFactory(String protocol) throws SOAPException;
-}
diff --git a/specs/java.xml.ws/src/main/java/javax/xml/soap/SOAPConnectionFactory.java b/specs/java.xml.ws/src/main/java/javax/xml/soap/SOAPConnectionFactory.java
deleted file mode 100644
index 9466f2d99ce..00000000000
--- a/specs/java.xml.ws/src/main/java/javax/xml/soap/SOAPConnectionFactory.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.soap;
-
-public abstract class SOAPConnectionFactory {
-
- private static final String DEFAULT_SOAP_CONNECTION_FACTORY = "com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnectionFactory";
-
- public static SOAPConnectionFactory newInstance() throws SOAPException, UnsupportedOperationException {
- try {
- return $FactoryFinder.find(SOAPConnectionFactory.class, DEFAULT_SOAP_CONNECTION_FACTORY, true);
- } catch (Exception ex) {
- throw new SOAPException("Unable to create SOAP connection factory: " + ex.getMessage(), ex);
- }
- }
-
- public abstract SOAPConnection createConnection() throws SOAPException;
-
-}
diff --git a/specs/java.xml.ws/src/main/java/javax/xml/soap/SOAPFactory.java b/specs/java.xml.ws/src/main/java/javax/xml/soap/SOAPFactory.java
deleted file mode 100644
index eebdcc5f8ce..00000000000
--- a/specs/java.xml.ws/src/main/java/javax/xml/soap/SOAPFactory.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.soap;
-
-import org.w3c.dom.Element;
-
-import javax.xml.namespace.QName;
-
-public abstract class SOAPFactory {
-
- private static final String DEFAULT_SOAP_FACTORY = "com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl";
-
- public SOAPElement createElement(Element domElement) throws SOAPException {
- throw new UnsupportedOperationException("createElement(org.w3c.dom.Element) must be overridden by all subclasses of SOAPFactory.");
- }
-
- public abstract SOAPElement createElement(Name name) throws SOAPException;
-
- public SOAPElement createElement(QName qname) throws SOAPException {
- throw new UnsupportedOperationException("createElement(QName) must be overridden by all subclasses of SOAPFactory.");
- }
-
- public abstract SOAPElement createElement(String localName) throws SOAPException;
-
-
- public abstract SOAPElement createElement(String localName, String prefix, String uri) throws SOAPException;
-
- public abstract Detail createDetail() throws SOAPException;
-
- public abstract SOAPFault createFault(String reasonText, QName faultCode) throws SOAPException;
-
- public abstract SOAPFault createFault() throws SOAPException;
-
- public abstract Name createName(String localName, String prefix, String uri) throws SOAPException;
-
- public abstract Name createName(String localName) throws SOAPException;
-
- public static SOAPFactory newInstance() throws SOAPException {
- try {
- SOAPFactory factory = $FactoryFinder.find(SOAPFactory.class, DEFAULT_SOAP_FACTORY, false);
- if (factory != null) {
- return factory;
- }
- return newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
- } catch (Exception ex) {
- throw new SOAPException("Unable to create SOAP Factory: " + ex.getMessage(), ex);
- }
-
- }
-
- public static SOAPFactory newInstance(String protocol) throws SOAPException {
- return SAAJMetaFactory.getInstance().newSOAPFactory(protocol);
- }
-}
diff --git a/specs/java.xml.ws/src/main/java/javax/xml/ws/spi/$FactoryFinder.java b/specs/java.xml.ws/src/main/java/javax/xml/ws/spi/$FactoryFinder.java
deleted file mode 100644
index 12bce644faf..00000000000
--- a/specs/java.xml.ws/src/main/java/javax/xml/ws/spi/$FactoryFinder.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.ws.spi;
-
-import javax.xml.ws.WebServiceException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Properties;
-import java.util.ServiceLoader;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-class $FactoryFinder {
-
- private static final Logger LOGGER = Logger.getLogger("javax.xml.ws");
-
- @SuppressWarnings("unchecked")
- static T find(Class factoryClass, String fallbackClassName) {
- ClassLoader classLoader = contextClassLoader();
-
- T provider = firstByServiceLoader(factoryClass);
- if (provider != null) {
- return provider;
- }
-
- String factoryId = factoryClass.getName();
-
- provider = (T) fromJDKProperties(factoryId, fallbackClassName, classLoader);
- if (provider != null) {
- return provider;
- }
-
- provider = (T) fromSystemProperty(factoryId, fallbackClassName, classLoader);
- if (provider != null) {
- return provider;
- }
-
- try {
- Class spiClass = org.apache.karaf.specs.locator.OsgiLocator.locate(factoryClass);
- if (spiClass != null) {
- return spiClass.getConstructor().newInstance();
- }
- } catch (Throwable t) {
- }
-
- if (fallbackClassName == null) {
- throw new WebServiceException("Provider for " + factoryId + " cannot be found", null);
- }
-
- return (T) newInstance(fallbackClassName, fallbackClassName, classLoader);
- }
-
- private static Object fromSystemProperty(String factoryId, String fallbackClassName, ClassLoader classLoader) {
- try {
- String systemProp = System.getProperty(factoryId);
- if (systemProp != null) {
- return newInstance(systemProp, fallbackClassName, classLoader);
- }
- } catch (SecurityException ignored) {
- }
- return null;
- }
-
- private static Object fromJDKProperties(String factoryId, String fallbackClassName, ClassLoader classLoader) {
- Path path = null;
- try {
- String JAVA_HOME = System.getProperty("java.home");
- path = Paths.get(JAVA_HOME, "conf", "jaxws.properties");
- if (!Files.exists(path)) {
- path = Paths.get(JAVA_HOME, "lib", "jaxws.properties");
- }
- if (Files.exists(path)) {
- Properties props = new Properties();
- try (InputStream inStream = Files.newInputStream(path)) {
- props.load(inStream);
- }
- String factoryClassName = props.getProperty(factoryId);
- return newInstance(factoryClassName, fallbackClassName, classLoader);
- }
- } catch (Exception ignored) {
- LOGGER.log(Level.SEVERE, "Error reading JAX-WS configuration from [" + path +
- "] file. Check it is accessible and has correct format.", ignored);
- }
- return null;
- }
-
- private static T firstByServiceLoader(Class spiClass) throws WebServiceException {
- LOGGER.log(Level.FINE, "Using java.util.ServiceLoader to find {0}", spiClass.getName());
- try {
- ServiceLoader serviceLoader = ServiceLoader.load(spiClass);
- for (T impl : serviceLoader) {
- LOGGER.fine("ServiceProvider loading Facility used; returning object [" + impl.getClass().getName() + "]");
- return impl;
- }
- } catch (Throwable t) {
- throw new WebServiceException("Error while searching for service [" + spiClass.getName() + "]", t);
- }
- return null;
- }
-
- private static void checkPackageAccess(String className) {
- SecurityManager s = System.getSecurityManager();
- if (s != null) {
- int i = className.lastIndexOf('.');
- if (i != -1) {
- s.checkPackageAccess(className.substring(0, i));
- }
- }
- }
-
- private static Class nullSafeLoadClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
- if (classLoader == null) {
- return Class.forName(className);
- } else {
- return classLoader.loadClass(className);
- }
- }
-
- private static Object newInstance(String className, String defaultImplClassName, ClassLoader classLoader) throws WebServiceException {
- try {
- return safeLoadClass(className, defaultImplClassName, classLoader).getConstructor().newInstance();
- } catch (ClassNotFoundException x) {
- throw new WebServiceException("Provider " + className + " not found", x);
- } catch (Exception x) {
- throw new WebServiceException("Provider " + className + " could not be instantiated: " + x, x);
- }
- }
-
- private static Class> safeLoadClass(String className, String defaultImplClassName, ClassLoader classLoader) throws ClassNotFoundException {
- try {
- checkPackageAccess(className);
- } catch (SecurityException se) {
- if (defaultImplClassName != null && defaultImplClassName.equals(className)) {
- return Class.forName(className);
- }
- throw se;
- }
- return nullSafeLoadClass(className, classLoader);
- }
-
- private static ClassLoader contextClassLoader() throws WebServiceException {
- try {
- return Thread.currentThread().getContextClassLoader();
- } catch (Exception x) {
- throw new WebServiceException(x.toString(), x);
- }
- }
-
-}
diff --git a/specs/java.xml.ws/src/main/java/javax/xml/ws/spi/Provider.java b/specs/java.xml.ws/src/main/java/javax/xml/ws/spi/Provider.java
deleted file mode 100644
index 9eca1402a94..00000000000
--- a/specs/java.xml.ws/src/main/java/javax/xml/ws/spi/Provider.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.ws.spi;
-
-import org.w3c.dom.Element;
-
-import javax.xml.namespace.QName;
-import javax.xml.transform.Source;
-import javax.xml.ws.*;
-import javax.xml.ws.wsaddressing.W3CEndpointReference;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-
-public abstract class Provider {
-
- private static final String DEFAULT_JAXWSPROVIDER = "com.sun.xml.internal.ws.spi.ProviderImpl";
-
- protected Provider() {
- }
-
- public static Provider provider() {
- try {
- return $FactoryFinder.find(Provider.class, DEFAULT_JAXWSPROVIDER);
- } catch (WebServiceException ex) {
- throw ex;
- } catch (Exception ex) {
- throw new WebServiceException("Unable to createEndpointReference Provider", ex);
- }
- }
-
- public abstract ServiceDelegate createServiceDelegate(URL wsdlDocumentLocation, QName serviceName,
- Class extends Service> serviceClass);
-
- public ServiceDelegate createServiceDelegate(URL wsdlDocumentLocation, QName serviceName,
- Class extends Service> serviceClass, WebServiceFeature... features) {
- throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour.");
- }
-
- public abstract Endpoint createEndpoint(String bindingId, Object implementor);
-
- public abstract Endpoint createAndPublishEndpoint(String address, Object implementor);
-
- public abstract EndpointReference readEndpointReference(Source eprInfoset);
-
- public abstract T getPort(EndpointReference endpointReference, Class serviceEndpointInterface,
- WebServiceFeature... features);
-
- public abstract W3CEndpointReference createW3CEndpointReference(String address, QName serviceName,
- QName portName, List metadata,
- String wsdlDocumentLocation,
- List referenceParameters);
-
- public W3CEndpointReference createW3CEndpointReference(String address,
- QName interfaceName, QName serviceName, QName portName,
- List metadata, String wsdlDocumentLocation,
- List referenceParameters,
- List elements, Map attributes) {
- throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour.");
- }
-
- public Endpoint createAndPublishEndpoint(String address, Object implementor, WebServiceFeature... features) {
- throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour.");
- }
-
- public Endpoint createEndpoint(String bindingId, Object implementor, WebServiceFeature... features) {
- throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour.");
- }
-
- public Endpoint createEndpoint(String bindingId, Class> implementorClass,
- Invoker invoker, WebServiceFeature... features) {
- throw new UnsupportedOperationException("JAX-WS 2.2 implementation must override this default behaviour.");
- }
-
-}
diff --git a/specs/java.xml/pom.xml b/specs/java.xml/pom.xml
deleted file mode 100644
index 0e5d1584f6d..00000000000
--- a/specs/java.xml/pom.xml
+++ /dev/null
@@ -1,139 +0,0 @@
-
-
-
-
-
- 4.0.0
-
-
- org.apache.karaf.specs
- specs
- 4.5.0-SNAPSHOT
-
-
- org.apache.karaf.specs.java.xml
- jar
- Apache Karaf :: Specs :: Java Xml
-
-
-
-
- org.apache.karaf
- karaf-bom
- ${project.version}
- pom
- import
-
-
-
-
-
-
- org.apache.geronimo.specs
- geronimo-stax-api_1.2_spec
- 1.2
-
-
- xml-apis
- xml-apis
- 1.4.01
-
-
- org.apache.karaf.specs
- org.apache.karaf.specs.locator
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- true
-
-
-
-
-
-
-
-
diff --git a/specs/java.xml/src/main/java/javax/xml/datatype/$FactoryFinder.java b/specs/java.xml/src/main/java/javax/xml/datatype/$FactoryFinder.java
deleted file mode 100644
index 1e550400c77..00000000000
--- a/specs/java.xml/src/main/java/javax/xml/datatype/$FactoryFinder.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.datatype;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.ServiceConfigurationError;
-import java.util.ServiceLoader;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-class $FactoryFinder {
-
- private static final String DEFAULT_PACKAGE = "com.sun.xml.internal.";
-
- private static final Logger LOGGER = Logger.getLogger("jvaax.xml.datatype");
-
- final private static Properties cacheProps = new Properties();
-
- private static volatile boolean firstTime = true;
-
- static private Class getProviderClass(String className, ClassLoader cl, boolean doFallback, boolean useBSClsLoader) throws ClassNotFoundException {
- try {
- if (cl == null) {
- if (useBSClsLoader) {
- return Class.forName(className, false, $FactoryFinder.class.getClassLoader());
- } else {
- cl = getContextClassLoader();
- if (cl == null) {
- throw new ClassNotFoundException();
- }
- else {
- return Class.forName(className, false, cl);
- }
- }
- }
- else {
- return Class.forName(className, false, cl);
- }
- }
- catch (ClassNotFoundException e1) {
- if (doFallback) {
- return Class.forName(className, false, $FactoryFinder.class.getClassLoader());
- }
- else {
- throw e1;
- }
- }
- }
-
-
- static T newInstance(Class type, String className, ClassLoader cl, boolean doFallback) throws DatatypeConfigurationException {
- return newInstance(type, className, cl, doFallback, false);
- }
-
-
- static T newInstance(Class type, String className, ClassLoader cl, boolean doFallback, boolean useBSClsLoader) throws DatatypeConfigurationException {
- assert type != null;
- if (System.getSecurityManager() != null) {
- if (className != null && className.startsWith(DEFAULT_PACKAGE)) {
- cl = null;
- useBSClsLoader = true;
- }
- }
- try {
- Class> providerClass = getProviderClass(className, cl, doFallback, useBSClsLoader);
- if (!type.isAssignableFrom(providerClass)) {
- throw new ClassCastException(className + " cannot be cast to " + type.getName());
- }
- Object instance = providerClass.getConstructor().newInstance();
- final ClassLoader clD = cl;
- LOGGER.fine(() -> "created new instance of " + providerClass + " using ClassLoader: " + clD);
- return type.cast(instance);
- }
- catch (ClassNotFoundException x) {
- throw new DatatypeConfigurationException("Provider " + className + " not found", x);
- }
- catch (Exception x) {
- throw new DatatypeConfigurationException("Provider " + className + " could not be instantiated: " + x, x);
- }
- }
-
-
- static T find(Class type, String fallbackClassName) throws DatatypeConfigurationException {
- return find(type, type.getName(), null, fallbackClassName);
- }
-
- static T find(Class type, String factoryId, ClassLoader cl, String fallbackClassName) throws DatatypeConfigurationException
- {
- try {
- // If we are deployed into an OSGi environment, leverage it
- Class extends T> spiClass = org.apache.karaf.specs.locator.OsgiLocator.locate(type, factoryId);
- if (spiClass != null) {
- return spiClass.getConstructor().newInstance();
- }
- } catch (Throwable e) {
- }
-
- try {
- final String systemProp;
- if (type.getName().equals(factoryId)) {
- systemProp = getSystemProperty(factoryId);
- } else {
- systemProp = System.getProperty(factoryId);
- }
- if (systemProp != null) {
- LOGGER.fine(() -> "found system property, value=" + systemProp);
- return newInstance(type, systemProp, cl, true);
- }
- }
- catch (SecurityException se) {
- throw new DatatypeConfigurationException("Failed to read factoryId '" + factoryId + "'", se);
- }
- try {
- if (firstTime) {
- synchronized (cacheProps) {
- if (firstTime) {
- firstTime = false;
- String javaHome = getSystemProperty("java.home");
- String configFile;
- configFile = javaHome + File.separator + "conf" + File.separator + "jaxp.properties";
- File jaxp = new File(configFile);
- if (doesFileExist(jaxp)) {
- cacheProps.load(getFileInputStream(jaxp));
- }
- configFile = javaHome + File.separator + "conf" + File.separator + "stax.properties";
- File stax = new File(configFile);
- if (doesFileExist(stax)) {
- cacheProps.load(getFileInputStream(stax));
- }
- }
- }
- }
- final String factoryClassName = cacheProps.getProperty(factoryId);
- if (factoryClassName != null) {
- return newInstance(type, factoryClassName, cl, true);
- }
- }
- catch (Exception ex) {
- LOGGER.log(Level.FINE, "Error loading JDK properties", ex);
- }
- if (type.getName().equals(factoryId)) {
- final T provider = findServiceProvider(type, cl);
- if (provider != null) {
- return provider;
- }
- } else {
- assert fallbackClassName == null;
- }
- if (fallbackClassName == null) {
- throw new DatatypeConfigurationException("Provider for " + factoryId + " cannot be found", null);
- }
- LOGGER.fine(() -> "loaded from fallback value: " + fallbackClassName);
- return newInstance(type, fallbackClassName, cl, true);
- }
-
-
- private static T findServiceProvider(final Class type, final ClassLoader cl) throws DatatypeConfigurationException {
- try {
- return AccessController.doPrivileged((PrivilegedAction) () -> {
- final ServiceLoader serviceLoader;
- if (cl == null) {
- serviceLoader = ServiceLoader.load(type);
- } else {
- serviceLoader = ServiceLoader.load(type, cl);
- }
- final Iterator iterator = serviceLoader.iterator();
- if (iterator.hasNext()) {
- return iterator.next();
- } else {
- return null;
- }
- });
- } catch(ServiceConfigurationError e) {
- final RuntimeException x = new RuntimeException("Provider for " + type + " cannot be created", e);
- throw new DatatypeConfigurationException(x.getMessage(), x);
- }
- }
-
- private static ClassLoader getContextClassLoader() throws SecurityException{
- return AccessController.doPrivileged((PrivilegedAction) () -> {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null) {
- cl = ClassLoader.getSystemClassLoader();
- }
- return cl;
- });
- }
-
- private static String getSystemProperty(final String propName) {
- return AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty(propName));
- }
-
- private static FileInputStream getFileInputStream(final File file) throws FileNotFoundException {
- try {
- return AccessController.doPrivileged((PrivilegedExceptionAction) () -> new FileInputStream(file));
- } catch (PrivilegedActionException e) {
- throw (FileNotFoundException)e.getException();
- }
- }
-
- private static boolean doesFileExist(final File f) {
- return AccessController.doPrivileged((PrivilegedAction) f::exists);
- }
-}
diff --git a/specs/java.xml/src/main/java/javax/xml/datatype/DatatypeFactory.java b/specs/java.xml/src/main/java/javax/xml/datatype/DatatypeFactory.java
deleted file mode 100644
index 5ff92db72ab..00000000000
--- a/specs/java.xml/src/main/java/javax/xml/datatype/DatatypeFactory.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.datatype;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.GregorianCalendar;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public abstract class DatatypeFactory {
-
- public static final String DATATYPEFACTORY_PROPERTY = "javax.xml.datatype.DatatypeFactory";
-
- private static final String DATATYPEFACTORY_IMPLEMENTATION_CLASS = "com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl";
-
- private static final Pattern XDTSCHEMA_YMD = Pattern.compile("[^DT]*");
-
- private static final Pattern XDTSCHEMA_DTD = Pattern.compile("[^YM]*[DT].*");
-
-
- protected DatatypeFactory() {
- }
-
-
- public static DatatypeFactory newDefaultInstance() {
- try {
- return $FactoryFinder.newInstance(DatatypeFactory.class, DATATYPEFACTORY_IMPLEMENTATION_CLASS, null, false, true);
- } catch (DatatypeConfigurationException e) {
- throw new RuntimeException("Unable to create default instance", e);
- }
- }
-
- public static DatatypeFactory newInstance() throws DatatypeConfigurationException {
- return $FactoryFinder.find(DatatypeFactory.class, DATATYPEFACTORY_IMPLEMENTATION_CLASS);
- }
-
-
- public static DatatypeFactory newInstance(String factoryClassName, ClassLoader classLoader) throws DatatypeConfigurationException {
- return $FactoryFinder.newInstance(DatatypeFactory.class, factoryClassName, classLoader, false);
- }
-
- public abstract Duration newDuration(final String lexicalRepresentation);
-
- public abstract Duration newDuration(final long durationInMilliSeconds);
-
- public abstract Duration newDuration(final boolean isPositive, final BigInteger years, final BigInteger months,
- final BigInteger days, final BigInteger hours, final BigInteger minutes, final BigDecimal seconds);
-
- public Duration newDuration(final boolean isPositive, final int years, final int months,
- final int days, final int hours, final int minutes, final int seconds) {
- BigInteger realYears = (years != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) years) : null;
- BigInteger realMonths = (months != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) months) : null;
- BigInteger realDays = (days != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) days) : null;
- BigInteger realHours = (hours != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) hours) : null;
- BigInteger realMinutes = (minutes != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) minutes) : null;
- BigDecimal realSeconds = (seconds != DatatypeConstants.FIELD_UNDEFINED) ? BigDecimal.valueOf((long) seconds) : null;
- return newDuration(isPositive, realYears, realMonths, realDays, realHours, realMinutes, realSeconds);
- }
-
-
- public Duration newDurationDayTime(final String lexicalRepresentation) {
- if (lexicalRepresentation == null) {
- throw new NullPointerException("Trying to create an xdt:dayTimeDuration with an invalid lexical representation of \"null\"");
- }
- Matcher matcher = XDTSCHEMA_DTD.matcher(lexicalRepresentation);
- if (!matcher.matches()) {
- throw new IllegalArgumentException("Trying to create an xdt:dayTimeDuration with an invalid"
- + " lexical representation of \"" + lexicalRepresentation
- + "\", data model requires years and months only.");
- }
- return newDuration(lexicalRepresentation);
- }
-
- public Duration newDurationDayTime(final long durationInMilliseconds) {
- return newDuration(durationInMilliseconds);
- }
-
- public Duration newDurationDayTime(final boolean isPositive, final BigInteger day,
- final BigInteger hour, final BigInteger minute, final BigInteger second) {
- return newDuration(isPositive, null, null,
- day, hour, minute, (second != null) ? new BigDecimal(second) : null);
- }
-
- public Duration newDurationDayTime(final boolean isPositive, final int day,
- final int hour, final int minute, final int second) {
- return newDurationDayTime(isPositive, BigInteger.valueOf((long) day), BigInteger.valueOf((long) hour),
- BigInteger.valueOf((long) minute), BigInteger.valueOf((long) second));
- }
-
- public Duration newDurationYearMonth(final String lexicalRepresentation) {
- if (lexicalRepresentation == null) {
- throw new NullPointerException(
- "Trying to create an xdt:yearMonthDuration with an invalid"
- + " lexical representation of \"null\"");
- }
- Matcher matcher = XDTSCHEMA_YMD.matcher(lexicalRepresentation);
- if (!matcher.matches()) {
- throw new IllegalArgumentException(
- "Trying to create an xdt:yearMonthDuration with an invalid"
- + " lexical representation of \"" + lexicalRepresentation
- + "\", data model requires days and times only.");
- }
- return newDuration(lexicalRepresentation);
- }
-
-
- public Duration newDurationYearMonth(final long durationInMilliseconds) {
- Duration fullDuration = newDuration(durationInMilliseconds);
- boolean isPositive = fullDuration.getSign() != -1;
- BigInteger years = (BigInteger) fullDuration.getField(DatatypeConstants.YEARS);
- if (years == null) {
- years = BigInteger.ZERO;
- }
- BigInteger months = (BigInteger) fullDuration.getField(DatatypeConstants.MONTHS);
- if (months == null) {
- months = BigInteger.ZERO;
- }
- return newDurationYearMonth(isPositive, years, months);
- }
-
-
- public Duration newDurationYearMonth(final boolean isPositive, final BigInteger year, final BigInteger month) {
- return newDuration(isPositive, year, month,
- null, null, null, null);
- }
-
-
- public Duration newDurationYearMonth(final boolean isPositive, final int year, final int month) {
- return newDurationYearMonth(isPositive, BigInteger.valueOf((long) year), BigInteger.valueOf((long) month));
- }
-
- public abstract XMLGregorianCalendar newXMLGregorianCalendar();
-
- public abstract XMLGregorianCalendar newXMLGregorianCalendar(final String lexicalRepresentation);
-
- public abstract XMLGregorianCalendar newXMLGregorianCalendar(final GregorianCalendar cal);
-
- public abstract XMLGregorianCalendar newXMLGregorianCalendar(
- final BigInteger year,
- final int month,
- final int day,
- final int hour,
- final int minute,
- final int second,
- final BigDecimal fractionalSecond,
- final int timezone);
-
- public XMLGregorianCalendar newXMLGregorianCalendar(
- final int year,
- final int month,
- final int day,
- final int hour,
- final int minute,
- final int second,
- final int millisecond,
- final int timezone) {
- BigInteger realYear = (year != DatatypeConstants.FIELD_UNDEFINED) ? BigInteger.valueOf((long) year) : null;
- BigDecimal realMillisecond = null;
- if (millisecond != DatatypeConstants.FIELD_UNDEFINED) {
- if (millisecond < 0 || millisecond > 1000) {
- throw new IllegalArgumentException(
- "javax.xml.datatype.DatatypeFactory#newXMLGregorianCalendar("
- + "int year, int month, int day, int hour, int minute, int second, int millisecond, int timezone)"
- + "with invalid millisecond: " + millisecond
- );
- }
- realMillisecond = BigDecimal.valueOf((long) millisecond).movePointLeft(3);
- }
- return newXMLGregorianCalendar(realYear, month,
- day,
- hour,
- minute,
- second,
- realMillisecond,
- timezone
- );
- }
-
-
- public XMLGregorianCalendar newXMLGregorianCalendarDate(
- final int year,
- final int month,
- final int day,
- final int timezone) {
-
- return newXMLGregorianCalendar(
- year,
- month,
- day,
- DatatypeConstants.FIELD_UNDEFINED,
- DatatypeConstants.FIELD_UNDEFINED,
- DatatypeConstants.FIELD_UNDEFINED,
- DatatypeConstants.FIELD_UNDEFINED,
- timezone);
- }
-
-
- public XMLGregorianCalendar newXMLGregorianCalendarTime(
- final int hours,
- final int minutes,
- final int seconds,
- final int timezone) {
-
- return newXMLGregorianCalendar(
- DatatypeConstants.FIELD_UNDEFINED,
- DatatypeConstants.FIELD_UNDEFINED,
- DatatypeConstants.FIELD_UNDEFINED,
- hours,
- minutes,
- seconds,
- DatatypeConstants.FIELD_UNDEFINED,
- timezone);
- }
-
-
- public XMLGregorianCalendar newXMLGregorianCalendarTime(
- final int hours,
- final int minutes,
- final int seconds,
- final BigDecimal fractionalSecond,
- final int timezone) {
-
- return newXMLGregorianCalendar(
- null,
- DatatypeConstants.FIELD_UNDEFINED,
- DatatypeConstants.FIELD_UNDEFINED,
- hours,
- minutes,
- seconds,
- fractionalSecond,
- timezone);
- }
-
-
- public XMLGregorianCalendar newXMLGregorianCalendarTime(
- final int hours,
- final int minutes,
- final int seconds,
- final int milliseconds,
- final int timezone) {
-
-
- BigDecimal realMilliseconds = null;
- if (milliseconds != DatatypeConstants.FIELD_UNDEFINED) {
- if (milliseconds < 0 || milliseconds > 1000) {
- throw new IllegalArgumentException(
- "javax.xml.datatype.DatatypeFactory#newXMLGregorianCalendarTime("
- + "int hours, int minutes, int seconds, int milliseconds, int timezone)"
- + "with invalid milliseconds: " + milliseconds
- );
- }
-
- realMilliseconds = BigDecimal.valueOf((long) milliseconds).movePointLeft(3);
- }
-
- return newXMLGregorianCalendarTime(
- hours,
- minutes,
- seconds,
- realMilliseconds,
- timezone
- );
- }
-}
diff --git a/specs/java.xml/src/main/java/javax/xml/parsers/$FactoryFinder.java b/specs/java.xml/src/main/java/javax/xml/parsers/$FactoryFinder.java
deleted file mode 100644
index f209bf40601..00000000000
--- a/specs/java.xml/src/main/java/javax/xml/parsers/$FactoryFinder.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.parsers;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.ServiceConfigurationError;
-import java.util.ServiceLoader;
-import java.util.function.Supplier;
-
-class $FactoryFinder {
-
- private static final String DEFAULT_PACKAGE = "com.sun.xml.internal.";
-
- private static boolean debug;
-
- final private static Properties cacheProps = new Properties();
-
- private static volatile boolean firstTime = true;
-
- static {
- try {
- String val = getSystemProperty("jaxp.debug");
- debug = val != null && !"false".equals(val);
- }
- catch (SecurityException se) {
- debug = false;
- }
- }
-
- private static void dPrint(Supplier msgGen) {
- if (debug) {
- System.err.println("JAXP: " + msgGen.get());
- }
- }
-
-
- static private Class getProviderClass(String className, ClassLoader cl, boolean doFallback, boolean useBSClsLoader) throws ClassNotFoundException {
- try {
- if (cl == null) {
- if (useBSClsLoader) {
- return Class.forName(className, false, $FactoryFinder.class.getClassLoader());
- } else {
- cl = getContextClassLoader();
- if (cl == null) {
- throw new ClassNotFoundException();
- }
- else {
- return Class.forName(className, false, cl);
- }
- }
- }
- else {
- return Class.forName(className, false, cl);
- }
- }
- catch (ClassNotFoundException e1) {
- if (doFallback) {
- return Class.forName(className, false, $FactoryFinder.class.getClassLoader());
- }
- else {
- throw e1;
- }
- }
- }
-
-
- static T newInstance(Class type, String className, ClassLoader cl, boolean doFallback) throws FactoryConfigurationError {
- return newInstance(type, className, cl, doFallback, false);
- }
-
-
- static T newInstance(Class type, String className, ClassLoader cl, boolean doFallback, boolean useBSClsLoader) throws FactoryConfigurationError {
- assert type != null;
- if (System.getSecurityManager() != null) {
- if (className != null && className.startsWith(DEFAULT_PACKAGE)) {
- cl = null;
- useBSClsLoader = true;
- }
- }
- try {
- Class> providerClass = getProviderClass(className, cl, doFallback, useBSClsLoader);
- if (!type.isAssignableFrom(providerClass)) {
- throw new ClassCastException(className + " cannot be cast to " + type.getName());
- }
- Object instance = providerClass.getConstructor().newInstance();
- final ClassLoader clD = cl;
- dPrint(()->"created new instance of " + providerClass + " using ClassLoader: " + clD);
- return type.cast(instance);
- }
- catch (ClassNotFoundException x) {
- throw new FactoryConfigurationError(x, "Provider " + className + " not found");
- }
- catch (Exception x) {
- throw new FactoryConfigurationError(x, "Provider " + className + " could not be instantiated: " + x);
- }
- }
-
-
- static T find(Class type, String fallbackClassName) throws FactoryConfigurationError {
- return find(type, type.getName(), null, fallbackClassName);
- }
-
- static T find(Class type, String factoryId, ClassLoader cl, String fallbackClassName) throws FactoryConfigurationError
- {
- try {
- // If we are deployed into an OSGi environment, leverage it
- Class extends T> spiClass = org.apache.karaf.specs.locator.OsgiLocator.locate(type, factoryId);
- if (spiClass != null) {
- return spiClass.getConstructor().newInstance();
- }
- } catch (Throwable e) {
- }
-
- try {
- final String systemProp;
- if (type.getName().equals(factoryId)) {
- systemProp = getSystemProperty(factoryId);
- } else {
- systemProp = System.getProperty(factoryId);
- }
- if (systemProp != null) {
- dPrint(()->"found system property, value=" + systemProp);
- return newInstance(type, systemProp, cl, true);
- }
- }
- catch (SecurityException se) {
- throw new FactoryConfigurationError(se, "Failed to read factoryId '" + factoryId + "'");
- }
- try {
- if (firstTime) {
- synchronized (cacheProps) {
- if (firstTime) {
- firstTime = false;
- String javaHome = getSystemProperty("java.home");
- String configFile;
- configFile = javaHome + File.separator + "conf" + File.separator + "jaxp.properties";
- File jaxp = new File(configFile);
- if (doesFileExist(jaxp)) {
- cacheProps.load(getFileInputStream(jaxp));
- }
- configFile = javaHome + File.separator + "conf" + File.separator + "stax.properties";
- File stax = new File(configFile);
- if (doesFileExist(stax)) {
- cacheProps.load(getFileInputStream(stax));
- }
- }
- }
- }
- final String factoryClassName = cacheProps.getProperty(factoryId);
- if (factoryClassName != null) {
- return newInstance(type, factoryClassName, cl, true);
- }
- }
- catch (Exception ex) {
- if (debug) ex.printStackTrace();
- }
- if (type.getName().equals(factoryId)) {
- final T provider = findServiceProvider(type, cl);
- if (provider != null) {
- return provider;
- }
- } else {
- assert fallbackClassName == null;
- }
- if (fallbackClassName == null) {
- throw new FactoryConfigurationError("Provider for " + factoryId + " cannot be found");
- }
- dPrint(()->"loaded from fallback value: " + fallbackClassName);
- return newInstance(type, fallbackClassName, cl, true);
- }
-
-
- private static T findServiceProvider(final Class type, final ClassLoader cl) {
- try {
- return AccessController.doPrivileged((PrivilegedAction) () -> {
- final ServiceLoader serviceLoader;
- if (cl == null) {
- serviceLoader = ServiceLoader.load(type);
- } else {
- serviceLoader = ServiceLoader.load(type, cl);
- }
- final Iterator iterator = serviceLoader.iterator();
- if (iterator.hasNext()) {
- return iterator.next();
- } else {
- return null;
- }
- });
- } catch(ServiceConfigurationError e) {
- final RuntimeException x = new RuntimeException("Provider for " + type + " cannot be created", e);
- throw new FactoryConfigurationError(x, x.getMessage());
- }
- }
-
- private static ClassLoader getContextClassLoader() throws SecurityException{
- return AccessController.doPrivileged((PrivilegedAction) () -> {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null) {
- cl = ClassLoader.getSystemClassLoader();
- }
- return cl;
- });
- }
-
- private static String getSystemProperty(final String propName) {
- return AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty(propName));
- }
-
- private static FileInputStream getFileInputStream(final File file) throws FileNotFoundException {
- try {
- return AccessController.doPrivileged((PrivilegedExceptionAction) () -> new FileInputStream(file));
- } catch (PrivilegedActionException e) {
- throw (FileNotFoundException)e.getException();
- }
- }
-
- private static boolean doesFileExist(final File f) {
- return AccessController.doPrivileged((PrivilegedAction) f::exists);
- }
-}
diff --git a/specs/java.xml/src/main/java/javax/xml/parsers/DocumentBuilderFactory.java b/specs/java.xml/src/main/java/javax/xml/parsers/DocumentBuilderFactory.java
deleted file mode 100644
index 1a6865e46ef..00000000000
--- a/specs/java.xml/src/main/java/javax/xml/parsers/DocumentBuilderFactory.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.parsers;
-
-import javax.xml.validation.Schema;
-
-
-public abstract class DocumentBuilderFactory {
-
- private static final String DEFAULT_IMPL = "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl";
-
- private boolean validating = false;
- private boolean namespaceAware = false;
- private boolean whitespace = false;
- private boolean expandEntityRef = true;
- private boolean ignoreComments = false;
- private boolean coalescing = false;
-
- protected DocumentBuilderFactory() {
- }
-
- public static DocumentBuilderFactory newDefaultInstance() {
- return $FactoryFinder.newInstance(DocumentBuilderFactory.class, DEFAULT_IMPL, null, false, true);
- }
-
- public static DocumentBuilderFactory newInstance() {
- return $FactoryFinder.find(DocumentBuilderFactory.class, DEFAULT_IMPL);
- }
-
- public static DocumentBuilderFactory newInstance(String factoryClassName, ClassLoader classLoader) {
- return $FactoryFinder.newInstance(DocumentBuilderFactory.class, factoryClassName, classLoader, false);
- }
-
- public abstract DocumentBuilder newDocumentBuilder() throws ParserConfigurationException;
-
- public boolean isNamespaceAware() {
- return namespaceAware;
- }
-
- public void setNamespaceAware(boolean awareness) {
- this.namespaceAware = awareness;
- }
-
- public boolean isValidating() {
- return validating;
- }
-
- public void setValidating(boolean validating) {
- this.validating = validating;
- }
-
- public boolean isIgnoringElementContentWhitespace() {
- return whitespace;
- }
-
- public void setIgnoringElementContentWhitespace(boolean whitespace) {
- this.whitespace = whitespace;
- }
-
- public boolean isExpandEntityReferences() {
- return expandEntityRef;
- }
-
- public void setExpandEntityReferences(boolean expandEntityRef) {
- this.expandEntityRef = expandEntityRef;
- }
-
- public boolean isIgnoringComments() {
- return ignoreComments;
- }
-
- public void setIgnoringComments(boolean ignoreComments) {
- this.ignoreComments = ignoreComments;
- }
-
- public boolean isCoalescing() {
- return coalescing;
- }
-
- public void setCoalescing(boolean coalescing) {
- this.coalescing = coalescing;
- }
-
- public abstract void setAttribute(String name, Object value) throws IllegalArgumentException;
-
- public abstract Object getAttribute(String name) throws IllegalArgumentException;
-
- public abstract void setFeature(String name, boolean value) throws ParserConfigurationException;
-
- public abstract boolean getFeature(String name) throws ParserConfigurationException;
-
-
- public Schema getSchema() {
- throw new UnsupportedOperationException(
- "This parser does not support specification \""
- + this.getClass().getPackage().getSpecificationTitle()
- + "\" version \""
- + this.getClass().getPackage().getSpecificationVersion()
- + "\""
- );
-
- }
-
- public void setSchema(Schema schema) {
- throw new UnsupportedOperationException(
- "This parser does not support specification \""
- + this.getClass().getPackage().getSpecificationTitle()
- + "\" version \""
- + this.getClass().getPackage().getSpecificationVersion()
- + "\""
- );
- }
-
- public boolean isXIncludeAware() {
- throw new UnsupportedOperationException(
- "This parser does not support specification \""
- + this.getClass().getPackage().getSpecificationTitle()
- + "\" version \""
- + this.getClass().getPackage().getSpecificationVersion()
- + "\""
- );
- }
-
- public void setXIncludeAware(final boolean state) {
- if (state) {
- throw new UnsupportedOperationException(" setXIncludeAware " +
- "is not supported on this JAXP" +
- " implementation or earlier: " + this.getClass());
- }
- }
-}
diff --git a/specs/java.xml/src/main/java/javax/xml/parsers/SAXParserFactory.java b/specs/java.xml/src/main/java/javax/xml/parsers/SAXParserFactory.java
deleted file mode 100644
index 4ff834387cc..00000000000
--- a/specs/java.xml/src/main/java/javax/xml/parsers/SAXParserFactory.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.parsers;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXNotRecognizedException;
-import org.xml.sax.SAXNotSupportedException;
-
-import javax.xml.validation.Schema;
-
-public abstract class SAXParserFactory {
-
- private static final String DEFAULT_IMPL = "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl";
-
- private boolean validating = false;
-
- private boolean namespaceAware = false;
-
- protected SAXParserFactory() {
-
- }
-
- public static SAXParserFactory newDefaultInstance() {
- return $FactoryFinder.newInstance(SAXParserFactory.class, DEFAULT_IMPL, null, false, true);
- }
-
-
- public static SAXParserFactory newInstance() {
- return $FactoryFinder.find(SAXParserFactory.class, DEFAULT_IMPL);
- }
-
- public static SAXParserFactory newInstance(String factoryClassName, ClassLoader classLoader) {
- return $FactoryFinder.newInstance(SAXParserFactory.class, factoryClassName, classLoader, false);
- }
-
-
- public abstract SAXParser newSAXParser() throws ParserConfigurationException, SAXException;
-
- public boolean isNamespaceAware() {
- return namespaceAware;
- }
-
- public void setNamespaceAware(boolean awareness) {
- this.namespaceAware = awareness;
- }
-
- public boolean isValidating() {
- return validating;
- }
-
- public void setValidating(boolean validating) {
- this.validating = validating;
- }
-
- public abstract void setFeature(String name, boolean value)
- throws ParserConfigurationException, SAXNotRecognizedException,
- SAXNotSupportedException;
-
- public abstract boolean getFeature(String name)
- throws ParserConfigurationException, SAXNotRecognizedException,
- SAXNotSupportedException;
-
-
- public Schema getSchema() {
- throw new UnsupportedOperationException(
- "This parser does not support specification \""
- + this.getClass().getPackage().getSpecificationTitle()
- + "\" version \""
- + this.getClass().getPackage().getSpecificationVersion()
- + "\""
- );
- }
-
- public void setSchema(Schema schema) {
- throw new UnsupportedOperationException(
- "This parser does not support specification \""
- + this.getClass().getPackage().getSpecificationTitle()
- + "\" version \""
- + this.getClass().getPackage().getSpecificationVersion()
- + "\""
- );
- }
-
- public boolean isXIncludeAware() {
- throw new UnsupportedOperationException(
- "This parser does not support specification \""
- + this.getClass().getPackage().getSpecificationTitle()
- + "\" version \""
- + this.getClass().getPackage().getSpecificationVersion()
- + "\""
- );
- }
-
- public void setXIncludeAware(final boolean state) {
- if (state) {
- throw new UnsupportedOperationException(" setXIncludeAware " +
- "is not supported on this JAXP" +
- " implementation or earlier: " + this.getClass());
- }
- }
-}
diff --git a/specs/java.xml/src/main/java/javax/xml/stream/$FactoryFinder.java b/specs/java.xml/src/main/java/javax/xml/stream/$FactoryFinder.java
deleted file mode 100644
index 919cba8d995..00000000000
--- a/specs/java.xml/src/main/java/javax/xml/stream/$FactoryFinder.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.stream;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.ServiceConfigurationError;
-import java.util.ServiceLoader;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-class $FactoryFinder {
-
- private static final String DEFAULT_PACKAGE = "com.sun.xml.internal.";
-
- private static final Logger LOGGER = Logger.getLogger("javax.xml.stream");
-
- final private static Properties cacheProps = new Properties();
-
- private static volatile boolean firstTime = true;
-
- static private Class getProviderClass(String className, ClassLoader cl, boolean doFallback, boolean useBSClsLoader) throws ClassNotFoundException {
- try {
- if (cl == null) {
- if (useBSClsLoader) {
- return Class.forName(className, false, $FactoryFinder.class.getClassLoader());
- } else {
- cl = getContextClassLoader();
- if (cl == null) {
- throw new ClassNotFoundException();
- }
- else {
- return Class.forName(className, false, cl);
- }
- }
- }
- else {
- return Class.forName(className, false, cl);
- }
- }
- catch (ClassNotFoundException e1) {
- if (doFallback) {
- return Class.forName(className, false, $FactoryFinder.class.getClassLoader());
- }
- else {
- throw e1;
- }
- }
- }
-
-
- static T newInstance(Class type, String className, ClassLoader cl, boolean doFallback) throws FactoryConfigurationError {
- return newInstance(type, className, cl, doFallback, false);
- }
-
-
- static T newInstance(Class type, String className, ClassLoader cl, boolean doFallback, boolean useBSClsLoader) throws FactoryConfigurationError {
- assert type != null;
- if (System.getSecurityManager() != null) {
- if (className != null && className.startsWith(DEFAULT_PACKAGE)) {
- cl = null;
- useBSClsLoader = true;
- }
- }
- try {
- Class> providerClass = getProviderClass(className, cl, doFallback, useBSClsLoader);
- if (!type.isAssignableFrom(providerClass)) {
- throw new ClassCastException(className + " cannot be cast to " + type.getName());
- }
- Object instance = providerClass.getConstructor().newInstance();
- final ClassLoader clD = cl;
- LOGGER.fine(() -> "created new instance of " + providerClass + " using ClassLoader: " + clD);
- return type.cast(instance);
- }
- catch (ClassNotFoundException x) {
- throw new FactoryConfigurationError("Provider " + className + " not found", x);
- }
- catch (Exception x) {
- throw new FactoryConfigurationError("Provider " + className + " could not be instantiated: " + x, x);
- }
- }
-
-
- static T find(Class type, String fallbackClassName) throws FactoryConfigurationError {
- return find(type, type.getName(), null, fallbackClassName);
- }
-
- static T find(Class type, String factoryId, ClassLoader cl, String fallbackClassName) throws FactoryConfigurationError
- {
- try {
- // If we are deployed into an OSGi environment, leverage it
- Class extends T> spiClass = org.apache.karaf.specs.locator.OsgiLocator.locate(type, factoryId);
- if (spiClass != null) {
- return spiClass.getConstructor().newInstance();
- }
- } catch (Throwable e) {
- }
-
- try {
- final String systemProp;
- if (type.getName().equals(factoryId)) {
- systemProp = getSystemProperty(factoryId);
- } else {
- systemProp = System.getProperty(factoryId);
- }
- if (systemProp != null) {
- LOGGER.fine(() -> "found system property, value=" + systemProp);
- return newInstance(type, systemProp, cl, true);
- }
- }
- catch (SecurityException se) {
- throw new FactoryConfigurationError("Failed to read factoryId '" + factoryId + "'", se);
- }
- try {
- if (firstTime) {
- synchronized (cacheProps) {
- if (firstTime) {
- firstTime = false;
- String javaHome = getSystemProperty("java.home");
- String configFile;
- configFile = javaHome + File.separator + "conf" + File.separator + "jaxp.properties";
- File jaxp = new File(configFile);
- if (doesFileExist(jaxp)) {
- cacheProps.load(getFileInputStream(jaxp));
- }
- configFile = javaHome + File.separator + "conf" + File.separator + "stax.properties";
- File stax = new File(configFile);
- if (doesFileExist(stax)) {
- cacheProps.load(getFileInputStream(stax));
- }
- }
- }
- }
- final String factoryClassName = cacheProps.getProperty(factoryId);
- if (factoryClassName != null) {
- return newInstance(type, factoryClassName, cl, true);
- }
- }
- catch (Exception ex) {
- LOGGER.log(Level.FINE, "Error loading JDK properties file", ex);
- }
- if (type.getName().equals(factoryId)) {
- final T provider = findServiceProvider(type, cl);
- if (provider != null) {
- return provider;
- }
- } else {
- assert fallbackClassName == null;
- }
- if (fallbackClassName == null) {
- throw new FactoryConfigurationError("Provider for " + factoryId + " cannot be found", null);
- }
- LOGGER.fine(() -> "loaded from fallback value: " + fallbackClassName);
- return newInstance(type, fallbackClassName, cl, true);
- }
-
-
- private static T findServiceProvider(final Class type, final ClassLoader cl) {
- try {
- return AccessController.doPrivileged((PrivilegedAction) () -> {
- final ServiceLoader serviceLoader;
- serviceLoader = ServiceLoader.load(type, cl != null ? cl : Thread.currentThread().getContextClassLoader());
- final Iterator iterator = serviceLoader.iterator();
- if (iterator.hasNext()) {
- return iterator.next();
- } else {
- return null;
- }
- });
- } catch(ServiceConfigurationError e) {
- final RuntimeException x = new RuntimeException("Provider for " + type + " cannot be created", e);
- throw new FactoryConfigurationError(x, x.getMessage());
- }
- }
-
- private static ClassLoader getContextClassLoader() throws SecurityException{
- return AccessController.doPrivileged((PrivilegedAction) () -> {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null) {
- cl = ClassLoader.getSystemClassLoader();
- }
- return cl;
- });
- }
-
- private static String getSystemProperty(final String propName) {
- return AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty(propName));
- }
-
- private static FileInputStream getFileInputStream(final File file) throws FileNotFoundException {
- try {
- return AccessController.doPrivileged((PrivilegedExceptionAction) () -> new FileInputStream(file));
- } catch (PrivilegedActionException e) {
- throw (FileNotFoundException)e.getException();
- }
- }
-
- private static boolean doesFileExist(final File f) {
- return AccessController.doPrivileged((PrivilegedAction) f::exists);
- }
-}
diff --git a/specs/java.xml/src/main/java/javax/xml/stream/XMLEventFactory.java b/specs/java.xml/src/main/java/javax/xml/stream/XMLEventFactory.java
deleted file mode 100644
index f08eadd29eb..00000000000
--- a/specs/java.xml/src/main/java/javax/xml/stream/XMLEventFactory.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.stream;
-
-import java.util.Iterator;
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.namespace.QName;
-import javax.xml.stream.events.*;
-
-public abstract class XMLEventFactory {
-
- private static final String DEFAULT_IMPL = "com.sun.xml.internal.stream.events.XMLEventFactoryImpl";
-
- protected XMLEventFactory(){}
-
- public static XMLEventFactory newDefaultFactory() {
- return $FactoryFinder.newInstance(XMLEventFactory.class, DEFAULT_IMPL, null, false, true);
- }
-
- public static XMLEventFactory newInstance() throws FactoryConfigurationError {
- return $FactoryFinder.find(XMLEventFactory.class, DEFAULT_IMPL);
- }
-
- public static XMLEventFactory newFactory() throws FactoryConfigurationError {
- return $FactoryFinder.find(XMLEventFactory.class, DEFAULT_IMPL);
- }
-
- @Deprecated
- public static XMLEventFactory newInstance(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError {
- return $FactoryFinder.find(XMLEventFactory.class, factoryId, classLoader, null);
- }
-
- public static XMLEventFactory newFactory(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError {
- return $FactoryFinder.find(XMLEventFactory.class, factoryId, classLoader, null);
- }
-
- public abstract void setLocation(Location location);
-
- public abstract Attribute createAttribute(String prefix, String namespaceURI, String localName, String value);
-
- public abstract Attribute createAttribute(String localName, String value);
-
- public abstract Attribute createAttribute(QName name, String value);
-
- public abstract Namespace createNamespace(String namespaceURI);
-
- public abstract Namespace createNamespace(String prefix, String namespaceUri);
-
- public abstract StartElement createStartElement(QName name, Iterator extends Attribute> attributes, Iterator extends Namespace> namespaces);
-
- public abstract StartElement createStartElement(String prefix, String namespaceUri, String localName);
-
- public abstract StartElement createStartElement(String prefix, String namespaceUri, String localName, Iterator extends Attribute> attributes, Iterator extends Namespace> namespaces);
-
- public abstract StartElement createStartElement(String prefix, String namespaceUri, String localName, Iterator extends Attribute> attributes, Iterator extends Namespace> namespaces, NamespaceContext context);
-
- public abstract EndElement createEndElement(QName name, Iterator extends Namespace> namespaces);
-
- public abstract EndElement createEndElement(String prefix, String namespaceUri, String localName);
-
- public abstract EndElement createEndElement(String prefix, String namespaceUri, String localName, Iterator extends Namespace> namespaces);
-
- public abstract Characters createCharacters(String content);
-
- public abstract Characters createCData(String content);
-
- public abstract Characters createSpace(String content);
-
- public abstract Characters createIgnorableSpace(String content);
-
- public abstract StartDocument createStartDocument();
-
- public abstract StartDocument createStartDocument(String encoding, String version, boolean standalone);
-
- public abstract StartDocument createStartDocument(String encoding, String version);
-
- public abstract StartDocument createStartDocument(String encoding);
-
- public abstract EndDocument createEndDocument();
-
- public abstract EntityReference createEntityReference(String name, EntityDeclaration declaration);
-
- public abstract Comment createComment(String text);
-
- public abstract ProcessingInstruction createProcessingInstruction(String target, String data);
-
- public abstract DTD createDTD(String dtd);
-}
diff --git a/specs/java.xml/src/main/java/javax/xml/stream/XMLInputFactory.java b/specs/java.xml/src/main/java/javax/xml/stream/XMLInputFactory.java
deleted file mode 100644
index 1b87e3c3b3a..00000000000
--- a/specs/java.xml/src/main/java/javax/xml/stream/XMLInputFactory.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.stream;
-
-import javax.xml.stream.util.XMLEventAllocator;
-import javax.xml.transform.Source;
-
-public abstract class XMLInputFactory {
-
- public static final String IS_NAMESPACE_AWARE= "javax.xml.stream.isNamespaceAware";
-
- public static final String IS_VALIDATING= "javax.xml.stream.isValidating";
-
- public static final String IS_COALESCING= "javax.xml.stream.isCoalescing";
-
- public static final String IS_REPLACING_ENTITY_REFERENCES= "javax.xml.stream.isReplacingEntityReferences";
-
- public static final String IS_SUPPORTING_EXTERNAL_ENTITIES= "javax.xml.stream.isSupportingExternalEntities";
-
- public static final String SUPPORT_DTD= "javax.xml.stream.supportDTD";
-
- public static final String REPORTER= "javax.xml.stream.reporter";
-
- public static final String RESOLVER= "javax.xml.stream.resolver";
-
- public static final String ALLOCATOR= "javax.xml.stream.allocator";
-
- private static final String DEFAULT_IMPL = "com.sun.xml.internal.stream.XMLInputFactoryImpl";
-
- protected XMLInputFactory(){}
-
- private static void setProperties(XMLInputFactory factory) {
- factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true);
- factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
- factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);
- factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
- factory.setXMLResolver((publicID, systemID, baseURI, namespace) -> {
- throw new XMLStreamException("Reading external entities is disabled");
- });
- }
-
- public static XMLInputFactory newDefaultFactory() {
- XMLInputFactory factory = $FactoryFinder.newInstance(XMLInputFactory.class, DEFAULT_IMPL, null, false, true);
- setProperties(factory);
- return factory;
- }
-
- public static XMLInputFactory newInstance() throws FactoryConfigurationError {
- XMLInputFactory factory = $FactoryFinder.find(XMLInputFactory.class, DEFAULT_IMPL);
- setProperties(factory);
- return factory;
- }
-
- @Deprecated
- public static XMLInputFactory newFactory() throws FactoryConfigurationError {
- return newInstance();
- }
-
- public static XMLInputFactory newFactory(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError {
- XMLInputFactory factory = $FactoryFinder.find(XMLInputFactory.class, factoryId, classLoader, null);
- setProperties(factory);
- return factory;
- }
-
- @Deprecated
- public static XMLInputFactory newInstance(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError {
- return newFactory(factoryId, classLoader);
- }
-
- public abstract XMLStreamReader createXMLStreamReader(java.io.Reader reader) throws XMLStreamException;
-
- public abstract XMLStreamReader createXMLStreamReader(Source source) throws XMLStreamException;
-
- public abstract XMLStreamReader createXMLStreamReader(java.io.InputStream stream) throws XMLStreamException;
-
- public abstract XMLStreamReader createXMLStreamReader(java.io.InputStream stream, String encoding) throws XMLStreamException;
-
- public abstract XMLStreamReader createXMLStreamReader(String systemId, java.io.InputStream stream) throws XMLStreamException;
-
- public abstract XMLStreamReader createXMLStreamReader(String systemId, java.io.Reader reader) throws XMLStreamException;
-
- public abstract XMLEventReader createXMLEventReader(java.io.Reader reader) throws XMLStreamException;
-
- public abstract XMLEventReader createXMLEventReader(String systemId, java.io.Reader reader) throws XMLStreamException;
-
- public abstract XMLEventReader createXMLEventReader(XMLStreamReader reader) throws XMLStreamException;
-
- public abstract XMLEventReader createXMLEventReader(Source source) throws XMLStreamException;
-
- public abstract XMLEventReader createXMLEventReader(java.io.InputStream stream) throws XMLStreamException;
-
- public abstract XMLEventReader createXMLEventReader(java.io.InputStream stream, String encoding) throws XMLStreamException;
-
- public abstract XMLEventReader createXMLEventReader(String systemId, java.io.InputStream stream) throws XMLStreamException;
-
- public abstract XMLStreamReader createFilteredReader(XMLStreamReader reader, StreamFilter filter) throws XMLStreamException;
-
- public abstract XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter) throws XMLStreamException;
-
- public abstract XMLResolver getXMLResolver();
-
- public abstract void setXMLResolver(XMLResolver resolver);
-
- public abstract XMLReporter getXMLReporter();
-
- public abstract void setXMLReporter(XMLReporter reporter);
-
- public abstract void setProperty(java.lang.String name, Object value) throws IllegalArgumentException;
-
- public abstract Object getProperty(java.lang.String name) throws IllegalArgumentException;
-
- public abstract boolean isPropertySupported(String name);
-
- public abstract void setEventAllocator(XMLEventAllocator allocator);
-
- public abstract XMLEventAllocator getEventAllocator();
-
-}
diff --git a/specs/java.xml/src/main/java/javax/xml/stream/XMLOutputFactory.java b/specs/java.xml/src/main/java/javax/xml/stream/XMLOutputFactory.java
deleted file mode 100644
index 69ccca38f21..00000000000
--- a/specs/java.xml/src/main/java/javax/xml/stream/XMLOutputFactory.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.stream;
-
-import javax.xml.transform.Result;
-import java.io.OutputStream;
-import java.io.Writer;
-
-public abstract class XMLOutputFactory {
-
- public static final String IS_REPAIRING_NAMESPACES = "javax.xml.stream.isRepairingNamespaces";
-
- private static final String DEFAULT_IMPL = "com.sun.xml.internal.stream.XMLOutputFactoryImpl";
-
- protected XMLOutputFactory() {
- }
-
- public static XMLOutputFactory newDefaultFactory() {
- return $FactoryFinder.newInstance(XMLOutputFactory.class, DEFAULT_IMPL, null, false, true);
- }
-
- public static XMLOutputFactory newInstance() throws FactoryConfigurationError {
- return $FactoryFinder.find(XMLOutputFactory.class, DEFAULT_IMPL);
- }
-
- public static XMLOutputFactory newFactory() throws FactoryConfigurationError {
- return $FactoryFinder.find(XMLOutputFactory.class, DEFAULT_IMPL);
- }
-
- @Deprecated
- public static XMLInputFactory newInstance(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError {
- return $FactoryFinder.find(XMLInputFactory.class, factoryId, classLoader, null);
- }
-
- public static XMLOutputFactory newFactory(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError {
- return $FactoryFinder.find(XMLOutputFactory.class, factoryId, classLoader, null);
- }
-
- public abstract XMLStreamWriter createXMLStreamWriter(Writer stream) throws XMLStreamException;
-
- public abstract XMLStreamWriter createXMLStreamWriter(OutputStream stream) throws XMLStreamException;
-
- public abstract XMLStreamWriter createXMLStreamWriter(OutputStream stream, String encoding) throws XMLStreamException;
-
- public abstract XMLStreamWriter createXMLStreamWriter(Result result) throws XMLStreamException;
-
- public abstract XMLEventWriter createXMLEventWriter(Result result) throws XMLStreamException;
-
- public abstract XMLEventWriter createXMLEventWriter(OutputStream stream) throws XMLStreamException;
-
- public abstract XMLEventWriter createXMLEventWriter(OutputStream stream, String encoding) throws XMLStreamException;
-
- public abstract XMLEventWriter createXMLEventWriter(Writer stream) throws XMLStreamException;
-
- public abstract void setProperty(String name, Object value) throws IllegalArgumentException;
-
- public abstract Object getProperty(String name) throws IllegalArgumentException;
-
- public abstract boolean isPropertySupported(String name);
-}
diff --git a/specs/java.xml/src/main/java/javax/xml/transform/$FactoryFinder.java b/specs/java.xml/src/main/java/javax/xml/transform/$FactoryFinder.java
deleted file mode 100644
index 20f3b87720c..00000000000
--- a/specs/java.xml/src/main/java/javax/xml/transform/$FactoryFinder.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.transform;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.ServiceConfigurationError;
-import java.util.ServiceLoader;
-import java.util.function.Supplier;
-
-class $FactoryFinder {
-
- private static final String DEFAULT_PACKAGE = "com.sun.xml.internal.";
-
- private static boolean debug;
-
- final private static Properties cacheProps = new Properties();
-
- private static volatile boolean firstTime = true;
-
- static {
- try {
- String val = getSystemProperty("jaxp.debug");
- debug = val != null && !"false".equals(val);
- } catch (SecurityException se) {
- debug = false;
- }
- }
-
- private static void dPrint(Supplier msgGen) {
- if (debug) {
- System.err.println("JAXP: " + msgGen.get());
- }
- }
-
-
- static private Class getProviderClass(String className, ClassLoader cl, boolean doFallback, boolean useBSClsLoader) throws ClassNotFoundException {
- try {
- if (cl == null) {
- if (useBSClsLoader) {
- return Class.forName(className, false, $FactoryFinder.class.getClassLoader());
- } else {
- cl = getContextClassLoader();
- if (cl == null) {
- throw new ClassNotFoundException();
- } else {
- return Class.forName(className, false, cl);
- }
- }
- } else {
- return Class.forName(className, false, cl);
- }
- } catch (ClassNotFoundException e1) {
- if (doFallback) {
- return Class.forName(className, false, $FactoryFinder.class.getClassLoader());
- } else {
- throw e1;
- }
- }
- }
-
-
- static T newInstance(Class type, String className, ClassLoader cl, boolean doFallback) {
- return newInstance(type, className, cl, doFallback, false);
- }
-
-
- static T newInstance(Class type, String className, ClassLoader cl, boolean doFallback, boolean useBSClsLoader) {
- assert type != null;
- if (System.getSecurityManager() != null) {
- if (className != null && className.startsWith(DEFAULT_PACKAGE)) {
- cl = null;
- useBSClsLoader = true;
- }
- }
- try {
- Class> providerClass = getProviderClass(className, cl, doFallback, useBSClsLoader);
- if (!type.isAssignableFrom(providerClass)) {
- throw new ClassCastException(className + " cannot be cast to " + type.getName());
- }
- Object instance = providerClass.getConstructor().newInstance();
- final ClassLoader clD = cl;
- dPrint(() -> "created new instance of " + providerClass + " using ClassLoader: " + clD);
- return type.cast(instance);
- } catch (ClassNotFoundException x) {
- throw new TransformerFactoryConfigurationError(x, "Provider " + className + " not found");
- } catch (Exception x) {
- throw new TransformerFactoryConfigurationError(x, "Provider " + className + " could not be instantiated: " + x);
- }
- }
-
-
- static T find(Class type, String fallbackClassName) {
- return find(type, type.getName(), null, fallbackClassName);
- }
-
- static T find(Class type, String factoryId, ClassLoader cl, String fallbackClassName) {
- try {
- // If we are deployed into an OSGi environment, leverage it
- Class extends T> spiClass = org.apache.karaf.specs.locator.OsgiLocator.locate(type, factoryId);
- if (spiClass != null) {
- return spiClass.getConstructor().newInstance();
- }
- } catch (Throwable e) {
- }
-
- try {
- final String systemProp;
- if (type.getName().equals(factoryId)) {
- systemProp = getSystemProperty(factoryId);
- } else {
- systemProp = System.getProperty(factoryId);
- }
- if (systemProp != null) {
- dPrint(() -> "found system property, value=" + systemProp);
- return newInstance(type, systemProp, cl, true);
- }
- } catch (SecurityException se) {
- throw new TransformerFactoryConfigurationError(se, "Failed to read factoryId '" + factoryId + "'");
- }
- try {
- if (firstTime) {
- synchronized (cacheProps) {
- if (firstTime) {
- firstTime = false;
- String javaHome = getSystemProperty("java.home");
- String configFile;
- configFile = javaHome + File.separator + "conf" + File.separator + "jaxp.properties";
- File jaxp = new File(configFile);
- if (doesFileExist(jaxp)) {
- cacheProps.load(getFileInputStream(jaxp));
- }
- configFile = javaHome + File.separator + "conf" + File.separator + "stax.properties";
- File stax = new File(configFile);
- if (doesFileExist(stax)) {
- cacheProps.load(getFileInputStream(stax));
- }
- }
- }
- }
- final String factoryClassName = cacheProps.getProperty(factoryId);
- if (factoryClassName != null) {
- return newInstance(type, factoryClassName, cl, true);
- }
- } catch (Exception ex) {
- if (debug) ex.printStackTrace();
- }
- if (type.getName().equals(factoryId)) {
- final T provider = findServiceProvider(type, cl);
- if (provider != null) {
- return provider;
- }
- } else {
- assert fallbackClassName == null;
- }
- if (fallbackClassName == null) {
- throw new TransformerFactoryConfigurationError("Provider for " + factoryId + " cannot be found");
- }
- dPrint(() -> "loaded from fallback value: " + fallbackClassName);
- return newInstance(type, fallbackClassName, cl, true);
- }
-
-
- private static T findServiceProvider(final Class type, final ClassLoader cl) {
- try {
- return AccessController.doPrivileged((PrivilegedAction) () -> {
- final ServiceLoader serviceLoader;
- if (cl == null) {
- serviceLoader = ServiceLoader.load(type);
- } else {
- serviceLoader = ServiceLoader.load(type, cl);
- }
- final Iterator iterator = serviceLoader.iterator();
- if (iterator.hasNext()) {
- return iterator.next();
- } else {
- return null;
- }
- });
- } catch (ServiceConfigurationError e) {
- final RuntimeException x = new RuntimeException("Provider for " + type + " cannot be created", e);
- throw new TransformerFactoryConfigurationError(x, x.getMessage());
- }
- }
-
- private static ClassLoader getContextClassLoader() throws SecurityException {
- return AccessController.doPrivileged((PrivilegedAction) () -> {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null) {
- cl = ClassLoader.getSystemClassLoader();
- }
- return cl;
- });
- }
-
- private static String getSystemProperty(final String propName) {
- return AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty(propName));
- }
-
- private static FileInputStream getFileInputStream(final File file) throws FileNotFoundException {
- try {
- return AccessController.doPrivileged((PrivilegedExceptionAction) () -> new FileInputStream(file));
- } catch (PrivilegedActionException e) {
- throw (FileNotFoundException) e.getException();
- }
- }
-
- private static boolean doesFileExist(final File f) {
- return AccessController.doPrivileged((PrivilegedAction) f::exists);
- }
-}
diff --git a/specs/java.xml/src/main/java/javax/xml/transform/TransformerFactory.java b/specs/java.xml/src/main/java/javax/xml/transform/TransformerFactory.java
deleted file mode 100644
index 886b07b0dbd..00000000000
--- a/specs/java.xml/src/main/java/javax/xml/transform/TransformerFactory.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.transform;
-
-public abstract class TransformerFactory {
-
- private static final String DEFAULT_IMPL = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";
-
- protected TransformerFactory() {
- }
-
- public static TransformerFactory newDefaultInstance() {
- return $FactoryFinder.newInstance(TransformerFactory.class, DEFAULT_IMPL, null, false, true);
- }
-
- public static TransformerFactory newInstance() throws TransformerFactoryConfigurationError {
- return $FactoryFinder.find(TransformerFactory.class, DEFAULT_IMPL);
- }
-
- public static TransformerFactory newInstance(String factoryClassName, ClassLoader classLoader) throws TransformerFactoryConfigurationError {
- return $FactoryFinder.newInstance(TransformerFactory.class, factoryClassName, classLoader, false, false);
- }
-
- public abstract Transformer newTransformer(Source source) throws TransformerConfigurationException;
-
- public abstract Transformer newTransformer() throws TransformerConfigurationException;
-
- public abstract Templates newTemplates(Source source) throws TransformerConfigurationException;
-
- public abstract Source getAssociatedStylesheet(Source source, String media, String title, String charset) throws TransformerConfigurationException;
-
- public abstract void setURIResolver(URIResolver resolver);
-
- public abstract URIResolver getURIResolver();
-
- public abstract void setFeature(String name, boolean value) throws TransformerConfigurationException;
-
- public abstract boolean getFeature(String name);
-
- public abstract void setAttribute(String name, Object value);
-
- public abstract Object getAttribute(String name);
-
- public abstract void setErrorListener(ErrorListener listener);
-
- public abstract ErrorListener getErrorListener();
-
-}
diff --git a/specs/java.xml/src/main/java/javax/xml/validation/$SchemaFactoryFinder.java b/specs/java.xml/src/main/java/javax/xml/validation/$SchemaFactoryFinder.java
deleted file mode 100644
index d96ccfd0a81..00000000000
--- a/specs/java.xml/src/main/java/javax/xml/validation/$SchemaFactoryFinder.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.validation;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.net.URL;
-import java.security.*;
-import java.util.Properties;
-import java.util.ServiceConfigurationError;
-import java.util.ServiceLoader;
-import java.util.function.Supplier;
-
-class $SchemaFactoryFinder {
-
- private static boolean debug = false;
- private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xerces.internal";
- private static final Properties cacheProps = new Properties();
-
- private static volatile boolean firstTime = true;
-
- static {
- try {
- debug = getSystemProperty("jaxp.debug") != null;
- } catch (Exception unused) {
- debug = false;
- }
- }
-
- private static void debugPrintln(Supplier msgGen) {
- if (debug) {
- System.err.println("JAXP: " + msgGen.get());
- }
- }
-
- private final ClassLoader classLoader;
-
- public $SchemaFactoryFinder(ClassLoader loader) {
- this.classLoader = loader;
- if (debug) {
- debugDisplayClassLoader();
- }
- }
-
- private void debugDisplayClassLoader() {
- try {
- if (classLoader == getContextClassLoader()) {
- debugPrintln(() -> "using thread context class loader (" + classLoader + ") for search");
- return;
- }
- } catch (Throwable unused) {
- }
-
- if (classLoader == ClassLoader.getSystemClassLoader()) {
- debugPrintln(() -> "using system class loader (" + classLoader + ") for search");
- return;
- }
-
- debugPrintln(() -> "using class loader (" + classLoader + ") for search");
- }
-
- public SchemaFactory newFactory(String schemaLanguage) {
- if (schemaLanguage == null) {
- throw new NullPointerException();
- }
- SchemaFactory f = _newFactory(schemaLanguage);
- if (f != null) {
- debugPrintln(() -> "factory '" + f.getClass().getName() + "' was found for " + schemaLanguage);
- } else {
- debugPrintln(() -> "unable to find a factory for " + schemaLanguage);
- }
- return f;
- }
-
- private SchemaFactory _newFactory(String schemaLanguage) {
- SchemaFactory sf;
-
- String propertyName = SERVICE_CLASS.getName() + ":" + schemaLanguage;
-
- try {
- debugPrintln(() -> "Looking up system property '" + propertyName + "'");
- String r = getSystemProperty(propertyName);
- if (r != null) {
- debugPrintln(() -> "The value is '" + r + "'");
- sf = createInstance(r, true);
- if (sf != null) return sf;
- } else
- debugPrintln(() -> "The property is undefined.");
- } catch (Throwable t) {
- if (debug) {
- debugPrintln(() -> "failed to look up system property '" + propertyName + "'");
- t.printStackTrace();
- }
- }
-
- String javah = getSystemProperty("java.home");
- String configFile = javah + File.separator +
- "conf" + File.separator + "jaxp.properties";
-
-
- try {
- if (firstTime) {
- synchronized (cacheProps) {
- if (firstTime) {
- File f = new File(configFile);
- firstTime = false;
- if (doesFileExist(f)) {
- debugPrintln(() -> "Read properties file " + f);
- cacheProps.load(getFileInputStream(f));
- }
- }
- }
- }
- final String factoryClassName = cacheProps.getProperty(propertyName);
- debugPrintln(() -> "found " + factoryClassName + " in $java.home/conf/jaxp.properties");
-
- if (factoryClassName != null) {
- sf = createInstance(factoryClassName, true);
- if (sf != null) {
- return sf;
- }
- }
- } catch (Exception ex) {
- if (debug) {
- ex.printStackTrace();
- }
- }
-
- final SchemaFactory factoryImpl = findServiceProvider(schemaLanguage);
-
-
- if (factoryImpl != null) {
- return factoryImpl;
- }
-
- if (schemaLanguage.equals("http://www.w3.org/2001/XMLSchema")) {
- debugPrintln(() -> "attempting to use the platform default XML Schema validator");
- return createInstance("com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory", true);
- }
-
- debugPrintln(() -> "all things were tried, but none was found. bailing out.");
- return null;
- }
-
- private Class> createClass(String className) {
- Class> clazz;
- boolean internal = false;
- if (System.getSecurityManager() != null) {
- if (className != null && className.startsWith(DEFAULT_PACKAGE)) {
- internal = true;
- }
- }
-
- try {
- if (classLoader != null && !internal) {
- clazz = Class.forName(className, false, classLoader);
- } else {
- clazz = Class.forName(className);
- }
- } catch (Throwable t) {
- if (debug) {
- t.printStackTrace();
- }
- return null;
- }
-
- return clazz;
- }
-
- SchemaFactory createInstance(String className) {
- return createInstance(className, false);
- }
-
- SchemaFactory createInstance(String className, boolean useServicesMechanism) {
- SchemaFactory schemaFactory = null;
-
- debugPrintln(() -> "createInstance(" + className + ")");
-
- Class> clazz = createClass(className);
- if (clazz == null) {
- debugPrintln(() -> "failed to getClass(" + className + ")");
- return null;
- }
- debugPrintln(() -> "loaded " + className + " from " + which(clazz));
-
- try {
- if (!SchemaFactory.class.isAssignableFrom(clazz)) {
- throw new ClassCastException(clazz.getName()
- + " cannot be cast to " + SchemaFactory.class);
- }
- if (!useServicesMechanism) {
- schemaFactory = newInstanceNoServiceLoader(clazz);
- }
- if (schemaFactory == null) {
- schemaFactory = (SchemaFactory) clazz.newInstance();
- }
- } catch (ClassCastException | IllegalAccessException | InstantiationException classCastException) {
- debugPrintln(() -> "could not instantiate " + clazz.getName());
- if (debug) {
- classCastException.printStackTrace();
- }
- return null;
- }
-
- return schemaFactory;
- }
-
- private static SchemaFactory newInstanceNoServiceLoader(
- Class> providerClass
- ) {
- if (System.getSecurityManager() == null) {
- return null;
- }
- try {
- final Method creationMethod =
- providerClass.getDeclaredMethod(
- "newXMLSchemaFactoryNoServiceLoader"
- );
- final int modifiers = creationMethod.getModifiers();
-
- if (!Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers)) {
- return null;
- }
-
- // Only calls "newXMLSchemaFactoryNoServiceLoader" if it's
- final Class> returnType = creationMethod.getReturnType();
- if (SERVICE_CLASS.isAssignableFrom(returnType)) {
- return SERVICE_CLASS.cast(creationMethod.invoke(null, (Object[]) null));
- } else {
- throw new ClassCastException(returnType
- + " cannot be cast to " + SERVICE_CLASS);
- }
- } catch (ClassCastException e) {
- throw new SchemaFactoryConfigurationError(e.getMessage(), e);
- } catch (Exception exc) {
- return null;
- }
- }
-
- private boolean isSchemaLanguageSupportedBy(final SchemaFactory factory,
- final String schemaLanguage,
- AccessControlContext acc) {
- return AccessController.doPrivileged(
- (PrivilegedAction) () -> factory.isSchemaLanguageSupported(schemaLanguage), acc);
- }
-
- private SchemaFactory findServiceProvider(final String schemaLanguage) {
- assert schemaLanguage != null;
- final AccessControlContext acc = AccessController.getContext();
- try {
- return AccessController.doPrivileged((PrivilegedAction) () -> {
- final ServiceLoader loader =
- ServiceLoader.load(SERVICE_CLASS);
- for (SchemaFactory factory : loader) {
- if (isSchemaLanguageSupportedBy(factory, schemaLanguage, acc)) {
- return factory;
- }
- }
- return null;
- });
- } catch (ServiceConfigurationError error) {
- throw new SchemaFactoryConfigurationError(
- "Provider for " + SERVICE_CLASS + " cannot be created", error);
- }
- }
-
- private static final Class SERVICE_CLASS = SchemaFactory.class;
-
-
- private static String which(Class> clazz) {
- return getClassSource(clazz);
- }
-
- static ClassLoader getContextClassLoader() throws SecurityException {
- return AccessController.doPrivileged((PrivilegedAction) () -> {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null) {
- cl = ClassLoader.getSystemClassLoader();
- }
- return cl;
- });
- }
-
- private static String getSystemProperty(final String propName) {
- return AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty(propName));
- }
-
- private static FileInputStream getFileInputStream(final File file) throws FileNotFoundException {
- try {
- return AccessController.doPrivileged((PrivilegedExceptionAction) () -> new FileInputStream(file));
- } catch (PrivilegedActionException e) {
- throw (FileNotFoundException)e.getException();
- }
- }
-
- private static String getClassSource(Class> cls) {
- return AccessController.doPrivileged((PrivilegedAction) () -> {
- CodeSource cs = cls.getProtectionDomain().getCodeSource();
- if (cs != null) {
- URL loc = cs.getLocation();
- return loc != null ? loc.toString() : "(no location)";
- } else {
- return "(no code source)";
- }
- });
- }
-
- private static boolean doesFileExist(final File f) {
- return AccessController.doPrivileged((PrivilegedAction) f::exists);
- }
-}
diff --git a/specs/java.xml/src/main/java/javax/xml/validation/SchemaFactory.java b/specs/java.xml/src/main/java/javax/xml/validation/SchemaFactory.java
deleted file mode 100644
index da93cc62e48..00000000000
--- a/specs/java.xml/src/main/java/javax/xml/validation/SchemaFactory.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.validation;
-
-import org.w3c.dom.ls.LSResourceResolver;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXNotRecognizedException;
-import org.xml.sax.SAXNotSupportedException;
-
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import java.io.File;
-import java.net.URL;
-
-public abstract class SchemaFactory {
-
- private static final String DEFAULT_IMPL = "com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory";
-
- protected SchemaFactory() {
- }
-
- public static SchemaFactory newDefaultInstance() {
- return new $SchemaFactoryFinder(null).createInstance(DEFAULT_IMPL, true);
- }
-
- public static SchemaFactory newInstance(String schemaLanguage) {
- ClassLoader cl = $SchemaFactoryFinder.getContextClassLoader();
- if (cl == null) {
- cl = SchemaFactory.class.getClassLoader();
- }
- SchemaFactory f = new $SchemaFactoryFinder(cl).newFactory(schemaLanguage);
- if (f == null) {
- throw new IllegalArgumentException(
- "No SchemaFactory"
- + " that implements the schema language specified by: " + schemaLanguage
- + " could be loaded");
- }
- return f;
- }
-
- public static SchemaFactory newInstance(String schemaLanguage, String factoryClassName, ClassLoader classLoader) {
- ClassLoader cl = classLoader;
- if (cl == null) {
- cl = $SchemaFactoryFinder.getContextClassLoader();
- }
- SchemaFactory f = new $SchemaFactoryFinder(cl).createInstance(factoryClassName);
- if (f == null) {
- throw new IllegalArgumentException(
- "Factory " + factoryClassName
- + " could not be loaded to implement the schema language specified by: " + schemaLanguage);
- }
- if (f.isSchemaLanguageSupported(schemaLanguage)) {
- return f;
- } else {
- throw new IllegalArgumentException(
- "Factory " + f.getClass().getName()
- + " does not implement the schema language specified by: " + schemaLanguage);
- }
-
- }
-
- public abstract boolean isSchemaLanguageSupported(String schemaLanguage);
-
- public boolean getFeature(String name)
- throws SAXNotRecognizedException, SAXNotSupportedException {
-
- if (name == null) {
- throw new NullPointerException("the name parameter is null");
- }
- throw new SAXNotRecognizedException(name);
- }
-
- public void setFeature(String name, boolean value)
- throws SAXNotRecognizedException, SAXNotSupportedException {
-
- if (name == null) {
- throw new NullPointerException("the name parameter is null");
- }
- throw new SAXNotRecognizedException(name);
- }
-
- public void setProperty(String name, Object object)
- throws SAXNotRecognizedException, SAXNotSupportedException {
-
- if (name == null) {
- throw new NullPointerException("the name parameter is null");
- }
- throw new SAXNotRecognizedException(name);
- }
-
- public Object getProperty(String name)
- throws SAXNotRecognizedException, SAXNotSupportedException {
-
- if (name == null) {
- throw new NullPointerException("the name parameter is null");
- }
- throw new SAXNotRecognizedException(name);
- }
-
- public abstract void setErrorHandler(ErrorHandler errorHandler);
-
- public abstract ErrorHandler getErrorHandler();
-
- public abstract void setResourceResolver(LSResourceResolver resourceResolver);
-
- public abstract LSResourceResolver getResourceResolver();
-
- public Schema newSchema(Source schema) throws SAXException {
- return newSchema(new Source[]{schema});
- }
-
- public Schema newSchema(File schema) throws SAXException {
- return newSchema(new StreamSource(schema));
- }
-
- public Schema newSchema(URL schema) throws SAXException {
- return newSchema(new StreamSource(schema.toExternalForm()));
- }
-
- public abstract Schema newSchema(Source[] schemas) throws SAXException;
-
- public abstract Schema newSchema() throws SAXException;
-}
diff --git a/specs/java.xml/src/main/java/javax/xml/xpath/$XPathFactoryFinder.java b/specs/java.xml/src/main/java/javax/xml/xpath/$XPathFactoryFinder.java
deleted file mode 100644
index f6cc156bf3b..00000000000
--- a/specs/java.xml/src/main/java/javax/xml/xpath/$XPathFactoryFinder.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.xpath;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.net.URL;
-import java.security.*;
-import java.util.Properties;
-import java.util.ServiceConfigurationError;
-import java.util.ServiceLoader;
-import java.util.function.Supplier;
-
-class $XPathFactoryFinder {
- private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xpath.internal";
-
- private static boolean debug = false;
-
- static {
- try {
- debug = getSystemProperty("jaxp.debug") != null;
- } catch (Exception unused) {
- debug = false;
- }
- }
-
- private static final Properties cacheProps = new Properties();
-
- private volatile static boolean firstTime = true;
-
- private static void debugPrintln(Supplier msgGen) {
- if (debug) {
- System.err.println("JAXP: " + msgGen.get());
- }
- }
-
- private final ClassLoader classLoader;
-
- public $XPathFactoryFinder(ClassLoader loader) {
- this.classLoader = loader;
- if (debug) {
- debugDisplayClassLoader();
- }
- }
-
- private void debugDisplayClassLoader() {
- try {
- if (classLoader == getContextClassLoader()) {
- debugPrintln(() -> "using thread context class loader (" + classLoader + ") for search");
- return;
- }
- } catch (Throwable unused) {
- }
-
- if (classLoader == ClassLoader.getSystemClassLoader()) {
- debugPrintln(() -> "using system class loader (" + classLoader + ") for search");
- return;
- }
-
- debugPrintln(() -> "using class loader (" + classLoader + ") for search");
- }
-
- public XPathFactory newFactory(String uri) throws XPathFactoryConfigurationException {
- if (uri == null) {
- throw new NullPointerException();
- }
- XPathFactory f = _newFactory(uri);
- if (f != null) {
- debugPrintln(() -> "factory '" + f.getClass().getName() + "' was found for " + uri);
- } else {
- debugPrintln(() -> "unable to find a factory for " + uri);
- }
- return f;
- }
-
- private XPathFactory _newFactory(String uri) throws XPathFactoryConfigurationException {
- XPathFactory xpathFactory = null;
-
- String propertyName = SERVICE_CLASS.getName() + ":" + uri;
-
- try {
- debugPrintln(() -> "Looking up system property '" + propertyName + "'");
- String r = getSystemProperty(propertyName);
- if (r != null) {
- debugPrintln(() -> "The value is '" + r + "'");
- xpathFactory = createInstance(r, true);
- if (xpathFactory != null) {
- return xpathFactory;
- }
- } else
- debugPrintln(() -> "The property is undefined.");
- } catch (Throwable t) {
- if (debug) {
- debugPrintln(() -> "failed to look up system property '" + propertyName + "'");
- t.printStackTrace();
- }
- }
-
- String javah = getSystemProperty("java.home");
- String configFile = javah + File.separator +
- "conf" + File.separator + "jaxp.properties";
-
- try {
- if (firstTime) {
- synchronized (cacheProps) {
- if (firstTime) {
- File f = new File(configFile);
- firstTime = false;
- if (doesFileExist(f)) {
- debugPrintln(() -> "Read properties file " + f);
- cacheProps.load(getFileInputStream(f));
- }
- }
- }
- }
- final String factoryClassName = cacheProps.getProperty(propertyName);
- debugPrintln(() -> "found " + factoryClassName + " in $java.home/conf/jaxp.properties");
-
- if (factoryClassName != null) {
- xpathFactory = createInstance(factoryClassName, true);
- if (xpathFactory != null) {
- return xpathFactory;
- }
- }
- } catch (Exception ex) {
- if (debug) {
- ex.printStackTrace();
- }
- }
-
- assert xpathFactory == null;
- xpathFactory = findServiceProvider(uri);
-
-
- if (xpathFactory != null) {
- return xpathFactory;
- }
-
- if (uri.equals(XPathFactory.DEFAULT_OBJECT_MODEL_URI)) {
- debugPrintln(() -> "attempting to use the platform default W3C DOM XPath lib");
- return createInstance("com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl", true);
- }
-
- debugPrintln(() -> "all things were tried, but none was found. bailing out.");
- return null;
- }
-
- private Class> createClass(String className) {
- Class clazz;
- boolean internal = false;
- if (System.getSecurityManager() != null) {
- if (className != null && className.startsWith(DEFAULT_PACKAGE)) {
- internal = true;
- }
- }
-
- try {
- if (classLoader != null && !internal) {
- clazz = Class.forName(className, false, classLoader);
- } else {
- clazz = Class.forName(className);
- }
- } catch (Throwable t) {
- if (debug) {
- t.printStackTrace();
- }
- return null;
- }
-
- return clazz;
- }
-
- XPathFactory createInstance(String className)
- throws XPathFactoryConfigurationException {
- return createInstance(className, false);
- }
-
- XPathFactory createInstance(String className, boolean useServicesMechanism)
- throws XPathFactoryConfigurationException {
- XPathFactory xPathFactory = null;
-
- debugPrintln(() -> "createInstance(" + className + ")");
-
- Class> clazz = createClass(className);
- if (clazz == null) {
- debugPrintln(() -> "failed to getClass(" + className + ")");
- return null;
- }
- debugPrintln(() -> "loaded " + className + " from " + which(clazz));
-
- try {
- if (!useServicesMechanism) {
- xPathFactory = newInstanceNoServiceLoader(clazz);
- }
- if (xPathFactory == null) {
- xPathFactory = (XPathFactory) clazz.newInstance();
- }
- } catch (ClassCastException | IllegalAccessException | InstantiationException classCastException) {
- debugPrintln(() -> "could not instantiate " + clazz.getName());
- if (debug) {
- classCastException.printStackTrace();
- }
- return null;
- }
-
- return xPathFactory;
- }
-
- private static XPathFactory newInstanceNoServiceLoader(
- Class> providerClass
- ) throws XPathFactoryConfigurationException {
- if (System.getSecurityManager() == null) {
- return null;
- }
- try {
- Method creationMethod =
- providerClass.getDeclaredMethod(
- "newXPathFactoryNoServiceLoader"
- );
- final int modifiers = creationMethod.getModifiers();
-
- // Do not call "newXPathFactoryNoServiceLoader" if it's
- if (!Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers)) {
- return null;
- }
-
- // Only calls "newXPathFactoryNoServiceLoader" if it's
- final Class> returnType = creationMethod.getReturnType();
- if (SERVICE_CLASS.isAssignableFrom(returnType)) {
- return SERVICE_CLASS.cast(creationMethod.invoke(null, (Object[]) null));
- } else {
- throw new ClassCastException(returnType
- + " cannot be cast to " + SERVICE_CLASS);
- }
- } catch (ClassCastException e) {
- throw new XPathFactoryConfigurationException(e);
- } catch (Exception exc) {
- return null;
- }
- }
-
- private boolean isObjectModelSupportedBy(final XPathFactory factory,
- final String objectModel,
- AccessControlContext acc) {
- return AccessController.doPrivileged(
- (PrivilegedAction) () -> factory.isObjectModelSupported(objectModel), acc);
- }
-
- private XPathFactory findServiceProvider(final String objectModel)
- throws XPathFactoryConfigurationException {
-
- assert objectModel != null;
- final AccessControlContext acc = AccessController.getContext();
- try {
- return AccessController.doPrivileged((PrivilegedAction) () -> {
- final ServiceLoader loader =
- ServiceLoader.load(SERVICE_CLASS);
- for (XPathFactory factory : loader) {
- if (isObjectModelSupportedBy(factory, objectModel, acc)) {
- return factory;
- }
- }
- return null;
- });
- } catch (ServiceConfigurationError error) {
- throw new XPathFactoryConfigurationException(error);
- }
- }
-
- private static final Class SERVICE_CLASS = XPathFactory.class;
-
- private static String which(Class> clazz) {
- return getClassSource(clazz);
- }
-
- static ClassLoader getContextClassLoader() throws SecurityException{
- return AccessController.doPrivileged((PrivilegedAction) () -> {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null) {
- cl = ClassLoader.getSystemClassLoader();
- }
- return cl;
- });
- }
-
- private static String getSystemProperty(final String propName) {
- return AccessController.doPrivileged((PrivilegedAction) () -> System.getProperty(propName));
- }
-
- private static FileInputStream getFileInputStream(final File file) throws FileNotFoundException {
- try {
- return AccessController.doPrivileged((PrivilegedExceptionAction) () -> new FileInputStream(file));
- } catch (PrivilegedActionException e) {
- throw (FileNotFoundException)e.getException();
- }
- }
-
- private static String getClassSource(Class> cls) {
- return AccessController.doPrivileged((PrivilegedAction) () -> {
- CodeSource cs = cls.getProtectionDomain().getCodeSource();
- if (cs != null) {
- URL loc = cs.getLocation();
- return loc != null ? loc.toString() : "(no location)";
- } else {
- return "(no code source)";
- }
- });
- }
-
- private static boolean doesFileExist(final File f) {
- return AccessController.doPrivileged((PrivilegedAction) f::exists);
- }
-}
diff --git a/specs/java.xml/src/main/java/javax/xml/xpath/XPathFactory.java b/specs/java.xml/src/main/java/javax/xml/xpath/XPathFactory.java
deleted file mode 100644
index c236a7c0ad1..00000000000
--- a/specs/java.xml/src/main/java/javax/xml/xpath/XPathFactory.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 javax.xml.xpath;
-
-public abstract class XPathFactory {
-
- public static final String DEFAULT_PROPERTY_NAME = "javax.xml.xpath.XPathFactory";
-
- public static final String DEFAULT_OBJECT_MODEL_URI = "http://java.sun.com/jaxp/xpath/dom";
-
- private static final String DEFAULT_IMPL = "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl";
-
- protected XPathFactory() {
- }
-
- public static XPathFactory newDefaultInstance() {
- try {
- return new $XPathFactoryFinder(null).createInstance(DEFAULT_IMPL, true);
- } catch (XPathFactoryConfigurationException e) {
- throw new RuntimeException(
- "XPathFactory#newInstance() failed to create an XPathFactory for the default object model: "
- + DEFAULT_OBJECT_MODEL_URI
- + " with the XPathFactoryConfigurationException: "
- + e.getMessage(), e
- );
- }
- }
-
- public static XPathFactory newInstance() {
- try {
- return newInstance(DEFAULT_OBJECT_MODEL_URI);
- } catch (XPathFactoryConfigurationException e) {
- throw new RuntimeException(
- "XPathFactory#newInstance() failed to create an XPathFactory for the default object model: "
- + DEFAULT_OBJECT_MODEL_URI
- + " with the XPathFactoryConfigurationException: "
- + e.getMessage(), e
- );
- }
- }
-
- public static XPathFactory newInstance(final String uri) throws XPathFactoryConfigurationException {
- if (uri == null) {
- throw new NullPointerException(
- "XPathFactory#newInstance(String uri) cannot be called with uri == null");
- }
- if (uri.length() == 0) {
- throw new IllegalArgumentException(
- "XPathFactory#newInstance(String uri) cannot be called with uri == \"\"");
- }
- ClassLoader classLoader = $XPathFactoryFinder.getContextClassLoader();
- if (classLoader == null) {
- classLoader = XPathFactory.class.getClassLoader();
- }
- XPathFactory xpathFactory = new $XPathFactoryFinder(classLoader).newFactory(uri);
- if (xpathFactory == null) {
- throw new XPathFactoryConfigurationException(
- "No XPathFactory implementation found for the object model: "
- + uri);
- }
- return xpathFactory;
- }
-
- public static XPathFactory newInstance(String uri, String factoryClassName, ClassLoader classLoader) throws XPathFactoryConfigurationException {
- ClassLoader cl = classLoader;
- if (uri == null) {
- throw new NullPointerException("XPathFactory#newInstance(String uri) cannot be called with uri == null");
- }
- if (uri.length() == 0) {
- throw new IllegalArgumentException("XPathFactory#newInstance(String uri) cannot be called with uri == \"\"");
- }
- if (cl == null) {
- cl = $XPathFactoryFinder.getContextClassLoader();
- }
- XPathFactory f = new $XPathFactoryFinder(cl).createInstance(factoryClassName);
-
- if (f == null) {
- throw new XPathFactoryConfigurationException(
- "No XPathFactory implementation found for the object model: "
- + uri);
- }
- if (f.isObjectModelSupported(uri)) {
- return f;
- } else {
- throw new XPathFactoryConfigurationException("Factory "
- + factoryClassName + " doesn't support given " + uri
- + " object model");
- }
-
- }
-
- public abstract boolean isObjectModelSupported(String objectModel);
-
- public abstract void setFeature(String name, boolean value)
- throws XPathFactoryConfigurationException;
-
- public abstract boolean getFeature(String name)
- throws XPathFactoryConfigurationException;
-
- public abstract void setXPathVariableResolver(XPathVariableResolver resolver);
-
- public abstract void setXPathFunctionResolver(XPathFunctionResolver resolver);
-
- public abstract XPath newXPath();
-
-}
diff --git a/specs/java.xml/src/main/java/org/w3c/dom/ElementTraversal.java b/specs/java.xml/src/main/java/org/w3c/dom/ElementTraversal.java
deleted file mode 100644
index 16406b532d5..00000000000
--- a/specs/java.xml/src/main/java/org/w3c/dom/ElementTraversal.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2009 World Wide Web Consortium,
- *
- * (Massachusetts Institute of Technology, European Research Consortium for
- * Informatics and Mathematics, Keio University). All Rights Reserved. This
- * work is distributed under the W3C(r) Software License [1] in the hope that
- * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
- */
-
-package org.w3c.dom;
-
-/**
- * The ElementTraversal
interface is a set of read-only attributes
- * which allow an author to easily navigate between elements in a document.
- * In conforming implementations of Element Traversal, all objects that
- * implement {@link Element} must also implement the
- * ElementTraversal
interface. Four of the methods,
- * {@link #getFirstElementChild}, {@link #getLastElementChild},
- * {@link #getPreviousElementSibling}, and {@link #getNextElementSibling},
- * each return a live reference to another element with the defined
- * relationship to the current element, if the related element exists. The
- * fifth method, {@link #getChildElementCount}, exposes the number of child
- * elements of an element, for preprocessing before navigation.
- *
See also the
- * Element Traversal Specification.
- */
-public interface ElementTraversal {
-
- /**
- * Returns the first child element node of this element. null
- * if this element has no child elements.
- */
- Element getFirstElementChild();
-
- /**
- * Returns the last child element node of this element. null
- * if this element has no child elements.
- */
- Element getLastElementChild();
-
- /**
- * Returns the previous sibling element node of this element.
- * null
if this element has no element sibling nodes that
- * come before this one in the document tree.
- */
- Element getPreviousElementSibling();
-
- /**
- * Returns the next sibling element node of this element.
- * null
if this element has no element sibling nodes that
- * come after this one in the document tree.
- */
- Element getNextElementSibling();
-
- /**
- * Returns the current number of element nodes that are children of this
- * element. 0
if this element has no child nodes that are of
- * nodeType
1
.
- */
- int getChildElementCount();
-}
diff --git a/specs/locator/pom.xml b/specs/locator/pom.xml
deleted file mode 100644
index 0f6c629838f..00000000000
--- a/specs/locator/pom.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
- 4.0.0
-
-
- org.apache.karaf.specs
- specs
- 4.5.0-SNAPSHOT
-
-
- org.apache.karaf.specs.locator
- Apache Karaf :: Specs :: Locator
-
-
-
-
- org.apache.karaf
- karaf-bom
- ${project.version}
- pom
- import
-
-
-
-
-
-
- org.osgi
- osgi.core
- provided
-
-
-
-
diff --git a/specs/locator/src/main/java/org/apache/karaf/specs/locator/OsgiLocator.java b/specs/locator/src/main/java/org/apache/karaf/specs/locator/OsgiLocator.java
deleted file mode 100644
index cbc2b7c02de..00000000000
--- a/specs/locator/src/main/java/org/apache/karaf/specs/locator/OsgiLocator.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.karaf.specs.locator;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-public class OsgiLocator {
-
- public static final long DEFAULT_TIMEOUT = 0L;
- public static final String TIMEOUT = "org.apache.karaf.specs.timeout";
-
- private static final Map>> FACTORIES = new HashMap<>();
-
- private static final ReadWriteLock LOCK = new ReentrantReadWriteLock();
-
- private OsgiLocator() {
- }
-
- public static void unregister(String id, Callable factory) {
- LOCK.writeLock().lock();
- try {
- List> l = FACTORIES.get(id);
- if (l != null) {
- l.remove(factory);
- }
- } finally {
- LOCK.writeLock().unlock();
- }
- }
-
- public static void register(String id, Callable factory) {
- LOCK.writeLock().lock();
- try {
- FACTORIES.computeIfAbsent(id, k -> new ArrayList<>())
- .add(0, factory);
- synchronized (LOCK) {
- LOCK.notifyAll();
- }
- } finally {
- LOCK.writeLock().unlock();
- }
- }
-
-
- public static Class locate(Class factoryId) {
- return locate(factoryId, factoryId.getName());
- }
-
- private static long getTimeout() {
- long timeout = DEFAULT_TIMEOUT;
- try {
- String prop = System.getProperty(TIMEOUT);
- if (prop != null) {
- timeout = Long.parseLong(prop);
- }
- } catch (Throwable t) { }
- return timeout;
- }
-
- public static Class locate(Class factoryClass, String factoryId) {
- long timeout = getTimeout();
- if (timeout <= 0) {
- return doLocate(factoryClass, factoryId);
- }
- long t0 = System.currentTimeMillis();
- long t1 = t0;
- while (t1 - t0 < timeout) {
- Class impl = doLocate(factoryClass, factoryId);
- if (impl != null) {
- return impl;
- }
- synchronized (LOCK) {
- try {
- LOCK.wait(timeout - (t1 - t0));
- } catch (InterruptedException e) {
- return null;
- }
- }
- t1 = System.currentTimeMillis();
- }
- return null;
- }
-
- private static Class doLocate(Class factoryClass, String factoryId) {
- LOCK.readLock().lock();
- try {
- List> l = FACTORIES.get(factoryId);
- if (l != null && !l.isEmpty()) {
- // look up the System property first
- String factoryClassName = System.getProperty(factoryId);
- try {
- for (Callable i : l) {
- Class c = null;
- try {
- c = i.call();
- } catch (Exception ex) {
- // do nothing here
- }
- if (c != null && factoryClass == c.getClassLoader().loadClass(factoryClass.getName())
- && (factoryClassName == null || c.getName().equals(factoryClassName)))
- {
- return c;
- }
- }
- } catch (Exception ex) {
- // do nothing here
- }
- }
- return null;
- } finally {
- LOCK.readLock().unlock();
- }
- }
-
- public static List> locateAll(Class factoryId) {
- return locateAll(factoryId, factoryId.getName());
- }
-
- public static List> locateAll(Class factoryClass, String factoryId) {
- LOCK.readLock().lock();
- try {
- List> classes = new ArrayList<>();
- List> l = FACTORIES.get(factoryId);
- if (l != null) {
- for (Callable i : l) {
- try {
- Class c = i.call();
- if (c != null && factoryClass.isAssignableFrom(c)) {
- classes.add(c);
- }
- } catch (Exception e) {
- }
- }
- }
- return classes;
- } finally {
- LOCK.readLock().unlock();
- }
- }
-
-}
diff --git a/specs/locator/src/test/java/org/apache/karaf/specs/locator/MockCallable.java b/specs/locator/src/test/java/org/apache/karaf/specs/locator/MockCallable.java
deleted file mode 100644
index 092d5bdd002..00000000000
--- a/specs/locator/src/test/java/org/apache/karaf/specs/locator/MockCallable.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.karaf.specs.locator;
-
-import java.util.concurrent.Callable;
-
-public class MockCallable implements Callable {
-
- public Class call() throws Exception {
- return this.getClass();
- }
-
-}
diff --git a/specs/locator/src/test/java/org/apache/karaf/specs/locator/MockCallable2.java b/specs/locator/src/test/java/org/apache/karaf/specs/locator/MockCallable2.java
deleted file mode 100644
index 7fba2f4ad2c..00000000000
--- a/specs/locator/src/test/java/org/apache/karaf/specs/locator/MockCallable2.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.karaf.specs.locator;
-
-import java.util.concurrent.Callable;
-
-public class MockCallable2 implements Callable {
-
- public Class call() throws Exception {
- return this.getClass();
- }
-
-}
diff --git a/specs/locator/src/test/java/org/apache/karaf/specs/locator/OsgiLocatorTest.java b/specs/locator/src/test/java/org/apache/karaf/specs/locator/OsgiLocatorTest.java
deleted file mode 100644
index 7fc9dbdf77e..00000000000
--- a/specs/locator/src/test/java/org/apache/karaf/specs/locator/OsgiLocatorTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.karaf.specs.locator;
-
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class OsgiLocatorTest extends Assert {
-
- @BeforeClass
- public static void setup() {
- OsgiLocator.register("Factory", new MockCallable());
- OsgiLocator.register("Factory", new MockCallable2());
- }
-
- @Test
- public void testLocatorWithSystemProperty() {
- System.setProperty(OsgiLocator.TIMEOUT, "0");
- System.setProperty("Factory", "org.apache.karaf.specs.locator.MockCallable");
- Class clazz = OsgiLocator.locate(Object.class, "Factory");
- assertNotNull("Expected to find a class", clazz);
- assertEquals("Got the wrong class", MockCallable.class.getName(), clazz.getName());
-
- System.setProperty("Factory", "org.apache.karaf.specs.locator");
- clazz = OsgiLocator.locate(Object.class, "Factory");
- assertNull("Did not expect to find a class", clazz);
- }
-
- @Test
- public void testLocatorWithoutSystemProperty() {
- System.setProperty(OsgiLocator.TIMEOUT, "0");
- System.clearProperty("Factory");
- Class clazz = OsgiLocator.locate(Object.class, "Factory");
- assertNotNull("Expected to find a class", clazz);
- assertEquals("Got the wrong class", MockCallable2.class.getName(), clazz.getName());
- }
-
- @Test
- public void testLocatorWithSystemPropertyAndTimeout() {
- long timeout = 1000;
- System.setProperty(OsgiLocator.TIMEOUT, Long.toString(timeout));
- System.setProperty("Factory", "org.apache.karaf.specs.locator.MockCallable");
- Class clazz = OsgiLocator.locate(Object.class, "Factory");
- assertNotNull("Expected to find a class", clazz);
- assertEquals("Got the wrong class.", MockCallable.class.getName(), clazz.getName());
-
- System.setProperty("Factory", "org.apache.karaf.specs.locator");
- long t0 = System.currentTimeMillis();
- clazz = OsgiLocator.locate(Object.class, "Factory");
- long t1 = System.currentTimeMillis();
- assertNull("Did not expect to find a class", clazz);
- assertTrue("Timeout issue", (t1 - t0) > timeout / 2);
- }
-
- @Test
- public void testLocatorWithoutSystemPropertyAndTimeout() {
- long timeout = 1000;
- System.setProperty(OsgiLocator.TIMEOUT, Long.toString(timeout));
- System.clearProperty("Factory");
- long t0 = System.currentTimeMillis();
- Class clazz = OsgiLocator.locate(Object.class, "Factory");
- long t1 = System.currentTimeMillis();
- assertNotNull("Expected to find a class", clazz);
- assertEquals("Got the wrong class", MockCallable2.class.getName(), clazz.getName());
- assertTrue("Timeout issue", (t1 - t0) < timeout / 2);
- }
-
-}
diff --git a/specs/pom.xml b/specs/pom.xml
deleted file mode 100644
index 77d4c357323..00000000000
--- a/specs/pom.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
- 4.0.0
-
-
- org.apache.karaf
- karaf
- 4.5.0-SNAPSHOT
- ../pom.xml
-
-
- org.apache.karaf.specs
- specs
- pom
- Apache Karaf :: Specs
-
-
- locator
- activator
- java.xml
- java.xml.ws
-
-
-
-
diff --git a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-wrapper-java11.conf b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-wrapper-java11.conf
index 7a6c6695ac7..378b1318d0b 100644
--- a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-wrapper-java11.conf
+++ b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/unix/karaf-wrapper-java11.conf
@@ -30,7 +30,7 @@ set.default.PATH_WITH_JAVA=%JAVA_HOME%%WRAPPER_FILE_SEPARATOR%bin%WRAPPER_PATH_S
# Include JAVA_HOME/bin in the default PATH variable
set.PATH=%PATH_WITH_JAVA%
-set.JDK_JAVA_OPTIONS=--add-reads=java.xml=java.logging --add-exports=java.base/org.apache.karaf.specs.locator=java.xml,ALL-UNNAMED --patch-module java.base=%KARAF_HOME%/lib/endorsed/org.apache.karaf.specs.locator-%KARAF_VERSION%.jar --patch-module java.xml=%KARAF_HOME%/lib/endorsed/org.apache.karaf.specs.java.xml-%KARAF_VERSION%.jar --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.naming/javax.naming.spi=ALL-UNNAMED --add-opens java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.file=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.ftp=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED --add-exports=java.base/sun.net.www.content.text=ALL-UNNAMED --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED --add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED --add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED
+set.JDK_JAVA_OPTIONS=--add-reads=java.xml=java.logging --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.naming/javax.naming.spi=ALL-UNNAMED --add-opens java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.file=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.ftp=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED --add-exports=java.base/sun.net.www.content.text=ALL-UNNAMED --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED --add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED --add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED
# Java Application
wrapper.working.dir=%KARAF_BASE%
diff --git a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/windows/karaf-wrapper-java11.conf b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/windows/karaf-wrapper-java11.conf
index 68e20305a2e..0df09b7b5bf 100644
--- a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/windows/karaf-wrapper-java11.conf
+++ b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/windows/karaf-wrapper-java11.conf
@@ -30,7 +30,7 @@ set.default.PATH_WITH_JAVA=%JAVA_HOME%%WRAPPER_FILE_SEPARATOR%bin%WRAPPER_PATH_S
# Include JAVA_HOME/bin in the default PATH variable
set.PATH=%PATH_WITH_JAVA%
-set.JDK_JAVA_OPTIONS=--add-reads=java.xml=java.logging --add-exports=java.base/org.apache.karaf.specs.locator=java.xml,ALL-UNNAMED --patch-module java.base=%KARAF_HOME%/lib/endorsed/org.apache.karaf.specs.locator-%KARAF_VERSION%.jar --patch-module java.xml=%KARAF_HOME%/lib/endorsed/org.apache.karaf.specs.java.xml-%KARAF_VERSION%.jar --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.naming/javax.naming.spi=ALL-UNNAMED --add-opens java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.file=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.ftp=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED --add-exports=java.base/sun.net.www.content.text=ALL-UNNAMED --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED --add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED --add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED
+set.JDK_JAVA_OPTIONS=--add-reads=java.xml=java.logging --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.naming/javax.naming.spi=ALL-UNNAMED --add-opens java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.file=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.ftp=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED --add-exports=java.base/sun.net.www.content.text=ALL-UNNAMED --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED --add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED --add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED
# Java Application
wrapper.working.dir=%KARAF_BASE%
diff --git a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/windows64/karaf-wrapper-java11.conf b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/windows64/karaf-wrapper-java11.conf
index 79978caeb9a..41a76963b23 100644
--- a/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/windows64/karaf-wrapper-java11.conf
+++ b/wrapper/src/main/resources/org/apache/karaf/wrapper/internal/windows64/karaf-wrapper-java11.conf
@@ -30,7 +30,7 @@ set.default.PATH_WITH_JAVA=%JAVA_HOME%%WRAPPER_FILE_SEPARATOR%bin%WRAPPER_PATH_S
# Include JAVA_HOME/bin in the default PATH variable
set.PATH=%PATH_WITH_JAVA%
-set.JDK_JAVA_OPTIONS=--add-reads=java.xml=java.logging --add-exports=java.base/org.apache.karaf.specs.locator=java.xml,ALL-UNNAMED --patch-module java.base=%KARAF_HOME%/lib/endorsed/org.apache.karaf.specs.locator-%KARAF_VERSION%.jar --patch-module java.xml=%KARAF_HOME%/lib/endorsed/org.apache.karaf.specs.java.xml-%KARAF_VERSION%.jar --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.naming/javax.naming.spi=ALL-UNNAMED --add-opens java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.file=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.ftp=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED --add-exports=java.base/sun.net.www.content.text=ALL-UNNAMED --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED --add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED --add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED
+set.JDK_JAVA_OPTIONS=--add-reads=java.xml=java.logging --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.naming/javax.naming.spi=ALL-UNNAMED --add-opens java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.file=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.ftp=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED --add-exports=java.base/sun.net.www.content.text=ALL-UNNAMED --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED --add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED --add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED
# Java Application
wrapper.working.dir=%KARAF_BASE%