Class KafkaEvent

    • Field Summary

      • Fields inherited from class java.util.EventObject

        source
    • Constructor Summary

      Constructors 
      Constructor Description
      KafkaEvent​(java.lang.Object source, java.lang.Object container)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> T getContainer​(java.lang.Class<T> type)
      Get the container for which the event was published, which will be the parent container if the source that emitted the event is a child container, or the source itself otherwise.
      <T> T getSource​(java.lang.Class<T> type)
      Get the container (source) that published the event.
      • Methods inherited from class org.springframework.context.ApplicationEvent

        getTimestamp
      • Methods inherited from class java.util.EventObject

        getSource, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • KafkaEvent

        public KafkaEvent​(java.lang.Object source,
                          java.lang.Object container)
    • Method Detail

      • getContainer

        public <T> T getContainer​(java.lang.Class<T> type)
        Get the container for which the event was published, which will be the parent container if the source that emitted the event is a child container, or the source itself otherwise. The type is required here to avoid a dependency tangle between the event and listener packages.
        Type Parameters:
        T - the type.
        Parameters:
        type - the container type (e.g. MessageListenerContainer.class).
        Returns:
        the container.
        Since:
        2.2.1
        See Also:
        getSource(Class)
      • getSource

        public <T> T getSource​(java.lang.Class<T> type)
        Get the container (source) that published the event. This is provided as an alternative to EventObject.getSource() to avoid the need to cast in user code. The type is required here to avoid a dependency tangle between the event and listener packages.
        Type Parameters:
        T - the type.
        Parameters:
        type - the container type (e.g. MessageListenerContainer.class).
        Returns:
        the container.
        Since:
        2.2.1
        See Also:
        getContainer(Class), EventObject.getSource()