Class SimpleEventHandler

java.lang.Object
com.github.philippheuer.events4j.simple.SimpleEventHandler
All Implemented Interfaces:
com.github.philippheuer.events4j.api.service.IEventHandler, AutoCloseable

public class SimpleEventHandler extends Object implements com.github.philippheuer.events4j.api.service.IEventHandler
  • Constructor Details

    • SimpleEventHandler

      public SimpleEventHandler()
  • Method Details

    • registerListener

      public void registerListener(Object eventListener)
      Registers a listener using EventSubscriber method annotations.
      Parameters:
      eventListener - The class instance annotated with EventSubscriber annotations.
    • onEvent

      public <E> com.github.philippheuer.events4j.api.domain.IDisposable onEvent(Class<E> eventClass, Consumer<E> consumer)
      Registers a new consumer based event handler
      Specified by:
      onEvent in interface com.github.philippheuer.events4j.api.service.IEventHandler
      Type Parameters:
      E - the event type
      Parameters:
      eventClass - the event class to obtain events from
      consumer - the event consumer / handler method
      Returns:
      a new Disposable of the given eventType
    • publish

      public void publish(Object event)
      Dispatched a event to the simple based method listeners.
      Specified by:
      publish in interface com.github.philippheuer.events4j.api.service.IEventHandler
      Parameters:
      event - The event that will be dispatched to the simple based method listeners.
    • close

      public void close()
      Shutdown
      Specified by:
      close in interface AutoCloseable
    • getConsumerBasedHandlers

      public ConcurrentMap<Class<?>,List<Consumer<Object>>> getConsumerBasedHandlers()
      Consumer based handlers