commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r469259 - in /jakarta/commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/beanutils/ src/test/org/apache/commons/configuration/beanutils/ xdocs/
Date Mon, 30 Oct 2006 20:22:52 GMT
Author: oheger
Date: Mon Oct 30 12:22:50 2006
New Revision: 469259

URL: http://svn.apache.org/viewvc?view=rev&rev=469259
Log:
Updated ConfigurationDynaBean to better work together with different types of configurations;
fix for CONFIGURATION-227

Added:
    jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/beanutils/TestConfigurationDynaBeanXMLConfig.java
  (with props)
Modified:
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java
    jakarta/commons/proper/configuration/trunk/xdocs/changes.xml

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java?view=diff&rev=469259&r1=469258&r2=469259
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java
Mon Oct 30 12:22:50 2006
@@ -25,6 +25,7 @@
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationMap;
 import org.apache.commons.configuration.ConversionException;
+import org.apache.commons.configuration.SubsetConfiguration;
 import org.apache.commons.lang.BooleanUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -44,12 +45,20 @@
  * {@link org.apache.commons.configuration.Configuration#getList(String)}
  * method. Setting an indexed property always throws an exception.</p>
  *
+ * <p>Note: Some of the methods expect that a dot (&quot;.&quot;) is used as
+ * property delimitor for the wrapped configuration. This is true for most of
+ * the default configurations. Hierarchical configurations, for which a specific
+ * expression engine is set, may cause problems.</p>
+ *
  * @author <a href="mailto:ricardo.gladwell@btinternet.com">Ricardo Gladwell</a>
  * @version $Revision$, $Date$
  * @since 1.0-rc1
  */
 public class ConfigurationDynaBean extends ConfigurationMap implements DynaBean
 {
+    /** Constant for the property delimiter.*/
+    private static final String PROPERTY_DELIMITER = ".";
+
     /** The logger.*/
     private static Log log = LogFactory.getLog(ConfigurationDynaBean.class);
 
@@ -184,10 +193,10 @@
         if (result == null)
         {
             // otherwise attempt to create bean from configuration subset
-            Configuration subset = getConfiguration().subset(name);
+            Configuration subset = new SubsetConfiguration(getConfiguration(), name, PROPERTY_DELIMITER);
             if (!subset.isEmpty())
             {
-                result = new ConfigurationDynaBean(getConfiguration().subset(name));
+                result = new ConfigurationDynaBean(subset);
             }
         }
 
@@ -265,11 +274,7 @@
      */
     public void remove(String name, String key)
     {
-        Configuration subset = getConfiguration().subset(name);
-        if (subset == null)
-        {
-            throw new IllegalArgumentException("Mapped property '" + name + "' does not exist.");
-        }
+        Configuration subset = new SubsetConfiguration(getConfiguration(), name, PROPERTY_DELIMITER);
         subset.setProperty(key, null);
     }
 
@@ -290,6 +295,7 @@
             {
                 List list = (List) property;
                 list.set(index, value);
+                getConfiguration().setProperty(name, list);
             }
             else if (property.getClass().isArray())
             {

Added: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/beanutils/TestConfigurationDynaBeanXMLConfig.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/beanutils/TestConfigurationDynaBeanXMLConfig.java?view=auto&rev=469259
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/beanutils/TestConfigurationDynaBeanXMLConfig.java
(added)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/beanutils/TestConfigurationDynaBeanXMLConfig.java
Mon Oct 30 12:22:50 2006
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.configuration.beanutils;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.XMLConfiguration;
+
+/**
+ * An additional test class for ConfigurationDynaBean. This test class performs
+ * the same tests as the default test class, but uses a XMLConfiguration as
+ * underlying configuration object.
+ *
+ * @author <a
+ * href="http://jakarta.apache.org/commons/configuration/team-list.html">Commons
+ * Configuration team</a>
+ * @version $Id$
+ */
+public class TestConfigurationDynaBeanXMLConfig extends
+        TestConfigurationDynaBean
+{
+    /**
+     * Creates the underlying configuration object. This implementation will
+     * create a XMLConfiguration.
+     * @return the underlying configuration
+     */
+    protected Configuration createConfiguration()
+    {
+        return new XMLConfiguration();
+    }
+}

Propchange: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/beanutils/TestConfigurationDynaBeanXMLConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/beanutils/TestConfigurationDynaBeanXMLConfig.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/beanutils/TestConfigurationDynaBeanXMLConfig.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?view=diff&rev=469259&r1=469258&r2=469259
==============================================================================
--- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Mon Oct 30 12:22:50 2006
@@ -23,6 +23,10 @@
 
   <body>
     <release version="1.4-dev" date="in SVN">
+      <action dev="oheger" type="update" issue="CONFIGURATION-227">
+        The compatibility of ConfigurationDynaBean with other configuration types
+        than those that inherit from BaseConfiguration was improved.
+      </action>
       <action dev="oheger" type="update" issue="CONFIGURATION-233" due-to="Rainer Jung">
         The getList() method of CompositeConfiguration does now fully support
         variable interpolation. So it is possible to refer to a variable in



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message