Package alpine.event.framework
Interface IEventService
- All Known Implementing Classes:
BaseEventService,EventService,SingleThreadedEventService
public interface IEventService
Defines an EventService. All event services must be singletons and implement a static
getInstance() method.
- Since:
- 1.2.0
- Author:
- Steve Springett
-
Method Summary
Modifier and TypeMethodDescriptionbooleanhasSubscriptions(Event event) Determines if the specified event is able to be processed by the EventService.booleanDetermines if the specified event is currently being processed.booleanisEventBeingProcessed(UUID chainIdentifier) Determines if the specified event is currently being processed.voidPublishes events.voidshutdown()Shuts down the executioner.booleanShuts down thisIEventService, and waits for already queued events to be processed until a giventimeoutelapses.voidsubscribe(Class<? extends Event> eventType, Class<? extends Subscriber> subscriberType) Subscribes to an event.voidunsubscribe(Class<? extends Subscriber> subscriberType) Unsubscribes a subscriber.
-
Method Details
-
publish
Publishes events. Published events will get dispatched to all subscribers in the order in which they subscribed. Subscribers are informed asynchronously one after the next.- Parameters:
event- An Event to publish- Since:
- 1.2.0
-
subscribe
Subscribes to an event. Subscribes are automatically notified of all events for which they are subscribed.- Parameters:
eventType- The type of event to subscribe tosubscriberType- The Subscriber that gets informed when the type of event is published- Since:
- 1.2.0
-
unsubscribe
Unsubscribes a subscriber. All event types the subscriber has subscribed to will be unsubscribed. Once unsubscribed, the subscriber will no longer be informed of published events.- Parameters:
subscriberType- The Subscriber to unsubscribe.- Since:
- 1.2.0
-
hasSubscriptions
Determines if the specified event is able to be processed by the EventService. If a subscriber exists for the event type, this method will return true, otherwise false.- Parameters:
event- the event to query if subscribers exist- Returns:
- true if the event has subscribers, false it not
- Since:
- 1.2.0
-
shutdown
void shutdown()Shuts down the executioner. Once shut down, future work will not be performed. This should only be called prior to the application being shut down.- Since:
- 1.2.0
-
shutdown
Shuts down thisIEventService, and waits for already queued events to be processed until a giventimeoutelapses.Events enqueued during shutdown will not be processed.
- Parameters:
timeout- TheDurationto wait for event processing to complete- Returns:
truewhen all queued events were processed prior totimeoutelapsing, otherwisefalse- Since:
- 2.3.0
-
isEventBeingProcessed
Determines if the specified event is currently being processed. Processing may indicate the the subscriber task is in the queue and work has not started yet, or may indicate the task is currently being executed. When this event returns false, it does not indicate completion, only that there are no subscriber tasks waiting or working on the specified event.- Parameters:
event- the event to query- Returns:
- a boolean
- Since:
- 1.4.0
-
isEventBeingProcessed
Determines if the specified event is currently being processed. Processing may indicate the the subscriber task is in the queue and work has not started yet, or may indicate the task is currently being executed. When this event returns false, it does not indicate completion, only that there are no subscriber tasks waiting or working on the specified event.- Parameters:
chainIdentifier- the UUID of the event to query- Returns:
- a boolean
- Since:
- 1.4.0
-