commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r724962 - in /commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2: ./ combined/
Date Wed, 10 Dec 2008 03:15:56 GMT
Author: rgoers
Date: Tue Dec  9 19:15:56 2008
New Revision: 724962

URL: http://svn.apache.org/viewvc?rev=724962&view=rev
Log:
Fix checkstyle errors in last set of changes I made

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DefaultConfigurationBuilder.java
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/MultiFileHierarchicalConfiguration.java
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PatternSubtreeConfigurationWrapper.java
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/combined/DynamicCombinedConfiguration.java

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DefaultConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DefaultConfigurationBuilder.java?rev=724962&r1=724961&r2=724962&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DefaultConfigurationBuilder.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DefaultConfigurationBuilder.java
Tue Dec  9 19:15:56 2008
@@ -671,7 +671,7 @@
         {
             XMLBeanDeclaration decl = new XMLBeanDeclaration(config);
             String key = config.getString(KEY_LOOKUP_KEY);
-            ConfigurationInterpolator.registerGlobalLookup(key, (StrLookup)BeanHelper.createBean(decl));
+            ConfigurationInterpolator.registerGlobalLookup(key, (StrLookup) BeanHelper.createBean(decl));
         }
     }
 
@@ -1112,10 +1112,10 @@
                 return true;
             }
 
