commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1405621 - in /commons/proper/configuration/trunk/src: changes/ main/java/org/apache/commons/configuration/ main/java/org/apache/commons/configuration/builder/ main/java/org/apache/commons/configuration/event/ test/java/org/apache/commons/c...
Date Sun, 04 Nov 2012 19:33:08 GMT
Author: oheger
Date: Sun Nov  4 19:33:08 2012
New Revision: 1405621

URL: http://svn.apache.org/viewvc?rev=1405621&view=rev
Log:
[CONFIGURATION-419] Made EventSource an interface.

Added:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/BaseEventSource.java
      - copied, changed from r1396283, commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java
  (with props)
Modified:
    commons/proper/configuration/trunk/src/changes/changes.xml
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractConfiguration.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/ConfigurationUtils.java
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicConfigurationBuilder.java
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestEventSource.java

Modified: commons/proper/configuration/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/changes/changes.xml?rev=1405621&r1=1405620&r2=1405621&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/changes/changes.xml (original)
+++ commons/proper/configuration/trunk/src/changes/changes.xml Sun Nov  4 19:33:08 2012
@@ -48,6 +48,10 @@
         XMLConfiguration now adds attributes of elements defining a list to
         all list nodes.
       </action>
+      <action dev="oheger" type="update" issue="CONFIGURATION-419">
+        EventSource is now an interface. With BaseEventSource there is a
+        default implementation.
+      </action>
     </release>
 
     <release version="1.9" date="2012-08-22"

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractConfiguration.java?rev=1405621&r1=1405620&r2=1405621&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractConfiguration.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/AbstractConfiguration.java
Sun Nov  4 19:33:08 2012
@@ -31,7 +31,7 @@ import java.util.Properties;
 
 import org.apache.commons.configuration.event.ConfigurationErrorEvent;
 import org.apache.commons.configuration.event.ConfigurationErrorListener;
-import org.apache.commons.configuration.event.EventSource;
+import org.apache.commons.configuration.event.BaseEventSource;
 import org.apache.commons.configuration.interpol.ConfigurationInterpolator;
 import org.apache.commons.lang.BooleanUtils;
 import org.apache.commons.lang.ClassUtils;
@@ -78,7 +78,7 @@ import org.apache.commons.logging.impl.N
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen </a>
  * @version $Id$
  */
