src/javax/xml/parsers/DocumentBuilderFactory.java

Print this page

        

@@ -38,22 +38,17 @@
 
  */
 
 public abstract class DocumentBuilderFactory {
 
-    /** The default property name according to the JAXP spec */
-    private static final String DEFAULT_PROPERTY_NAME = "javax.xml.parsers.DocumentBuilderFactory";
-
     private boolean validating = false;
     private boolean namespaceAware = false;
     private boolean whitespace = false;
     private boolean expandEntityRef = true;
     private boolean ignoreComments = false;
     private boolean coalescing = false;
 
-    private boolean canonicalState = false;
-
     /**
      * <p>Protected constructor to prevent instantiation.
      * Use {@link #newInstance()}.</p>
      */
     protected DocumentBuilderFactory () {

@@ -83,18 +78,16 @@
      * 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.parsers.DocumentBuilderFactory</code>
-     * in jars available to the runtime.
+     * 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.
      * </li>
      * <li>
-     * Platform default <code>DocumentBuilderFactory</code> instance.
+     * Otherwise, the system-default implementation is returned.
      * </li>
      * </ul>
      *
      * Once an application has obtained a reference to a
      * <code>DocumentBuilderFactory</code> it can use the factory to

@@ -111,25 +104,20 @@
      * java -Djaxp.debug=1 YourProgram ....
      * </pre>
      *
      * @return New instance of a <code>DocumentBuilderFactory</code>
      *
-     * @throws FactoryConfigurationError if the implementation is not
-     *   available or cannot be instantiated.
+     * @throws FactoryConfigurationError in case of {@linkplain
+     * java.util.ServiceConfigurationError service configuration error} or if
+     * the implementation is not available or cannot be instantiated.
      */
     public static DocumentBuilderFactory newInstance() {
-        try {
-            return (DocumentBuilderFactory) FactoryFinder.find(
+        return FactoryFinder.find(
                 /* The default property name according to the JAXP spec */
-                "javax.xml.parsers.DocumentBuilderFactory",
+                DocumentBuilderFactory.class, // "javax.xml.parsers.DocumentBuilderFactory"
                 /* The fallback implementation class name */
                 "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
-        } catch (FactoryFinder.ConfigurationError e) {
-            throw new FactoryConfigurationError(e.getException(),
-                                                e.getMessage());
-        }
-
     }
 
     /**
      * <p>Obtain a new instance of a <code>DocumentBuilderFactory</code> from class name.
      * This function is useful when there are multiple providers in the classpath.

@@ -163,17 +151,13 @@
      * @see #newInstance()
      *
      * @since 1.6
      */
     public static DocumentBuilderFactory newInstance(String factoryClassName, ClassLoader classLoader){
-        try {
             //do not fallback if given classloader can't find the class, throw exception
-            return (DocumentBuilderFactory) FactoryFinder.newInstance(factoryClassName, classLoader, false);
-        } catch (FactoryFinder.ConfigurationError e) {
-            throw new FactoryConfigurationError(e.getException(),
-                                                e.getMessage());
-        }
+            return FactoryFinder.newInstance(DocumentBuilderFactory.class,
+                        factoryClassName, classLoader, false);
     }
 
     /**
      * Creates a new instance of a {@link javax.xml.parsers.DocumentBuilder}
      * using the currently configured parameters.

@@ -449,21 +433,10 @@
          */
         public abstract boolean getFeature(String name)
                 throws ParserConfigurationException;
 
 
-    /** <p>Get current state of canonicalization.</p>
-     *
-     * @return current state canonicalization control
-     */
-    /*
-    public boolean getCanonicalization() {
-        return canonicalState;
-    }
-    */
-
-
     /**
      * Gets the {@link Schema} object specified through
      * the {@link #setSchema(Schema schema)} method.
      *
      * @return

@@ -486,21 +459,10 @@
             + "\""
             );
 
     }
 
-    /* <p>Set canonicalization control to <code>true</code> or
-     * </code>false</code>.</p>
-     *
-     * @param state of canonicalization
-     */
-    /*
-    public void setCanonicalization(boolean state) {
-        canonicalState = state;
-    }
-    */
-
     /**
      * <p>Set the {@link Schema} to be used by parsers created
      * from this factory.
      *
      * <p>