commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1479371 - in /commons/proper/configuration/trunk/src: main/java/org/apache/commons/configuration/ main/java/org/apache/commons/configuration/web/ test/java/org/apache/commons/configuration/
Date Sun, 05 May 2013 20:16:53 GMT
Author: oheger
Date: Sun May  5 20:16:52 2013
New Revision: 1479371

URL: http://svn.apache.org/r1479371
Log:
Added a final getProperty() method to AbstractConfiguration.

This method is responsible for synchronization handling. There is now a new
protected getPropertyInternal() method which has to be defined by concrete
subclasses.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractConfiguration.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/BaseConfiguration.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/BaseHierarchicalConfiguration.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/CompositeConfiguration.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/DataConfiguration.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/DatabaseConfiguration.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/DynamicCombinedConfiguration.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/JNDIConfiguration.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/MapConfiguration.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/PatternSubtreeConfigurationWrapper.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/SubsetConfiguration.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/AppletConfiguration.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletConfiguration.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletContextConfiguration.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletFilterConfiguration.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletRequestConfiguration.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/NonCloneableConfiguration.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestAbstractConfigurationBasicFeatures.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestAbstractConfigurationSynchronization.java

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractConfiguration.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractConfiguration.java
Sun May  5 20:16:52 2013
@@ -846,6 +846,35 @@ public abstract class AbstractConfigurat
         return new PrefixedKeysIterator(getKeys(), prefix);
     }
 
