Java 类org.springframework.context.event.SimpleApplicationEventMulticaster 实例源码

项目:lams    文件:AbstractApplicationContext.java   
/**
 * Initialize the ApplicationEventMulticaster.
 * Uses SimpleApplicationEventMulticaster if none defined in the context.
 * @see org.springframework.context.event.SimpleApplicationEventMulticaster
 */
protected void initApplicationEventMulticaster() {
    ConfigurableListableBeanFactory beanFactory = getBeanFactory();
    if (beanFactory.containsLocalBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME)) {
        this.applicationEventMulticaster =
                beanFactory.getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class);
        if (logger.isDebugEnabled()) {
            logger.debug("Using ApplicationEventMulticaster [" + this.applicationEventMulticaster + "]");
        }
    }
    else {
        this.applicationEventMulticaster = new SimpleApplicationEventMulticaster(beanFactory);
        beanFactory.registerSingleton(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, this.applicationEventMulticaster);
        if (logger.isDebugEnabled()) {
            logger.debug("Unable to locate ApplicationEventMulticaster with name '" +
                    APPLICATION_EVENT_MULTICASTER_BEAN_NAME +
                    "': using default [" + this.applicationEventMulticaster + "]");
        }
    }
}
项目:spring4-understanding    文件:AbstractApplicationContext.java   
/**
 * Initialize the ApplicationEventMulticaster.
 * Uses SimpleApplicationEventMulticaster if none defined in the context.
 * @see org.springframework.context.event.SimpleApplicationEventMulticaster
 */
protected void initApplicationEventMulticaster() {
    ConfigurableListableBeanFactory beanFactory = getBeanFactory();
    if (beanFactory.containsLocalBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME)) {
        this.applicationEventMulticaster =
                beanFactory.getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class);
        if (logger.isDebugEnabled()) {
            logger.debug("Using ApplicationEventMulticaster [" + this.applicationEventMulticaster + "]");
        }
    }
    else {
        this.applicationEventMulticaster = new SimpleApplicationEventMulticaster(beanFactory);
        beanFactory.registerSingleton(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, this.applicationEventMulticaster);
        if (logger.isDebugEnabled()) {
            logger.debug("Unable to locate ApplicationEventMulticaster with name '" +
                    APPLICATION_EVENT_MULTICASTER_BEAN_NAME +
                    "': using default [" + this.applicationEventMulticaster + "]");
        }
    }
}
项目:my-spring-cache-redis    文件:AbstractApplicationContext.java   
/**
 * Initialize the ApplicationEventMulticaster.
 * Uses SimpleApplicationEventMulticaster if none defined in the context.
 * @see org.springframework.context.event.SimpleApplicationEventMulticaster
 */
protected void initApplicationEventMulticaster() {
    ConfigurableListableBeanFactory beanFactory = getBeanFactory();
    if (beanFactory.containsLocalBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME)) {
        this.applicationEventMulticaster =
                beanFactory.getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class);
        if (logger.isDebugEnabled()) {
            logger.debug("Using ApplicationEventMulticaster [" + this.applicationEventMulticaster + "]");
        }
    }
    else {
        this.applicationEventMulticaster = new SimpleApplicationEventMulticaster(beanFactory);
        beanFactory.registerSingleton(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, this.applicationEventMulticaster);
        if (logger.isDebugEnabled()) {
            logger.debug("Unable to locate ApplicationEventMulticaster with name '" +
                    APPLICATION_EVENT_MULTICASTER_BEAN_NAME +
                    "': using default [" + this.applicationEventMulticaster + "]");
        }
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DelegatingApplicationListener.java   
@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);
    }
}
项目:spring    文件:AbstractApplicationContext.java   
/**
 * Initialize the ApplicationEventMulticaster.
 * Uses SimpleApplicationEventMulticaster if none defined in the context.
 * @see org.springframework.context.event.SimpleApplicationEventMulticaster
 */
