edu.cmu.sphinx.util.props
Class ConfigurationManager

java.lang.Object
  extended byedu.cmu.sphinx.util.props.ConfigurationManager

public class ConfigurationManager
extends java.lang.Object

Manages the configuration for the system. The configuration manager provides the following services:

For an overview of how to use this configuration management system to create and configure components please see: Sphinx-4 Configuration Management

For a description of how to create your own configurable components see: Configurable


Field Summary
static java.lang.String PROP_COMMON_LOG_LEVEL
          A common property (used by all components) that sets the log level for the component.
static java.lang.String PROP_COMMON_LOG_TERSE
          A common property (used by all components) that sets the tersness of the log output
static java.lang.String PROP_SHOW_CREATIONS
          Sphinx Property that defines whether or not the configuration manager will trace object creations
static boolean PROP_SHOW_CREATIONS_DEFAULT
          The default value for PROP_SHOW_CREATIONS
 
Constructor Summary
ConfigurationManager(java.net.URL url)
          Creates a new configuration manager.
 
Method Summary
 void editConfig(java.lang.String name)
           
 java.lang.String[] getInstanceNames(java.lang.Class type)
          Gets all instances that are of the given type or are assignable to that type.
 PropertySheet getPropertySheet(java.lang.String instanceName)
          Returns the property sheet for the given object instance
 Registry getRegistry(java.lang.String instanceName)
          Returns the registry for the given object instance
 Configurable lookup(java.lang.String name)
          Looks up a configurable component by name.
 void save(java.io.File file)
          Saves the current configuration to the given file
 void setProperty(java.lang.String component, java.lang.String prop, java.lang.String value)
          Sets the property of the given component to the given value.
 void showConfig()
          Shows the current configuration
 void showConfig(java.lang.String name)
          Show the configuration for the compnent with the given name
 void showConfigAsGDL(java.lang.String path)
          Dumps the config as a GDL plot
 void showConfigAsHTML(java.lang.String path)
          Dumps the config as a set of HTML tables
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_SHOW_CREATIONS

public static final java.lang.String PROP_SHOW_CREATIONS
Sphinx Property that defines whether or not the configuration manager will trace object creations

See Also:
Constant Field Values

PROP_SHOW_CREATIONS_DEFAULT

public static final boolean PROP_SHOW_CREATIONS_DEFAULT
The default value for PROP_SHOW_CREATIONS

See Also:
Constant Field Values

PROP_COMMON_LOG_LEVEL

public static final java.lang.String PROP_COMMON_LOG_LEVEL
A common property (used by all components) that sets the log level for the component.

See Also:
Level, Constant Field Values

PROP_COMMON_LOG_TERSE

public static final java.lang.String PROP_COMMON_LOG_TERSE
A common property (used by all components) that sets the tersness of the log output

See Also:
Constant Field Values
Constructor Detail

ConfigurationManager

public ConfigurationManager(java.net.URL url)
                     throws java.io.IOException,
                            PropertyException
Creates a new configuration manager. Initial properties are loaded from the given URL. No need to keep the notion of 'context' around anymore we will just pass around this property manager.

Parameters:
url - place to load initial properties from
Throws:
java.io.IOException - if an error occurs while loading properties from the URL
PropertyException
Method Detail

getPropertySheet

public PropertySheet getPropertySheet(java.lang.String instanceName)
Returns the property sheet for the given object instance

Parameters:
instanceName - the instance name of the object
Returns:
the property sheet for the object.

getRegistry

public Registry getRegistry(java.lang.String instanceName)
Returns the registry for the given object instance

Parameters:
instanceName - the instance name of the object
Returns:
the property sheet for the object.

getInstanceNames

public java.lang.String[] getInstanceNames(java.lang.Class type)
Gets all instances that are of the given type or are assignable to that type. Object.class matches all.

Parameters:
type - the desired type of instance
Returns:
the set of all instances

lookup

public Configurable lookup(java.lang.String name)
                    throws java.lang.InstantiationException,
                           PropertyException
Looks up a configurable component by name. Creates it if necessary

Parameters:
name - the name of the component
Returns:
the compnent, or null if a component was not found.
Throws:
java.lang.InstantiationException - if the requested object could not be properly created, or is not a configurable object.
PropertyException - if an error occurs while setting a property

setProperty

public void setProperty(java.lang.String component,
                        java.lang.String prop,
                        java.lang.String value)
                 throws PropertyException
Sets the property of the given component to the given value. Component must be an exisiting, instantiatied component

Parameters:
component - an existing component
prop - the property name
value - the new value.
Throws:
PropertyException

save

public void save(java.io.File file)
          throws java.io.IOException
Saves the current configuration to the given file

Parameters:
file - place to save the configuration
Throws:
java.io.IOException - if an error occurs while writing to the file

showConfig

public void showConfig()
Shows the current configuration


showConfig

public void showConfig(java.lang.String name)
Show the configuration for the compnent with the given name

Parameters:
name - the component name

editConfig

public void editConfig(java.lang.String name)

showConfigAsHTML

public void showConfigAsHTML(java.lang.String path)
                      throws java.io.IOException
Dumps the config as a set of HTML tables

Parameters:
path - where to output the HTML
Throws:
java.io.IOException - if an error occurs

showConfigAsGDL

public void showConfigAsGDL(java.lang.String path)
                     throws java.io.IOException
Dumps the config as a GDL plot

Parameters:
path - where to output the GDL
Throws:
java.io.IOException - if an error occurs