|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.cmu.sphinx.util.props.ConfigurationManager
public class ConfigurationManager
Manages a set of Configurable
s, their parametrization and the relationships between them. Configurations
can be specified either by xml or on-the-fly during runtime.
Configurable
,
PropertySheet
Constructor Summary | |
---|---|
ConfigurationManager()
Creates a new empty configuration manager. |
|
ConfigurationManager(java.lang.String configFileName)
Creates a new configuration manager. |
|
ConfigurationManager(java.net.URL url)
Creates a new configuration manager. |
Method Summary | ||
---|---|---|
void |
addConfigurable(java.lang.Class<? extends Configurable> confClass,
java.lang.String name)
Registers a new configurable to this configuration manager. |
|
void |
addConfigurable(java.lang.Class<? extends Configurable> confClass,
java.lang.String name,
java.util.Map<java.lang.String,java.lang.Object> props)
Registers a new configurable to this configuration manager. |
|
void |
addConfigurable(Configurable configurable,
java.lang.String name)
Adds an already instantiated Configurable to this configuration manager. |
|
void |
addConfigurationChangeListener(ConfigurationChangeListener l)
Adds a new listener for configuration change events. |
|
void |
addSubConfiguration(ConfigurationManager subCM)
|
|
void |
addSubConfiguration(ConfigurationManager subCM,
boolean doOverrideComponents)
Adds a subconfiguration to this instance by registering all subCM-components and all its global properties. |
|
java.lang.Object |
clone()
Creates a deep copy of the given CM instance. |
|
boolean |
equals(java.lang.Object obj)
Test wether the given configuration manager instance equals this instance in terms of same configuration. |
|
java.util.Collection<java.lang.String> |
getComponentNames()
Returns all names of configurables registered to this instance. |
|
java.net.URL |
getConfigURL()
Returns the url of the xml-configuration which defined this configuration or null if it was created
dynamically. |
|
GlobalProperties |
getGlobalProperties()
Returns a copy of the map of global properties set for this configuration manager. |
|
java.lang.String |
getGlobalProperty(java.lang.String propertyName)
Returns a global property. |
|
GlobalProperty |
getGloPropReference(java.lang.String propertyName)
|
|
static
|
getInstance(java.lang.Class<C> targetClass)
Creates an instance of the given Configurable by using the default parameters as defined by the
class annotations to parameterize the component. |
|
static
|
getInstance(java.lang.Class<C> targetClass,
java.util.Map<java.lang.String,java.lang.Object> props)
Creates an instance of the given Configurable by using the default parameters as defined by the
class annotations to parameterize the component. |
|
static
|
getInstance(java.lang.Class<C> targetClass,
java.util.Map<java.lang.String,java.lang.Object> props,
java.lang.String compName)
Creates an instance of the given Configurable by using the default parameters as defined by the
class annotations to parameterize the component. |
|
java.util.Collection<java.lang.String> |
getInstanceNames(java.lang.Class<? extends Configurable> type)
Gets all instances that are of the given type. |
|
PropertySheet |
getPropertySheet(java.lang.String instanceName)
Returns the property sheet for the given object instance |
|
java.util.List<PropertySheet> |
getPropSheets(java.lang.Class<? extends Configurable> confClass)
Given a Configurable -class/interface, all property-sheets which are subclassing/implemting this
class/interface are collected and returned. |
|
java.util.logging.Logger |
getRootLogger()
Returns the root-logger of this configuration manager. |
|
java.lang.String |
getStrippedComponentName(java.lang.String propertyName)
|
|
Configurable |
lookup(java.lang.String instanceName)
Looks up a configurable component by name. |
|
void |
removeConfigurable(java.lang.String name)
Removes a configurable from this configuration manager. |
|
void |
removeConfigurationChangeListener(ConfigurationChangeListener l)
Removes a listener for configuration change events. |
|
void |
renameConfigurable(java.lang.String oldName,
java.lang.String newName)
|
|
void |
setGlobalProperty(java.lang.String propertyName,
java.lang.String value)
Sets a global property. |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ConfigurationManager()
public ConfigurationManager(java.lang.String configFileName) throws PropertyException
configFileName
- The location of the configuration file.
PropertyException
public ConfigurationManager(java.net.URL url) throws PropertyException
url
- The location of the configuration file.
PropertyException
Method Detail |
---|
public PropertySheet getPropertySheet(java.lang.String instanceName)
instanceName
- the instance name of the object
public java.util.Collection<java.lang.String> getInstanceNames(java.lang.Class<? extends Configurable> type)
type
- the desired type of instance
public java.util.Collection<java.lang.String> getComponentNames()
ConfigurationManager
public Configurable lookup(java.lang.String instanceName) throws InternalConfigurationException
instanceName
- the name of the component
InternalConfigurationException
- If the requested object could not be properly created, or is not a
configurable object, or if an error occured while setting a component
property.public java.util.List<PropertySheet> getPropSheets(java.lang.Class<? extends Configurable> confClass)
Configurable
-class/interface, all property-sheets which are subclassing/implemting this
class/interface are collected and returned. No Configurable
will be instantiated by this method.
public void addConfigurable(java.lang.Class<? extends Configurable> confClass, java.lang.String name)
confClass
- The class of the configurable to be instantiated and to be added to this configuration manager
instance.name
- The desired lookup-name of the configurable
java.lang.IllegalArgumentException
- if the there's already a component with the same name
registered to
this configuration manager instance.public void addConfigurable(java.lang.Class<? extends Configurable> confClass, java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> props)
confClass
- The class of the configurable to be instantiated and to be added to this configuration manager
instance.name
- The desired lookup-name of the configurableprops
- The properties to be used for component configuration
java.lang.IllegalArgumentException
- if the there's already a component with the same name
registered to
this configuration manager instance.public void addConfigurable(Configurable configurable, java.lang.String name)
Configurable
to this configuration manager.
name
- The desired lookup-instanceName of the configurablepublic void renameConfigurable(java.lang.String oldName, java.lang.String newName)
public void removeConfigurable(java.lang.String name)
public void addSubConfiguration(ConfigurationManager subCM)
subCM
- The subconfiguration that shouwld be to this instancepublic void addSubConfiguration(ConfigurationManager subCM, boolean doOverrideComponents)
subCM
- The subconfiguration that shouwld be to this instancedoOverrideComponents
- If true
non-instantiated components will be overriden by elements of
subCM even if already being registered to this CM-instance. The same holds for global
properties.
java.lang.RuntimeException
- if an already instantiated component in this instance is redefined in subCM.public GlobalProperties getGlobalProperties()
public java.lang.String getGlobalProperty(java.lang.String propertyName)
propertyName
- The name of the global property or null
if no such property existspublic GlobalProperty getGloPropReference(java.lang.String propertyName)
public java.net.URL getConfigURL()
null
if it was created
dynamically.
public void setGlobalProperty(java.lang.String propertyName, java.lang.String value)
propertyName
- The name of the global property.value
- The new value of the global property. If the value is null
the property becomes
removed.public java.lang.String getStrippedComponentName(java.lang.String propertyName)
public void addConfigurationChangeListener(ConfigurationChangeListener l)
public void removeConfigurationChangeListener(ConfigurationChangeListener l)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public static <C extends Configurable> C getInstance(java.lang.Class<C> targetClass) throws PropertyException
Configurable
by using the default parameters as defined by the
class annotations to parameterize the component.
PropertyException
public static <C extends Configurable> C getInstance(java.lang.Class<C> targetClass, java.util.Map<java.lang.String,java.lang.Object> props) throws PropertyException
Configurable
by using the default parameters as defined by the
class annotations to parameterize the component. Default prarmeters will be overrided if a their names are
containd in the given props
-map
PropertyException
public static <C extends Configurable> C getInstance(java.lang.Class<C> targetClass, java.util.Map<java.lang.String,java.lang.Object> props, java.lang.String compName) throws PropertyException
Configurable
by using the default parameters as defined by the
class annotations to parameterize the component. Default prarmeters will be overrided if a their names are
containd in the given props
-map. The component is used to create a parameterized logger for the
Configurable being created.
PropertyException
public java.util.logging.Logger getRootLogger()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |