Search in sources :

Example 6 with ApplicationListener

use of org.springframework.context.ApplicationListener in project spring-boot by spring-projects.

the class RemoteSpringApplication method getListeners.

private Collection<ApplicationListener<?>> getListeners() {
    List<ApplicationListener<?>> listeners = new ArrayList<>();
    listeners.add(new AnsiOutputApplicationListener());
    listeners.add(new ConfigFileApplicationListener());
    listeners.add(new ClasspathLoggingApplicationListener());
    listeners.add(new LoggingApplicationListener());
    listeners.add(new RemoteUrlPropertyExtractor());
    return listeners;
}
Also used : ArrayList(java.util.ArrayList) ClasspathLoggingApplicationListener(org.springframework.boot.context.logging.ClasspathLoggingApplicationListener) ApplicationListener(org.springframework.context.ApplicationListener) AnsiOutputApplicationListener(org.springframework.boot.context.config.AnsiOutputApplicationListener) LoggingApplicationListener(org.springframework.boot.context.logging.LoggingApplicationListener) ConfigFileApplicationListener(org.springframework.boot.context.config.ConfigFileApplicationListener) ConfigFileApplicationListener(org.springframework.boot.context.config.ConfigFileApplicationListener) AnsiOutputApplicationListener(org.springframework.boot.context.config.AnsiOutputApplicationListener) ClasspathLoggingApplicationListener(org.springframework.boot.context.logging.ClasspathLoggingApplicationListener) LoggingApplicationListener(org.springframework.boot.context.logging.LoggingApplicationListener) ClasspathLoggingApplicationListener(org.springframework.boot.context.logging.ClasspathLoggingApplicationListener)

Example 7 with ApplicationListener

use of org.springframework.context.ApplicationListener in project spring-boot by spring-projects.

the class DelegatingApplicationListener method onApplicationEvent.

@Override
public void onApplicationEvent(ApplicationEvent event) {
    if (event instanceof ApplicationEnvironmentPreparedEvent) {
        List<ApplicationListener<ApplicationEvent>> delegates = getListeners(((ApplicationEnvironmentPreparedEvent) event).getEnvironment());
        if (delegates.isEmpty()) {
            return;
        }
        this.multicaster = new SimpleApplicationEventMulticaster();
        for (ApplicationListener<ApplicationEvent> listener : delegates) {
            this.multicaster.addApplicationListener(listener);
        }
    }
    if (this.multicaster != null) {
        this.multicaster.multicastEvent(event);
    }
}
Also used : SimpleApplicationEventMulticaster(org.springframework.context.event.SimpleApplicationEventMulticaster) ApplicationListener(org.springframework.context.ApplicationListener) ApplicationEvent(org.springframework.context.ApplicationEvent) ApplicationEnvironmentPreparedEvent(org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent)

Aggregations

ApplicationListener (org.springframework.context.ApplicationListener)7 ArrayList (java.util.ArrayList)2 ApplicationEvent (org.springframework.context.ApplicationEvent)2 LinkedList (java.util.LinkedList)1 Test (org.junit.Test)1 Logger (org.slf4j.Logger)1 BeanFactory (org.springframework.beans.factory.BeanFactory)1 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)1 ConfigurableBeanFactory (org.springframework.beans.factory.config.ConfigurableBeanFactory)1 SpringApplicationBuilder (org.springframework.boot.builder.SpringApplicationBuilder)1 AnsiOutputApplicationListener (org.springframework.boot.context.config.AnsiOutputApplicationListener)1 ConfigFileApplicationListener (org.springframework.boot.context.config.ConfigFileApplicationListener)1 ApplicationEnvironmentPreparedEvent (org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent)1 ApplicationStartingEvent (org.springframework.boot.context.event.ApplicationStartingEvent)1 ClasspathLoggingApplicationListener (org.springframework.boot.context.logging.ClasspathLoggingApplicationListener)1 LoggingApplicationListener (org.springframework.boot.context.logging.LoggingApplicationListener)1 ApplicationContextException (org.springframework.context.ApplicationContextException)1 ApplicationEventMulticaster (org.springframework.context.event.ApplicationEventMulticaster)1 SimpleApplicationEventMulticaster (org.springframework.context.event.SimpleApplicationEventMulticaster)1 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)1