Package org.astrogrid.config

Configuration package; provides a simple set of methods for application-wide access to properties, using both traditional key/value pairs and XPath querying.

See:
          Description

Class Summary
Config Defines the methods that a Configurator must implement.
ConfigFactory For those who might want to create multiple configuration instances, this factory can be used.
FailbackConfig All Things To All Men Configuration.
SimpleConfig A static singleton for easy one-line access to an application-global configuration file.
 

Exception Summary
ConfigException Thrown when problems encountered with getting configuration properties.
PropertyNotFoundException Thrown when a property cannot be found.
 

Package org.astrogrid.config Description

Configuration package; provides a simple set of methods for application-wide access to properties, using both traditional key/value pairs and XPath querying.

Background

The configuration package has to be able to:

  • Provide simple, backward-compatible access to key/value properties
  • Run without any configuration file present, with values set by the code, for unit tests
  • Load from several files (eg user-entered values, plus programmer-entered values)
  • Provide a getproperty(XPath) returning XML nodes (implies a load from XML) for structured properties

    Simple

    For the most simplest of configurations, use the static methods on the SimpleConfig class. These access a single (hidden) instance, and allows programmers to use the configuration with a minimum of code, like this:

    Using Properties:

    
    String fruit = SimpleConfig.getProperty("GlobalFruit");
    

    Implementation

    The SimpleConfig implemenation is FailbackConfig - see the class doc for how it works. To get access to all its features, use SimpleConfig.getSingleton().



    Copyright © 2002-2007 AstroGrid. All Rights Reserved.