Class DeferredApplicationEventPublisher
java.lang.Object
io.microsphere.spring.context.event.DeferredApplicationEventPublisher
- All Implemented Interfaces:
EventListener,org.springframework.context.ApplicationEventPublisher,org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
public class DeferredApplicationEventPublisher
extends Object
implements org.springframework.context.ApplicationEventPublisher, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
Before Spring Framework 4.2,
AbstractApplicationContext is an implementation of ApplicationEventPublisher
can't handle the early event that is published
before ApplicationEventMulticaster's initialization, in this scenario, DeferredApplicationEventPublisher
is introduced and used to resolve publishEvent(ApplicationEvent) too early
to publish ApplicationEvent when Spring ApplicationContexts' ApplicationEventMulticaster is not ready.
First, DeferredApplicationEventPublisher stores these early events temporarily, and then
re-publish them on Application context is ready.
In contrast, If current runtime is based on Spring Framework that supports
early application events, DeferredApplicationEventPublisher only delegates the
Application Context that was injected by
constructor.
- Since:
- 1.0.0
- Author:
- Mercy
-
Constructor Summary
ConstructorsConstructorDescriptionDeferredApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher delegate) -
Method Summary
Modifier and TypeMethodDescriptionvoidonApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event) voidpublishEvent(Object event) Current method will not be invoked before Spring 4.2voidpublishEvent(org.springframework.context.ApplicationEvent event) protected booleanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
-
Constructor Details
-
DeferredApplicationEventPublisher
public DeferredApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher delegate) - Parameters:
delegate-ApplicationEventPublisher
-
-
Method Details
-
supportsPublishEventMethod
protected boolean supportsPublishEventMethod() -
publishEvent
public void publishEvent(org.springframework.context.ApplicationEvent event) - Specified by:
publishEventin interfaceorg.springframework.context.ApplicationEventPublisher
-
publishEvent
Current method will not be invoked before Spring 4.2- Specified by:
publishEventin interfaceorg.springframework.context.ApplicationEventPublisher- Parameters:
event- theApplicationEventor the payload ofevent
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event) - Specified by:
onApplicationEventin interfaceorg.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
-