Overview

The configuration component allows an application to load up arbitrary configuration data that is backed by multiple datasources.

It is backed by Commons Configuration for accessing data and implements the Configuration API.

It is written for use in any container compatible with Avalon's Merlin or ECM container.

Configuration

First, here is the role configuration.


    <role
        name="org.apache.commons.configuration.Configuration"
        shorthand="config"
        default-class="org.apache.fulcrum.configuration.DefaultConfigurationService"/>

Now comes the basic configuration of the component. Here we will configure the various configuration sources.



    <config>
      <properties fileName="src/test/org/test.properties"/>
      <xml fileName="src/test/org/test.xml" optional="true"/>
      <key>value</key>
    </config>

The component supports the following sources of configuration which can be used as a list in arbitrary sequence. The order in that list is important. See the Commons Configuration Site for details on the configuration sources.

NameAttributesDescription
propertiesfileName="/path/to/file.properties" (req.)

optional="true" (opt.)
Load config from a Java Properties file. If optional is set to true, do not complain if the file is missing.
xmlfileName="/path/to/file.xml" (req.)

optional="true" (opt.)
Load config from a XML file. If optional is set to true, do not complain if the file is missing.
jndiprefix="java:comp/env" (req.)Load config from a JNDI context.
systemnoneLoad config from the System Properties
everything elsenoneAdd contents of this tag as a property to the configuration.

The old syntax with the attribute configurationPath="somepath" still works for reasons of backward compatibility.

Usage

The configurationPath is the location of the file read in by the ConfigurationFactory. This then returns your Configuration object.

To see an example, look at the test case ConfigTest.