Author: oheger
Date: Fri Jul 11 20:29:52 2014
New Revision: 1609812
URL: http://svn.apache.org/r1609812
Log:
Added a clearEventListeners() method to BaseEventSource.
This method replaces the clearConfigurationListeners() method.
Modified:
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/BaseEventSource.java
commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/event/TestEventSource.java
Modified:
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/BaseEventSource.java
URL:
http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/BaseEventSource.java?rev=1609812&r1=1609811&r2=1609812&view=diff
==============================================================================
---
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/BaseEventSource.java
(original)
+++
commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/BaseEventSource.java
Fri Jul 11 20:29:52 2014
@@ -147,7 +147,9 @@ public class BaseEventSource implements
/**
* Removes all registered configuration listeners.
+ * @deprecated Use clearEventListeners()
*/
+ @Deprecated
public void clearConfigurationListeners()
{
listeners.clear();
@@ -215,6 +217,14 @@ public class BaseEventSource implements
}
/**
+ * Removes all registered event listeners.
+ */
+ public void clearEventListeners()
+ {
+ eventListeners.clear();
+ }
+
+ /**
* Removes all registered error listeners.
*
* @since 1.4
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=1609812&r1=1609811&r2=1609812&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
Fri Jul 11 20:29:52 2014
@@ -342,6 +342,25 @@ public class TestEventSource
}
/**
+ * Tests whether all event listeners can be removed.
+ */
+ @Test
+ public void testClearEventListeners()
+ {
+ source.addEventListener(ConfigurationEvent.ANY,
+ new EventListenerTestImpl(source));
+ source.addEventListener(ConfigurationEvent.ANY_HIERARCHICAL,
+ new EventListenerTestImpl(source));
+
+ source.clearEventListeners();
+ assertTrue("Got ANY listeners",
+ source.getEventListeners(ConfigurationEvent.ANY).isEmpty());
+ assertTrue("Got HIERARCHICAL listeners",
+ source.getEventListeners(ConfigurationEvent.ANY_HIERARCHICAL)
+ .isEmpty());
+ }
+
+ /**
* A test event listener implementation.
*/
static class TestListener implements ConfigurationListener,