# HG changeset patch # User mkos # Date 1442576818 -7200 # Node ID ed5d9f5bf8905ae6091ee50590a49152eb048f1c # Parent 52d9ad2536ba6c6f1cc5561c0a0ee2b4847fd62c 8131667: JAX-WS Plugability Layer: using java.util.ServiceLoader Reviewed-by: alanb diff -r 52d9ad2536ba -r ed5d9f5bf890 src/java.xml.ws/share/classes/javax/xml/ws/package-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/java.xml.ws/share/classes/javax/xml/ws/package-info.java Fri Sep 18 13:46:58 2015 +0200 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed 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. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/** + * This package contains the core JAX-WS APIs. + */ +package javax.xml.ws; diff -r 52d9ad2536ba -r ed5d9f5bf890 src/java.xml.ws/share/classes/javax/xml/ws/package.html --- a/src/java.xml.ws/share/classes/javax/xml/ws/package.html Fri Sep 11 10:26:35 2015 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ - - - -
-This package contains the core JAX-WS APIs. - - diff -r 52d9ad2536ba -r ed5d9f5bf890 src/java.xml.ws/share/classes/javax/xml/ws/spi/FactoryFinder.java --- a/src/java.xml.ws/share/classes/javax/xml/ws/spi/FactoryFinder.java Fri Sep 11 10:26:35 2015 -0700 +++ b/src/java.xml.ws/share/classes/javax/xml/ws/spi/FactoryFinder.java Fri Sep 18 13:46:58 2015 +0200 @@ -27,33 +27,25 @@ import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.xml.ws.WebServiceException; class FactoryFinder { - /** - * Creates an instance of the specified class using the specified - * {@code ClassLoader} object. - * - * @exception WebServiceException if the given class could not be found - * or could not be instantiated - */ - private static Object newInstance(String className, - ClassLoader classLoader) - { - try { - Class spiClass = safeLoadClass(className, classLoader); - return spiClass.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 final Logger logger = Logger.getLogger("javax.xml.ws"); + + private static final ServiceLoaderUtil.ExceptionHandlerP firstByServiceLoader(Class
spiClass,
+ Logger logger,
+ ExceptionHandler serviceLoader = ServiceLoader.load(spiClass);
+
+ for (P impl : serviceLoader) {
+ logger.fine("ServiceProvider loading Facility used; returning object [" +
+ impl.getClass().getName() + "]");
+
+ return impl;
+ }
+ } catch (Throwable t) {
+ throw handler.createException(t, "Error while searching for service [" + spiClass.getName() + "]");
+ }
+ return null;
+ }
+
+ static void checkPackageAccess(String className) {
+ // 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));
+ }
+ }
+ }
+
+ static Class nullSafeLoadClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
+ if (classLoader == null) {
+ return Class.forName(className);
+ } else {
+ return classLoader.loadClass(className);
+ }
+ }
+
+ // Returns instance of required class. It checks package access (security)
+ // unless it is defaultClassname. It means if you are trying to instantiate
+ // default implementation (fallback), pass the class name to both first and second parameter.
+ static