Example usage for org.springframework.context.event ApplicationEventMulticaster removeApplicationListener

List of usage examples for org.springframework.context.event ApplicationEventMulticaster removeApplicationListener

Introduction

In this page you can find the example usage for org.springframework.context.event ApplicationEventMulticaster removeApplicationListener.

Prototype

void removeApplicationListener(ApplicationListener<?> listener);

Source Link

Document

Remove a listener from the notification list.

Usage

From source file:org.springframework.context.support.ApplicationListenerDetector.java

@Override
public void postProcessBeforeDestruction(Object bean, String beanName) {
    if (bean instanceof ApplicationListener) {
        try {/*w  w  w  . j av  a 2  s .c o m*/
            ApplicationEventMulticaster multicaster = this.applicationContext.getApplicationEventMulticaster();
            multicaster.removeApplicationListener((ApplicationListener<?>) bean);
            multicaster.removeApplicationListenerBean(beanName);
        } catch (IllegalStateException ex) {
            // ApplicationEventMulticaster not initialized yet - no need to remove a listener
        }
    }
}