Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3B59FD44A for ; Sun, 4 Nov 2012 19:33:35 +0000 (UTC) Received: (qmail 66885 invoked by uid 500); 4 Nov 2012 19:33:35 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 66822 invoked by uid 500); 4 Nov 2012 19:33:34 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 66815 invoked by uid 99); 4 Nov 2012 19:33:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Nov 2012 19:33:34 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Nov 2012 19:33:30 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 27F8B2388A5B for ; Sun, 4 Nov 2012 19:33:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@commons.apache.org From: oheger@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121104193309.27F8B2388A5B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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. + + EventSource is now an interface. With BaseEventSource there is a + default implementation. + Henning P. Schmiedehausen * @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 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 null) - * @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; + +/** + *

+ * An interface for configuration implementations which support registration of + * event listeners. + *

+ *

+ * 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. + *

+ * + * @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 null) + * @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;