public class DeferredApplicationEventPublisher extends Object implements org.springframework.context.ApplicationEventPublisher, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
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.
| 构造器和说明 |
|---|
DeferredApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher delegate) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event) |
void |
publishEvent(org.springframework.context.ApplicationEvent event) |
void |
publishEvent(Object event)
Current method will not be invoked before Spring 4.2
|
protected boolean |
supportsPublishEventMethod() |
public DeferredApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher delegate)
delegate - ApplicationEventPublisherprotected boolean supportsPublishEventMethod()
public void publishEvent(org.springframework.context.ApplicationEvent event)
publishEvent 在接口中 org.springframework.context.ApplicationEventPublisherpublic void publishEvent(Object event)
event - the ApplicationEvent or the payload of eventpublic void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
onApplicationEvent 在接口中 org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>Copyright © 2020. All rights reserved.