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 2014/07/11 22:17:59 UTC

svn commit: r1609793 - /commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/BaseEventSource.java

Author: oheger
Date: Fri Jul 11 20:17:59 2014
New Revision: 1609793

URL: http://svn.apache.org/r1609793
Log:
Added an alternative method for querying event listeners.

The new method is more generic and allows filtering by an event type. The old
method for querying configuration listeners has been deprecated.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/event/BaseEventSource.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=1609793&r1=1609792&r2=1609793&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:17:59 2014
@@ -20,6 +20,8 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
@@ -114,12 +116,37 @@ public class BaseEventSource implements 
      * of the currently registered listeners; manipulating it has no effect
      * on this event source object)
      */
+    @Deprecated
     public Collection<ConfigurationListener> getConfigurationListeners()
     {
         return Collections.unmodifiableCollection(new ArrayList<ConfigurationListener>(listeners));
     }
 
     /**
+     * Returns a collection with all event listeners of the specified event type
+     * that are currently registered at this object.
+     *
+     * @param eventType the event type object
+     * @param <T> the event type
+     * @return a collection with the event listeners of the specified event type
+     *         (this collection is a snapshot of the currently registered
+     *         listeners; manipulating it has no effect on this event source
+     *         object)
+     */
+    public <T extends Event> Collection<EventListener<? super T>> getEventListeners(
+            EventType<T> eventType)
+    {
+        List<EventListener<? super T>> result =
+                new LinkedList<EventListener<? super T>>();
+        for (EventListener<? super T> l : eventListeners
+                .getEventListeners(eventType))
+        {
+            result.add(l);
+        }
+        return result;
+    }
+
+    /**
      * Removes all registered configuration listeners.
      */
     public void clearConfigurationListeners()