src/javax/xml/transform/TransformerFactory.java
Print this page
@@ -73,15 +73,17 @@
* when the first attempt is made to read from it, no further attempts are
* made to check for its existence. It is not possible to change the value
* of any property in jaxp.properties after it has been read for the first time.
* </li>
* <li>
- * 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
- * <code>META-INF/services/javax.xml.transform.TransformerFactory</code>
- * in jars available to the runtime.
+ * <p>Uses the service-provider loading facilities, defined by the {@link java.util.ServiceLoader} class, to attempt
+ * to locate and load an implementation of the service. In case of multiple providers, the first non-default implementation
+ * shall be instantiated and returned. The default implementation is returned if it is the only one
+ * found by the service loader.</p>
+ * <p>
+ * If a misconfigured provider is encountered and {@link java.util.ServiceConfigurationError} is thrown, the error will be wrapped
+ * in a {@link javax.xml.transform.TransformerFactoryConfigurationError}.</p>
* </li>
* <li>
* Platform default <code>TransformerFactory</code> instance.
* </li>
* </ul>
@@ -95,21 +97,15 @@
* @throws TransformerFactoryConfigurationError Thrown if the implementation
* is not available or cannot be instantiated.
*/
public static TransformerFactory newInstance()
throws TransformerFactoryConfigurationError {
- try {
- return (TransformerFactory) FactoryFinder.find(
+ return (TransformerFactory) FactoryFinder.find(TransformerFactory.class,
/* The default property name according to the JAXP spec */
"javax.xml.transform.TransformerFactory",
/* The fallback implementation class name, XSLTC */
"com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
- } catch (FactoryFinder.ConfigurationError e) {
- throw new TransformerFactoryConfigurationError(
- e.getException(),
- e.getMessage());
- }
}
/**
* <p>Obtain a new instance of a <code>TransformerFactory</code> from factory class name.
* This function is useful when there are multiple providers in the classpath.
@@ -145,18 +141,12 @@
*
* @since 1.6
*/
public static TransformerFactory newInstance(String factoryClassName, ClassLoader classLoader)
throws TransformerFactoryConfigurationError{
- try {
//do not fallback if given classloader can't find the class, throw exception
return (TransformerFactory) FactoryFinder.newInstance(factoryClassName, classLoader, false);
- } catch (FactoryFinder.ConfigurationError e) {
- throw new TransformerFactoryConfigurationError(
- e.getException(),
- e.getMessage());
- }
}
/**
* <p>Process the <code>Source</code> into a <code>Transformer</code>
* <code>Object</code>. The <code>Source</code> is an XSLT document that
* conforms to <a href="http://www.w3.org/TR/xslt">