protected void initApplicationEventMulticaster() {
    ConfigurableListableBeanFactory beanFactory = getBeanFactory();
    if (beanFactory.containsLocalBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME)) {
        this.applicationEventMulticaster =
                beanFactory.getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class);
        if (logger.isDebugEnabled()) {
            logger.debug("Using ApplicationEventMulticaster [" + this.applicationEventMulticaster + "]");
        }
    }
    else {
        this.applicationEventMulticaster = new SimpleApplicationEventMulticaster(beanFactory);
        beanFactory.registerSingleton(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, this.applicationEventMulticaster);
        if (logger.isDebugEnabled()) {
            logger.debug("Unable to locate ApplicationEventMulticaster with name '" +
                    APPLICATION_EVENT_MULTICASTER_BEAN_NAME +
                    "': using default [" + this.applicationEventMulticaster + "]");
        }
    }
}
项目:spring-boot-concourse    文件:DelegatingApplicationListener.java   
@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);
    }
}
项目:contestparser    文件:DelegatingApplicationListener.java   
@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);
    }
}
项目:class-guard    文件:AbstractApplicationContext.java   
/**
 * Initialize the ApplicationEventMulticaster.
 * Uses SimpleApplicationEventMulticaster if none defined in the context.
 * @see org.springframework.context.event.SimpleApplicationEventMulticaster
 */
protected void initApplicationEventMulticaster() {
    ConfigurableListableBeanFactory beanFactory = getBeanFactory();
    if (beanFactory.containsLocalBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME)) {
        this.applicationEventMulticaster =
                beanFactory.getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class);
        if (logger.isDebugEnabled()) {
            logger.debug("Using ApplicationEventMulticaster [" + this.applicationEventMulticaster + "]");
        }
    }
    else {
        this.applicationEventMulticaster = new SimpleApplicationEventMulticaster(beanFactory);
        beanFactory.registerSingleton(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, this.applicationEventMulticaster);
        if (logger.isDebugEnabled()) {
            logger.debug("Unable to locate ApplicationEventMulticaster with name '" +
                    APPLICATION_EVENT_MULTICASTER_BEAN_NAME +
                    "': using default [" + this.applicationEventMulticaster + "]");
        }
    }
}
项目:spring-rich-client    文件:DefaultApplicationLifecycleAdvisorTests.java   
public void testApplicationEventNotification() throws Exception {
    TestAdvisor advisor = new TestAdvisor();
    advisor.afterPropertiesSet();
    Application.load(null);
    new Application(advisor);
    StaticApplicationContext applicationContext = new StaticApplicationContext();
    Application.instance().setApplicationContext(applicationContext);
    applicationContext.registerSingleton( "eventMulticaster", SimpleApplicationEventMulticaster.class );
    applicationContext.refresh();

    advisor.setWindowCommandBarDefinitions(
        "org/springframework/richclient/config/app-lifecycle-test-ctx.xml");

    // Fire up test.....
    advisor.testInit();

    TestCommand cmd = (TestCommand)advisor.getBeanFactory().getBean("testCommand");
    assertEquals("Command must be notified of refresh", 1, cmd.getCount());

    advisor.onApplicationEvent(new ApplicationEvent(this) {});
    assertEquals("Command must be notified", 2, cmd.getCount());
}
项目:spring-richclient    文件:DefaultApplicationLifecycleAdvisorTests.java   
public void testApplicationEventNotification() throws Exception {
    TestAdvisor advisor = new TestAdvisor();
    advisor.afterPropertiesSet();
    Application.load(null);
    new Application(advisor);
    StaticApplicationContext applicationContext = new StaticApplicationContext();
    Application.instance().setApplicationContext(applicationContext);
    applicationContext.registerSingleton( "eventMulticaster", SimpleApplicationEventMulticaster.class );
    applicationContext.refresh();

    advisor.setWindowCommandBarDefinitions(
        "org/springframework/richclient/config/app-lifecycle-test-ctx.xml");

    // Fire up test.....
    advisor.testInit();

    TestCommand cmd = (TestCommand)advisor.getBeanFactory().getBean("testCommand");
    assertEquals("Command must be notified of refresh", 1, cmd.getCount());

    advisor.onApplicationEvent(new ApplicationEvent(this) {});
    assertEquals("Command must be notified", 2, cmd.getCount());
}
项目:freqtrade-java    文件:FreqTradeConfiguration.java   
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
    SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();

    taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setThreadNamePrefix("asyncEventExecutor-");
    taskExecutor.setCorePoolSize(4);
    taskExecutor.initialize();

    eventMulticaster.setTaskExecutor(taskExecutor);
    return eventMulticaster;
}
项目:flow-platform    文件:AppConfig.java   
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
    multicasterExecutor.initialize();
    SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
    eventMulticaster.setTaskExecutor(multicasterExecutor);
    return eventMulticaster;
}
项目:metacat    文件:CommonServerConfig.java   
/**
 * A multicast (async) event publisher to replace the synchronous one used by Spring via the ApplicationContext.
 *
 * @param taskExecutor The task executor to use
 * @return The application event multicaster to use
 */
