Index: xdocs/changes.xml
===================================================================
--- xdocs/changes.xml	(revision 713250)
+++ xdocs/changes.xml	(working copy)
@@ -85,6 +85,10 @@
     </release>
 
     <release version="1.6" date="in SVN" description="">
+      <action dev="oheger" type="add" issue="CONFIGURATION-349" due-to="Ralph Goers">
+        Added MultiFileHierarchicalConfiguration, DynamicCombinedConfiguration
+        and PatternSubtreeConfigurationWrapper.
+      </action>
       <action dev="oheger" type="fix" issue="CONFIGURATION-345">
         PropertiesConfiguration now per default uses the encoding "ISO-8859-1"
         for loading properties files.
Index: xdocs/userguide/howto_multitenant.xml
===================================================================
--- xdocs/userguide/howto_multitenant.xml	(revision 0)
+++ xdocs/userguide/howto_multitenant.xml	(revision 0)
@@ -0,0 +1,148 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+<document>
+
+  <properties>
+    <title>Mutli-tenant Configurations</title>
+    <author email="rgoers@apache.org">Ralph Goers</author>
+  </properties>
+
+  <body>
+    <section name="Multi-tenant Configurations">
+      <p>
+        In a multi-tenant environment a single instance of the application
+        while run on behalf of many clients. Typically, this will require
+        that each client have its own unique configuration. The simplest
+        approach to enable an application to be multi-tenant is for it
+        to not really be aware of it at all. This requires that the
+        configuration framework take on some of the responsility for
+        making the application work correctly.
+      </p>
+      <p>
+        One approach to enable this support in a web application might be
+        to use a Servlet Filter and then use the Log4j or SLF4J MDC to
+        save the attributes needed to identify the client. These attributes
+        can then be used to identify the specific client configuration to
+        be used. The classes described below use this technique to allow
+        configurations to transparently provide the configuration appropriate
+        for the clients.
+      </p>
+
+      <subsection name="MultiFileHierarchicalConfiguration">
+        <p>
+          The constructor for this class accepts a pattern. The pattern can
+          contain keys that will be resolved using the ConfigurationInterpolator
+          on each call to a method in the class. The configuration file will then
+          be located using the resolved pattern and a new XMLConfiguration
+          will be created and cached for subsequent requests. The ExpressionEngine,
+          ReloadingStrategy and listeners will be propogated to each of the
+          created configurations.
+        </p>
+      </subsection>
+      <subsection name="DynamicCombinedConfiguration">
+        <p>
+          The CombinedConfiguration class allows multiple configuration files to be
+          merged together. However, it will not merge a MultiFileHierarchicalConfiguration
+          properly since the underlying configuration file will be different depending
+          on the resolution of the location pattern. DynamicCombinedConfiguration
+          solves this by creating a new CombinedConfiguration for each pattern.
+        </p>
+      </subsection>
+      <subsection name="Sample Configuration">
+        <p>
+           This sample configuration illustrates how to use DynamicCombinedConfiguration
+           in combination with MultiFileHierarchicalConfiguration to create a multi-tenant
+           configuration.
+        </p>
+        <source><![CDATA[
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!-- Test configuration definition file that demonstrates complex initialization -->
+<configuration>
+  <header>
+    <result delimiterParsingDisabled="true" forceReloadCheck="true"
+            config-class="org.apache.commons.configuration.DynamicCombinedConfiguration"
+            keyPattern="${sys:Id}">
+      <expressionEngine
+          config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
+    </result>
+    <providers>
+      <provider config-tag="multifile"
+         config-class="org.apache.commons.configuration.DefaultConfigurationBuilder$FileConfigurationProvider"
+         configurationClass="org.apache.commons.configuration.MultiFileHierarchicalConfiguration"/>
+    </providers>
+  </header>
+  <override>
+    <multifile filePattern="/opt/configs/${sys:Id}/config.xml" config-name="clientConfig"/>
+    <xml fileName="/opt/configs/default/config.xml" config-name="defaultConfig"/>
+  </override>
+</configuration>
+]]></source>
+      </subsection>
+      <subsection name="PatternSubtreeConfigurationWrapper">
+        <p>
+          Applications are often composed of many components each of which need their
+          own configuration. This can be accomodated by having a configuration file
+          per component, but this can make things hard to manage when there are many
+          clients and many components. A second approach is to combine them into
+          a single configuration file. However, this either means the subcomponent
+          has to be aware of the surrounding configuration and navigate past it or the
+          application must be provided just the portion of the configuration it
+          can process. PatternSubtreeConfigurationWrapper can be used for this purpose.
+        </p>
+        <p>
+          Normal practice when using dependency injection frameworks is to have the
+          attributes needed to make components work correctly injected into them.
+          When working with Commons Configuration this works very well. Components
+          simply need to have a HierarchicalConfiguration attribute along with
+          a corresponding setter and getter. The injection framework can then be
+          used to provide the component with the correct configuration using
+          PatternSubtreeConfigurationWrapper as shown in the next example.
+        </p>
+        <p>
+        <source><![CDATA[
+  <bean id="configurationBuilder"
+        class="org.apache.commons.configuration.DefaultConfigurationBuilder">
+    <property name="fileName">
+      <value>configuration.xml</value>
+    </property>
+  </bean>
+  <bean id="applicationConfig" factory-bean="configurationBuilder"
+        factory-method="getConfiguration">
+  </bean>
+  <bean id="subcomponentConfig"
+        class="org.apache.commons.configuration.PatternSubtreeConfigurationWrapper"
+        autowire='autodetect'>
+    <constructor-arg index="0">
+      <ref bean="applicationConfig"/>
+    </constructor-arg>
+    <constructor-arg index="1" value="/Components/MyComponent"
+  </bean>
+  <bean id='MyComponent' class='org.test.MyComponent' autowire='autodetect'>
+    <property name="configuration">
+      <ref bean="subcomponentConfig"/>
+    </property>
+  </bean>
+]]></source>
+        </p>
+      </subsection>
+    </section>
+
+  </body>
+
+</document>
Index: xdocs/userguide/user_guide.xml
===================================================================
--- xdocs/userguide/user_guide.xml	(revision 713250)
+++ xdocs/userguide/user_guide.xml	(working copy)
@@ -132,6 +132,13 @@
         <li><a href="howto_configurationbuilder.html#An_example">An example</a></li>
         <li><a href="howto_configurationbuilder.html#Extending_the_configuration_definition_file_format">Extending the configuration definition file format</a></li>
       </ul>
+      <li><a href="howto_multitenant.html#Multi-tenant Configurations">Multi-tenant Configurations</a></li>
+      <ul>
+        <li><a href="howto_multitenant.html#MultiFileHierarchicalConfiguration">MultiFileHierarchicalConfiguration</a></li>
+        <li><a href="howto_multitenant.html#DynamicCombinedConfiguration">DynamicCombinedConfiguration</a></li>
+        <li><a href="howto_multitenant.html#Sample Configuration">Sample Configuration</a></li>
+        <li><a href="howto_multitenant.html#PatternSubtreeConfigurationWrapper">PatternSubtreeConfigurationWrapper</a></li>
+      </ul>
       <li><a href="howto_events.html#Configuration_Events">Configuration Events</a></li>
       <ul>
         <li><a href="howto_events.html#Configuration_listeners">Configuration listeners</a></li>
