org.springframework.context.event.ApplicationEventMulticaster Java Examples
The following examples show how to use
org.springframework.context.event.ApplicationEventMulticaster.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractApplicationContext.java From spring-analysis-note with MIT License | 6 votes |
/** * Initialize the ApplicationEventMulticaster. * Uses SimpleApplicationEventMulticaster if none defined in the context. * @see org.springframework.context.event.SimpleApplicationEventMulticaster */ protected void initApplicationEventMulticaster() { ConfigurableListableBeanFactory beanFactory = getBeanFactory(); // 如有有自己注册class Name 是 applicationEventMulticaster,使用自定义广播器 if (beanFactory.containsLocalBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME)) { this.applicationEventMulticaster = beanFactory.getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class); if (logger.isTraceEnabled()) { logger.trace("Using ApplicationEventMulticaster [" + this.applicationEventMulticaster + "]"); } } else { // 没有自定义,使用默认的事件广播器 this.applicationEventMulticaster = new SimpleApplicationEventMulticaster(beanFactory); beanFactory.registerSingleton(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, this.applicationEventMulticaster); if (logger.isTraceEnabled()) { logger.trace("No '" + APPLICATION_EVENT_MULTICASTER_BEAN_NAME + "' bean, using " + "[" + this.applicationEventMulticaster.getClass().getSimpleName() + "]"); } } }
Example #2
Source File: AppConfig.java From flow-platform-x with Apache License 2.0 | 6 votes |
@Bean(name = "applicationEventMulticaster") public ApplicationEventMulticaster simpleApplicationEventMulticaster() { SimpleApplicationEventMulticaster multicaster = new SimpleApplicationEventMulticaster() { @Override public void multicastEvent(ApplicationEvent event, ResolvableType eventType) { if (event instanceof SyncEvent) { ResolvableType type = (eventType != null ? eventType : ResolvableType.forInstance(event)); for (final ApplicationListener<?> listener : getApplicationListeners(event, type)) { invokeListener(listener, event); } return; } super.multicastEvent(event, eventType); } }; SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor("s-event-"); multicaster.setTaskExecutor(executor); return multicaster; }
Example #3
Source File: AbstractApplicationContext.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * 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 + "]"); } } }
Example #4
Source File: AbstractApplicationContext.java From java-technology-stack with MIT License | 6 votes |
/** * 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.isTraceEnabled()) { logger.trace("Using ApplicationEventMulticaster [" + this.applicationEventMulticaster + "]"); } } else { this.applicationEventMulticaster = new SimpleApplicationEventMulticaster(beanFactory); beanFactory.registerSingleton(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, this.applicationEventMulticaster); if (logger.isTraceEnabled()) { logger.trace("No '" + APPLICATION_EVENT_MULTICASTER_BEAN_NAME + "' bean, using " + "[" + this.applicationEventMulticaster.getClass().getSimpleName() + "]"); } } }
Example #5
Source File: AbstractApplicationContext.java From lams with GNU General Public License v2.0 | 6 votes |
/** * 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 + "]"); } } }
Example #6
Source File: AsynchronousSpringEventsConfiguration.java From integration-patterns with MIT License | 5 votes |
@Bean(name = "applicationEventMulticaster") public ApplicationEventMulticaster simpleApplicationEventMulticaster() { final SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster(); // FIXME use fixed size thread pool eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor()); return eventMulticaster; }
Example #7
Source File: NotificationEventBusConfig.java From stream-registry with Apache License 2.0 | 5 votes |
@Bean(name = "zoneServiceEventEmitter") public NotificationEventEmitter<Zone> zoneServiceEventEmitter(ApplicationEventMulticaster applicationEventMulticaster) { return DefaultNotificationEventEmitter.<Zone>builder() .classType(Zone.class) .applicationEventMulticaster(applicationEventMulticaster) .build(); }
Example #8
Source File: InputAdaptersConfiguration.java From ddd-with-spring with Apache License 2.0 | 5 votes |
@Bean(name = "applicationEventMulticaster") public ApplicationEventMulticaster simpleApplicationEventMulticaster() { SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster(); eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor()); return eventMulticaster; }
Example #9
Source File: Application.java From daming with Apache License 2.0 | 5 votes |
@Bean(name = "applicationEventMulticaster") public ApplicationEventMulticaster simpleApplicationEventMulticaster() { SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster(); eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor()); return eventMulticaster; }
Example #10
Source File: ChildApplicationContextFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void publishEvent(ApplicationEvent event) { Assert.notNull(event, "Event must not be null"); if (logger.isTraceEnabled()) { logger.trace("Publishing event in " + getDisplayName() + ": " + event); } ((ApplicationEventMulticaster) getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME)).multicastEvent(event); if (!(getParent() == null || event instanceof ContextRefreshedEvent || event instanceof ContextClosedEvent)) { getParent().publishEvent(event); } }
Example #11
Source File: AsynchronousSpringEventsConfig.java From wetech-admin with MIT License | 5 votes |
@Bean(name = "applicationEventMulticaster") public ApplicationEventMulticaster simpleApplicationEventMulticaster() { SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster(); eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor()); return eventMulticaster; }
Example #12
Source File: ApplicationListenerDetector.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void postProcessBeforeDestruction(Object bean, String beanName) { if (this.applicationContext != null && bean instanceof ApplicationListener) { ApplicationEventMulticaster multicaster = this.applicationContext.getApplicationEventMulticaster(); multicaster.removeApplicationListener((ApplicationListener<?>) bean); multicaster.removeApplicationListenerBean(beanName); } }
Example #13
Source File: AbstractApplicationContext.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Return the internal ApplicationEventMulticaster used by the context. * @return the internal ApplicationEventMulticaster (never {@code null}) * @throws IllegalStateException if the context has not been initialized yet */ ApplicationEventMulticaster getApplicationEventMulticaster() throws IllegalStateException { if (this.applicationEventMulticaster == null) { throw new IllegalStateException("ApplicationEventMulticaster not initialized - " + "call 'refresh' before multicasting events via the context: " + this); } return this.applicationEventMulticaster; }
Example #14
Source File: NotificationEventBusConfig.java From stream-registry with Apache License 2.0 | 5 votes |
@Bean(name = "streamServiceEventEmitter") public NotificationEventEmitter<Stream> streamServiceEventEmitter(ApplicationEventMulticaster applicationEventMulticaster) { return DefaultNotificationEventEmitter.<Stream>builder() .classType(Stream.class) .applicationEventMulticaster(applicationEventMulticaster) .build(); }
Example #15
Source File: MetacatApplicationEventMulticaster.java From metacat with Apache License 2.0 | 5 votes |
private ApplicationEventMulticaster createApplicationEventMultiCaster(final String name) { final SimpleApplicationEventMulticaster result = new SimpleApplicationEventMulticaster(); final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(metacatProperties.getEvent().getBus().getExecutor().getThread().getCount()); executor.initialize(); RegistryUtil.registerThreadPool(registry, "metacat.event.pool." + name, executor.getThreadPoolExecutor()); result.setTaskExecutor(executor); return result; }
Example #16
Source File: AbstractApplicationContext.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Return the internal ApplicationEventMulticaster used by the context. * @return the internal ApplicationEventMulticaster (never {@code null}) * @throws IllegalStateException if the context has not been initialized yet */ ApplicationEventMulticaster getApplicationEventMulticaster() throws IllegalStateException { if (this.applicationEventMulticaster == null) { throw new IllegalStateException("ApplicationEventMulticaster not initialized - " + "call 'refresh' before multicasting events via the context: " + this); } return this.applicationEventMulticaster; }
Example #17
Source File: PostProcessorRegistrationDelegate.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public void postProcessBeforeDestruction(Object bean, String beanName) { if (bean instanceof ApplicationListener) { ApplicationEventMulticaster multicaster = this.applicationContext.getApplicationEventMulticaster(); multicaster.removeApplicationListener((ApplicationListener<?>) bean); multicaster.removeApplicationListenerBean(beanName); } }
Example #18
Source File: EventPublisherAutoConfiguration.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
/** * 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) ApplicationEventMulticaster applicationEventMulticaster(@Qualifier("asyncExecutor") final Executor executor, final TenantAware tenantAware) { final SimpleApplicationEventMulticaster simpleApplicationEventMulticaster = new TenantAwareApplicationEventPublisher( tenantAware, applicationEventFilter()); simpleApplicationEventMulticaster.setTaskExecutor(executor); return simpleApplicationEventMulticaster; }
Example #19
Source File: AsynchronousSpringEventConfiguration.java From data-prep with Apache License 2.0 | 5 votes |
@Bean(name = "applicationEventMulticaster") public ApplicationEventMulticaster simpleApplicationEventMulticaster() { SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster(); eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor()); return eventMulticaster; }
Example #20
Source File: DefaultNotificationEventEmitter.java From stream-registry with Apache License 2.0 | 5 votes |
@Builder private DefaultNotificationEventEmitter(Class<T> classType, ApplicationEventMulticaster applicationEventMulticaster) { Objects.requireNonNull(applicationEventMulticaster, "ApplicationEventMulticaster can not be null"); this.classType = Optional.ofNullable(classType) .filter(SUPPORTED_ENTITY_CLASSES::contains) .orElseThrow(() -> typeException(classType)); this.applicationEventMulticaster = applicationEventMulticaster; }
Example #21
Source File: AbstractApplicationContext.java From spring-analysis-note with MIT License | 5 votes |
/** * Return the internal ApplicationEventMulticaster used by the context. * @return the internal ApplicationEventMulticaster (never {@code null}) * @throws IllegalStateException if the context has not been initialized yet */ ApplicationEventMulticaster getApplicationEventMulticaster() throws IllegalStateException { if (this.applicationEventMulticaster == null) { throw new IllegalStateException("ApplicationEventMulticaster not initialized - " + "call 'refresh' before multicasting events via the context: " + this); } return this.applicationEventMulticaster; }
Example #22
Source File: ButlerConfig.java From cf-butler with Apache License 2.0 | 5 votes |
@Bean(name = "applicationEventMulticaster") public ApplicationEventMulticaster simpleApplicationEventMulticaster() { SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster(); eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor()); return eventMulticaster; }
Example #23
Source File: ApplicationListenerDetector.java From java-technology-stack with MIT License | 5 votes |
@Override public void postProcessBeforeDestruction(Object bean, String beanName) { if (bean instanceof ApplicationListener) { try { 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 } } }
Example #24
Source File: AbstractApplicationContext.java From java-technology-stack with MIT License | 5 votes |
/** * Return the internal ApplicationEventMulticaster used by the context. * @return the internal ApplicationEventMulticaster (never {@code null}) * @throws IllegalStateException if the context has not been initialized yet */ ApplicationEventMulticaster getApplicationEventMulticaster() throws IllegalStateException { if (this.applicationEventMulticaster == null) { throw new IllegalStateException("ApplicationEventMulticaster not initialized - " + "call 'refresh' before multicasting events via the context: " + this); } return this.applicationEventMulticaster; }
Example #25
Source File: NotificationEventListenerTest.java From stream-registry with Apache License 2.0 | 5 votes |
@Bean public ApplicationEventMulticaster simpleApplicationEventMulticaster() { SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster(); eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor()); return eventMulticaster; }
Example #26
Source File: NotificationEventListenerKafkaIntegrationTest.java From stream-registry with Apache License 2.0 | 5 votes |
@Bean public ApplicationEventMulticaster simpleApplicationEventMulticaster() { SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster(); eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor()); return eventMulticaster; }
Example #27
Source File: ApplicationListenerDetector.java From spring-analysis-note with MIT License | 5 votes |
@Override public void postProcessBeforeDestruction(Object bean, String beanName) { if (bean instanceof ApplicationListener) { try { 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 } } }
Example #28
Source File: NotificationEventBusConfig.java From stream-registry with Apache License 2.0 | 5 votes |
@Bean(name = "applicationEventMulticaster") public ApplicationEventMulticaster simpleApplicationEventMulticaster() { SimpleApplicationEventMulticaster eventMulticaster = new SimpleApplicationEventMulticaster(); eventMulticaster.setTaskExecutor(new SimpleAsyncTaskExecutor()); return eventMulticaster; }
Example #29
Source File: NotificationEventBusConfig.java From stream-registry with Apache License 2.0 | 5 votes |
@Bean(name = "consumerBindingServiceEventEmitter") public NotificationEventEmitter<ConsumerBinding> consumerBindingServiceEventEmitter(ApplicationEventMulticaster applicationEventMulticaster) { return DefaultNotificationEventEmitter.<ConsumerBinding>builder() .classType(ConsumerBinding.class) .applicationEventMulticaster(applicationEventMulticaster) .build(); }
Example #30
Source File: NotificationEventBusConfig.java From stream-registry with Apache License 2.0 | 5 votes |
@Bean(name = "consumerServiceEventEmitter") public NotificationEventEmitter<Consumer> consumerServiceEventEmitter(ApplicationEventMulticaster applicationEventMulticaster) { return DefaultNotificationEventEmitter.<Consumer>builder() .classType(Consumer.class) .applicationEventMulticaster(applicationEventMulticaster) .build(); }