org.apache.commons.configuration
public class ConfigurationFactory extends Object
Factory class to create a CompositeConfiguration from a .xml file using Digester. By default it can handle the Configurations from commons- configuration. If you need to add your own, then you can pass in your own digester rules to use. It is also namespace aware, by providing a digesterRuleNamespaceURI.
Note: Almost all of the features provided by this class and many
more are also available for the DefaultConfigurationBuilder
class. DefaultConfigurationBuilder
also has a more robust
merge algorithm for constructing combined configurations. So it is
recommended to use this class instead of ConfigurationFactory
.
Version: $Id: ConfigurationFactory.java 524006 2007-03-30 09:33:17Z oheger $
Nested Class Summary | |
---|---|
static class | ConfigurationFactory.AdditionalConfigurationData
A simple data class that holds all information about a configuration
from the <additional> section. |
static class | ConfigurationFactory.CallOptionalMethodRule
A special implementation of Digester's CallMethodRule that
is internally used for calling a file configuration's load()
method. |
static class | ConfigurationFactory.ConfigurationBuilder
An internally used helper class for constructing the composite
configuration object. |
class | ConfigurationFactory.DigesterConfigurationFactory
A base class for digester factory classes. |
class | ConfigurationFactory.FileConfigurationFactory
A tiny inner class that allows the Configuration Factory to
let the digester construct FileConfiguration objects
that already have the correct base Path set.
|
class | ConfigurationFactory.JNDIConfigurationFactory
A tiny inner class that allows the Configuration Factory to
let the digester construct JNDIConfiguration objects. |
class | ConfigurationFactory.PropertiesConfigurationFactory
A factory that returns an XMLPropertiesConfiguration for .xml files
and a PropertiesConfiguration for the others.
|
class | ConfigurationFactory.PropertyListConfigurationFactory
A factory that returns an XMLPropertyListConfiguration for .xml files
and a PropertyListConfiguration for the others.
|
class | ConfigurationFactory.SystemConfigurationFactory
A tiny inner class that allows the Configuration Factory to
let the digester construct SystemConfiguration objects. |
Field Summary | |
---|---|
static String | ATTR_FILENAME Constant for the fileName attribute. |
static String | ATTR_OPTIONAL Constant for the optional attribute. |
String | basePath The basePath to prefix file paths for file based property files. |
String | configurationFileName The XML file with the details about the configuration to load |
URL | configurationURL The URL to the XML file with the details about the configuration to load. |
String | digesterRuleNamespaceURI The digester namespace to parse |
URL | digesterRules URL for xml digester rules file |
static String | DEF_BASE_PATH Constant for the default base path (points to actual directory). |
String | implicitBasePath
The implicit base path for included files. |
static Log | log static logger |
static String | METH_LOAD Constant for the load method. |
static String | SEC_ADDITIONAL Constant for the additional section. |
static String | SEC_OVERRIDE Constant for the override section. |
static String | SEC_ROOT Constant for the root element in the info file. |
Constructor Summary | |
---|---|
ConfigurationFactory()
Constructor | |
ConfigurationFactory(String configurationFileName)
Constructor with ConfigurationFile Name passed
|
Method Summary | |
---|---|
void | configureNamespace(Digester digester)
Configure the current digester to be namespace aware and to have
a Configuration object to which all of the other configurations
should be added
|
protected void | enableDigesterSubstitutor(Digester digester)
Adds a substitutor to interpolate system properties
|
String | getBasePath()
Returns the Base path from which this Configuration Factory operates.
|
Configuration | getConfiguration()
Return the configuration provided by this factory. |
String | getConfigurationFileName()
Returns the configurationFile.
|
URL | getConfigurationURL()
Returns the URL of the configuration file to be loaded.
|
String | getDigesterRuleNamespaceURI()
Returns the digesterRuleNamespaceURI.
|
URL | getDigesterRules()
Returns the digesterRules.
|
protected void | initDefaultDigesterRules(Digester digester)
Initializes the parsing rules for the default digester
This allows the Configuration Factory to understand the default types:
Properties, XML and JNDI. |
protected void | initDigesterSectionRules(Digester digester, String matchString, boolean additional)
Sets up digester rules for a specified section of the configuration
info file.
|
void | setBasePath(String basePath)
Sets the basePath for all file references from this Configuration Factory.
|
void | setConfigurationFileName(String configurationFileName)
Sets the configurationFile.
|
void | setConfigurationURL(URL url)
Sets the URL of the configuration to load. |
void | setDigesterRuleNamespaceURI(String digesterRuleNamespaceURI)
Sets the digesterRuleNamespaceURI.
|
void | setDigesterRules(URL digesterRules)
Sets the digesterRules.
|
protected void | setupDigesterInstance(Digester digester, String matchString, ObjectCreationFactory factory, String method, boolean additional)
Sets up digester rules for a configuration to be loaded.
|
protected void | setupUnionRules(Digester digester, String matchString)
Sets up rules for configurations in the additional section.
|
Parameters: configurationFileName The path to the configuration file
Parameters: digester The Digester to configure
Parameters: digester The digester to which we add the substitutor
Returns: The base Path of this configuration factory.
Returns: A Configuration object
Throws: ConfigurationException A generic exception that we had trouble during the loading of the configuration data.
Returns: The name of the configuration file. Can be null.
Returns: the URL of the configuration to load
Returns: A String with the digesterRuleNamespaceURI.
Returns: URL
<override>
and <additional>
.
Parameters: digester The digester to configure
Parameters: digester the current digester instance matchString specifies the section additional a flag if rules for the additional section are to be added
Parameters: basePath The new basePath to set.
Parameters: configurationFileName The name of the configurationFile to use.
Parameters: url the URL of the configuration to load
Parameters: digesterRuleNamespaceURI The new digesterRuleNamespaceURI to use
Parameters: digesterRules The digesterRules to set
Parameters: digester the current digester matchString the pattern to match with this rule factory an ObjectCreationFactory instance to use for creating new objects method the name of a method to be called or null for none additional a flag if rules for the additional section are to be added
Parameters: digester the current digester matchString the pattern to match with this rule