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,AbstractApplicationContext
is an implementation ofApplicationEventPublisher
can't handle the earlyevent
that ispublished
beforeApplicationEventMulticaster
's initialization, in this scenario,DeferredApplicationEventPublisher
is introduced and used to resolvepublishEvent(ApplicationEvent)
too early to publishApplicationEvent
whenSpring ApplicationContexts' ApplicationEventMulticaster
is not ready. First,DeferredApplicationEventPublisher
stores these early events temporarily, and thenre-publish
them onApplication context is ready
.In contrast, If current runtime is based on Spring Framework that
supports early application events
,DeferredApplicationEventPublisher
only delegates theApplication Context
that 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 void
onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
void
publishEvent(java.lang.Object event)
Current method will not be invoked before Spring 4.2void
publishEvent(org.springframework.context.ApplicationEvent event)
protected boolean
supportsPublishEventMethod()
-
-
-
Method Detail
-
supportsPublishEventMethod
protected boolean supportsPublishEventMethod()
-
publishEvent
public void publishEvent(org.springframework.context.ApplicationEvent event)
- Specified by:
publishEvent
in interfaceorg.springframework.context.ApplicationEventPublisher
-
publishEvent
public void publishEvent(java.lang.Object event)
Current method will not be invoked before Spring 4.2- Specified by:
publishEvent
in interfaceorg.springframework.context.ApplicationEventPublisher
- Parameters:
event
- theApplicationEvent
or the payload ofevent
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
- Specified by:
onApplicationEvent
in interfaceorg.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
-
-