Class 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 Detail

      • EventTypeMap

        public static final java.util.concurrent.ConcurrentMap<java.lang.String,​java.lang.Class<?>> EventTypeMap
        事件类型标识与实际运行时类型的映射,用于跨语言事件支持。
    • Method Detail

      • setApplicationEventPublisher

        public void setApplicationEventPublisher​(@NotNull
                                                 org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
        Specified by:
        setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAware
      • publishToLocalOnly

        public void publishToLocalOnly​(E event)
        Description copied from interface: EventPubSub
        仅在本地(当前ApplicationContext)发布事件,不对外广播。
        Specified by:
        publishToLocalOnly in interface EventPubSub<E>
      • publish

        public void publish​(E event)
        Description copied from interface: EventPubSub
        发布事件。被ShouldBroadcast标注的事件将通过其指定的频道发送广播。
        Specified by:
        publish in interface EventPubSub<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:
        afterPropertiesSet in interface org.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)