Interface EventService

All Known Implementing Classes:
DefaultEventService

public interface EventService
Rarog's event service - used to handle events published by plugins. As opposed to the Spring event system - events published by one plugin can be received by others. Exceptions thrown by event listeners are logged, but aren't breaking the execution. Any object can be published as event, it will be passed to EventHandlers with matching parameter types.
  • Method Details

    • publishSyncEvent

      void publishSyncEvent(Object event)
      Publishes the event in a synchronous way, the method returns after all the handlers process the event. Swallows the exceptions in listeners
      Parameters:
      event - Event to be published.
    • publishSyncEventWithExceptions

      void publishSyncEventWithExceptions(Object event)
      Publishes the event in a synchronous way, the method returns after all the handlers process the event. Rethrows the exceptions in listeners as EventDeliveryFailedException
      Parameters:
      event - Event to be published.
    • publishAsyncEvent

      void publishAsyncEvent(Object event)
      Publishes the event in an asynchronous manner. The method returns just after single task of invoking all handlers sequentially is submitted to TaskManager Swallows the exceptions in listeners
      Parameters:
      event - Event to be published.
    • publishParallelAsyncEvent

      void publishParallelAsyncEvent(Object event)
      Publishes the event in an asynchronous, parallel manner. The method submits single task per event handler to TaskManager and returns. Events are processed in parallel if there are available threads in TaskManager's thread pool. Swallows the exceptions in listeners
      Parameters:
      event - Event to be published.
    • publishEvent

      default void publishEvent(Object event, EventService.EventType eventType)
      Publishes the event in the way defined by the eventType parameter.
      Parameters:
      event - Event to be published.
      eventType - Defines how the event will be processed
    • registerListener

      void registerListener(EventListener listener)
      Registers all EventHandlers from passed object. If handlers with more than one parameter are found, this fact is logged and the method is skipped but processing is not stopped. If the passed EventListener doesn't have any valid handlers, IllegalArgumentException is thrown.
      Parameters:
      listener - Event Listener class which defines EventHandler methods.
    • unregisterListener

      void unregisterListener(EventListener listener)
      Unregisters all EventHandlers from passed object.
      Parameters:
      listener - Event Listener class which defines EventHandler methods.