commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1438931 - /commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicConfigurationBuilder.java
Date Sat, 26 Jan 2013 18:05:00 GMT
Author: oheger
Date: Sat Jan 26 18:05:00 2013
New Revision: 1438931

URL: http://svn.apache.org/viewvc?rev=1438931&view=rev
Log:
BasicConfigurationBuilder now uses the new functionality of ConfigurationUtils for obtaining
an EventSource.

Modified:
    commons/proper/configuration/trunk/src/main/java/org/apache/commons/configuration/builder/BasicConfigurationBuilder.java

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=1438931&r1=1438930&r2=1438931&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
Sat Jan 26 18:05:00 2013
@@ -26,6 +26,7 @@ import java.util.Map;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.ConfigurationRuntimeException;
+import org.apache.commons.configuration.ConfigurationUtils;
 import org.apache.commons.configuration.beanutils.BeanDeclaration;
 import org.apache.commons.configuration.beanutils.BeanHelper;
 import org.apache.commons.configuration.beanutils.ConstructorArg;
@@ -99,32 +100,6 @@ import org.apache.commons.lang3.event.Ev
 public class BasicConfigurationBuilder<T extends Configuration> implements
         ConfigurationBuilder<T>
 {
-    /**
-     * A dummy event source that is used for registering listeners if no
-     * compatible result object is available. This source has empty dummy
-     * implementations for listener registration methods.
-     */
-    private static final EventSource DUMMY_EVENT_SOURCE = new EventSource()
-    {
-        public void addConfigurationListener(ConfigurationListener l)
-        {
-        }
-
-        public boolean removeConfigurationListener(ConfigurationListener l)
-        {
-            return false;
-        }
-
-        public void addErrorListener(ConfigurationErrorListener l)
-        {
-        }
-
-        public boolean removeErrorListener(ConfigurationErrorListener l)
-        {
-            return false;
-        }
-    };
-
     /** The class of the objects produced by this builder instance. */
     private final Class<T> resultClass;
 
@@ -644,7 +619,7 @@ public class BasicConfigurationBuilder<T
      */
     private void registerEventListeners(T obj)
     {
-        EventSource evSrc = fetchEventSource(obj);
+        EventSource evSrc = ConfigurationUtils.asEventSource(obj, true);
         for (ConfigurationListener l : configListeners)
         {
             evSrc.addConfigurationListener(l);
@@ -664,7 +639,7 @@ public class BasicConfigurationBuilder<T
      */
     private EventSource fetchEventSource()
     {
-        return fetchEventSource(result);
+        return ConfigurationUtils.asEventSource(result, true);
     }
 
     /**
@@ -706,18 +681,4 @@ public class BasicConfigurationBuilder<T
         }
         return filteredMap;
     }
-
-    /**
-     * Returns an {@code EventSource} for the specified object. If the object is
-     * an {@code EventSource}, it is returned. Otherwise, a dummy event source
-     * is returned.
-     *
-     * @param obj the object in question
-     * @return an {@code EventSource} for this object
-     */
-    private static EventSource fetchEventSource(Object obj)
-    {
-        return (obj instanceof EventSource) ? (EventSource) obj
-                : DUMMY_EVENT_SOURCE;
-    }
 }



Mime
View raw message