@Bean
public ApplicationEventMulticaster asyncEventMulticaster(final TaskExecutor taskExecutor) {
    final SimpleApplicationEventMulticaster applicationEventMulticaster = new SimpleApplicationEventMulticaster();
    applicationEventMulticaster.setTaskExecutor(taskExecutor);
    return applicationEventMulticaster;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EventPublishingRunListener.java   
public EventPublishingRunListener(SpringApplication application, String[] args) {
    this.application = application;
    this.args = args;
    this.initialMulticaster = new SimpleApplicationEventMulticaster();
    for (ApplicationListener<?> listener : application.getListeners()) {
        this.initialMulticaster.addApplicationListener(listener);
    }
}
项目:spring-boot-concourse    文件:EventPublishingRunListener.java   
public EventPublishingRunListener(SpringApplication application, String[] args) {
    this.application = application;
    this.args = args;
    this.initialMulticaster = new SimpleApplicationEventMulticaster();
    for (ApplicationListener<?> listener : application.getListeners()) {
        this.initialMulticaster.addApplicationListener(listener);
    }
}
项目:contestparser    文件:EventPublishingRunListener.java   
public EventPublishingRunListener(SpringApplication application, String[] args) {
    this.application = application;
    this.args = args;
    this.multicaster = new SimpleApplicationEventMulticaster();
    for (ApplicationListener<?> listener : application.getListeners()) {
        this.multicaster.addApplicationListener(listener);
    }
}
项目:hawkbit    文件:TestConfiguration.java   
@Bean(name = AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME)
SimpleApplicationEventMulticaster applicationEventMulticaster(final ApplicationEventFilter applicationEventFilter) {
    final SimpleApplicationEventMulticaster simpleApplicationEventMulticaster = new FilterEnabledApplicationEventPublisher(
            applicationEventFilter);
    simpleApplicationEventMulticaster.setTaskExecutor(asyncExecutor());
    return simpleApplicationEventMulticaster;
}
项目:hawkbit    文件:EventPublisherAutoConfiguration.java   
/**
 * Server internal event publisher that allows parallel event processing if
 * the event listener is marked as so.
 *
 * @return publisher bean
 */
@Bean(name = AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME)
public ApplicationEventMulticaster applicationEventMulticaster() {
    final SimpleApplicationEventMulticaster simpleApplicationEventMulticaster = new TenantAwareApplicationEventPublisher(
            tenantAware, applicationEventFilter());
    simpleApplicationEventMulticaster.setTaskExecutor(executor);
    return simpleApplicationEventMulticaster;
}
项目:gemini.blueprint    文件:ExtenderConfiguration.java   
private OsgiBundleApplicationContextEventMulticaster createDefaultEventMulticaster() {
    isMulticasterManagedInternally = true;
    return new OsgiBundleApplicationContextEventMulticasterAdapter(new SimpleApplicationEventMulticaster());
}
项目:flow-platform    文件:AppConfig.java   
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
    SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
    eventMulticaster.setTaskExecutor(executor);
    return eventMulticaster;
}
项目:message-gateway    文件:MessageGatewayConfiguration.java   
@Bean
public SimpleApplicationEventMulticaster applicationEventMulticaster() {
    final SimpleApplicationEventMulticaster multicaster = new SimpleApplicationEventMulticaster();
    multicaster.setTaskExecutor(new SimpleAsyncTaskExecutor());
    return multicaster;
}
项目:Catdogtion    文件:CatdogtionApplication.java   
@Bean(name = "applicationEventMulticaster")
public ApplicationEventMulticaster simpleApplicationEventMulticaster() {
  SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster();
  eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor());
  return eventMulticaster;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringApplicationTests.java   
@Bean(name = AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME)
public ApplicationEventMulticaster applicationEventMulticaster() {
    return spy(new SimpleApplicationEventMulticaster());
}
项目:spring-boot-concourse    文件:SpringApplicationTests.java   
@Bean(name = AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME)
public ApplicationEventMulticaster applicationEventMulticaster() {
    return spy(new SimpleApplicationEventMulticaster());
}
项目:contestparser    文件:SpringApplicationTests.java   
@Bean
public SimpleApplicationEventMulticaster applicationEventMulticaster() {
    return new SimpleApplicationEventMulticaster();
}
项目:spring-osgi    文件:ExtenderConfiguration.java   
private OsgiBundleApplicationContextEventMulticaster createDefaultEventMulticaster() {
    isMulticasterManagedInternally = true;
    return new OsgiBundleApplicationContextEventMulticasterAdapter(new SimpleApplicationEventMulticaster());
}