commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joe...@apache.org
Subject svn commit: r757114 - in /commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/ src/java/org/apache/commons/configuration/interpol/ src/test/org/apache/commons/configuration/ xdocs/ xdocs/userguide/
Date Sun, 22 Mar 2009 00:55:26 GMT
Author: joehni
Date: Sun Mar 22 00:55:25 2009
New Revision: 757114

URL: http://svn.apache.org/viewvc?rev=757114&view=rev
Log:
Merge changes from c2 for CONFIGURATION-369, CONFIGURATION-375, CONFIGURATION-376 and CONFIGURATION-377.

Modified:
    commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/   (props
changed)
    commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/SubnodeConfiguration.java
    commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/interpol/ConfigurationInterpolator.java
    commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/   (props
changed)
    commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestSubnodeConfiguration.java
    commons/proper/configuration/trunk/xdocs/   (props changed)
    commons/proper/configuration/trunk/xdocs/changes.xml
    commons/proper/configuration/trunk/xdocs/userguide/howto_multitenant.xml   (props changed)

Propchange: commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Mar 22 00:55:25 2009
@@ -1 +1 @@
-/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2:751544-751840,755692
+/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2:751544-751840,755692,757108

Modified: commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/SubnodeConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/SubnodeConfiguration.java?rev=757114&r1=757113&r2=757114&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/SubnodeConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/SubnodeConfiguration.java
Sun Mar 22 00:55:25 2009
@@ -21,6 +21,7 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.commons.configuration.interpol.ConfigurationInterpolator;
 import org.apache.commons.configuration.tree.ConfigurationNode;
 
 /**
@@ -326,14 +327,16 @@
     }
 
     /**
-     * Performs interpolation. This implementation will ask the parent
-     * configuration to perform the interpolation so that variables can be
-     * evaluated in the global context.
+     * Creates a ConfigurationInterpolator with a chain to the parent's
+     * interpolator. 
      *
-     * @param value the value to be interpolated
+     * @return the new interpolator
      */
-    protected Object interpolate(Object value)
-    {
-        return getParent().interpolate(value);
+    @Override
+    protected ConfigurationInterpolator createInterpolator() {
+        ConfigurationInterpolator interpolator = super.createInterpolator();
+        interpolator.setParentInterpolator(getParent().getInterpolator());
+        return interpolator;
     }
+    
 }

Modified: commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/interpol/ConfigurationInterpolator.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/interpol/ConfigurationInterpolator.java?rev=757114&r1=757113&r2=757114&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/interpol/ConfigurationInterpolator.java
(original)
+++ commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/interpol/ConfigurationInterpolator.java
Sun Mar 22 00:55:25 2009
@@ -286,12 +286,19 @@
             String prefix = var.substring(0, prefixPos);
             String name = var.substring(prefixPos + 1);
             String value = fetchLookupForPrefix(prefix).lookup(name);
+            if (value == null && getParentInterpolator() != null) {
+                value = getParentInterpolator().fetchLookupForPrefix(prefix).lookup(name);
+            }
             if (value != null)
             {
                 return value;
-            }
+            } 
+        }
+        String value = fetchNoPrefixLookup().lookup(var);
+        if (value == null && getParentInterpolator() != null) {
+            value = getParentInterpolator().fetchNoPrefixLookup().lookup(var);
         }
