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
class. DefaultConfigurationBuilder
DefaultConfigurationBuilder
also has a more robust
merge algorithm for constructing combined configurations. So it is
recommended to use this class instead of ConfigurationFactory
.
Modifier and Type | Class and Description |
---|---|
static class |
ConfigurationFactory.AdditionalConfigurationData
A simple data class that holds all information about a configuration
from the
<additional> section. |
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.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.
|
Constructor and Description |
---|
ConfigurationFactory()
Constructor
|
ConfigurationFactory(String configurationFileName)
Constructor with ConfigurationFile Name passed
|
Modifier and Type | Method and Description |
---|---|
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.
|
public ConfigurationFactory()
public ConfigurationFactory(String configurationFileName)
configurationFileName
- The path to the configuration filepublic Configuration getConfiguration() throws ConfigurationException
ConfigurationException
- A generic exception that we had trouble during the
loading of the configuration data.public String getConfigurationFileName()
public void setConfigurationFileName(String configurationFileName)
configurationFileName
- The name of the configurationFile to use.public URL getConfigurationURL()
public void setConfigurationURL(URL url)
url
- the URL of the configuration to loadpublic URL getDigesterRules()
public void setDigesterRules(URL digesterRules)
digesterRules
- The digesterRules to setprotected void enableDigesterSubstitutor(Digester digester)
digester
- The digester to which we add the substitutorprotected void initDefaultDigesterRules(Digester digester)
<override>
and <additional>
.digester
- The digester to configureprotected void initDigesterSectionRules(Digester digester, String matchString, boolean additional)
digester
- the current digester instancematchString
- specifies the sectionadditional
- a flag if rules for the additional section are to be
addedprotected void setupDigesterInstance(Digester digester, String matchString, ObjectCreationFactory factory, String method, boolean additional)
digester
- the current digestermatchString
- the pattern to match with this rulefactory
- an ObjectCreationFactory instance to use for creating new
objectsmethod
- the name of a method to be called or null for noneadditional
- a flag if rules for the additional section are to be
addedprotected void setupUnionRules(Digester digester, String matchString)
digester
- the current digestermatchString
- the pattern to match with this rulepublic String getDigesterRuleNamespaceURI()
public void setDigesterRuleNamespaceURI(String digesterRuleNamespaceURI)
digesterRuleNamespaceURI
- The new digesterRuleNamespaceURI to usepublic String getBasePath()
public void setBasePath(String basePath)
basePath
- The new basePath to set.Copyright © 2012 JBoss by Red Hat. All Rights Reserved.