-            return ((ATTR_ATNAME.equals(name) && getNodeHandler()
+            return (ATTR_ATNAME.equals(name) && getNodeHandler()
                     .getAttributeValue(parent, RESERVED_PREFIX + ATTR_ATNAME) == null) ||
(ATTR_OPTIONALNAME
                     .equals(name) && getNodeHandler().getAttributeValue(parent,
-                    RESERVED_PREFIX + ATTR_OPTIONALNAME) == null));
+                    RESERVED_PREFIX + ATTR_OPTIONALNAME) == null);
         }
 
         /**
@@ -1561,9 +1561,12 @@
             String valueColumn = (String) attributes.get("valueColumn");
 
             DatabaseConfiguration config;
-            if (name == null) {
+            if (name == null)
+            {
                 config = new DatabaseConfiguration(datasource, table, keyColumn, valueColumn);
-            } else {
+            }
+            else 
+            {
                 config = new DatabaseConfiguration(datasource, table, nameColumn, keyColumn,
valueColumn, name);
             }
 

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/MultiFileHierarchicalConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/MultiFileHierarchicalConfiguration.java?rev=724962&r1=724961&r2=724962&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/MultiFileHierarchicalConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/MultiFileHierarchicalConfiguration.java
Tue Dec  9 19:15:56 2008
@@ -1,5 +1,18 @@
-/**
+/*
+ * 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.configuration2;
 
@@ -28,16 +41,33 @@
 import org.apache.commons.configuration2.tree.ConfigurationNode;
 
 /**
+ * This class provides access to multiple configuration files that reside in a location that
+ * can be specified by a pattern allowing applications to be multi-tenant.  For example,
+ * providing a pattern of "file:///opt/config/${product}/${client}/config.xml" will result
in
+ * "product" and "client" being resolved on every call. The configuration resulting from
the
+ * @since 1.6
+ * @author <a
+ * href="http://commons.apache.org/configuration/team-list.html">Commons
+ * Configuration team</a>
+ * @version $Id:  $resolved pattern will be saved for future access.
  *
  */
 public class MultiFileHierarchicalConfiguration extends AbstractHierarchicalFileConfiguration
     implements ConfigurationListener, ConfigurationErrorListener
 {
-    private ConcurrentMap<String, XMLConfiguration> configurationsMap = new ConcurrentHashMap<String,
XMLConfiguration>();
-    private String pattern;
-    private boolean init = false;
+    /** FILE URL prefix */
     private static final String FILE_URL_PREFIX = "file:";
 
+    /** Map of configurations */
+    private ConcurrentMap<String, XMLConfiguration> configurationsMap =
+            new ConcurrentHashMap<String, XMLConfiguration>();
+
+    /** key pattern for configurationsMap */
+    private String pattern;
+
+    /** True if the constructor has finished */
+    private boolean init;
+
     /**
      * Default Constructor
      */
@@ -597,8 +627,8 @@
             }
             catch (MalformedURLException ex2)
             {
-                throw new FileNotFoundException("Resource location [" + resourceLocation
+
-                        "] is not a URL or a well-formed file path");
+                throw new FileNotFoundException("Resource location [" + resourceLocation
+                        + "] is not a URL or a well-formed file path");
             }
         }
     }

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PatternSubtreeConfigurationWrapper.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PatternSubtreeConfigurationWrapper.java?rev=724962&r1=724961&r2=724962&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PatternSubtreeConfigurationWrapper.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PatternSubtreeConfigurationWrapper.java
Tue Dec  9 19:15:56 2008
@@ -1,3 +1,19 @@
+/*
+ * 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.configuration2;
 
 import org.apache.commons.configuration2.tree.ConfigurationNode;
@@ -19,13 +35,25 @@
 /**
  * Wraps a HierarchicalConfiguration and allows subtrees to be access via a configured path
with
  * replaceable tokens derived from the MDC.
+ * @since 1.6
+ * @author <a
+ * href="http://commons.apache.org/configuration/team-list.html">Commons
+ * Configuration team</a>
+ * @version $Id:  $
  */
 public class PatternSubtreeConfigurationWrapper extends AbstractHierarchicalFileConfiguration
 {
+    /** The wrapped configuration */
     private final AbstractHierarchicalFileConfiguration config;
+
+    /** The path to the subtree */
     private final String path;
+
+    /** True if the path ends with '/', false otherwise */
     private final boolean trailing;
-    private boolean init = false;
+
+    /** True if the constructor has finished */
+    private boolean init;
 
     /**
      * Constructor
@@ -389,7 +417,7 @@
 
     private String makePath()
     {
-        String pathPattern = (trailing) ? path.substring(0, path.length() - 1) : path;
+        String pathPattern = trailing ? path.substring(0, path.length() - 1) : path;
         return getSubstitutor().replace(pathPattern);
     }
 
@@ -410,4 +438,4 @@
         }
         return getSubstitutor().replace(pathPattern) + item;
     }
-}
\ No newline at end of file
+}

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/combined/DynamicCombinedConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/combined/DynamicCombinedConfiguration.java?rev=724962&r1=724961&r2=724962&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/combined/DynamicCombinedConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/combined/DynamicCombinedConfiguration.java
Tue Dec  9 19:15:56 2008
@@ -37,10 +37,18 @@
 import org.apache.commons.configuration2.SubConfiguration;
 
 /**
- *
+ * DynamicCombinedConfiguration allows a set of CombinedConfigurations to be used. Each CombinedConfiguration
+ * is referenced by a key that is dynamically constructed from a key pattern on each call.
The key pattern
+ * will be resolved using the configured ConfigurationInterpolator.
+ * @since 1.6
+ * @author <a
+ * href="http://commons.apache.org/configuration/team-list.html">Commons
+ * Configuration team</a>
+ * @version $Id:  $
  */
 public class DynamicCombinedConfiguration extends CombinedConfiguration
 {
+    /** The CombinedConfigurations */
     private ConcurrentMap<String, CombinedConfiguration> configs =
             new ConcurrentHashMap<String, CombinedConfiguration>();
 
@@ -51,6 +59,7 @@
     private ConcurrentMap<String, AbstractConfiguration> namedConfigurations =
             new ConcurrentHashMap<String, AbstractConfiguration>();
 
+    /** The key pattern for the CombinedConfiguration map */
     private String keyPattern;
 
     /** Stores the combiner. */
@@ -231,7 +240,7 @@
     {
         for (int index = 0; index < getNumberOfConfigurations(); index++)
         {
-            if (((configurations.get(index)).getConfiguration() == config))
+            if ((configurations.get(index)).getConfiguration() == config)
             {
                 removeConfigurationAt(index);
 
@@ -725,20 +734,20 @@
     {
         String key = getSubstitutor().replace(keyPattern);
         CombinedConfiguration config;
-        synchronized(getNodeCombiner())
+        synchronized (getNodeCombiner())
         {
             config = configs.get(key);
             if (config == null)
             {
                 config = new CombinedConfiguration(getNodeCombiner());
                 config.setExpressionEngine(this.getExpressionEngine());
-                for (ConfigurationErrorListener listener :
-                        (Collection<ConfigurationErrorListener>)config.getErrorListeners())
+                for (ConfigurationErrorListener listener
+                        : (Collection<ConfigurationErrorListener>) config.getErrorListeners())
                 {
                     config.addErrorListener(listener);
                 }
-                for (ConfigurationListener listener :
-                        (Collection<ConfigurationListener>)config.getConfigurationListeners())
+                for (ConfigurationListener listener
+                        : (Collection<ConfigurationListener>) config.getConfigurationListeners())
                 {
                     config.addConfigurationListener(listener);
                 }
@@ -755,9 +764,12 @@
     }
 
 
+    /**
+     * Internal class that identifies each Configuration.
+     */
     class ConfigData
     {
-                /** Stores a reference to the configuration. */
+        /** Stores a reference to the configuration. */
         private AbstractHierarchicalConfiguration configuration;
 
         /** Stores the name under which the configuration is stored. */
@@ -766,7 +778,7 @@
         /** Stores the at string.*/
         private String at;
 
-                /**
+        /**
          * Creates a new instance of <code>ConfigData</code> and initializes
          * it.
          *



Mime
View raw message