/* * Obtain a new instance of a * <code>DocumentBuilderFactory</code>. This static method creates * a new factory instance. * This method uses the following ordered lookup procedure to determine * the <code>DocumentBuilderFactory</code> implementation class to * load: * <ul> * <li> * Use the <code>javax.xml.parsers.DocumentBuilderFactory</code> system * property. * </li> * <li> * Use the properties file "lib/jaxp.properties" in the JRE directory. * This configuration file is in standard <code>java.util.Properties * </code> format and contains the fully qualified name of the * implementation class with the key being the system property defined * above. * * The jaxp.properties file is read only once by the JAXP implementation * and it's values are then cached for future use. If the file does not exist * 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. * </li> * <li> * Platform default <code>DocumentBuilderFactory</code> instance. * </li> * </ul> * * Once an application has obtained a reference to a * <code>DocumentBuilderFactory</code> it can use the factory to * configure and obtain parser instances. * * * <h2>Tip for Trouble-shooting</h2> * <p>Setting the <code>jaxp.debug</code> system property will cause * this method to print a lot of debug messages * to <tt>System.err</tt> about what it is doing and where it is looking at.</p> * * <p> If you have problems loading {@link DocumentBuilder}s, try:</p> * <pre> * java -Djaxp.debug=1 YourProgram .... * </pre> * * @return New instance of a <code>DocumentBuilderFactory</code> * * @exception FactoryConfigurationError if the implementation is not * available or cannot be instantiated. */ public static DocumentBuilderFactory newInstance() { try { return((DocumentBuilderFactory)FactoryFinder.find( /* The default property name according to the JAXP spec */ "javax.xml.parsers.DocumentBuilderFactory", /* The fallback implementation class name */ "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl")); } catch (FactoryFinder.ConfigurationError e) { throw new FactoryConfigurationError(e.getException(), e.getMessage()); } }
/* * @return New instance of a <code>DocumentBuilderFactory</code> * * @exception FactoryConfigurationError if the implementation is not * available or cannot be instantiated. */ public static DocumentBuilderFactory newInstance(String factoryClassName, java.lang.ClassLoader classLoader) { if (factoryClassName == null) { throw new FactoryConfigurationError("factoryClassName cannot be null."); } if (classLoader == null) { classLoader = SecuritySupport.getContextClassLoader(); } try { return((DocumentBuilderFactory)FactoryFinder.newInstance(factoryClassName, classLoader, false)); } catch (FactoryFinder.ConfigurationError e) { throw new FactoryConfigurationError(e.getException(), e.getMessage()); } }