-public abstract class AbstractConfiguration extends EventSource implements Configuration
+public abstract class AbstractConfiguration extends BaseEventSource implements Configuration
 {
     /**
      * Constant for the add property event type.

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/ConfigurationUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/ConfigurationUtils.java?rev=1405621&r1=1405620&r2=1405621&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/ConfigurationUtils.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/ConfigurationUtils.java
Sun Nov  4 19:33:08 2012
@@ -737,15 +737,14 @@ public final class ConfigurationUtils
      * each received error event.
      *
      * @param src the configuration, for which runtime exceptions are to be
-     * enabled; this configuration must be derived from
-     * {@link EventSource}
+     * enabled; this configuration must implement {@link EventSource}
      */
     public static void enableRuntimeExceptions(Configuration src)
     {
         if (!(src instanceof EventSource))
         {
             throw new IllegalArgumentException(
-                    "Configuration must be derived from EventSource!");
+                    "Configuration must implement EventSource!");
         }
         ((EventSource) src).addErrorListener(new ConfigurationErrorListener()
         {

Modified: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicConfigurationBuilder.java?rev=1405621&r1=1405620&r2=1405621&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicConfigurationBuilder.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicConfigurationBuilder.java
Sun Nov  4 19:33:08 2012
@@ -102,23 +102,19 @@ public class BasicConfigurationBuilder<T
      */
     private static final EventSource DUMMY_EVENT_SOURCE = new EventSource()
     {
-        @Override
         public void addConfigurationListener(ConfigurationListener l)
         {
         }
 
-        @Override
         public boolean removeConfigurationListener(ConfigurationListener l)
         {
             return false;
         }
 
-        @Override
         public void addErrorListener(ConfigurationErrorListener l)
         {
         }
 
-        @Override
         public boolean removeErrorListener(ConfigurationErrorListener l)
         {
             return false;

Copied: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/BaseEventSource.java
(from r1396283, commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java)
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/BaseEventSource.java?p2=commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/BaseEventSource.java&p1=commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java&r1=1396283&r2=1405621&rev=1405621&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java
(original)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/BaseEventSource.java
Sun Nov  4 19:33:08 2012
@@ -67,7 +67,7 @@ import java.util.concurrent.CopyOnWriteA
  * @version $Id$
  * @since 1.3
  */
-public class EventSource
+public class BaseEventSource implements EventSource
 {
     /** A collection for the registered event listeners. */
     private Collection<ConfigurationListener> listeners;
@@ -82,31 +82,19 @@ public class EventSource
     private int detailEvents;
 
     /**
-     * Creates a new instance of {@code EventSource}.
+     * Creates a new instance of {@code BaseEventSource}.
      */
-    public EventSource()
+    public BaseEventSource()
     {
         initListeners();
     }
 
-    /**
-     * Adds a configuration listener to this object.
-     *
-     * @param l the listener to add
-     */
     public void addConfigurationListener(ConfigurationListener l)
     {
         checkListener(l);
         listeners.add(l);
     }
 
-    /**
-     * Removes the specified event listener so that it does not receive any
-     * further events caused by this object.
-     *
-     * @param l the listener to be removed
-     * @return a flag whether the event listener was found
-     */
     public boolean removeConfigurationListener(ConfigurationListener l)
     {
         return listeners.remove(l);
@@ -168,27 +156,12 @@ public class EventSource
         }
     }
 
-    /**
-     * Adds a new configuration error listener to this object. This listener
-     * will then be notified about internal problems.
-     *
-     * @param l the listener to register (must not be <b>null</b>)
-     * @since 1.4
-     */
     public void addErrorListener(ConfigurationErrorListener l)
     {
         checkListener(l);
         errorListeners.add(l);
     }
 
-    /**
-     * Removes the specified error listener so that it does not receive any
-     * further events caused by this object.
-     *
-     * @param l the listener to remove
-     * @return a flag whether the listener could be found and removed
-     * @since 1.4
-     */
     public boolean removeErrorListener(ConfigurationErrorListener l)
     {
         return errorListeners.remove(l);
@@ -308,7 +281,7 @@ public class EventSource
      * Overrides the {@code clone()} method to correctly handle so far
      * registered event listeners. This implementation ensures that the clone
      * will have empty event listener lists, i.e. the listeners registered at an
-     * {@code EventSource} object will not be copied.
+     * {@code BaseEventSource} object will not be copied.
      *
      * @return the cloned object
      * @throws CloneNotSupportedException if cloning is not allowed
@@ -317,7 +290,7 @@ public class EventSource
     @Override
     protected Object clone() throws CloneNotSupportedException
     {
-        EventSource copy = (EventSource) super.clone();
+        BaseEventSource copy = (BaseEventSource) super.clone();
         copy.initListeners();
         return copy;
     }

Added: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java?rev=1405621&view=auto
==============================================================================
--- commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java
(added)
+++ commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java
Sun Nov  4 19:33:08 2012
@@ -0,0 +1,69 @@
+/*
+ * 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.event;
+
+/**
+ * <p>
+ * An interface for configuration implementations which support registration of
+ * event listeners.
+ * </p>
+ * <p>
+ * Through the methods provided by this interface it is possible to register and
+ * remove event listeners for configuration events. Both configuration change
+ * listeners and error listeners are supported.
+ * </p>
+ *
+ * @version $Id$
+ * @since 2.0
+ */
+public interface EventSource
+{
+    /**
+     * Adds a configuration listener to this object.
+     *
+     * @param l the listener to add
+     */
+    void addConfigurationListener(ConfigurationListener l);
+
+    /**
+     * Removes the specified event listener so that it does not receive any
+     * further events caused by this object.
+     *
+     * @param l the listener to be removed
+     * @return a flag whether the event listener was found
+     */
+    boolean removeConfigurationListener(ConfigurationListener l);
+
+    /**
+     * Adds a new configuration error listener to this object. This listener
+     * will then be notified about internal problems.
+     *
+     * @param l the listener to register (must not be <b>null</b>)
+     * @since 1.4
+     */
+    void addErrorListener(ConfigurationErrorListener l);
+
+    /**
+     * Removes the specified error listener so that it does not receive any
+     * further events caused by this object.
+     *
+     * @param l the listener to remove
+     * @return a flag whether the listener could be found and removed
+     * @since 1.4
+     */
+    boolean removeErrorListener(ConfigurationErrorListener l);
+}

Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/EventSource.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestEventSource.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestEventSource.java?rev=1405621&r1=1405620&r2=1405621&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestEventSource.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestEventSource.java
Sun Nov  4 19:33:08 2012
@@ -26,7 +26,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 /**
- * Test class for EventSource.
+ * Test class for BaseEventSource.
  *
  * @version $Id$
  */
@@ -331,7 +331,7 @@ public class TestEventSource
     {
         source.addConfigurationListener(new TestListener());
         source.addErrorListener(new TestListener());
-        EventSource copy = (EventSource) source.clone();
+        BaseEventSource copy = (BaseEventSource) source.clone();
         assertTrue("Configuration listeners registered for clone", copy
                 .getConfigurationListeners().isEmpty());
         assertTrue("Error listeners registered for clone", copy
@@ -369,7 +369,7 @@ public class TestEventSource
      * {@code fireEvent()} methods only creates event objects if
      * necessary. It also allows testing the clone() operation.
      */
-    static class CountingEventSource extends EventSource implements Cloneable
+    static class CountingEventSource extends BaseEventSource implements Cloneable
     {
         int eventCount;
 



Mime
View raw message