reintroduced "removeApplicationListener" method as well

master
Juergen Hoeller 16 years ago
parent af6457a67d
commit 9baf9cdc2f
  1. 12
      org.springframework.context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java
  2. 25
      org.springframework.context/src/main/java/org/springframework/context/event/ApplicationEventMulticaster.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();

@ -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.
*
* <p>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.
* <p>After a remove call, the multicaster will perform no action

Loading…
Cancel
Save