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.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidpublishAsyncEvent(Object event) Publishes the event in an asynchronous manner.default voidpublishEvent(Object event, EventService.EventType eventType) Publishes the event in the way defined by the eventType parameter.voidpublishParallelAsyncEvent(Object event) Publishes the event in an asynchronous, parallel manner.voidpublishSyncEvent(Object event) Publishes the event in a synchronous way, the method returns after all the handlers process the event.voidPublishes the event in a synchronous way, the method returns after all the handlers process the event.voidregisterListener(EventListener listener) Registers allEventHandlers from passed object.voidunregisterListener(EventListener listener) Unregisters allEventHandlers 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 toTaskManagerSwallows 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 toTaskManagerand 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 allEventHandlers 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 passedEventListenerdoesn't have any valid handlers,IllegalArgumentExceptionis thrown.- Parameters:
listener- Event Listener class which definesEventHandlermethods.
-
unregisterListener
Unregisters allEventHandlers from passed object.- Parameters:
listener- Event Listener class which definesEventHandlermethods.
-