You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2013/05/22 22:12:16 UTC

svn commit: r1485393 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration/builder/ test/java/org/apache/commons/configuration/builder/

Author: oheger
Date: Wed May 22 20:12:16 2013
New Revision: 1485393

URL: http://svn.apache.org/r1485393
Log:
Added support for setting a Synchronizer to BasicBuilderParameters.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderParameters.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderProperties.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBasicBuilderParameters.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderParameters.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderParameters.java?rev=1485393&r1=1485392&r2=1485393&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderParameters.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderParameters.java Wed May 22 20:12:16 2013
@@ -24,6 +24,7 @@ import java.util.Map;
 import org.apache.commons.configuration.interpol.ConfigurationInterpolator;
 import org.apache.commons.configuration.interpol.InterpolatorSpecification;
 import org.apache.commons.configuration.interpol.Lookup;
+import org.apache.commons.configuration.sync.Synchronizer;
 import org.apache.commons.logging.Log;
 
 /**
@@ -75,6 +76,9 @@ public class BasicBuilderParameters impl
     /** The key for the <em>parentInterpolator</em> property. */
     private static final String PROP_PARENT_INTERPOLATOR = "parentInterpolator";
 
+    /** The key for the <em>synchronizer</em> property. */
+    private static final String PROP_SYNCHRONIZER = "synchronizer";
+
     /** The map for storing the current property values. */
     private Map<String, Object> properties;
 
@@ -227,6 +231,15 @@ public class BasicBuilderParameters impl
     }
 
     /**
+     * {@inheritDoc} This implementation stores the passed in
+     * {@code Synchronizer} object in the internal parameters map.
+     */
+    public BasicBuilderParameters setSynchronizer(Synchronizer sync)
+    {
+        return setProperty(PROP_SYNCHRONIZER, sync);
+    }
+
+    /**
      * Merges this object with the given parameters object. This method adds all
      * property values defined by the passed in parameters object to the
      * internal storage which are not already in. So properties already defined

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderProperties.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderProperties.java?rev=1485393&r1=1485392&r2=1485393&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderProperties.java (original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicBuilderProperties.java Wed May 22 20:12:16 2013
@@ -21,6 +21,7 @@ import java.util.Map;
 
 import org.apache.commons.configuration.interpol.ConfigurationInterpolator;
 import org.apache.commons.configuration.interpol.Lookup;
+import org.apache.commons.configuration.sync.Synchronizer;
 import org.apache.commons.logging.Log;
 
 /**
@@ -140,4 +141,16 @@ public interface BasicBuilderProperties<
      * @see ConfigurationInterpolator#setParentInterpolator(ConfigurationInterpolator)
      */
     T setParentInterpolator(ConfigurationInterpolator parent);
+
+    /**
+     * Sets the {@code Synchronizer} object for this configuration. This object
+     * is used to protect this configuration instance against concurrent access.
+     * The concrete {@code Synchronizer} implementation used determines whether
+     * a configuration instance is thread-safe or not.
+     *
+     * @param sync the {@code Synchronizer} to be used (a value of <b>null</b>
+     *        means that a default {@code Synchronizer} is used)
+     * @return a reference to this object for method chaining
+     */
+    T setSynchronizer(Synchronizer sync);
 }

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBasicBuilderParameters.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBasicBuilderParameters.java?rev=1485393&r1=1485392&r2=1485393&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBasicBuilderParameters.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/builder/TestBasicBuilderParameters.java Wed May 22 20:12:16 2013
@@ -32,6 +32,7 @@ import java.util.Map;
 import org.apache.commons.configuration.interpol.ConfigurationInterpolator;
 import org.apache.commons.configuration.interpol.InterpolatorSpecification;
 import org.apache.commons.configuration.interpol.Lookup;
+import org.apache.commons.configuration.sync.Synchronizer;
 import org.apache.commons.logging.Log;
 import org.easymock.EasyMock;
 import org.junit.Before;
@@ -459,4 +460,17 @@ public class TestBasicBuilderParameters
         assertEquals("Wrong number of default lookups", 1, defLooks.size());
         assertTrue("Wrong default lookup", defLooks.contains(look));
     }
+
+    /**
+     * Tests whether a Synchronizer can be set.
+     */
+    @Test
+    public void testSetSynchronizer()
+    {
+        Synchronizer sync = EasyMock.createMock(Synchronizer.class);
+        EasyMock.replay(sync);
+        assertSame("Wrong result", params, params.setSynchronizer(sync));
+        assertSame("Synchronizer not set", sync,
+                params.getParameters().get("synchronizer"));
+    }
 }