src/javax/xml/stream/XMLOutputFactory.java

Print this page




 205    * Create a new instance of the factory.
 206    * If the classLoader argument is null, then the ContextClassLoader is used.
 207    * <p>
 208    * This method uses the following ordered lookup procedure to determine
 209    * the XMLOutputFactory implementation class to load:
 210    * </p>
 211    * <ul>
 212    * <li>
 213    *   Use the value of the system property identified by {@code factoryId}.
 214    * </li>
 215    * <li>
 216    *   Use the properties file "lib/stax.properties" in the JRE directory.
 217    *     This configuration file is in standard java.util.Properties format
 218    *     and contains the fully qualified name of the implementation class
 219    *     with the key being the given {@code factoryId}.
 220    * </li>
 221    * <li>
 222    *   If {@code factoryId} is "javax.xml.stream.XMLOutputFactory",
 223    *   use the service-provider loading facilities, defined by the
 224    *   {@link java.util.ServiceLoader} class, to attempt to locate and load an
 225    *   implementation of the service using the {@linkplain
 226    *   java.util.ServiceLoader#load(java.lang.Class) default loading mechanism}:
 227    *   the service-provider loading facility will use the {@linkplain

 228    *   java.lang.Thread#getContextClassLoader() current thread's context class loader}
 229    *   to attempt to load the service. If the context class
 230    *   loader is null, the {@linkplain
 231    *   ClassLoader#getSystemClassLoader() system class loader} will be used.
 232    * </li>
 233    * <li>
 234    *   Otherwise, throws a {@link FactoryConfigurationError}.
 235    * </li>
 236    * </ul>
 237    *




 238    * <p>
 239    * Note that this is a new method that replaces the deprecated
 240    *   {@link #newInstance(java.lang.String, java.lang.ClassLoader)
 241    *   newInstance(String factoryId, ClassLoader classLoader)} method.
 242    * No changes in behavior are defined by this replacement method relative
 243    * to the deprecated method.
 244    * </p>
 245    *
 246    * @param factoryId             Name of the factory to find, same as
 247    *                              a property name
 248    * @param classLoader           classLoader to use
 249    * @return the factory implementation
 250    * @throws FactoryConfigurationError in case of {@linkplain
 251    *   java.util.ServiceConfigurationError service configuration error} or if
 252    *   the implementation is not available or cannot be instantiated.
 253    */
 254   public static XMLOutputFactory newFactory(String factoryId,
 255           ClassLoader classLoader)
 256           throws FactoryConfigurationError {
 257       //do not fallback if given classloader can't find the class, throw exception




 205    * Create a new instance of the factory.
 206    * If the classLoader argument is null, then the ContextClassLoader is used.
 207    * <p>
 208    * This method uses the following ordered lookup procedure to determine
 209    * the XMLOutputFactory implementation class to load:
 210    * </p>
 211    * <ul>
 212    * <li>
 213    *   Use the value of the system property identified by {@code factoryId}.
 214    * </li>
 215    * <li>
 216    *   Use the properties file "lib/stax.properties" in the JRE directory.
 217    *     This configuration file is in standard java.util.Properties format
 218    *     and contains the fully qualified name of the implementation class
 219    *     with the key being the given {@code factoryId}.
 220    * </li>
 221    * <li>
 222    *   If {@code factoryId} is "javax.xml.stream.XMLOutputFactory",
 223    *   use the service-provider loading facilities, defined by the
 224    *   {@link java.util.ServiceLoader} class, to attempt to locate and load an
 225    *   implementation of the service using the specified {@code ClassLoader}.
 226    *   If {@code classLoader} is null, the {@linkplain
 227    *   java.util.ServiceLoader#load(java.lang.Class) default loading mechanism} will apply:
 228    *   That is, the service-provider loading facility will use the {@linkplain
 229    *   java.lang.Thread#getContextClassLoader() current thread's context class loader}
 230    *   to attempt to load the service. If the context class
 231    *   loader is null, the {@linkplain
 232    *   ClassLoader#getSystemClassLoader() system class loader} will be used.
 233    * </li>
 234    * <li>
 235    *   Otherwise, throws a {@link FactoryConfigurationError}.
 236    * </li>
 237    * </ul>
 238    *
 239    * @apiNote The parameter factoryId defined here is inconsistent with that
 240    * of other JAXP factories where the first parameter is fully qualified
 241    * factory class name that provides implementation of the factory.
 242    *
 243    * <p>
 244    * Note that this is a new method that replaces the deprecated
 245    *   {@link #newInstance(java.lang.String, java.lang.ClassLoader)
 246    *   newInstance(String factoryId, ClassLoader classLoader)} method.
 247    * No changes in behavior are defined by this replacement method relative
 248    * to the deprecated method.
 249    * </p>
 250    *
 251    * @param factoryId             Name of the factory to find, same as
 252    *                              a property name
 253    * @param classLoader           classLoader to use
 254    * @return the factory implementation
 255    * @throws FactoryConfigurationError in case of {@linkplain
 256    *   java.util.ServiceConfigurationError service configuration error} or if
 257    *   the implementation is not available or cannot be instantiated.
 258    */
 259   public static XMLOutputFactory newFactory(String factoryId,
 260           ClassLoader classLoader)
 261           throws FactoryConfigurationError {
 262       //do not fallback if given classloader can't find the class, throw exception