-        return fetchNoPrefixLookup().lookup(var);
+        return value;
     }
 
     /**
@@ -304,17 +311,7 @@
      */
     protected StrLookup fetchNoPrefixLookup()
     {
-        StrLookup lookup = null;
-        if (getDefaultLookup() != null) { 
-            lookup = getDefaultLookup();
-        }
-        if (lookup == null) { 
-            ConfigurationInterpolator parent = getParentInterpolator();
-            lookup = (parent == null) 
-                ? StrLookup.noneLookup() 
-                : parent.fetchNoPrefixLookup();
-        }
-        return lookup;
+        return (getDefaultLookup() != null) ? getDefaultLookup() : StrLookup.noneLookup();
     }
 
     /**
@@ -331,10 +328,7 @@
         StrLookup lookup = (StrLookup) localLookups.get(prefix);
         if (lookup == null)
         {
-            ConfigurationInterpolator parent = getParentInterpolator();
-            lookup = (parent == null) 
-                ? StrLookup.noneLookup() 
-                : parent.fetchLookupForPrefix(prefix);
+            lookup = StrLookup.noneLookup();
         }
         return lookup;
     }

Propchange: commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Mar 22 00:55:25 2009
@@ -1 +1 @@
-/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2:751544-751840,755692
+/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2:751544-751840,755692,757108

Modified: commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestSubnodeConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestSubnodeConfiguration.java?rev=757114&r1=757113&r2=757114&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestSubnodeConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestSubnodeConfiguration.java
Sun Mar 22 00:55:25 2009
@@ -334,9 +334,26 @@
     }
 
     /**
+     * An additional test for interpolation when the configurationAt() method is
+     * involved for a local interpolation.
+     */
+    public void testLocalInterpolationFromConfigurationAt()
+    {
+        parent.addProperty("base.dir", "/home/foo");
+        parent.addProperty("test.absolute.dir.dir1", "${base.dir}/path1");
+        parent.addProperty("test.absolute.dir.dir2", "${dir1}");
+
+        Configuration sub = parent.configurationAt("test.absolute.dir");
+        assertEquals("Wrong interpolation in subnode",
+            "/home/foo/path1", sub.getString("dir1"));
+        assertEquals("Wrong local interpolation in subnode",
+            "/home/foo/path1", sub.getString("dir2"));
+    }
+
+    /**
      * Tests manipulating the interpolator.
      */
-    public void todoTestInterpolator()
+    public void testInterpolator()
     {
         parent.addProperty("tablespaces.tablespace.name", "default");
         parent.addProperty("tablespaces.tablespace(-1).name", "test");

Propchange: commons/proper/configuration/trunk/xdocs/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Sun Mar 22 00:55:25 2009
@@ -0,0 +1 @@
+/commons/proper/configuration/branches/configuration2_experimental/xdocs:757105-757112

Modified: commons/proper/configuration/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/xdocs/changes.xml?rev=757114&r1=757113&r2=757114&view=diff
==============================================================================
--- commons/proper/configuration/trunk/xdocs/changes.xml (original)
+++ commons/proper/configuration/trunk/xdocs/changes.xml Sun Mar 22 00:55:25 2009
@@ -37,9 +37,23 @@
       <action dev="rgoers" type="fix" issue="CONFIGURATION-361">
         MultiFileHierarchicalConfiguration was not using basepath to
         construct the file url. It also threw an exception if the
-        file pattern resolved to a non-existant file. This is now
+        file pattern resolved to a non-existent file. This is now
         configurable.
       </action>
+      <action dev="joehni" type="update">
+        <fixes issue="CONFIGURATION-375" />
+        <fixes issue="CONFIGURATION-376" />
+        <fixes issue="CONFIGURATION-377" />
+        Align interpolation functionality of SubnodeConfiguration and
+        SubsetConfiguration. SubsetConfiguration will now also interpolate
+        keys of the parent configuration or use the local lookups of its
+        parent. SubnodeConfiguration is in turn now able to lookup local
+        keys as well.
+      </action>
+      <action dev="joehni" type="fix" issue="CONFIGURATION-369">
+        SubsetConfiguration did not use locally registered lookups of its
+        interpolator.
+      </action>
       <action dev="oheger" type="fix" issue="CONFIGURATION-359">
         Fixed broken links to the API documentation in the user's guide.
       </action>

Propchange: commons/proper/configuration/trunk/xdocs/userguide/howto_multitenant.xml
            ('svn:mergeinfo' removed)



Mime
View raw message