src/javax/xml/parsers/SAXParserFactory.java

Print this page

        

@@ -40,12 +40,10 @@
  *
  * @version $Revision: 1.9 $, $Date: 2010/05/25 16:19:44 $
  *
  */
 public abstract class SAXParserFactory {
-    /** The default property name according to the JAXP spec */
-    private static final String DEFAULT_PROPERTY_NAME = "javax.xml.parsers.SAXParserFactory";
 
     /**
      * <p>Should Parsers be validating?</p>
      */
     private boolean validating = false;

@@ -85,15 +83,21 @@
      * 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.SAXParserFactory</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. If there are providers other than the
+     * implementation specific default located, then the first provider that is
+     * not the default is instantiated and returned;
+     * Otherwise the default implementation is returned if it is on the
+     * classpath or installed as a module.
+     * <br>
+     * If a misconfigured provider is encountered and
+     * {@link java.util.ServiceConfigurationError} is thrown, the error will
+     * be wrapped in a {@link javax.xml.parsers.FactoryConfigurationException}.
      * </li>
      * <li>
      * Platform default <code>SAXParserFactory</code> instance.
      * </li>
      * </ul>

@@ -120,20 +124,15 @@
      * @throws FactoryConfigurationError if the implementation is
      *   not available or cannot be instantiated.
      */
 
     public static SAXParserFactory newInstance() {
-        try {
-            return (SAXParserFactory) FactoryFinder.find(
+        return FactoryFinder.find(
                 /* The default property name according to the JAXP spec */
-                "javax.xml.parsers.SAXParserFactory",
+                SAXParserFactory.class,
                 /* The fallback implementation class name */
                 "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
-        } catch (FactoryFinder.ConfigurationError e) {
-            throw new FactoryConfigurationError(e.getException(),
-                                                e.getMessage());
-        }
     }
 
     /**
      * <p>Obtain a new instance of a <code>SAXParserFactory</code> from class name.
      * This function is useful when there are multiple providers in the classpath.

@@ -167,17 +166,12 @@
      * @see #newInstance()
      *
      * @since 1.6
      */
     public static SAXParserFactory newInstance(String factoryClassName, ClassLoader classLoader){
-        try {
             //do not fallback if given classloader can't find the class, throw exception
             return (SAXParserFactory) FactoryFinder.newInstance(factoryClassName, classLoader, false);
-        } catch (FactoryFinder.ConfigurationError e) {
-            throw new FactoryConfigurationError(e.getException(),
-                                                e.getMessage());
-        }
     }
 
     /**
      * <p>Creates a new instance of a SAXParser using the currently
      * configured factory parameters.</p>

@@ -318,21 +312,10 @@
     public abstract boolean getFeature(String name)
         throws ParserConfigurationException, SAXNotRecognizedException,
                 SAXNotSupportedException;
 
 
-
-    /* <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.
      *
      *

@@ -355,21 +338,10 @@
             + this.getClass().getPackage().getSpecificationVersion()
             + "\""
             );
     }
 
-    /** <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>
      *
      * <p>When a {@link Schema} is non-null, a parser will use a validator