Class AbstractEventPubSub<E>
- java.lang.Object
-
- me.insidezhou.southernquiet.event.driver.AbstractEventPubSub<E>
-
- All Implemented Interfaces:
EventPubSub<E>,org.springframework.beans.factory.Aware,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationEventPublisherAware
public abstract class AbstractEventPubSub<E> extends java.lang.Object implements EventPubSub<E>, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationEventPublisherAware
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Class<?>>EventTypeMap事件类型标识与实际运行时类型的映射,用于跨语言事件支持。-
Fields inherited from interface me.insidezhou.southernquiet.event.EventPubSub
CustomApplicationEventChannel, DefaultEventChannel
-
-
Constructor Summary
Constructors Constructor Description AbstractEventPubSub(FrameworkAutoConfiguration.EventProperties eventProperties, org.springframework.context.ApplicationContext applicationContext)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()protected abstract voidbroadcast(E event, java.lang.String[] channels, java.lang.String eventType)广播事件。protected java.lang.String[]getEventChannel(ShouldBroadcast annotation)java.lang.StringgetEventTypeId(java.lang.Class<?> eventClass, ShouldBroadcast annotation)java.util.Set<java.lang.String>getListeningChannels()protected voidinitChannel(java.lang.String channel)voidpublish(E event)发布事件。被ShouldBroadcast标注的事件将通过其指定的频道发送广播。voidpublishToLocalOnly(E event)仅在本地(当前ApplicationContext)发布事件,不对外广播。voidsetApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
-
-
-
Constructor Detail
-
AbstractEventPubSub
public AbstractEventPubSub(FrameworkAutoConfiguration.EventProperties eventProperties, org.springframework.context.ApplicationContext applicationContext)
-
-
Method Detail
-
setApplicationEventPublisher
public void setApplicationEventPublisher(@NotNull org.springframework.context.ApplicationEventPublisher applicationEventPublisher)- Specified by:
setApplicationEventPublisherin interfaceorg.springframework.context.ApplicationEventPublisherAware
-
publishToLocalOnly
public void publishToLocalOnly(E event)
Description copied from interface:EventPubSub仅在本地(当前ApplicationContext)发布事件,不对外广播。- Specified by:
publishToLocalOnlyin interfaceEventPubSub<E>
-
publish
public void publish(E event)
Description copied from interface:EventPubSub发布事件。被ShouldBroadcast标注的事件将通过其指定的频道发送广播。- Specified by:
publishin interfaceEventPubSub<E>
-
getListeningChannels
public java.util.Set<java.lang.String> getListeningChannels()
- Specified by:
getListeningChannelsin interfaceEventPubSub<E>
-
getEventChannel
protected java.lang.String[] getEventChannel(ShouldBroadcast annotation)
-
getEventTypeId
public java.lang.String getEventTypeId(java.lang.Class<?> eventClass, ShouldBroadcast annotation)
-
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
java.lang.Exception
-
broadcast
protected abstract void broadcast(E event, java.lang.String[] channels, java.lang.String eventType)
广播事件。- Parameters:
event- 事件channels- 频道
-
initChannel
protected void initChannel(java.lang.String channel)
-
-