commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r821230 - in /commons/proper/configuration/branches/CONFIGURATION_390/src: java/org/apache/commons/configuration/ java/org/apache/commons/configuration/resolver/ test/org/apache/commons/configuration/
Date Sat, 03 Oct 2009 03:07:42 GMT
Author: rgoers
Date: Sat Oct  3 03:07:41 2009
New Revision: 821230

URL: http://svn.apache.org/viewvc?rev=821230&view=rev
Log:
Copy configurations when creating a CombinedConfiguration to eliminate need to lock DynamicCombinedConfiguration.
Add more debugging

Modified:
    commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/CombinedConfiguration.java
    commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/ConfigurationUtils.java
    commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java
    commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DynamicCombinedConfiguration.java
    commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/XMLConfiguration.java
    commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/resolver/CatalogResolver.java
    commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestMultiFileHierarchicalConfiguration.java

Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/CombinedConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/CombinedConfiguration.java?rev=821230&r1=821229&r2=821230&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/CombinedConfiguration.java
(original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/CombinedConfiguration.java
Sat Oct  3 03:07:41 2009
@@ -408,6 +408,10 @@
         }
 
         ConfigData cd = new ConfigData(config, name, at);
+        if (getLogger().isDebugEnabled())
+        {
+            getLogger().debug("Adding configuration " + config + " with name " + name);
+        }
         configurations.add(cd);
         if (name != null)
         {
@@ -634,142 +638,6 @@
             return combinedRoot;
         }
     }
