/** * Creates a new provider object. * * <p>The algorithm used to locate the provider subclass to use consists of the following steps: * * <p> * * <ul> * <li>If a resource with the name of <code>META-INF/services/javax.xml.ws.spi.Provider</code> * exists, then its first line, if present, is used as the UTF-8 encoded name of the * implementation class. * <li>If the $java.home/lib/jaxws.properties file exists and it is readable by the <code> * java.util.Properties.load(InputStream)</code> method and it contains an entry whose key * is <code>javax.xml.ws.spi.Provider</code>, then the value of that entry is used as the * name of the implementation class. * <li>If a system property with the name <code>javax.xml.ws.spi.Provider</code> is defined, * then its value is used as the name of the implementation class. * <li>Finally, a default implementation class name is used. * </ul> */ public static Provider provider() { try { Object provider = getProviderUsingServiceLoader(); if (provider == null) { provider = FactoryFinder.find(JAXWSPROVIDER_PROPERTY, DEFAULT_JAXWSPROVIDER); } if (!(provider instanceof Provider)) { Class pClass = Provider.class; String classnameAsResource = pClass.getName().replace('.', '/') + ".class"; ClassLoader loader = pClass.getClassLoader(); if (loader == null) { loader = ClassLoader.getSystemClassLoader(); } URL targetTypeURL = loader.getResource(classnameAsResource); throw new LinkageError( "ClassCastException: attempting to cast" + provider.getClass().getClassLoader().getResource(classnameAsResource) + "to" + targetTypeURL.toString()); } return (Provider) provider; } catch (WebServiceException ex) { throw ex; } catch (Exception ex) { throw new WebServiceException("Unable to createEndpointReference Provider", ex); } }
/* */ public static Provider provider() /* */ { /* */ try /* */ { /* 125 */ Object provider = getProviderUsingServiceLoader(); /* 126 */ if (provider == null) { /* 127 */ provider = FactoryFinder.find( "javax.xml.ws.spi.Provider", "com.sun.xml.internal.ws.spi.ProviderImpl"); /* */ } /* 129 */ if (!(provider instanceof Provider)) { /* 130 */ Class pClass = Provider.class; /* 131 */ String classnameAsResource = pClass.getName().replace('.', '/') + ".class"; /* 132 */ ClassLoader loader = pClass.getClassLoader(); /* 133 */ if (loader == null) { /* 134 */ loader = ClassLoader.getSystemClassLoader(); /* */ } /* 136 */ URL targetTypeURL = loader.getResource(classnameAsResource); /* 137 */ throw new LinkageError( "ClassCastException: attempting to cast" + provider.getClass().getClassLoader().getResource(classnameAsResource) + "to" + targetTypeURL.toString()); /* */ } /* */ /* 141 */ return (Provider) provider; /* */ } catch (WebServiceException ex) { /* 143 */ throw ex; /* */ } catch (Exception ex) { /* 145 */ throw new WebServiceException("Unable to createEndpointReference Provider", ex); /* */ } /* */ }
/** * Create a new instance of the factory. If the classLoader argument is null, then the * ContextClassLoader is used. * * <p>Note that this is a new method that replaces the deprecated newInstance(String factoryId, * ClassLoader classLoader) method. No changes in behavior are defined by this replacement method * relative to the deprecated method. * * @param factoryId Name of the factory to find, same as a property name * @param classLoader classLoader to use * @return the factory implementation * @throws FactoryConfigurationError if an instance of this factory cannot be loaded */ public static XMLInputFactory newFactory(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError { try { // do not fallback if given classloader can't find the class, throw exception return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader, null); } catch (FactoryFinder.ConfigurationError e) { throw new FactoryConfigurationError(e.getException(), e.getMessage()); } }
/* */ public static DocumentBuilderFactory newInstance( String factoryClassName, ClassLoader classLoader) /* */ { /* */ try /* */ { /* 170 */ return (DocumentBuilderFactory) FactoryFinder.newInstance(factoryClassName, classLoader, false); /* */ } catch (FactoryFinder.ConfigurationError e) { /* 172 */ throw new FactoryConfigurationError(e.getException(), e.getMessage()); /* */ } /* */ }
/* */ public static DatatypeFactory newInstance( String factoryClassName, ClassLoader classLoader) /* */ throws DatatypeConfigurationException /* */ { /* */ try /* */ { /* 176 */ return (DatatypeFactory) FactoryFinder.newInstance(factoryClassName, classLoader, false); /* */ } catch (FactoryFinder.ConfigurationError e) { /* 178 */ throw new DatatypeConfigurationException(e.getMessage(), e.getException()); /* */ } /* */ }
/* */ public static DocumentBuilderFactory newInstance() /* */ { /* */ try /* */ { /* 121 */ return (DocumentBuilderFactory) FactoryFinder.find( "javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"); /* */ } /* */ catch (FactoryFinder.ConfigurationError e) /* */ { /* 127 */ throw new FactoryConfigurationError(e.getException(), e.getMessage()); /* */ } /* */ }
/* */ public static DatatypeFactory newInstance() /* */ throws DatatypeConfigurationException /* */ { /* */ try /* */ { /* 129 */ return (DatatypeFactory) FactoryFinder.find( "javax.xml.datatype.DatatypeFactory", DATATYPEFACTORY_IMPLEMENTATION_CLASS); /* */ } /* */ catch (FactoryFinder.ConfigurationError e) /* */ { /* 135 */ throw new DatatypeConfigurationException(e.getMessage(), e.getException()); /* */ } /* */ }
/** * Create a new instance of the factory * * @param factoryId Name of the factory to find, same as a property name * @param classLoader classLoader to use * @return the factory implementation * @throws FactoryConfigurationError if an instance of this factory cannot be loaded */ public static XMLInputFactory newInstance(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError { return (XMLInputFactory) FactoryFinder.find(factoryId, "com.bea.xml.stream.XMLOutputFactoryBase", classLoader); }
/** * Create a new instance of the factory. * * @throws FactoryConfigurationError if an instance of this factory cannot be loaded */ public static XMLOutputFactory newInstance() throws FactoryConfigurationError { return (XMLOutputFactory) FactoryFinder.find( "javax.xml.stream.XMLOutputFactory", "com.bea.xml.stream.XMLOutputFactoryBase"); }
/** * Create a new instance of the factory. This static method creates a new factory instance. This * method uses the following ordered lookup procedure to determine the XMLInputFactory * implementation class to load: Use the javax.xml.stream.XMLInputFactory system property. Use the * properties file "lib/stax.properties" in the JRE directory. This configuration file is in * standard java.util.Properties format and contains the fully qualified name of the * implementation class with the key being the system property defined above. Use the Services API * (as detailed in the JAR specification), if available, to determine the classname. The Services * API will look for a classname in the file META-INF/services/javax.xml.stream.XMLInputFactory in * jars available to the runtime. Platform default XMLInputFactory instance. * * <p>Once an application has obtained a reference to a XMLInputFactory it can use the factory to * configure and obtain stream instances. * * <p>Note that this is a new method that replaces the deprecated newInstance() method. No changes * in behavior are defined by this replacement method relative to the deprecated method. * * @throws FactoryConfigurationError if an instance of this factory cannot be loaded */ public static XMLInputFactory newFactory() throws FactoryConfigurationError { return (XMLInputFactory) FactoryFinder.find("javax.xml.stream.XMLInputFactory", DEFAULIMPL); }