Class DeferredApplicationEventPublisher
- java.lang.Object
-
- io.microsphere.spring.context.event.DeferredApplicationEventPublisher
-
- All Implemented Interfaces:
java.util.EventListener,org.springframework.context.ApplicationEventPublisher,org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
public class DeferredApplicationEventPublisher extends java.lang.Object implements org.springframework.context.ApplicationEventPublisher, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>Before Spring Framework 4.2,AbstractApplicationContextis an implementation ofApplicationEventPublishercan't handle the earlyeventthat ispublishedbeforeApplicationEventMulticaster's initialization, in this scenario,DeferredApplicationEventPublisheris introduced and used to resolvepublishEvent(ApplicationEvent)too early to publishApplicationEventwhenSpring ApplicationContexts' ApplicationEventMulticasteris not ready. First,DeferredApplicationEventPublisherstores these early events temporarily, and thenre-publishthem onApplication context is ready.In contrast, If current runtime is based on Spring Framework that
supports early application events,DeferredApplicationEventPublisheronly delegates theApplication Contextthat was injected byconstructor.- Since:
- 1.0.0
- Author:
- Mercy
-
-
Constructor Summary
Constructors Constructor Description DeferredApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidonApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)voidpublishEvent(java.lang.Object event)Current method will not be invoked before Spring 4.2voidpublishEvent(org.springframework.context.ApplicationEvent event)protected booleansupportsPublishEventMethod()
-
-
-
Method Detail
-
supportsPublishEventMethod
protected boolean supportsPublishEventMethod()
-
publishEvent
public void publishEvent(org.springframework.context.ApplicationEvent event)
- Specified by:
publishEventin interfaceorg.springframework.context.ApplicationEventPublisher
-
publishEvent
public void publishEvent(java.lang.Object event)
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>
-
-