You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2009/10/01 08:20:28 UTC

svn commit: r820543 - in /commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base: ConfigurationSource.java FlatConfigurationSource.java HierarchicalConfigurationSource.java

Author: oheger
Date: Thu Oct  1 06:20:28 2009
New Revision: 820543

URL: http://svn.apache.org/viewvc?rev=820543&view=rev
Log:
Extracted a common base interface from the configuration source implementations.

Added:
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/ConfigurationSource.java   (with props)
Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatConfigurationSource.java
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/HierarchicalConfigurationSource.java

Added: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/ConfigurationSource.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/ConfigurationSource.java?rev=820543&view=auto
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/ConfigurationSource.java (added)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/ConfigurationSource.java Thu Oct  1 06:20:28 2009
@@ -0,0 +1,78 @@
+/*
+ * 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.base;
+
+/**
+ * <p>
+ * A base interface definition for sources of configuration settings.
+ * </p>
+ * <p>
+ * A {@code ConfigurationSource} provides access to configuration settings that
+ * are stored in a specific way. The actual storage scheme used by a concrete
+ * configuration source determines the way the properties can be accessed. For
+ * instance, some sources store their data as key-value pairs. They typically
+ * provide a map-like interface for accessing their content. Other sources are
+ * hierarchically organized and require a different interface.
+ * </p>
+ * <p>
+ * This base interface defines methods that are common to all variants of
+ * configuration sources. It allows treating different types of configuration
+ * sources in a uniform way as long as only these fundamental methods are
+ * involved. Because there are differences in the way the properties contained
+ * in the source are accessed, this interface does not define methods for
+ * reading or writing property values.
+ * </p>
+ *
+ * @author Commons Configuration team
+ * @version $Id$
+ */
+public interface ConfigurationSource
+{
+    /**
+     * Removes all properties contained in this {@code ConfigurationSource}.
+     */
+    void clear();
+
+    /**
+     * Adds a {@code ConfigurationSourceListener} for this {@code
+     * ConfigurationSource}. This listener will be notified about manipulations
+     * on this source. Support for event listeners is optional. An
+     * implementation can throw an {@code UnsupportedOperationException}
+     * exception.
+     *
+     * @param l the listener to be added (must not be <b>null</b>)
+     * @throws IllegalArgumentException if the listener is <b>null</b>
+     * @throws UnsupportedOperationException if this operation is not
+     *         implemented
+     */
+    void addConfigurationSourceListener(ConfigurationSourceListener l);
+
+    /**
+     * Removes the specified {@code ConfigurationSourceListener} from this
+     * {@code ConfigurationSource}. It will not receive notifications about
+     * changes on this source any more. The return value indicates whether the
+     * listener existed and could be removed. As was pointed out for
+     * {@link #addConfigurationSourceListener(ConfigurationSourceListener)},
+     * this is an optional operation.
+     *
+     * @param l the listener to be removed
+     * @return a flag whether the listener could be removed
+     * @throws UnsupportedOperationException if this operation is not
+     *         implemented
+     */
+    boolean removeConfigurationSourceListener(ConfigurationSourceListener l);
+}

Propchange: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/ConfigurationSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/ConfigurationSource.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/ConfigurationSource.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatConfigurationSource.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatConfigurationSource.java?rev=820543&r1=820542&r2=820543&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatConfigurationSource.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/FlatConfigurationSource.java Thu Oct  1 06:20:28 2009
@@ -61,7 +61,7 @@
  * @author Commons Configuration team
  * @version $Id$
  */
