reintroduced "removeApplicationListener" method as well
This commit is contained in:
parent
af6457a67d
commit
9baf9cdc2f
|
|
@ -45,12 +45,10 @@ import org.springframework.core.OrderComparator;
|
||||||
*
|
*
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @since 1.2.3
|
* @since 1.2.3
|
||||||
* @see #setCollectionClass
|
|
||||||
* @see #getApplicationListeners()
|
* @see #getApplicationListeners()
|
||||||
* @see SimpleApplicationEventMulticaster
|
* @see SimpleApplicationEventMulticaster
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractApplicationEventMulticaster
|
public abstract class AbstractApplicationEventMulticaster implements ApplicationEventMulticaster, BeanFactoryAware {
|
||||||
implements ApplicationEventMulticaster, BeanFactoryAware {
|
|
||||||
|
|
||||||
private final ListenerRetriever defaultRetriever = new ListenerRetriever();
|
private final ListenerRetriever defaultRetriever = new ListenerRetriever();
|
||||||
|
|
||||||
|
|
@ -68,6 +66,14 @@ public abstract class AbstractApplicationEventMulticaster
|
||||||
this.defaultRetriever.applicationListenerBeans.add(listenerBeanName);
|
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() {
|
public void removeAllListeners() {
|
||||||
this.defaultRetriever.applicationListeners.clear();
|
this.defaultRetriever.applicationListeners.clear();
|
||||||
this.defaultRetriever.applicationListenerBeans.clear();
|
this.defaultRetriever.applicationListenerBeans.clear();
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,12 @@ import org.springframework.context.ApplicationEvent;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface to be implemented by objects that can manage a number
|
* Interface to be implemented by objects that can manage a number of
|
||||||
* of ApplicationListeners, and publish events to them. An example
|
* {@link ApplicationListener} objects, and publish events to them.
|
||||||
* of such an object is an ApplicationEventPublisher, typically
|
*
|
||||||
* the ApplicationContext, which can use an ApplicationEventMulticaster
|
* <p>An {@link org.springframework.context.ApplicationEventPublisher}, typically
|
||||||
* as a helper to publish events to listeners.
|
* a Spring {@link org.springframework.context.ApplicationContext}, can use an
|
||||||
|
* ApplicationEventMulticaster as a delegate for actually publishing events.
|
||||||
*
|
*
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
|
@ -38,11 +39,23 @@ public interface ApplicationEventMulticaster {
|
||||||
void addApplicationListener(ApplicationListener listener);
|
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
|
* @param listenerBeanName the name of the listener bean to add
|
||||||
*/
|
*/
|
||||||
void addApplicationListenerBean(String listenerBeanName);
|
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.
|
* Remove all listeners registered with this multicaster.
|
||||||
* <p>After a remove call, the multicaster will perform no action
|
* <p>After a remove call, the multicaster will perform no action
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue