org.apache.xerces.util
Class ObjectFactory

java.lang.Object
  |
  +--org.apache.xerces.util.ObjectFactory

public class ObjectFactory
extends java.lang.Object

This class is duplicated for each JAXP subpackage so keep it in sync. It is package private and therefore is not exposed as part of the JAXP API.

This code is designed to implement the JAXP 1.1 spec pluggability feature and is designed to both compile and run on JDK version 1.1 and later. 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.FactoryFinder class and modified to be used as a general utility for creating objects dynamically.

Version:
$Id: ObjectFactory.java,v 1.2 2002/01/29 01:15:18 lehors Exp $

Inner Class Summary
static class ObjectFactory.ConfigurationError
          A configuration error.
 
Constructor Summary
ObjectFactory()
           
 
Method Summary
static java.lang.Object createObject(java.lang.String factoryId, java.lang.String fallbackClassName)
          Finds the implementation Class object in the specified order.
static java.lang.Object createObject(java.lang.String factoryId, java.lang.String propertiesFilename, java.lang.String fallbackClassName)
          Finds the implementation Class object in the specified order.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectFactory

public ObjectFactory()
Method Detail

createObject

public static java.lang.Object createObject(java.lang.String factoryId,
                                            java.lang.String fallbackClassName)
                                     throws ObjectFactory.ConfigurationError
Finds the implementation Class object in the specified order. The specified order is the following:
  1. query the system property using System.getProperty
  2. read META-INF/services/factoryId file
  3. use fallback classname
Parameters:
factoryId - Name of the factory to find, same as a property name
fallbackClassName - Implementation class name, if nothing else is found. Use null to mean no fallback.
Returns:
Class object of factory, never null
Throws:
ObjectFactory.ConfigurationError -  

createObject

public static java.lang.Object createObject(java.lang.String factoryId,
                                            java.lang.String propertiesFilename,
                                            java.lang.String fallbackClassName)
                                     throws ObjectFactory.ConfigurationError
Finds the implementation Class object in the specified order. The specified order is the following:
  1. query the system property using System.getProperty
  2. read $java.home/lib/propertiesFilename file
  3. read META-INF/services/factoryId file
  4. use fallback classname
Parameters:
factoryId - Name of the factory to find, same as a property name
propertiesFilename - The filename in the $java.home/lib directory of the properties file.
fallbackClassName - Implementation class name, if nothing else is found. Use null to mean no fallback.
Returns:
Class object of factory, never null
Throws:
ObjectFactory.ConfigurationError -  


Copyright © 1999-2002 Apache XML Project. All Rights Reserved.