public abstract class AbstractEventPubSub<E> extends java.lang.Object implements EventPubSub<E>, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationEventPublisherAware
| Modifier and Type | Field and Description |
|---|---|
static java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Class<?>> |
EventTypeMap
事件类型标识与实际运行时类型的映射,用于跨语言事件支持。
|
CustomApplicationEventChannel, DefaultEventChannel| Constructor and Description |
|---|
AbstractEventPubSub(FrameworkAutoConfiguration.EventProperties eventProperties,
org.springframework.context.ApplicationContext applicationContext) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected abstract void |
broadcast(E event,
java.lang.String[] channels,
java.lang.String eventType)
广播事件。
|
org.springframework.context.ApplicationEventPublisher |
getApplicationEventPublisher() |
protected java.lang.String[] |
getEventChannel(ShouldBroadcast annotation) |
java.lang.String |
getEventTypeId(java.lang.Class<?> eventClass,
ShouldBroadcast annotation) |
java.util.Set<java.lang.String> |
getListeningChannels() |
protected void |
initChannel(java.lang.String channel) |
void |
publish(E event)
发布事件。被
ShouldBroadcast标注的事件将通过其指定的频道发送广播。 |
void |
publishToLocalOnly(E event)
仅在本地(当前ApplicationContext)发布事件,不对外广播。
|
void |
setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) |
public static final java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Class<?>> EventTypeMap
public AbstractEventPubSub(FrameworkAutoConfiguration.EventProperties eventProperties, org.springframework.context.ApplicationContext applicationContext)
public org.springframework.context.ApplicationEventPublisher getApplicationEventPublisher()
public void setApplicationEventPublisher(@NotNull
org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAwarepublic void publishToLocalOnly(E event)
EventPubSubpublishToLocalOnly in interface EventPubSub<E>public void publish(E event)
EventPubSubShouldBroadcast标注的事件将通过其指定的频道发送广播。publish in interface EventPubSub<E>public java.util.Set<java.lang.String> getListeningChannels()
getListeningChannels in interface EventPubSub<E>protected java.lang.String[] getEventChannel(ShouldBroadcast annotation)
public java.lang.String getEventTypeId(java.lang.Class<?> eventClass,
ShouldBroadcast annotation)
public void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exceptionprotected abstract void broadcast(E event, java.lang.String[] channels, java.lang.String eventType)
event - 事件channels - 频道protected void initChannel(java.lang.String channel)