commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r713166 - in /commons/proper/configuration/trunk: conf/ src/java/org/apache/commons/configuration/ src/test/org/apache/commons/configuration/ xdocs/
Date Tue, 11 Nov 2008 21:02:38 GMT
Author: oheger
Date: Tue Nov 11 13:02:37 2008
New Revision: 713166

URL: http://svn.apache.org/viewvc?rev=713166&view=rev
Log:
CONFIGURATION-349: Changed visibility of DefaultConfigurationBuilder.XMLConfigurationProvider
from package local to public to allow for better extensibility. Thanks to Ralph Goers for
the patch.

Added:
    commons/proper/configuration/trunk/conf/testExtendedXMLConfigurationProvider.xml   (with
props)
Modified:
    commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java
    commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDefaultConfigurationBuilder.java
    commons/proper/configuration/trunk/xdocs/changes.xml

Added: commons/proper/configuration/trunk/conf/testExtendedXMLConfigurationProvider.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/conf/testExtendedXMLConfigurationProvider.xml?rev=713166&view=auto
==============================================================================
--- commons/proper/configuration/trunk/conf/testExtendedXMLConfigurationProvider.xml (added)
+++ commons/proper/configuration/trunk/conf/testExtendedXMLConfigurationProvider.xml Tue Nov
11 13:02:37 2008
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!-- Test configuration definition file that demonstrates complex initialization -->
+<configuration>
+  <header>
+    <result delimiterParsingDisabled="true">
+      <nodeCombiner config-class="org.apache.commons.configuration.tree.OverrideCombiner"/>
+      <expressionEngine config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
+    </result>
+    <providers>
+      <provider config-tag="test"
+                config-class="org.apache.commons.configuration.DefaultConfigurationBuilder$XMLConfigurationProvider"
+                configurationClass="org.apache.commons.configuration.TestDefaultConfigurationBuilder$ExtendedXMLConfiguration"/>
+    </providers>
+    <combiner>
+      <override>
+        <list-nodes>
+          <node>table</node>
+          <node>list</node>
+        </list-nodes>
+      </override>
+    </combiner>
+  </header>
+  <system/>
+  <properties fileName="test.properties" throwExceptionOnMissing="true"
+    config-name="properties">
+    <reloadingStrategy config-class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy"
+      refreshDelay="10000"/>
+  </properties>
+  <!-- Fetch the file name from a variable -->
+  <test fileName="${test_file_xml}" config-name="xml">
+    <expressionEngine config-class="org.apache.commons.configuration.tree.DefaultExpressionEngine"
+      propertyDelimiter="/" indexStart="[" indexEnd="]"/>
+  </test>
+  <additional>
+    <xml config-name="combiner1" fileName="${test_file_combine}"/>  -->
+    <xml config-name="combiner2" fileName="testcombine2.xml"/>
+  </additional>
+</configuration>
\ No newline at end of file

Propchange: commons/proper/configuration/trunk/conf/testExtendedXMLConfigurationProvider.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/configuration/trunk/conf/testExtendedXMLConfigurationProvider.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/configuration/trunk/conf/testExtendedXMLConfigurationProvider.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java?rev=713166&r1=713165&r2=713166&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java
(original)
+++ commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java
Tue Nov 11 13:02:37 2008
@@ -1281,8 +1281,10 @@
      * implementation acts like a <code>FileConfigurationProvider</code>, but
      * it will copy all entity IDs that have been registered for the
      * configuration builder to the new XML configuration before it is loaded.
+     *
+     * @since 1.6
      */
-    static class XMLConfigurationProvider extends FileConfigurationProvider
+    public static class XMLConfigurationProvider extends FileConfigurationProvider
     {
         /**
          * Creates a new instance of <code>XMLConfigurationProvider</code>.

Modified: commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDefaultConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDefaultConfigurationBuilder.java?rev=713166&r1=713165&r2=713166&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDefaultConfigurationBuilder.java
(original)
+++ commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestDefaultConfigurationBuilder.java
Tue Nov 11 13:02:37 2008
@@ -61,6 +61,9 @@
     private static final File PROVIDER_FILE = new File(
             "conf/testConfigurationProvider.xml");
 
+    private static final File EXTENDED_PROVIDER_FILE = new File(
+            "conf/testExtendedXMLConfigurationProvider.xml");
+
     /** Constant for the name of an optional configuration.*/
     private static final String OPTIONAL_NAME = "optionalConfig";
 
@@ -775,6 +778,22 @@
         assertNotNull("Provider 'test' not registered", provider);
     }
 
+        /**
+     * Tests loading a configuration definition file that defines new providers.
+     */
+    public void testExtendedXMLConfigurationProvider() throws ConfigurationException
+    {
+        factory.setFile(EXTENDED_PROVIDER_FILE);
+        CombinedConfiguration cc = factory.getConfiguration(true);
+        DefaultConfigurationBuilder.ConfigurationProvider provider = factory
+                .providerForTag("test");
+        assertNotNull("Provider 'test' not registered", provider);
+        Configuration config = cc.getConfiguration("xml");
+        assertNotNull("Test configuration not present", config);
+        assertTrue("Configuration is not ExtendedXMLConfiguration, is " +
+                config.getClass().getName(), config instanceof ExtendedXMLConfiguration);
+    }
+
     /**
      * A specialized combined configuration implementation used for testing
      * custom result classes.
@@ -796,5 +815,13 @@
             return super.getProperty(key);
         }
     }
+
+    public static class ExtendedXMLConfiguration extends XMLConfiguration
+    {
+        public ExtendedXMLConfiguration()
+        {
+        }
+
+    }
 }
 

Modified: commons/proper/configuration/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/xdocs/changes.xml?rev=713166&r1=713165&r2=713166&view=diff
==============================================================================
--- commons/proper/configuration/trunk/xdocs/changes.xml (original)
+++ commons/proper/configuration/trunk/xdocs/changes.xml Tue Nov 11 13:02:37 2008
@@ -23,6 +23,12 @@
 
   <body>
     <release version="1.6" date="in SVN" description="">
+      <action dev="oheger" type="add" issue="CONFIGURATION-349" due-to="Ralph Goers">
+        The visibility of DefaultConfigurationBuilder.XMLConfigurationProvider
+        was changed from package local to public. This makes it easier to
+        implement providers that create configuration classes derived from
+        XMLConfiguration.
+      </action>
       <action dev="oheger" type="fix" issue="CONFIGURATION-348">
         AbstractHierarchicalFileConfiguration.getKeys() now also checks whether
         a reload is required.



Mime
View raw message