commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1587024 - in /commons/proper/configuration/branches/immutableNodes/src: main/java/org/apache/commons/configuration/ test/java/org/apache/commons/configuration/ test/java/org/apache/commons/configuration/tree/
Date Sun, 13 Apr 2014 16:05:49 GMT
Author: oheger
Date: Sun Apr 13 16:05:48 2014
New Revision: 1587024

URL: http://svn.apache.org/r1587024
Log:
HierarchicalConfiguration now extends NodeModelSupport.

The new method was implemented in AbstractHierarchicalConfiguration. Access to
the NodeModel is guarded by the configuration's Synchronizer.

Modified:
    commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java
    commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/CombinedConfiguration.java
    commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/HierarchicalConfiguration.java
    commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/TestAbstractHierarchicalConfiguration.java
    commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestMergeCombiner.java
    commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestOverrideCombiner.java

Modified: commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java?rev=1587024&r1=1587023&r2=1587024&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java
(original)
+++ commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/AbstractHierarchicalConfiguration.java
Sun Apr 13 16:05:48 2014
@@ -272,6 +272,24 @@ public abstract class AbstractHierarchic
     }
 
     /**
+     * {@inheritDoc} This implementation returns the configuration's
+     * {@code NodeModel}. It is guarded by the current {@code Synchronizer}.
+     */
+    @Override
+    public NodeModel<T> getNodeModel()
+    {
+        beginRead(false);
+        try
+        {
+            return getModel();
+        }
+        finally
+        {
+            endRead();
+        }
+    }
+
+    /**
      * Returns the expression engine used by this configuration. This method
      * will never return <b>null</b>; if no specific expression engine was set,
      * the default expression engine will be returned.
@@ -789,11 +807,15 @@ public abstract class AbstractHierarchic
     }
 
     /**
-     * Returns the model used by this configuration.
+     * Returns the {@code NodeModel} used by this configuration. This method is
+     * intended for internal use only. Access to the model is granted without
+     * any synchronization. This is in contrast to the &quot;official&quot;
+     * {@code getNodeModel()} method which is guarded by the configuration's
+     * {@code Synchronizer}.
      *
      * @return the node model
      */
-    public NodeModel<T> getModel()
+    protected NodeModel<T> getModel()
     {
         return model;
     }

Modified: commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/CombinedConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/CombinedConfiguration.java?rev=1587024&r1=1587023&r2=1587024&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/CombinedConfiguration.java
(original)
+++ commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/CombinedConfiguration.java
Sun Apr 13 16:05:48 2014
@@ -1132,7 +1132,7 @@ public class CombinedConfiguration exten
                 ImmutableNode root =
                         ConfigurationUtils
                                 .convertToHierarchical(getConfiguration(),
-                                        conversionExpressionEngine).getModel()
+                                        conversionExpressionEngine).getNodeModel()
                                 .getInMemoryRepresentation();
                 rootNode = root;
                 return root;

Modified: commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/HierarchicalConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/HierarchicalConfiguration.java?rev=1587024&r1=1587023&r2=1587024&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/HierarchicalConfiguration.java
(original)
+++ commons/proper/configuration/branches/immutableNodes/src/main/java/org/apache/commons/configuration/HierarchicalConfiguration.java
Sun Apr 13 16:05:48 2014
@@ -20,7 +20,7 @@ import java.util.Collection;
 import java.util.List;
 
 import org.apache.commons.configuration.tree.ExpressionEngine;
-import org.apache.commons.configuration.tree.NodeModel;
+import org.apache.commons.configuration.tree.NodeModelSupport;
 
 /**
  * <p>
@@ -43,16 +43,9 @@ import org.apache.commons.configuration.
  * @param <T> the type of the nodes used by this hierarchical configuration
  */
 public interface HierarchicalConfiguration<T>
-    extends Configuration, ImmutableHierarchicalConfiguration
+    extends Configuration, ImmutableHierarchicalConfiguration, NodeModelSupport<T>
 {
     /**
-     * Returns the {@code NodeModel} used by this hierarchical configuration.
-     *
-     * @return the {@code NodeModel}
-     */
-    NodeModel<T> getModel();
-
-    /**
      * Returns the root node of this hierarchical configuration.
      *
      * @return the root node

Modified: commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/TestAbstractHierarchicalConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/TestAbstractHierarchicalConfiguration.java?rev=1587024&r1=1587023&r2=1587024&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/TestAbstractHierarchicalConfiguration.java
(original)
+++ commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/TestAbstractHierarchicalConfiguration.java
Sun Apr 13 16:05:48 2014
@@ -935,6 +935,27 @@ public class TestAbstractHierarchicalCon
     }
 
     /**
+     * Tests whether the configuration's node model can be correctly accessed.
+     */
+    @Test
+    public void testGetNodeModel()
+    {
+        SynchronizerTestImpl sync = new SynchronizerTestImpl();
+        config.setSynchronizer(sync);
+        NodeModel<ImmutableNode> model = config.getNodeModel();
+
+        assertTrue("Wrong node model: " + model,
+                model instanceof InMemoryNodeModel);
+        ImmutableNode rootNode = model.getNodeHandler().getRootNode();
+        assertEquals("Wrong number of children of root node", 1, rootNode
+                .getChildren().size());
+        assertTrue("Wrong children of root node", rootNode.getChildren()
+                .contains(NodeStructureHelper.ROOT_TABLES_TREE));
+        sync.verify(SynchronizerTestImpl.Methods.BEGIN_READ,
+                SynchronizerTestImpl.Methods.END_READ);
+    }
+
+    /**
      * Helper method for testing the getKeys(String) method.
      *
      * @param prefix the key to pass into getKeys()

Modified: commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestMergeCombiner.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestMergeCombiner.java?rev=1587024&r1=1587023&r2=1587024&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestMergeCombiner.java
(original)
+++ commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestMergeCombiner.java
Sun Apr 13 16:05:48 2014
@@ -181,7 +181,7 @@ public class TestMergeCombiner extends A
         List<QueryResult<ImmutableNode>> nds =
                 config.getExpressionEngine().query(config.getRootNode(),
                         "database.tables.table",
-                        config.getModel().getNodeHandler());
+                        config.getNodeModel().getNodeHandler());
         assertFalse("No node found", nds.isEmpty());
         assertFalse("Not a node result", nds.get(0).isAttributeResult());
         return nds.get(0).getNode();

Modified: commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestOverrideCombiner.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestOverrideCombiner.java?rev=1587024&r1=1587023&r2=1587024&view=diff
==============================================================================
--- commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestOverrideCombiner.java
(original)
+++ commons/proper/configuration/branches/immutableNodes/src/test/java/org/apache/commons/configuration/tree/TestOverrideCombiner.java
Sun Apr 13 16:05:48 2014
@@ -170,7 +170,7 @@ public class TestOverrideCombiner extend
         List<QueryResult<ImmutableNode>> nds =
                 config.getExpressionEngine().query(config.getRootNode(),
                         "database.tables.table",
-                        config.getModel().getNodeHandler());
+                        config.getNodeModel().getNodeHandler());
         assertFalse("No node found", nds.isEmpty());
         assertFalse("An attribute result", nds.get(0).isAttributeResult());
         return nds.get(0).getNode();



Mime
View raw message