-public interface FlatConfigurationSource
+public interface FlatConfigurationSource extends ConfigurationSource
 {
     /**
      * Checks if the configuration is empty. This is an optional operation. It
@@ -126,11 +126,6 @@
     void clearProperty(String key);
 
     /**
-     * Removes all properties from the configuration.
-     */
-    void clear();
-
-    /**
      * Gets a property from this configuration source. The return value is the
      * "raw" value of this property or <b>null</b> if the property is not
      * contained in this configuration source. For properties with multiple
@@ -209,34 +204,4 @@
      * @see #getProperty(String)
      */
     int valueCount(String key);
-
-    /**
-     * Adds a {@code ConfigurationSourceListener} for this {@code
-     * ConfigurationSource}. This listener will be notified about manipulations
-     * on this source. Support for event listeners is optional. An
-     * implementation can throw an {@code UnsupportedOperationException}
-     * exception. By using a wrapper that supports event notifications it is
-     * possible to monitor such a {@code ConfigurationSource}.
-     *
-     * @param l the listener to be added (must not be <b>null</b>)
-     * @throws IllegalArgumentException if the listener is <b>null</b>
-     * @throws UnsupportedOperationException if this operation is not
-     *         implemented
-     */
-    void addConfigurationSourceListener(ConfigurationSourceListener l);
-
-    /**
-     * Removes the specified {@code ConfigurationSourceListener} from this
-     * {@code ConfigurationSource}. It will not receive notifications about
-     * changes on this source any more. The return value indicates whether the
-     * listener existed and could be removed. As was pointed out for
-     * {@link #addConfigurationSourceListener(ConfigurationSourceListener)},
-     * this is an optional operation.
-     *
-     * @param l the listener to be removed
-     * @return a flag whether the listener could be removed
-     * @throws UnsupportedOperationException if this operation is not
-     *         implemented
-     */
-    boolean removeConfigurationSourceListener(ConfigurationSourceListener l);
 }

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/HierarchicalConfigurationSource.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/HierarchicalConfigurationSource.java?rev=820543&r1=820542&r2=820543&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/HierarchicalConfigurationSource.java (original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/base/HierarchicalConfigurationSource.java Thu Oct  1 06:20:28 2009
@@ -51,7 +51,7 @@
  * @param <T> the type of the nodes used by this hierarchical configuration
  *        source
  */
-public interface HierarchicalConfigurationSource<T>
+public interface HierarchicalConfigurationSource<T> extends ConfigurationSource
 {
     /**
      * Returns the {@code NodeHandler} for dealing with the nodes used by this
@@ -81,44 +81,4 @@
      * @throws IllegalArgumentException if the root node is <b>null</b>
      */
     void setRootNode(T root);
-
-    /**
-     * Removes all properties contained in this {@code
-     * HierarchicalConfigurationSource}. This is an optional operation. It can
-     * be implemented by removing the content of the root node.
-     *
-     * @throws UnsupportedOperationException if this operation is not
-     *         implemented
-     */
-    void clear();
-
-    /**
-     * Adds a {@code ConfigurationSourceListener} for this {@code
-     * HierarchicalConfigurationSource}. This listener will be notified about
-     * manipulations on this source. Support for event listeners is optional. An
-     * implementation can throw an {@code UnsupportedOperationException}
-     * exception.
-     *
-     * @param l the listener to be added (must not be <b>null</b>)
-     * @throws IllegalArgumentException if the listener is <b>null</b>
-     * @throws UnsupportedOperationException if this operation is not
-     *         implemented
-     */
-    void addConfigurationSourceListener(ConfigurationSourceListener l);
-
-    /**
-     * Removes the specified {@code ConfigurationSourceListener} from this
-     * {@code HierarchicalConfigurationSource}. It will not receive
-     * notifications about changes on this source any more. The return value
-     * indicates whether the listener existed and could be removed. As was
-     * pointed out for
-     * {@link #addConfigurationSourceListener(ConfigurationSourceListener)},
-     * this is an optional operation.
-     *
-     * @param l the listener to be removed
-     * @return a flag whether the listener could be removed
-     * @throws UnsupportedOperationException if this operation is not
-     *         implemented
-     */
-    boolean removeConfigurationSourceListener(ConfigurationSourceListener l);
 }