Index: src/test/java/org/apache/commons/configuration2/combined/TestDynamicCombinedConfiguration.java
===================================================================
--- src/test/java/org/apache/commons/configuration2/combined/TestDynamicCombinedConfiguration.java	(revision 0)
+++ src/test/java/org/apache/commons/configuration2/combined/TestDynamicCombinedConfiguration.java	(revision 0)
@@ -0,0 +1,57 @@
+package org.apache.commons.configuration2.combined;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.framework.TestCase;
+import org.apache.commons.configuration2.combined.DynamicCombinedConfiguration;
+import org.apache.commons.configuration2.MultiFileHierarchicalConfiguration;
+import org.apache.commons.configuration2.XMLConfiguration;
+
+/**
+ *
+ */
+public class TestDynamicCombinedConfiguration extends TestCase
+{
+    private static String PATTERN ="${sys:Id}";
+    private static String PATTERN1 = "target/test-classes/testMultiConfiguration_${sys:Id}.xml";
+    private static String DEFAULT_FILE = "target/test-classes/testMultiConfiguration_default.xml";
+
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public TestDynamicCombinedConfiguration( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( TestDynamicCombinedConfiguration.class );
+    }
+
+    public void testConfiguration() throws Exception
+    {
+        DynamicCombinedConfiguration config = new DynamicCombinedConfiguration();
+        config.setKeyPattern(PATTERN);
+        MultiFileHierarchicalConfiguration multi = new MultiFileHierarchicalConfiguration(PATTERN1);
+        config.addConfiguration(multi, "Multi");
+        XMLConfiguration xml = new XMLConfiguration(DEFAULT_FILE);
+        config.addConfiguration(xml, "Default");
+
+        verify("1001", config, 15);
+        verify("1002", config, 25);
+        verify("1003", config, 35);
+        verify("1004", config, 50);
+    }
+
+    private void verify(String key, DynamicCombinedConfiguration config, int rows)
+    {
+        System.setProperty("Id", key);
+        assertTrue(config.getInt("rowsPerPage") == rows);
+    }
+}
Index: src/test/java/org/apache/commons/configuration2/TestMultiFileHierarchicalConfiguration.java
===================================================================
--- src/test/java/org/apache/commons/configuration2/TestMultiFileHierarchicalConfiguration.java	(revision 0)
+++ src/test/java/org/apache/commons/configuration2/TestMultiFileHierarchicalConfiguration.java	(revision 0)
@@ -0,0 +1,56 @@
+package org.apache.commons.configuration2;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.commons.configuration2.reloading.FileChangedReloadingStrategy;
+
+/**
+ * Unit test for simple MultiConfigurationTest.
+ */
+public class TestMultiFileHierarchicalConfiguration
+    extends TestCase
+{
+    private static String PATTERN1 = "target/test-classes/testMultiConfiguration_${sys:Id}.xml";
+    
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public TestMultiFileHierarchicalConfiguration( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( TestMultiFileHierarchicalConfiguration.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testMultiConfiguration()
+    {
+        //set up a reloading strategy
+        FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
+        strategy.setRefreshDelay(10000);
+        
+        MultiFileHierarchicalConfiguration config = new MultiFileHierarchicalConfiguration(PATTERN1);
+        config.setReloadingStrategy(strategy);
+
+        System.setProperty("Id", "1001");
+        assertTrue(config.getInt("rowsPerPage") == 15);
+
+        System.setProperty("Id", "1002");
+        assertTrue(config.getInt("rowsPerPage") == 25);
+
+        System.setProperty("Id", "1003");
+        assertTrue(config.getInt("rowsPerPage") == 35);
+    }
+}
Index: src/test/java/org/apache/commons/configuration2/TestPatternSubtreeConfiguration.java
===================================================================
--- src/test/java/org/apache/commons/configuration2/TestPatternSubtreeConfiguration.java	(revision 0)
+++ src/test/java/org/apache/commons/configuration2/TestPatternSubtreeConfiguration.java	(revision 0)
@@ -0,0 +1,68 @@
+package org.apache.commons.configuration2;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.commons.configuration2.reloading.FileChangedReloadingStrategy;
+import org.apache.commons.configuration2.expr.xpath.XPathExpressionEngine;
+
+import java.io.File;
+
+/**
+ * Unit test for simple MultiConfigurationTest.
+ */
+public class TestPatternSubtreeConfiguration extends TestCase
+{
+    private static String CONFIG_FILE = "target/test-classes/testPatternSubtreeConfig.xml";
+    private static String PATTERN = "BusinessClient[@name='${sys:Id}']";
+    private XMLConfiguration conf;
+
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public TestPatternSubtreeConfiguration( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite() throws Exception
+    {
+        return new TestSuite(TestPatternSubtreeConfiguration.class );
+    }
+
+    protected void setUp() throws Exception
+    {
+        conf = new XMLConfiguration();
+        conf.setFile(new File(CONFIG_FILE));
+        conf.load();
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testMultiConfiguration()
+    {
+        //set up a reloading strategy
+        FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
+        strategy.setRefreshDelay(10000);
+
+        PatternSubtreeConfigurationWrapper config = new PatternSubtreeConfigurationWrapper(this.conf, PATTERN);
+        config.setReloadingStrategy(strategy);
+        config.setExpressionEngine(new XPathExpressionEngine());
+
+        System.setProperty("Id", "1001");
+        assertTrue(config.getInt("rowsPerPage") == 15);
+
+        System.setProperty("Id", "1002");
+        assertTrue(config.getInt("rowsPerPage") == 25);
+
+        System.setProperty("Id", "1003");
+        assertTrue(config.getInt("rowsPerPage") == 35);
+    }
+}
\ No newline at end of file
Index: src/test/resources/testMultiConfiguration_1001.xml
===================================================================
--- src/test/resources/testMultiConfiguration_1001.xml	(revision 0)
+++ src/test/resources/testMultiConfiguration_1001.xml	(revision 0)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<configuration>
+  <colors>
+    <background>#808080</background>
+    <text>#000000</text>
+    <header>#008000</header>
+    <link normal="#000080" visited="#800080"/>
+    <default>${colors.header}</default>
+  </colors>
+  <rowsPerPage>15</rowsPerPage>
+  <buttons>
+    <name>OK,Cancel,Help</name>
+  </buttons>
+  <numberFormat pattern="###\,###.##"/>
+</configuration>
Index: src/test/resources/testMultiConfiguration_1002.xml
===================================================================
--- src/test/resources/testMultiConfiguration_1002.xml	(revision 0)
+++ src/test/resources/testMultiConfiguration_1002.xml	(revision 0)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<configuration>
+  <colors>
+    <background>#2222222</background>
+    <text>#000000</text>
+    <header>#222222</header>
+    <link normal="#020202" visited="#202020"/>
+    <default>${colors.header3}</default>
+  </colors>
+  <rowsPerPage>25</rowsPerPage>
+  <buttons>
+    <name>OK-2,Cancel-2,Help-2</name>
+  </buttons>
+  <numberFormat pattern="###\,###.##"/>
+</configuration>
Index: src/test/resources/testMultiConfiguration_1003.xml
===================================================================
--- src/test/resources/testMultiConfiguration_1003.xml	(revision 0)
+++ src/test/resources/testMultiConfiguration_1003.xml	(revision 0)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<configuration>
+  <colors>
+    <background>#333333</background>
+    <text>#FFFFFF</text>
+    <header>#333333</header>
+    <link normal="#030303" visited="#303030"/>
+    <default>${colors.header3}</default>
+  </colors>
+  <rowsPerPage>35</rowsPerPage>
+  <buttons>
+    <name>OK-3,Cancel-3,Help-3</name>
+  </buttons>
+  <numberFormat pattern="###\,###.##"/>
+</configuration>
Index: src/test/resources/testMultiConfiguration_1004.xml
===================================================================
--- src/test/resources/testMultiConfiguration_1004.xml	(revision 0)
+++ src/test/resources/testMultiConfiguration_1004.xml	(revision 0)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<configuration>
+  <colors>
+    <default>${colors.header4}</default>
+  </colors>
+  <buttons>
+    <name>OK-1,Cancel-2,Help-3</name>
+  </buttons>
+  <numberFormat pattern="###\,###.##"/>
+</configuration>
\ No newline at end of file
Index: src/test/resources/testMultiConfiguration_default.xml
===================================================================
--- src/test/resources/testMultiConfiguration_default.xml	(revision 0)
+++ src/test/resources/testMultiConfiguration_default.xml	(revision 0)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<configuration>
+  <colors>
+    <background>#40404040</background>
+    <text>#000000</text>
+    <header>#444444</header>
+    <link normal="#040404" visited="#404040"/>
+    <default>${colors.default}</default>
+  </colors>
+  <rowsPerPage>50</rowsPerPage>
+  <buttons>
+    <name>OK-4,Cancel-4,Help-4</name>
+  </buttons>
+  <numberFormat pattern="###\,###.##"/>
+</configuration>
\ No newline at end of file
Index: src/test/resources/testPatternSubtreeConfig.xml
===================================================================
--- src/test/resources/testPatternSubtreeConfig.xml	(revision 0)
+++ src/test/resources/testPatternSubtreeConfig.xml	(revision 0)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<Configuration>
+  <BusinessClient name="1001">
+    <colors>
+      <background>#808080</background>
+      <text>#000000</text>
+      <header>#008000</header>
+      <link normal="#000080" visited="#800080"/>
+      <default>${colors.header}</default>
+    </colors>
+    <rowsPerPage>15</rowsPerPage>
+    <buttons>
+      <name>OK,Cancel,Help</name>
+    </buttons>
+    <numberFormat pattern="###\,###.##"/>
+  </BusinessClient>
+  <BusinessClient name="1002">
+    <colors>
+      <background>#2222222</background>
+      <text>#000000</text>
+      <header>#222222</header>
+      <link normal="#020202" visited="#202020"/>
+      <default>${colors.header3}</default>
+    </colors>
+    <rowsPerPage>25</rowsPerPage>
+    <buttons>
+      <name>OK-2,Cancel-2,Help-2</name>
+    </buttons>
+    <numberFormat pattern="###\,###.##"/>
+  </BusinessClient>
+  <BusinessClient name="1003">
+    <colors>
+      <background>#333333</background>
+      <text>#FFFFFF</text>
+      <header>#333333</header>
+      <link normal="#030303" visited="#303030"/>
+      <default>${colors.header3}</default>
+    </colors>
+    <rowsPerPage>35</rowsPerPage>
+    <buttons>
+      <name>OK-3,Cancel-3,Help-3</name>
+    </buttons>
+    <numberFormat pattern="###\,###.##"/>
+  </BusinessClient>
+</Configuration>
\ No newline at end of file
Index: src/main/java/org/apache/commons/configuration2/PatternSubtreeConfigurationWrapper.java
===================================================================
--- src/main/java/org/apache/commons/configuration2/PatternSubtreeConfigurationWrapper.java	(revision 0)
+++ src/main/java/org/apache/commons/configuration2/PatternSubtreeConfigurationWrapper.java	(revision 0)
@@ -0,0 +1,413 @@
+package org.apache.commons.configuration2;
+
+import org.apache.commons.configuration2.tree.ConfigurationNode;
+import org.apache.commons.configuration2.expr.ExpressionEngine;
+import org.apache.commons.configuration2.event.ConfigurationListener;
+import org.apache.commons.configuration2.event.ConfigurationErrorListener;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Collection;
+import java.io.Writer;
+import java.io.Reader;
+
+
+
+/**
+ * Wraps a HierarchicalConfiguration and allows subtrees to be access via a configured path with
+ * replaceable tokens derived from the MDC.
+ */
+public class PatternSubtreeConfigurationWrapper extends AbstractHierarchicalFileConfiguration
+{
+    private final AbstractHierarchicalFileConfiguration config;
+    private final String path;
+    private final boolean trailing;
+    private boolean init = false;
+
+    /**
+     * Constructor
+     * @param config The Configuration to be wrapped.
+     * @param path The base path pattern.
+     */
+    public PatternSubtreeConfigurationWrapper(AbstractHierarchicalFileConfiguration config, String path)
+    {
+        this.config = config;
+        this.path = path;
+        this.trailing = path.endsWith("/");
+        this.init = true;
+    }
+
+    public void addProperty(String key, Object value)
+    {
+        config.addProperty(makePath(key), value);
+    }
+
+    public void clear()
+    {
+        getConfig().clear();
+    }
+
+    public void clearProperty(String key)
+    {
+        config.clearProperty(makePath(key));
+    }
+
+    public boolean containsKey(String key)
+    {
+        return config.containsKey(makePath(key));
+    }
+
+    public BigDecimal getBigDecimal(String key, BigDecimal defaultValue)
+    {
+        return config.getBigDecimal(makePath(key), defaultValue);
+    }
+
+    public BigDecimal getBigDecimal(String key)
+    {
+        return config.getBigDecimal(makePath(key));
+    }
+
+    public BigInteger getBigInteger(String key, BigInteger defaultValue)
+    {
+        return config.getBigInteger(makePath(key), defaultValue);
+    }
+
+    public BigInteger getBigInteger(String key)
+    {
+        return config.getBigInteger(makePath(key));
+    }
+
+    public boolean getBoolean(String key, boolean defaultValue)
+    {
+        return config.getBoolean(makePath(key), defaultValue);
+    }
+
+    public Boolean getBoolean(String key, Boolean defaultValue)
+    {
+        return config.getBoolean(makePath(key), defaultValue);
+    }
+
+    public boolean getBoolean(String key)
+    {
+        return config.getBoolean(makePath(key));
+    }
+
+    public byte getByte(String key, byte defaultValue)
+    {
+        return config.getByte(makePath(key), defaultValue);
+    }
+
+    public Byte getByte(String key, Byte defaultValue)
+    {
+        return config.getByte(makePath(key), defaultValue);
+    }
+
+    public byte getByte(String key)
+    {
+        return config.getByte(makePath(key));
+    }
+
+    public double getDouble(String key, double defaultValue)
+    {
+        return config.getDouble(makePath(key), defaultValue);
+    }
+
+    public Double getDouble(String key, Double defaultValue)
+    {
+        return config.getDouble(makePath(key), defaultValue);
+    }
+
+    public double getDouble(String key)
+    {
+        return config.getDouble(makePath(key));
+    }
+
+    public float getFloat(String key, float defaultValue)
+    {
+        return config.getFloat(makePath(key), defaultValue);
+    }
+
+    public Float getFloat(String key, Float defaultValue)
+    {
+        return config.getFloat(makePath(key), defaultValue);
+    }
+
+    public float getFloat(String key)
+    {
+        return config.getFloat(makePath(key));
+    }
+
+    public int getInt(String key, int defaultValue)
+    {
+        return config.getInt(makePath(key), defaultValue);
+    }
+
+    public int getInt(String key)
+    {
+        return config.getInt(makePath(key));
+    }
+
+    public Integer getInteger(String key, Integer defaultValue)
+    {
+        return config.getInteger(makePath(key), defaultValue);
+    }
+    @Override
+    public Iterator<String> getKeys()
+    {
+        return config.getKeys(makePath());
+    }
+
+    @Override
+    public Iterator<String> getKeys(String prefix)
+    {
+        return config.getKeys(makePath(prefix));
+    }
+
+    @Override
+    public <T> List<T> getList(String key, List<T> defaultValue)
+    {
+        return config.getList(makePath(key), defaultValue);
+    }
+
+    @Override
+    public <T> List<T> getList(String key)
+    {
+        return config.getList(makePath(key));
+    }
+
+    public long getLong(String key, long defaultValue)
+    {
+        return config.getLong(makePath(key), defaultValue);
+    }
+
+    public Long getLong(String key, Long defaultValue)
+    {
+        return config.getLong(makePath(key), defaultValue);
+    }
+
+    public long getLong(String key)
+    {
+        return config.getLong(makePath(key));
+    }
+
+    public Properties getProperties(String key)
+    {
+        return config.getProperties(makePath(key));
+    }
+
+    public Object getProperty(String key)
+    {
+        return config.getProperty(makePath(key));
+    }
+
+    public short getShort(String key, short defaultValue)
+    {
+        return config.getShort(makePath(key), defaultValue);
+    }
+
+    public Short getShort(String key, Short defaultValue)
+    {
+        return config.getShort(makePath(key), defaultValue);
+    }
+
+    public short getShort(String key)
+    {
+        return config.getShort(makePath(key));
+    }
+
+    public String getString(String key, String defaultValue)
+    {
+        return config.getString(makePath(key), defaultValue);
+    }
+
+    public String getString(String key)
+    {
+        return config.getString(makePath(key));
+    }
+
+    public String[] getStringArray(String key)
+    {
+        return config.getStringArray(makePath(key));
+    }
+
+    public boolean isEmpty()
+    {
+        return getConfig().isEmpty();
+    }
+
+    public void setProperty(String key, Object value)
+    {
+        getConfig().setProperty(key, value);
+    }
+
+    public Configuration subset(String prefix)
+    {
+        return getConfig().subset(prefix);
+    }
+
+    @Override
+    public ConfigurationNode getRootNode()
+    {
+        return getConfig().getRootNode();
+    }
+
+    @Override
+    public void setRootNode(ConfigurationNode rootNode)
+    {
+        if (!init)
+        {
+            super.setRootNode(rootNode);
+        }
+    }
+
+    @Override
+    public ExpressionEngine getExpressionEngine()
+    {
+        return config.getExpressionEngine();
+    }
+
+    @Override
+    public void setExpressionEngine(ExpressionEngine expressionEngine)
+    {
+        if (init)
+        {
+            config.setExpressionEngine(expressionEngine);
+        }
+        else
+        {
+            super.setExpressionEngine(expressionEngine);
+        }
+    }
+
+    @Override
+    public void addNodes(String key, Collection<? extends ConfigurationNode> nodes)
+    {
+        config.addNodes(makePath(key), nodes);
+    }
+
+    @Override
+    public SubConfiguration<ConfigurationNode> configurationAt(String key, boolean supportUpdates)
+    {
+        return config.configurationAt(makePath(key), supportUpdates);
+    }
+
+    @Override
+    public SubConfiguration<ConfigurationNode> configurationAt(String key)
+    {
+        return config.configurationAt(makePath(key));
+    }
+
+    @Override
+    public List<SubConfiguration<ConfigurationNode>> configurationsAt(String key)
+    {
+        return config.configurationsAt(makePath(key));
+    }
+
+    @Override
+    public void clearTree(String key)
+    {
+        config.clearTree(makePath(key));
+    }
+
+    @Override
+    public int getMaxIndex(String key)
+    {
+        return config.getMaxIndex(makePath(key));
+    }
+
+    @Override
+    public Configuration interpolatedConfiguration()
+    {
+        return getConfig().interpolatedConfiguration();
+    }
+
+    @Override
+    public void addConfigurationListener(ConfigurationListener l)
+    {
+        getConfig().addConfigurationListener(l);
+    }
+
+    @Override
+    public boolean removeConfigurationListener(ConfigurationListener l)
+    {
+        return getConfig().removeConfigurationListener(l);
+    }
+
+    @Override
+    public Collection getConfigurationListeners()
+    {
+        return getConfig().getConfigurationListeners();
+    }
+
+    @Override
+    public void clearConfigurationListeners()
+    {
+        getConfig().clearConfigurationListeners();
+    }
+
+    @Override
+    public void addErrorListener(ConfigurationErrorListener l)
+    {
+        getConfig().addErrorListener(l);
+    }
+
+    @Override
+    public boolean removeErrorListener(ConfigurationErrorListener l)
+    {
+        return getConfig().removeErrorListener(l);
+    }
+
+    @Override
+    public void clearErrorListeners()
+    {
+        getConfig().clearErrorListeners();
+    }
+
+    public void save(Writer writer) throws ConfigurationException
+    {
+        config.save(writer);
+    }
+
+    public void load(Reader reader) throws ConfigurationException
+    {
+        config.load(reader);
+    }
+
+    @Override
+    public Collection getErrorListeners()
+    {
+        return getConfig().getErrorListeners();
+    }
+
+    private SubConfiguration<ConfigurationNode> getConfig()
+    {
+        return config.configurationAt(makePath());
+    }
+
+    private String makePath()
+    {
+        String pathPattern = (trailing) ? path.substring(0, path.length() - 1) : path;
+        return getSubstitutor().replace(pathPattern);
+    }
+
+    private String makePath(String item)
+    {
+        String pathPattern;
+        if ((item.length() == 0 || item.startsWith("/")) && trailing)
+        {
+            pathPattern = path.substring(0, path.length() - 1);
+        }
+        else  if (!item.startsWith("/") || !trailing)
+        {
+            pathPattern = path + "/";
+        }
+        else
+        {
+            pathPattern = path;
+        }
+        return getSubstitutor().replace(pathPattern) + item;
+    }
+}
\ No newline at end of file
Index: src/main/java/org/apache/commons/configuration2/combined/DynamicCombinedConfiguration.java
===================================================================
--- src/main/java/org/apache/commons/configuration2/combined/DynamicCombinedConfiguration.java	(revision 0)
+++ src/main/java/org/apache/commons/configuration2/combined/DynamicCombinedConfiguration.java	(revision 0)
@@ -0,0 +1,815 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.configuration2.combined;
+
+
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.List;
+import java.util.Iterator;
+import java.util.Collection;
+import java.util.Set;
+import java.util.Properties;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import org.apache.commons.configuration2.event.ConfigurationListener;
+import org.apache.commons.configuration2.event.ConfigurationErrorListener;
+import org.apache.commons.configuration2.expr.ExpressionEngine;
+import org.apache.commons.configuration2.AbstractConfiguration;
+import org.apache.commons.configuration2.AbstractHierarchicalConfiguration;
+import org.apache.commons.configuration2.Configuration;
+import org.apache.commons.configuration2.SubConfiguration;
+
+/**
+ *
+ */
+public class DynamicCombinedConfiguration extends CombinedConfiguration
+{
+    private ConcurrentMap<String, CombinedConfiguration> configs =
+            new ConcurrentHashMap<String, CombinedConfiguration>();
+
+    /** Stores a list with the contained configurations. */
+    private List<ConfigData> configurations = new CopyOnWriteArrayList<ConfigData>();
+
+    /** Stores a map with the named configurations. */
+    private ConcurrentMap<String, AbstractConfiguration> namedConfigurations =
+            new ConcurrentHashMap<String, AbstractConfiguration>();
+
+    private String keyPattern;
+
+    /** Stores the combiner. */
+    private NodeCombiner nodeCombiner;
+
+    /**
+     * Creates a new instance of <code>CombinedConfiguration</code> and
+     * initializes the combiner to be used.
+     *
+     * @param comb the node combiner (can be <b>null</b>, then a union combiner
+     * is used as default)
+     */
+    public DynamicCombinedConfiguration(NodeCombiner comb)
+    {
+        super();
+        setNodeCombiner(comb);
+    }
+
+    /**
+     * Creates a new instance of <code>CombinedConfiguration</code> that uses
+     * a union combiner.
+     *
+     */
+    public DynamicCombinedConfiguration()
+    {
+        super();
+    }
+
+    public void setKeyPattern(String pattern)
+    {
+        this.keyPattern = pattern;
+    }
+
+    public String getKeyPattern()
+    {
+        return this.keyPattern;
+    }
+
+    /**
+     * Returns the node combiner that is used for creating the combined node
+     * structure.
+     *
+     * @return the node combiner
+     */
+    @Override
+    public NodeCombiner getNodeCombiner()
+    {
+        return nodeCombiner;
+    }
+
+    /**
+     * Sets the node combiner. This object will be used when the combined node
+     * structure is to be constructed. It must not be <b>null</b>, otherwise an
+     * <code>IllegalArgumentException</code> exception is thrown. Changing the
+     * node combiner causes an invalidation of this combined configuration, so
+     * that the new combiner immediately takes effect.
+     *
+     * @param nodeCombiner the node combiner
+     */
+    @Override
+    public void setNodeCombiner(NodeCombiner nodeCombiner)
+    {
+        if (nodeCombiner == null)
+        {
+            throw new IllegalArgumentException(
+                    "Node combiner must not be null!");
+        }
+        this.nodeCombiner = nodeCombiner;
+        invalidateAll();
+    }
+    /**
+     * Adds a new configuration to this combined configuration. It is possible
+     * (but not mandatory) to give the new configuration a name. This name must
+     * be unique, otherwise a <code>ConfigurationRuntimeException</code> will
+     * be thrown. With the optional <code>at</code> argument you can specify
+     * where in the resulting node structure the content of the added
+     * configuration should appear. This is a string that uses dots as property
+     * delimiters (independent on the current expression engine). For instance
+     * if you pass in the string <code>&quot;database.tables&quot;</code>,
+     * all properties of the added configuration will occur in this branch.
+     *
+     * @param config the configuration to add (must not be <b>null</b>)
+     * @param name the name of this configuration (can be <b>null</b>)
+     * @param at the position of this configuration in the combined tree (can be
+     * <b>null</b>)
+     */
+    @Override
+    public void addConfiguration(AbstractHierarchicalConfiguration<?> config, String name,
+            String at)
+    {
+        ConfigData cd = new ConfigData(config, name, at);
+        configurations.add(cd);
+        if (name != null)
+        {
+            namedConfigurations.put(name, config);
+        }
+    }
+       /**
+     * Returns the number of configurations that are contained in this combined
+     * configuration.
+     *
+     * @return the number of contained configurations
+     */
+    @Override
+    public int getNumberOfConfigurations()
+    {
+        return configurations.size();
+    }
+
+    /**
+     * Returns the configuration at the specified index. The contained
+     * configurations are numbered in the order they were added to this combined
+     * configuration. The index of the first configuration is 0.
+     *
+     * @param index the index
+     * @return the configuration at this index
+     */
+    @Override
+    public Configuration getConfiguration(int index)
+    {
+        ConfigData cd = configurations.get(index);
+        return cd.getConfiguration();
+    }
+
+    /**
+     * Returns the configuration with the given name. This can be <b>null</b>
+     * if no such configuration exists.
+     *
+     * @param name the name of the configuration
+     * @return the configuration with this name
+     */
+    @Override
+    public Configuration getConfiguration(String name)
+    {
+        return namedConfigurations.get(name);
+    }
+
+    /**
+     * Returns a set with the names of all configurations contained in this
+     * combined configuration. Of course here are only these configurations
+     * listed, for which a name was specified when they were added.
+     *
+     * @return a set with the names of the contained configurations (never
+     * <b>null</b>)
+     */
+    @Override
+    public Set<String> getConfigurationNames()
+    {
+        return namedConfigurations.keySet();
+    }
+
+    /**
+     * Removes the configuration with the specified name.
+     *
+     * @param name the name of the configuration to be removed
+     * @return the removed configuration (<b>null</b> if this configuration
+     * was not found)
+     */
+    @Override
+    public Configuration removeConfiguration(String name)
+    {
+        Configuration conf = getConfiguration(name);
+        if (conf != null)
+        {
+            removeConfiguration(conf);
+        }
+        return conf;
+    }
+
+    /**
+     * Removes the specified configuration from this combined configuration.
+     *
+     * @param config the configuration to be removed
+     * @return a flag whether this configuration was found and could be removed
+     */
+    @Override
+    public boolean removeConfiguration(Configuration config)
+    {
+        for (int index = 0; index < getNumberOfConfigurations(); index++)
+        {
+            if (((configurations.get(index)).getConfiguration() == config))
+            {
+                removeConfigurationAt(index);
+
+            }
+        }
+
+        return super.removeConfiguration(config);
+    }
+
+    /**
+     * Removes the configuration at the specified index.
+     *
+     * @param index the index
+     * @return the removed configuration
+     */
+    @Override
+    public Configuration removeConfigurationAt(int index)
+    {
+        ConfigData cd = configurations.remove(index);
+        if (cd.getName() != null)
+        {
+            namedConfigurations.remove(cd.getName());
+        }
+        return super.removeConfigurationAt(index);
+    }
+    /**
+     * Returns the configuration root node of this combined configuration. This
+     * method will construct a combined node structure using the current node
+     * combiner if necessary.
+     *
+     * @return the combined root node
+     */
+    @Override
+    public Object getRootNode()
+    {
+        return getCurrentConfig().getRootNode();
+    }
+
+    @Override
+    public void addProperty(String key, Object value)
+    {
+        this.getCurrentConfig().addProperty(key, value);
+    }
+
+    @Override
+    public void clear()
+    {
+        if (configs != null)
+        {
+            this.getCurrentConfig().clear();
+        }
+    }
+
+    @Override
+    public void clearProperty(String key)
+    {
+        this.getCurrentConfig().clearProperty(key);
+    }
+
+    @Override
+    public boolean containsKey(String key)
+    {
+        return this.getCurrentConfig().containsKey(key);
+    }
+
+    @Override
+    public BigDecimal getBigDecimal(String key, BigDecimal defaultValue)
+    {
+        return this.getCurrentConfig().getBigDecimal(key, defaultValue);
+    }
+
+    @Override
+    public BigDecimal getBigDecimal(String key)
+    {
+        return this.getCurrentConfig().getBigDecimal(key);
+    }
+
+    @Override
+    public BigInteger getBigInteger(String key, BigInteger defaultValue)
+    {
+        return this.getCurrentConfig().getBigInteger(key, defaultValue);
+    }
+
+    @Override
+    public BigInteger getBigInteger(String key)
+    {
+        return this.getCurrentConfig().getBigInteger(key);
+    }
+
+    @Override
+    public boolean getBoolean(String key, boolean defaultValue)
+    {
+        return this.getCurrentConfig().getBoolean(key, defaultValue);
+    }
+
+    @Override
+    public Boolean getBoolean(String key, Boolean defaultValue)
+    {
+        return this.getCurrentConfig().getBoolean(key, defaultValue);
+    }
+
+    @Override
+    public boolean getBoolean(String key)
+    {
+        return this.getCurrentConfig().getBoolean(key);
+    }
+
+    @Override
+    public byte getByte(String key, byte defaultValue)
+    {
+        return this.getCurrentConfig().getByte(key, defaultValue);
+    }
+
+    @Override
+    public Byte getByte(String key, Byte defaultValue)
+    {
+        return this.getCurrentConfig().getByte(key, defaultValue);
+    }
+
+    @Override
+    public byte getByte(String key)
+    {
+        return this.getCurrentConfig().getByte(key);
+    }
+
+    @Override
+    public double getDouble(String key, double defaultValue)
+    {
+        return this.getCurrentConfig().getDouble(key, defaultValue);
+    }
+
+    @Override
+    public Double getDouble(String key, Double defaultValue)
+    {
+        return this.getCurrentConfig().getDouble(key, defaultValue);
+    }
+
+    @Override
+    public double getDouble(String key)
+    {
+        return this.getCurrentConfig().getDouble(key);
+    }
+
+    @Override
+    public float getFloat(String key, float defaultValue)
+    {
+        return this.getCurrentConfig().getFloat(key, defaultValue);
+    }
+
+    @Override
+    public Float getFloat(String key, Float defaultValue)
+    {
+        return this.getCurrentConfig().getFloat(key, defaultValue);
+    }
+
+    @Override
+    public float getFloat(String key)
+    {
+        return this.getCurrentConfig().getFloat(key);
+    }
+
+    @Override
+    public int getInt(String key, int defaultValue)
+    {
+        return this.getCurrentConfig().getInt(key, defaultValue);
+    }
+
+    @Override
+    public int getInt(String key)
+    {
+        return this.getCurrentConfig().getInt(key);
+    }
+
+    @Override
+    public Integer getInteger(String key, Integer defaultValue)
+    {
+        return this.getCurrentConfig().getInteger(key, defaultValue);
+    }
+
+    @Override
+    public Iterator<String> getKeys()
+    {
+        return this.getCurrentConfig().getKeys();
+    }
+
+    @Override
+    public Iterator<String> getKeys(String prefix)
+    {
+        return this.getCurrentConfig().getKeys(prefix);
+    }
+
+    @Override
+    public <T> List<T> getList(String key, List<T> defaultValue)
+    {
+        return this.getCurrentConfig().getList(key, defaultValue);
+    }
+
+    @Override
+    public <T> List<T> getList(String key)
+    {
+        return this.getCurrentConfig().getList(key);
+    }
+
+    @Override
+    public long getLong(String key, long defaultValue)
+    {
+        return this.getCurrentConfig().getLong(key, defaultValue);
+    }
+
+    @Override
+    public Long getLong(String key, Long defaultValue)
+    {
+        return this.getCurrentConfig().getLong(key, defaultValue);
+    }
+
+    @Override
+    public long getLong(String key)
+    {
+        return this.getCurrentConfig().getLong(key);
+    }
+
+    @Override
+    public Properties getProperties(String key)
+    {
+        return this.getCurrentConfig().getProperties(key);
+    }
+
+    @Override
+    public Object getProperty(String key)
+    {
+        return this.getCurrentConfig().getProperty(key);
+    }
+
+    @Override
+    public short getShort(String key, short defaultValue)
+    {
+        return this.getCurrentConfig().getShort(key, defaultValue);
+    }
+
+    @Override
+    public Short getShort(String key, Short defaultValue)
+    {
+        return this.getCurrentConfig().getShort(key, defaultValue);
+    }
+
+    @Override
+    public short getShort(String key)
+    {
+        return this.getCurrentConfig().getShort(key);
+    }
+
+    @Override
+    public String getString(String key, String defaultValue)
+    {
+        return this.getCurrentConfig().getString(key, defaultValue);
+    }
+
+    @Override
+    public String getString(String key)
+    {
+        return this.getCurrentConfig().getString(key);
+    }
+
+    @Override
+    public String[] getStringArray(String key)
+    {
+        return this.getCurrentConfig().getStringArray(key);
+    }
+
+    @Override
+    public boolean isEmpty()
+    {
+        return this.getCurrentConfig().isEmpty();
+    }
+
+    @Override
+    public void setProperty(String key, Object value)
+    {
+        if (configs != null)
+        {
+            this.getCurrentConfig().setProperty(key, value);
+        }
+    }
+
+    @Override
+    public Configuration subset(String prefix)
+    {
+        return this.getCurrentConfig().subset(prefix);
+    }
+
+    @Override
+    public ExpressionEngine getExpressionEngine()
+    {
+        return super.getExpressionEngine();
+    }
+
+    @Override
+    public void setExpressionEngine(ExpressionEngine expressionEngine)
+    {
+        super.setExpressionEngine(expressionEngine);
+    }
+
+    @Override
+    public SubConfiguration<Object> configurationAt(String key, boolean supportUpdates)
+    {
+        return this.getCurrentConfig().configurationAt(key, supportUpdates);
+    }
+
+    @Override
+    public SubConfiguration<Object> configurationAt(String key)
+    {
+        return this.getCurrentConfig().configurationAt(key);
+    }
+
+    @Override
+    public List<SubConfiguration<Object>> configurationsAt(String key)
+    {
+        return this.getCurrentConfig().configurationsAt(key);
+    }
+
+    @Override
+    public void clearTree(String key)
+    {
+        this.getCurrentConfig().clearTree(key);
+    }
+
+    @Override
+    public int getMaxIndex(String key)
+    {
+        return this.getCurrentConfig().getMaxIndex(key);
+    }
+
+    @Override
+    public Configuration interpolatedConfiguration()
+    {
+        return this.getCurrentConfig().interpolatedConfiguration();
+    }
+
+
+    /**
+     * Returns the configuration source, in which the specified key is defined.
+     * This method will determine the configuration node that is identified by
+     * the given key. The following constellations are possible:
+     * <ul>
+     * <li>If no node object is found for this key, <b>null</b> is returned.</li>
+     * <li>If the key maps to multiple nodes belonging to different
+     * configuration sources, a <code>IllegalArgumentException</code> is
+     * thrown (in this case no unique source can be determined).</li>
+     * <li>If exactly one node is found for the key, the (child) configuration
+     * object, to which the node belongs is determined and returned.</li>
+     * <li>For keys that have been added directly to this combined
+     * configuration and that do not belong to the namespaces defined by
+     * existing child configurations this configuration will be returned.</li>
+     * </ul>
+     *
+     * @param key the key of a configuration property
+     * @return the configuration, to which this property belongs or <b>null</b>
+     * if the key cannot be resolved
+     * @throws IllegalArgumentException if the key maps to multiple properties
+     * and the source cannot be determined, or if the key is <b>null</b>
+     */
+    @Override
+    public Configuration getSource(String key)
+    {
+        if (key == null)
+        {
+            throw new IllegalArgumentException("Key must not be null!");
+        }
+        return getCurrentConfig().getSource(key);
+    }
+
+    @Override
+    public void addConfigurationListener(ConfigurationListener l)
+    {
+        super.addConfigurationListener(l);
+
+        for (CombinedConfiguration config : configs.values())
+        {
+            config.addConfigurationListener(l);
+        }
+    }
+
+    @Override
+    public boolean removeConfigurationListener(ConfigurationListener l)
+    {
+        for (CombinedConfiguration config : configs.values())
+        {
+            config.removeConfigurationListener(l);
+        }
+        return super.removeConfigurationListener(l);
+    }
+
+    @Override
+    public Collection getConfigurationListeners()
+    {
+        return super.getConfigurationListeners();
+    }
+
+    @Override
+    public void clearConfigurationListeners()
+    {
+        for (CombinedConfiguration config : configs.values())
+        {
+            config.clearConfigurationListeners();
+        }
+        super.clearConfigurationListeners();
+    }
+
+    @Override
+    public void addErrorListener(ConfigurationErrorListener l)
+    {
+        for (CombinedConfiguration config : configs.values())
+        {
+            config.addErrorListener(l);
+        }
+        super.addErrorListener(l);
+    }
+
+    @Override
+    public boolean removeErrorListener(ConfigurationErrorListener l)
+    {
+        for (CombinedConfiguration config : configs.values())
+        {
+            config.removeErrorListener(l);
+        }
+        return super.removeErrorListener(l);
+    }
+
+    @Override
+    public void clearErrorListeners()
+    {
+        for (CombinedConfiguration config : configs.values())
+        {
+            config.clearErrorListeners();
+        }
+        super.clearErrorListeners();
+    }
+
+    @Override
+    public Collection getErrorListeners()
+    {
+        return super.getErrorListeners();
+    }
+
+
+
+    /**
+     * Returns a copy of this object. This implementation performs a deep clone,
+     * i.e. all contained configurations will be cloned, too. For this to work,
+     * all contained configurations must be cloneable. Registered event
+     * listeners won't be cloned. The clone will use the same node combiner than
+     * the original.
+     *
+     * @return the copied object
+     */
+    @Override
+    public Object clone()
+    {
+        return super.clone();
+    }
+
+
+
+    /**
+     * Invalidates the current combined configuration. This means that the next time a
+     * property is accessed the combined node structure must be re-constructed.
+     * Invalidation of a combined configuration also means that an event of type
+     * <code>EVENT_COMBINED_INVALIDATE</code> is fired. Note that while other
+     * events most times appear twice (once before and once after an update),
+     * this event is only fired once (after update).
+     */
+    @Override
+    public void invalidate()
+    {
+        getCurrentConfig().invalidate();
+    }
+
+    public void invalidateAll()
+    {
+        if (configs == null)
+        {
+            return;
+        }
+        for (CombinedConfiguration config : configs.values())
+        {
+           config.invalidate();
+        }
+    }
+
+    private CombinedConfiguration getCurrentConfig()
+    {
+        String key = getSubstitutor().replace(keyPattern);
+        CombinedConfiguration config;
+        synchronized(getNodeCombiner())
+        {
+            config = configs.get(key);
+            if (config == null)
+            {
+                config = new CombinedConfiguration(getNodeCombiner());
+                config.setExpressionEngine(this.getExpressionEngine());
+                for (ConfigurationErrorListener listener :
+                        (Collection<ConfigurationErrorListener>)config.getErrorListeners())
+                {
+                    config.addErrorListener(listener);
+                }
+                for (ConfigurationListener listener :
+                        (Collection<ConfigurationListener>)config.getConfigurationListeners())
+                {
+                    config.addConfigurationListener(listener);
+                }
+                config.setForceReloadCheck(isForceReloadCheck());
+                for (ConfigData data : configurations)
+                {
+                    config.addConfiguration(data.getConfiguration(), data.getName(),
+                            data.getAt());
+                }
+                configs.put(key, config);
+            }
+        }
+        return config;
+    }
+
+
+    class ConfigData
+    {
+                /** Stores a reference to the configuration. */
+        private AbstractHierarchicalConfiguration configuration;
+
+        /** Stores the name under which the configuration is stored. */
+        private String name;
+
+        /** Stores the at string.*/
+        private String at;
+
+                /**
+         * Creates a new instance of <code>ConfigData</code> and initializes
+         * it.
+         *
+         * @param config the configuration
+         * @param n the name
+         * @param at the at position
+         */
+        public ConfigData(AbstractHierarchicalConfiguration config, String n, String at)
+        {
+            configuration = config;
+            name = n;
+            this.at = at;
+        }
+
+                /**
+         * Returns the stored configuration.
+         *
+         * @return the configuration
+         */
+        public AbstractHierarchicalConfiguration getConfiguration()
+        {
+            return configuration;
+        }
+
+        /**
+         * Returns the configuration's name.
+         *
+         * @return the name
+         */
+        public String getName()
+        {
+            return name;
+        }
+
+        /**
+         * Returns the at position of this configuration.
+         *
+         * @return the at position
+         */
+        public String getAt()
+        {
+            return at;
+        }
+
+    }
+}
Index: src/main/java/org/apache/commons/configuration2/MultiFileHierarchicalConfiguration.java
===================================================================
--- src/main/java/org/apache/commons/configuration2/MultiFileHierarchicalConfiguration.java	(revision 0)
+++ src/main/java/org/apache/commons/configuration2/MultiFileHierarchicalConfiguration.java	(revision 0)
@@ -0,0 +1,605 @@
+/**
+ *
+ */
+package org.apache.commons.configuration2;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Collection;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.io.FileNotFoundException;
+import java.io.Writer;
+import java.io.Reader;
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.commons.configuration2.event.ConfigurationListener;
+import org.apache.commons.configuration2.event.ConfigurationErrorListener;
+import org.apache.commons.configuration2.event.ConfigurationErrorEvent;
+import org.apache.commons.configuration2.event.ConfigurationEvent;
+import org.apache.commons.configuration2.expr.ExpressionEngine;
+import org.apache.commons.configuration2.tree.ConfigurationNode;
+
+/**
+ *
+ */
+public class MultiFileHierarchicalConfiguration extends AbstractHierarchicalFileConfiguration
+    implements ConfigurationListener, ConfigurationErrorListener
+{
+    private ConcurrentMap<String, XMLConfiguration> configurationsMap = new ConcurrentHashMap<String, XMLConfiguration>();
+    private String pattern;
+    private boolean init = false;
+    private static final String FILE_URL_PREFIX = "file:";
+
+    /**
+     * Default Constructor
+     */
+    public MultiFileHierarchicalConfiguration()
+    {
+        super();
+        this.init = true;
+    }
+
+    /**
+     * Constructor
+     * @param pathPattern The pattern to use to location configuration files.
+     */
+    public MultiFileHierarchicalConfiguration(String pathPattern)
+    {
+        super();
+        this.pattern = pathPattern;
+        this.init = true;
+    }
+
+    /**
+     * Set the File pattern
+     * @param pathPattern The pattern for the path to the configuration.
+     */
+    public void setFilePattern(String pathPattern)
+    {
+        this.pattern = pathPattern;
+    }
+
+
+    public void addProperty(String key, Object value)
+    {
+        this.getConfiguration().addProperty(key, value);
+    }
+
+    public void clear()
+    {
+        this.getConfiguration().clear();
+    }
+
+    public void clearProperty(String key)
+    {
+        this.getConfiguration().clearProperty(key);
+    }
+
+    public boolean containsKey(String key)
+    {
+        return this.getConfiguration().containsKey(key);
+    }
+
+    public BigDecimal getBigDecimal(String key, BigDecimal defaultValue)
+    {
+        return this.getConfiguration().getBigDecimal(key, defaultValue);
+    }
+
+    public BigDecimal getBigDecimal(String key)
+    {
+        return this.getConfiguration().getBigDecimal(key);
+    }
+
+    public BigInteger getBigInteger(String key, BigInteger defaultValue)
+    {
+        return this.getConfiguration().getBigInteger(key, defaultValue);
+    }
+
+    public BigInteger getBigInteger(String key)
+    {
+        return this.getConfiguration().getBigInteger(key);
+    }
+
+    public boolean getBoolean(String key, boolean defaultValue)
+    {
+        return this.getConfiguration().getBoolean(key, defaultValue);
+    }
+
+    public Boolean getBoolean(String key, Boolean defaultValue)
+    {
+        return this.getConfiguration().getBoolean(key, defaultValue);
+    }
+
+    public boolean getBoolean(String key)
+    {
+        return this.getConfiguration().getBoolean(key);
+    }
+
+    public byte getByte(String key, byte defaultValue)
+    {
+        return this.getConfiguration().getByte(key, defaultValue);
+    }
+
+    public Byte getByte(String key, Byte defaultValue)
+    {
+        return this.getConfiguration().getByte(key, defaultValue);
+    }
+
+    public byte getByte(String key)
+    {
+        return this.getConfiguration().getByte(key);
+    }
+
+    public double getDouble(String key, double defaultValue)
+    {
+        return this.getConfiguration().getDouble(key, defaultValue);
+    }
+
+    public Double getDouble(String key, Double defaultValue)
+    {
+        return this.getConfiguration().getDouble(key, defaultValue);
+    }
+
+    public double getDouble(String key)
+    {
+        return this.getConfiguration().getDouble(key);
+    }
+
+    public float getFloat(String key, float defaultValue)
+    {
+        return this.getConfiguration().getFloat(key, defaultValue);
+    }
+
+    public Float getFloat(String key, Float defaultValue)
+    {
+        return this.getConfiguration().getFloat(key, defaultValue);
+    }
+
+    public float getFloat(String key)
+    {
+        return this.getConfiguration().getFloat(key);
+    }
+
+    public int getInt(String key, int defaultValue)
+    {
+        return this.getConfiguration().getInt(key, defaultValue);
+    }
+
+    public int getInt(String key)
+    {
+        return this.getConfiguration().getInt(key);
+    }
+
+    public Integer getInteger(String key, Integer defaultValue)
+    {
+        return this.getConfiguration().getInteger(key, defaultValue);
+    }
+
+    @Override
+    public Iterator<String> getKeys()
+    {
+        return this.getConfiguration().getKeys();
+    }
+
+    @Override
+    public Iterator<String> getKeys(String prefix)
+    {
+        return this.getConfiguration().getKeys(prefix);
+    }
+
+    @Override
+    public <T> List<T> getList(String key, List<T> defaultValue)
+    {
+        return this.getConfiguration().getList(key, defaultValue);
+    }
+
+    @Override
+    public <T> List<T> getList(String key)
+    {
+        return this.getConfiguration().getList(key);
+    }
+
+    @Override
+    public long getLong(String key, long defaultValue)
+    {
+        return this.getConfiguration().getLong(key, defaultValue);
+    }
+
+    @Override
+    public Long getLong(String key, Long defaultValue)
+    {
+        return this.getConfiguration().getLong(key, defaultValue);
+    }
+
+    @Override
+    public long getLong(String key)
+    {
+        return this.getConfiguration().getLong(key);
+    }
+
+    @Override
+    public Properties getProperties(String key)
+    {
+        return this.getConfiguration().getProperties(key);
+    }
+
+    @Override
+    public Object getProperty(String key)
+    {
+        return this.getConfiguration().getProperty(key);
+    }
+
+    @Override
+    public short getShort(String key, short defaultValue)
+    {
+        return this.getConfiguration().getShort(key, defaultValue);
+    }
+
+    @Override
+    public Short getShort(String key, Short defaultValue)
+    {
+        return this.getConfiguration().getShort(key, defaultValue);
+    }
+
+    @Override
+    public short getShort(String key)
+    {
+        return this.getConfiguration().getShort(key);
+    }
+
+    @Override
+    public String getString(String key, String defaultValue)
+    {
+        return this.getConfiguration().getString(key, defaultValue);
+    }
+
+    @Override
+    public String getString(String key)
+    {
+        return this.getConfiguration().getString(key);
+    }
+
+    @Override
+    public String[] getStringArray(String key)
+    {
+        return this.getConfiguration().getStringArray(key);
+    }
+
+    @Override
+    public boolean isEmpty()
+    {
+        return this.getConfiguration().isEmpty();
+    }
+
+    @Override
+    public void setProperty(String key, Object value)
+    {
+        if (init)
+        {
+            this.getConfiguration().setProperty(key, value);
+        }
+    }
+
+    @Override
+    public Configuration subset(String prefix)
+    {
+        return this.getConfiguration().subset(prefix);
+    }
+
+    @Override
+    public ExpressionEngine getExpressionEngine()
+    {
+        return super.getExpressionEngine();
+    }
+
+    @Override
+    public void setExpressionEngine(ExpressionEngine expressionEngine)
+    {
+        super.setExpressionEngine(expressionEngine);
+    }
+
+    @Override
+    public void addNodes(String key, Collection<? extends ConfigurationNode> nodes)
+    {
+        this.getConfiguration().addNodes(key, nodes);
+    }
+
+    @Override
+    public SubConfiguration<ConfigurationNode> configurationAt(String key, boolean supportUpdates)
+    {
+        return this.getConfiguration().configurationAt(key, supportUpdates);
+    }
+
+    @Override
+    public SubConfiguration<ConfigurationNode> configurationAt(String key)
+    {
+        return this.getConfiguration().configurationAt(key);
+    }
+
+    @Override
+    public List<SubConfiguration<ConfigurationNode>> configurationsAt(String key)
+    {
+        return this.getConfiguration().configurationsAt(key);
+    }
+
+    @Override
+    public void clearTree(String key)
+    {
+        this.getConfiguration().clearTree(key);
+    }
+
+    @Override
+    public int getMaxIndex(String key)
+    {
+        return this.getConfiguration().getMaxIndex(key);
+    }
+
+    @Override
+    public Configuration interpolatedConfiguration()
+    {
+        return this.getConfiguration().interpolatedConfiguration();
+    }
+
+    @Override
+    public void addConfigurationListener(ConfigurationListener l)
+    {
+        super.addConfigurationListener(l);
+    }
+
+    @Override
+    public boolean removeConfigurationListener(ConfigurationListener l)
+    {
+        return super.removeConfigurationListener(l);
+    }
+
+    @Override
+    public Collection getConfigurationListeners()
+    {
+        return super.getConfigurationListeners();
+    }
+
+    @Override
+    public void clearConfigurationListeners()
+    {
+        super.clearConfigurationListeners();
+    }
+
+    @Override
+    public void addErrorListener(ConfigurationErrorListener l)
+    {
+        super.addErrorListener(l);
+    }
+
+    @Override
+    public boolean removeErrorListener(ConfigurationErrorListener l)
+    {
+        return super.removeErrorListener(l);
+    }
+
+    @Override
+    public void clearErrorListeners()
+    {
+        super.clearErrorListeners();
+    }
+
+    @Override
+    public Collection getErrorListeners()
+    {
+        return super.getErrorListeners();
+    }
+
+
+    public void save(Writer writer) throws ConfigurationException
+    {
+        if (init)
+        {
+            this.getConfiguration().save(writer);
+        }
+    }
+
+    public void load(Reader reader) throws ConfigurationException
+    {
+        if (init)
+        {
+            this.getConfiguration().load(reader);
+        }
+    }
+
+    public void load() throws ConfigurationException
+    {
+        this.getConfiguration().load();
+    }
+
+    public void load(String fileName) throws ConfigurationException
+    {
+        this.getConfiguration().load(fileName);
+    }
+
+    public void load(File file) throws ConfigurationException
+    {
+        this.getConfiguration().load(file);
+    }
+
+    public void load(URL url) throws ConfigurationException
+    {
+        this.getConfiguration().load(url);
+    }
+
+    public void load(InputStream in) throws ConfigurationException
+    {
+        this.getConfiguration().load(in);
+    }
+
+    public void load(InputStream in, String encoding) throws ConfigurationException
+    {
+        this.getConfiguration().load(in, encoding);
+    }
+
+    public void save() throws ConfigurationException
+    {
+        this.getConfiguration().save();
+    }
+
+    public void save(String fileName) throws ConfigurationException
+    {
+        this.getConfiguration().save(fileName);
+    }
+
+    public void save(File file) throws ConfigurationException
+    {
+        this.getConfiguration().save(file);
+    }
+
+    public void save(URL url) throws ConfigurationException
+    {
+        this.getConfiguration().save(url);
+    }
+
+    public void save(OutputStream out) throws ConfigurationException
+    {
+        this.getConfiguration().save(out);
+    }
+
+    public void save(OutputStream out, String encoding) throws ConfigurationException
+    {
+        this.getConfiguration().save(out, encoding);
+    }
+
+    @Override
+    public ConfigurationNode getRootNode()
+    {
+        return getConfiguration().getRootNode();
+    }
+
+    @Override
+    public void setRootNode(ConfigurationNode rootNode)
+    {
+        if (init)
+        {
+            getConfiguration().setRootNode(rootNode);
+        }
+        else
+        {
+            super.setRootNode(rootNode);
+        }
+    }
+
+    public void configurationChanged(ConfigurationEvent event)
+    {
+        if (event.getSource() instanceof XMLConfiguration)
+        {
+            Collection<ConfigurationListener> listeners = getConfigurationListeners();
+            for (ConfigurationListener listener : listeners)
+            {
+                listener.configurationChanged(event);
+            }
+        }
+    }
+
+    public void configurationError(ConfigurationErrorEvent event)
+    {
+        if (event.getSource() instanceof XMLConfiguration)
+        {
+            Collection<ConfigurationErrorListener> listeners = getErrorListeners();
+            for (ConfigurationErrorListener listener : listeners)
+            {
+                listener.configurationError(event);
+            }
+        }
+    }
+
+    /**
+     * First checks to see if the cache exists, if it does, get the associated Configuration.
+     * If not it will load a new Configuration and save it in the cache.
+     *
+     * @return the Configuration associated with the current value of the path pattern.
+     */
+    private AbstractHierarchicalFileConfiguration getConfiguration()
+    {
+        if (pattern == null)
+        {
+            throw new ConfigurationRuntimeException("File pattern must be defined");
+        }
+        String path = getSubstitutor().replace(pattern);
+
+        if (configurationsMap.containsKey(path))
+        {
+            return configurationsMap.get(path);
+        }
+
+        if (path.equals(pattern))
+        {
+            XMLConfiguration configuration = new XMLConfiguration()
+            {
+                public void load() throws ConfigurationException
+                {
+                }
+                public void save() throws ConfigurationException
+                {
+                }
+            };
+
+            configurationsMap.putIfAbsent(pattern, configuration);
+
+            return configuration;
+        }
+
+        XMLConfiguration configuration = new XMLConfiguration();
+        try
+        {
+            URL url = getURL(path);
+            configuration.setURL(url);
+            configuration.load();
+            configuration.setExpressionEngine(getExpressionEngine());
+            configuration.setReloadingStrategy(getReloadingStrategy());
+            configuration.addConfigurationListener(this);
+            configuration.addErrorListener(this);
+            configurationsMap.putIfAbsent(path, configuration);
+            configuration = configurationsMap.get(path);
+        }
+        catch (ConfigurationException ce)
+        {
+            throw new ConfigurationRuntimeException(ce);
+        }
+        catch (FileNotFoundException fnfe)
+        {
+            throw new ConfigurationRuntimeException(fnfe);
+        }
+
+        return configuration;
+    }
+
+    private URL getURL(String resourceLocation) throws FileNotFoundException
+    {
+        if (resourceLocation == null)
+        {
+            throw new IllegalArgumentException("A path pattern must be configured");
+        }
+        try
+        {
+            // try URL
+            return new URL(resourceLocation);
+        }
+        catch (MalformedURLException ex)
+        {
+            // no URL -> treat as file path
+            try
+            {
+                return new URL(FILE_URL_PREFIX + resourceLocation);
+            }
+            catch (MalformedURLException ex2)
+            {
+                throw new FileNotFoundException("Resource location [" + resourceLocation +
+                        "] is not a URL or a well-formed file path");
+            }
+        }
+    }
+}
