public class ObjectFactory extends Object
This code is designed to implement the JAXP 1.1 spec pluggability feature and is designed to run on JDK version 1.1 and later, and to compile on JDK 1.2 and onward. The code also runs both as part of an unbundled jar file and when bundled as part of the JDK.
This class was moved from the javax.xml.parsers.ObjectFactory
class and modified to be used as a general utility for creating objects
dynamically.
| Constructor and Description |
|---|
ObjectFactory() |
| Modifier and Type | Method and Description |
|---|---|
static Object |
createObject(String factoryId,
String fallbackClassName)
Finds the implementation Class object in the specified order.
|
static ClassLoader |
findClassLoader()
Figure out which ClassLoader to use.
|
static Class |
findProviderClass(String className,
boolean doFallback)
Find a Class using the same classloader for the ObjectFactory by default
or bootclassloader when Security Manager is in place
|
static Class |
lookUpFactoryClass(String factoryId)
Finds the implementation Class object in the specified order.
|
static Class |
lookUpFactoryClass(String factoryId,
String propertiesFilename,
String fallbackClassName)
Finds the implementation Class object in the specified order.
|
static Object |
newInstance(String className,
boolean doFallback)
Create an instance of a class using the same classloader for the ObjectFactory by default
or bootclassloader when Security Manager is in place
|
public static Object createObject(String factoryId, String fallbackClassName) throws ConfigurationError
System.getProperty
META-INF/services/factoryId file
factoryId - Name of the factory to find, same as
a property namefallbackClassName - Implementation class name, if nothing else
is found. Use null to mean no fallback.ObjectFactory.ConfigurationErrorConfigurationErrorpublic static Class lookUpFactoryClass(String factoryId) throws ConfigurationError
System.getProperty
$java.home/lib/propertiesFilename file
META-INF/services/factoryId file
factoryId - Name of the factory to find, same as
a property namepropertiesFilename - The filename in the $java.home/lib directory
of the properties file. If none specified,
${java.home}/lib/xalan.properties will be used.fallbackClassName - Implementation class name, if nothing else
is found. Use null to mean no fallback.ObjectFactory.ConfigurationErrorConfigurationErrorpublic static Class lookUpFactoryClass(String factoryId, String propertiesFilename, String fallbackClassName) throws ConfigurationError
System.getProperty
$java.home/lib/propertiesFilename file
META-INF/services/factoryId file
factoryId - Name of the factory to find, same as
a property namepropertiesFilename - The filename in the $java.home/lib directory
of the properties file. If none specified,
${java.home}/lib/xalan.properties will be used.fallbackClassName - Implementation class name, if nothing else
is found. Use null to mean no fallback.ObjectFactory.ConfigurationErrorConfigurationErrorpublic static ClassLoader findClassLoader() throws ConfigurationError
ConfigurationErrorpublic static Object newInstance(String className, boolean doFallback) throws ConfigurationError
ConfigurationErrorpublic static Class findProviderClass(String className, boolean doFallback) throws ClassNotFoundException, ConfigurationError
Copyright © 2018–2021 mhoffrogge. All rights reserved.