-    /*
-    public Object getProperty(String key)
-    {
-        synchronized(reloadLock)
-        {
-            return super.getProperty(key);
-        }
-    }
-
-    protected void addPropertyDirect(String key, Object obj)
-    {
-        synchronized(reloadLock)
-        {
-            super.addPropertyDirect(key, obj);
-        }
-    }
-
-    public void addNodes(String key, Collection nodes)
-    {
-        synchronized(reloadLock)
-        {
-            super.addNodes(key, nodes);
-        }
-    }
-
-    public boolean isEmpty()
-    {
-        synchronized(reloadLock)
-        {
-            return super.isEmpty();
-        }
-    }
-
-    public Configuration subset(String prefix)
-    {
-        synchronized(reloadLock)
-        {
-            return super.subset(prefix);
-        }
-    }
-
-    public SubnodeConfiguration configurationAt(String key, boolean supportUpdates)
-    {
-        synchronized(reloadLock)
-        {
-            return super.configurationAt(key, supportUpdates);
-        }
-    }
-
-    public SubnodeConfiguration configurationAt(String key)
-    {
-        synchronized(reloadLock)
-        {
-            return super.configurationAt(key);
-        }
-    }
-
-    public List configurationsAt(String key)
-    {
-        synchronized(reloadLock)
-        {
-            return super.configurationsAt(key);
-        }
-    }
-
-    protected SubnodeConfiguration createSubnodeConfiguration(ConfigurationNode node)
-    {
-        synchronized(reloadLock)
-        {
-            return super.createSubnodeConfiguration(node);
-        }
-    }
-
-    protected SubnodeConfiguration createSubnodeConfiguration(ConfigurationNode node, String
subnodeKey)
-    {
-        synchronized(reloadLock)
-        {
-            return super.createSubnodeConfiguration(node, subnodeKey);
-        }
-    }
-
-    public boolean containsKey(String key)
-    {
-        synchronized(reloadLock)
-        {
-            return super.containsKey(key);
-        }
-    }
-
-    public void setProperty(String key, Object value)
-    {
-        synchronized(reloadLock)
-        {
-            super.setProperty(key, value);
-        }
-    }
-
-    public void clearTree(String key)
-    {
-        synchronized(reloadLock)
-        {
-            super.clearTree(key);
-        }
-    }
-
-    public void clearProperty(String key)
-    {
-        synchronized(reloadLock)
-        {
-            super.clearProperty(key);
-        }
-    }
-
-    public Iterator getKeys()
-    {
-        synchronized(reloadLock)
-        {
-            return super.getKeys();
-        }
-    }
-
-    public Iterator getKeys(String prefix)
-    {
-        synchronized(reloadLock)
-        {
-            return super.getKeys(prefix);
-        }
-    }
-
-    public int getMaxIndex(String key)
-    {
-        synchronized(reloadLock)
-        {
-            return super.getMaxIndex(key);
-        }
-    } */
 
     /**
      * Clears this configuration. All contained configurations will be removed.
@@ -919,6 +787,10 @@
     {
         if (getNumberOfConfigurations() < 1)
         {
+            if (getLogger().isDebugEnabled())
+            {
+                getLogger().debug("No configurations defined for " + this);
+            }
             return new ViewNode();
         }
 

Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/ConfigurationUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/ConfigurationUtils.java?rev=821230&r1=821229&r2=821230&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/ConfigurationUtils.java
(original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/ConfigurationUtils.java
Sat Oct  3 03:07:41 2009
@@ -32,6 +32,7 @@
 import org.apache.commons.configuration.event.ConfigurationErrorListener;
 import org.apache.commons.configuration.event.EventSource;
 import org.apache.commons.configuration.tree.ExpressionEngine;
+import org.apache.commons.configuration.reloading.Reloadable;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.SystemUtils;
 import org.apache.commons.logging.Log;
@@ -223,7 +224,19 @@
 
         if (conf instanceof HierarchicalConfiguration)
         {
-            HierarchicalConfiguration hc = (HierarchicalConfiguration) conf;
+            HierarchicalConfiguration hc;
+            if (conf instanceof Reloadable)
+            {
+                Object lock = ((Reloadable) conf).getReloadLock();
+                synchronized(lock)
+                {
+                    hc = new HierarchicalConfiguration((HierarchicalConfiguration) conf);
+                }
+            }
+            else
+            {
+                hc = (HierarchicalConfiguration) conf;
+            }
             if (engine != null)
             {
                 hc.setExpressionEngine(engine);

Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java?rev=821230&r1=821229&r2=821230&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java
(original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java
Sat Oct  3 03:07:41 2009
@@ -40,6 +40,7 @@
 import org.apache.commons.configuration.resolver.EntityResolverSupport;
 import org.apache.commons.lang.text.StrLookup;
 import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
 import org.xml.sax.EntityResolver;
 
 /**
@@ -651,6 +652,11 @@
                     .next();
             ConfigurationDeclaration decl = new ConfigurationDeclaration(this,
                     conf);
+            if (getLogger().isDebugEnabled())
+            {
+                getLogger().debug("Creating configuration " + decl.getBeanClassName() + "
with name " +
+                    decl.getConfiguration().getString(ATTR_NAME));
+            }
             AbstractConfiguration newConf = createConfigurationAt(decl);
             if (newConf != null)
             {
@@ -1225,6 +1231,8 @@
      */
     static class ConfigurationBeanFactory implements BeanFactory
     {
+        private Log logger = LogFactory.getLog(DefaultConfigurationBuilder.class);
+
         /**
          * Creates an instance of a bean class. This implementation expects that
          * the passed in bean declaration is a declaration for a configuration.
@@ -1268,6 +1276,11 @@
                 }
                 else
                 {
+                    if (logger.isDebugEnabled())
+                    {
+                        logger.debug("Load failed for optional configuration " + tagName
+ ": "
+                            + ex.getMessage());
+                    }
                     // Notify registered error listeners
                     decl.getConfigurationBuilder().fireError(
                             EVENT_ERR_LOAD_OPTIONAL,

Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DynamicCombinedConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DynamicCombinedConfiguration.java?rev=821230&r1=821229&r2=821230&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DynamicCombinedConfiguration.java
(original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DynamicCombinedConfiguration.java
Sat Oct  3 03:07:41 2009
@@ -769,7 +769,7 @@
             config = (CombinedConfiguration) configs.get(key);
             if (config == null)
             {
-                config = new CombinedConfiguration(getNodeCombiner(), reloadLock);
+                config = new CombinedConfiguration(getNodeCombiner());
                 if (loggerName != null)
                 {
                     Log log = LogFactory.getLog(loggerName);

Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/XMLConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/XMLConfiguration.java?rev=821230&r1=821229&r2=821230&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/XMLConfiguration.java
(original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/XMLConfiguration.java
Sat Oct  3 03:07:41 2009
@@ -49,6 +49,7 @@
 import org.apache.commons.configuration.tree.ConfigurationNode;
 import org.apache.commons.configuration.resolver.EntityRegistry;
 import org.apache.commons.configuration.resolver.DefaultEntityResolver;
+import org.apache.commons.logging.LogFactory;
 import org.w3c.dom.Attr;
 import org.w3c.dom.CDATASection;
 import org.w3c.dom.DOMException;
@@ -226,6 +227,7 @@
     public XMLConfiguration()
     {
         super();
+        setLogger(LogFactory.getLog(XMLConfiguration.class));
     }
 
     /**
@@ -243,6 +245,7 @@
         super(c);
         clearReferences(getRootNode());
         setRootElementName(getRootNode().getName());
+        setLogger(LogFactory.getLog(XMLConfiguration.class));
     }
 
     /**
@@ -255,6 +258,7 @@
     public XMLConfiguration(String fileName) throws ConfigurationException
     {
         super(fileName);
+        setLogger(LogFactory.getLog(XMLConfiguration.class));
     }
 
     /**
@@ -267,6 +271,7 @@
     public XMLConfiguration(File file) throws ConfigurationException
     {
         super(file);
+        setLogger(LogFactory.getLog(XMLConfiguration.class));
     }
 
     /**
@@ -279,6 +284,7 @@
     public XMLConfiguration(URL url) throws ConfigurationException
     {
         super(url);
+        setLogger(LogFactory.getLog(XMLConfiguration.class));
     }
 
     /**

Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/resolver/CatalogResolver.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/resolver/CatalogResolver.java?rev=821230&r1=821229&r2=821230&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/resolver/CatalogResolver.java
(original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/resolver/CatalogResolver.java
Sat Oct  3 03:07:41 2009
@@ -23,6 +23,7 @@
 import org.apache.xml.resolver.Catalog;
 import org.apache.xml.resolver.readers.CatalogReader;
 import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.commons.logging.impl.NoOpLog;
 import org.apache.commons.configuration.FileSystem;
 import org.apache.commons.configuration.ConfigurationException;
@@ -199,7 +200,7 @@
             }
             catch (Exception e)
             {
-                log.debug("Failed to create InputSource for " + resolved + " ("
+                log.warn("Failed to create InputSource for " + resolved + " ("
                                 + e.toString() + ")");
                 return null;
             }
@@ -229,7 +230,7 @@
      */
     public void setLogger(Log log)
     {
-        this.log = (log != null) ? log : new NoOpLog();
+        this.log = (log != null) ? log : LogFactory.getLog(CatalogResolver.class);
     }
 
     private synchronized org.apache.xml.resolver.tools.CatalogResolver getResolver()

Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestMultiFileHierarchicalConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestMultiFileHierarchicalConfiguration.java?rev=821230&r1=821229&r2=821230&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestMultiFileHierarchicalConfiguration.java
(original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestMultiFileHierarchicalConfiguration.java
Sat Oct  3 03:07:41 2009
@@ -265,7 +265,7 @@
         }
 
         output.delete();
-    }
+    }    
 
     private void copyFile(File input, File output) throws IOException
     {



Mime
View raw message