+    /**
+     * {@inheritDoc} This implementation ensures proper synchronization.
+     * Subclasses have to define the abstract {@code getPropertyInternal()}
+     * method which is called from here.
+     */
+    public final Object getProperty(String key)
+    {
+        getSynchronizer().beginRead();
+        try
+        {
+            return getPropertyInternal(key);
+        }
+        finally
+        {
+            getSynchronizer().endRead();
+        }
+    }
+
+    /**
+     * Actually obtains the value of the specified property. This method is
+     * called by {@code getProperty()}. Concrete subclasses must define it to
+     * fetch the value of the desired property.
+     *
+     * @param key the key of the property in question
+     * @return the (raw) value of this property
+     * @since 2.0
+     */
+    protected abstract Object getPropertyInternal(String key);
+
     public Properties getProperties(String key)
     {
         return getProperties(key, null);
@@ -1344,7 +1373,7 @@ public abstract class AbstractConfigurat
      */
     public String[] getStringArray(String key)
     {
-        Object value = readProperty(key);
+        Object value = getProperty(key);
 
         String[] array;
 
@@ -1391,7 +1420,7 @@ public abstract class AbstractConfigurat
 
     public List<Object> getList(String key, List<Object> defaultValue)
     {
-        Object value = readProperty(key);
+        Object value = getProperty(key);
         List<Object> list;
 
         if (value instanceof String)
@@ -1440,7 +1469,7 @@ public abstract class AbstractConfigurat
      */
     protected Object resolveContainerStore(String key)
     {
-        Object value = readProperty(key);
+        Object value = getProperty(key);
         if (value != null)
         {
             if (value instanceof Collection)
@@ -1578,23 +1607,4 @@ public abstract class AbstractConfigurat
         c.setDelimiterParsingDisabled(isDelimiterParsingDisabled());
         return c;
     }
-
-    /**
-     * Obtains a value of a property. Ensures proper synchronization.
-     *
-     * @param key the key to be read
-     * @return the value of this property
-     */
-    private Object readProperty(String key)
-    {
-        getSynchronizer().beginRead();
-        try
-        {
-            return getProperty(key);
-        }
-        finally
-        {
-            getSynchronizer().endRead();
-        }
-    }
 }

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/BaseConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/BaseConfiguration.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/BaseConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/BaseConfiguration.java
Sun May  5 20:16:52 2013
@@ -62,7 +62,7 @@ public class BaseConfiguration extends A
     @Override
     protected void addPropertyDirect(String key, Object value)
     {
-        Object previousValue = getProperty(key);
+        Object previousValue = getPropertyInternal(key);
 
         if (previousValue == null)
         {
@@ -94,7 +94,8 @@ public class BaseConfiguration extends A
      *
      * @return object associated with the given configuration key.
      */
-    public Object getProperty(String key)
+    @Override
+    protected Object getPropertyInternal(String key)
     {
         return store.get(key);
     }

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/BaseHierarchicalConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/BaseHierarchicalConfiguration.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/BaseHierarchicalConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/BaseHierarchicalConfiguration.java
Sun May  5 20:16:52 2013
@@ -300,7 +300,8 @@ public class BaseHierarchicalConfigurati
      * @param key the key to be looked up
      * @return the found value
      */
-    public Object getProperty(String key)
+    @Override
+    protected Object getPropertyInternal(String key)
     {
         List<ConfigurationNode> nodes = fetchNodeList(key);
 

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/CompositeConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/CompositeConfiguration.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/CompositeConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/CompositeConfiguration.java
Sun May  5 20:16:52 2013
@@ -253,7 +253,8 @@ implements Cloneable
      *
      * @return object associated with the given configuration key.
      */
-    public Object getProperty(String key)
+    @Override
+    protected Object getPropertyInternal(String key)
     {
         Configuration firstMatchingConfiguration = null;
         for (Configuration config : configList)

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/DataConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/DataConfiguration.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/DataConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/DataConfiguration.java
Sun May  5 20:16:52 2013
@@ -123,7 +123,8 @@ public class DataConfiguration extends A
         return configuration;
     }
 
-    public Object getProperty(String key)
+    @Override
+    protected Object getPropertyInternal(String key)
     {
         return configuration.getProperty(key);
     }

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/DatabaseConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/DatabaseConfiguration.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/DatabaseConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/DatabaseConfiguration.java
Sun May  5 20:16:52 2013
@@ -310,7 +310,8 @@ public class DatabaseConfiguration exten
      * @param key the key of the desired property
      * @return the value of this property
      */
-    public Object getProperty(final String key)
+    @Override
+    protected Object getPropertyInternal(final String key)
     {
         JdbcOperation<Object> op = new JdbcOperation<Object>(EVENT_READ_PROPERTY,
key, null)
         {

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/DynamicCombinedConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/DynamicCombinedConfiguration.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/DynamicCombinedConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/DynamicCombinedConfiguration.java
Sun May  5 20:16:52 2013
@@ -519,7 +519,7 @@ public class DynamicCombinedConfiguratio
     }
 
     @Override
-    public Object getProperty(String key)
+    protected Object getPropertyInternal(String key)
     {
         return this.getCurrentConfig().getProperty(key);
     }

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/JNDIConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/JNDIConfiguration.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/JNDIConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/JNDIConfiguration.java
Sun May  5 20:16:52 2013
@@ -396,7 +396,8 @@ public class JNDIConfiguration extends A
      * @param key the key of the property
      * @return the value of this property
      */
-    public Object getProperty(String key)
+    @Override
+    protected Object getPropertyInternal(String key)
     {
         if (clearedProperties.contains(key))
         {

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/MapConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/MapConfiguration.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/MapConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/MapConfiguration.java
Sun May  5 20:16:52 2013
@@ -160,7 +160,8 @@ public class MapConfiguration extends Ab
         this.trimmingDisabled = trimmingDisabled;
     }
 
-    public Object getProperty(String key)
+    @Override
+    protected Object getPropertyInternal(String key)
     {
         Object value = map.get(key);
         if ((value instanceof String) && (!isDelimiterParsingDisabled()))

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/PatternSubtreeConfigurationWrapper.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/PatternSubtreeConfigurationWrapper.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/PatternSubtreeConfigurationWrapper.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/PatternSubtreeConfigurationWrapper.java
Sun May  5 20:16:52 2013
@@ -269,7 +269,7 @@ public class PatternSubtreeConfiguration
     }
 
     @Override
-    public Object getProperty(String key)
+    protected Object getPropertyInternal(String key)
     {
         return config.getProperty(makePath(key));
     }

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/SubsetConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/SubsetConfiguration.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/SubsetConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/SubsetConfiguration.java
Sun May  5 20:16:52 2013
@@ -182,7 +182,8 @@ public class SubsetConfiguration extends
         parent.clearProperty(getParentKey(key));
     }
 
-    public Object getProperty(String key)
+    @Override
+    protected Object getPropertyInternal(String key)
     {
         return parent.getProperty(getParentKey(key));
     }

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/AppletConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/AppletConfiguration.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/AppletConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/AppletConfiguration.java
Sun May  5 20:16:52 2013
@@ -46,7 +46,8 @@ public class AppletConfiguration extends
         this.applet = applet;
     }
 
-    public Object getProperty(String key)
+    @Override
+    protected Object getPropertyInternal(String key)
     {
         return handleDelimiters(applet.getParameter(key));
     }

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletConfiguration.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletConfiguration.java
Sun May  5 20:16:52 2013
@@ -59,7 +59,8 @@ public class ServletConfiguration extend
         this.config = config;
     }
 
-    public Object getProperty(String key)
+    @Override
+    protected Object getPropertyInternal(String key)
     {
         return handleDelimiters(config.getInitParameter(key));
     }

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletContextConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletContextConfiguration.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletContextConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletContextConfiguration.java
Sun May  5 20:16:52 2013
@@ -60,7 +60,8 @@ public class ServletContextConfiguration
         this.context = context;
     }
 
-    public Object getProperty(String key)
+    @Override
+    protected Object getPropertyInternal(String key)
     {
         return handleDelimiters(context.getInitParameter(key));
     }

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletFilterConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletFilterConfiguration.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletFilterConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletFilterConfiguration.java
Sun May  5 20:16:52 2013
@@ -47,7 +47,8 @@ public class ServletFilterConfiguration 
         this.config = config;
     }
 
-    public Object getProperty(String key)
+    @Override
+    protected Object getPropertyInternal(String key)
     {
         return handleDelimiters(config.getInitParameter(key));
     }

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletRequestConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletRequestConfiguration.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletRequestConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/web/ServletRequestConfiguration.java
Sun May  5 20:16:52 2013
@@ -49,7 +49,8 @@ public class ServletRequestConfiguration
         this.request = request;
     }
 
-    public Object getProperty(String key)
+    @Override
+    protected Object getPropertyInternal(String key)
     {
         String[] values = request.getParameterValues(key);
 

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/NonCloneableConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/NonCloneableConfiguration.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/NonCloneableConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/NonCloneableConfiguration.java
Sun May  5 20:16:52 2013
@@ -63,7 +63,8 @@ public class NonCloneableConfiguration e
     /**
      * Dummy implementation of this method.
      */
-    public Object getProperty(String key)
+    @Override
+    protected Object getPropertyInternal(String key)
     {
         return null;
     }

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestAbstractConfigurationBasicFeatures.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestAbstractConfigurationBasicFeatures.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestAbstractConfigurationBasicFeatures.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestAbstractConfigurationBasicFeatures.java
Sun May  5 20:16:52 2013
@@ -619,7 +619,8 @@ public class TestAbstractConfigurationBa
             return config.getKeys();
         }
 
-        public Object getProperty(String key)
+        @Override
+        protected Object getPropertyInternal(String key)
         {
             return config.getProperty(key);
         }

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestAbstractConfigurationSynchronization.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestAbstractConfigurationSynchronization.java?rev=1479371&r1=1479370&r2=1479371&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestAbstractConfigurationSynchronization.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestAbstractConfigurationSynchronization.java
Sun May  5 20:16:52 2013
@@ -112,8 +112,6 @@ public class TestAbstractConfigurationSy
      * Tests whether read access to properties is synchronized.
      */
     @Test
-    @Ignore
-    // TODO prevent subclasses from overriding getProperty()
     public void testGetPropertySynchronized()
     {
         assertEquals("Wrong raw value", "true", config.getProperty(PROP));



Mime
View raw message