From 9baf9cdc2f6d2f2a38893f1e685099b0c570570f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sun, 12 Apr 2009 20:59:52 +0000 Subject: [PATCH] reintroduced "removeApplicationListener" method as well --- .../AbstractApplicationEventMulticaster.java | 12 ++++++--- .../event/ApplicationEventMulticaster.java | 25 ++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/org.springframework.context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java b/org.springframework.context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java index f9a96f16bf..fa2106c642 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java +++ b/org.springframework.context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java @@ -45,12 +45,10 @@ import org.springframework.core.OrderComparator; * * @author Juergen Hoeller * @since 1.2.3 - * @see #setCollectionClass * @see #getApplicationListeners() * @see SimpleApplicationEventMulticaster */ -public abstract class AbstractApplicationEventMulticaster - implements ApplicationEventMulticaster, BeanFactoryAware { +public abstract class AbstractApplicationEventMulticaster implements ApplicationEventMulticaster, BeanFactoryAware { private final ListenerRetriever defaultRetriever = new ListenerRetriever(); @@ -68,6 +66,14 @@ public abstract class AbstractApplicationEventMulticaster this.defaultRetriever.applicationListenerBeans.add(listenerBeanName); } + public void removeApplicationListener(ApplicationListener listener) { + this.defaultRetriever.applicationListeners.remove(listener); + } + + public void removeApplicationListenerBean(String listenerBeanName) { + this.defaultRetriever.applicationListenerBeans.remove(listenerBeanName); + } + public void removeAllListeners() { this.defaultRetriever.applicationListeners.clear(); this.defaultRetriever.applicationListenerBeans.clear(); diff --git a/org.springframework.context/src/main/java/org/springframework/context/event/ApplicationEventMulticaster.java b/org.springframework.context/src/main/java/org/springframework/context/event/ApplicationEventMulticaster.java index ec7de14de7..6a2f2cd745 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/event/ApplicationEventMulticaster.java +++ b/org.springframework.context/src/main/java/org/springframework/context/event/ApplicationEventMulticaster.java @@ -20,11 +20,12 @@ import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; /** - * Interface to be implemented by objects that can manage a number - * of ApplicationListeners, and publish events to them. An example - * of such an object is an ApplicationEventPublisher, typically - * the ApplicationContext, which can use an ApplicationEventMulticaster - * as a helper to publish events to listeners. + * Interface to be implemented by objects that can manage a number of + * {@link ApplicationListener} objects, and publish events to them. + * + *

An {@link org.springframework.context.ApplicationEventPublisher}, typically + * a Spring {@link org.springframework.context.ApplicationContext}, can use an + * ApplicationEventMulticaster as a delegate for actually publishing events. * * @author Rod Johnson * @author Juergen Hoeller @@ -38,11 +39,23 @@ public interface ApplicationEventMulticaster { void addApplicationListener(ApplicationListener listener); /** - * Add a listener to be notified of all events. + * Add a listener bean to be notified of all events. * @param listenerBeanName the name of the listener bean to add */ void addApplicationListenerBean(String listenerBeanName); + /** + * Remove a listener from the notification list. + * @param listener the listener to remove + */ + void removeApplicationListener(ApplicationListener listener); + + /** + * Remove a listener bean from the notification list. + * @param listenerBeanName the name of the listener bean to add + */ + void removeApplicationListenerBean(String listenerBeanName); + /** * Remove all listeners registered with this multicaster. *

After a remove call, the multicaster will perform no action