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
EventHandler
s with
matching parameter types.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoid
publishAsyncEvent
(Object event) Publishes the event in an asynchronous manner.default void
publishEvent
(Object event, EventService.EventType eventType) Publishes the event in the way defined by the eventType parameter.void
publishParallelAsyncEvent
(Object event) Publishes the event in an asynchronous, parallel manner.void
publishSyncEvent
(Object event) Publishes the event in a synchronous way, the method returns after all the handlers process the event.void
Publishes the event in a synchronous way, the method returns after all the handlers process the event.void
registerListener
(EventListener listener) Registers allEventHandler
s from passed object.void
unregisterListener
(EventListener listener) Unregisters allEventHandler
s from passed object.
-
Method Details
-
publishSyncEvent
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
Publishes the event in a synchronous way, the method returns after all the handlers process the event. Rethrows the exceptions in listeners asEventDeliveryFailedException
- Parameters:
event
- Event to be published.
-
publishAsyncEvent
Publishes the event in an asynchronous manner. The method returns just after single task of invoking all handlers sequentially is submitted toTaskManager
Swallows the exceptions in listeners- Parameters:
event
- Event to be published.
-
publishParallelAsyncEvent
Publishes the event in an asynchronous, parallel manner. The method submits single task per event handler toTaskManager
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
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
Registers allEventHandler
s 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 passedEventListener
doesn't have any valid handlers,IllegalArgumentException
is thrown.- Parameters:
listener
- Event Listener class which definesEventHandler
methods.
-
unregisterListener
Unregisters allEventHandler
s from passed object.- Parameters:
listener
- Event Listener class which definesEventHandler
methods.
-