Package org.projectnessie.events.service
Class EventSubscribers
java.lang.Object
org.projectnessie.events.service.EventSubscribers
- All Implemented Interfaces:
AutoCloseable
Loads and holds all
EventSubscribers.
The main purpose of this class is to provide a single point of access to all subscribers, and also to provide a bit-mask of all event types that subscribers are subscribed to, for a fast and efficient type-based event filtering.
This class is meant to be used as a singleton, or in CDI Dependent pseudo-scope.
-
Constructor Summary
ConstructorsConstructorDescriptionEventSubscribers(Collection<org.projectnessie.events.spi.EventSubscriber> subscribers) EventSubscribers(org.projectnessie.events.spi.EventSubscriber... subscribers) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()List<org.projectnessie.events.spi.EventSubscriber> Returns an unmodifiable list of all subscribers.Map<org.projectnessie.events.spi.EventSubscription, org.projectnessie.events.spi.EventSubscriber> Returns an unmodifiable map of all active subscriptions with their subscribers.booleanhasSubscribersFor(org.projectnessie.events.api.EventType type) Returnstrueif there are any subscribers for the givenEventType.booleanhasSubscribersFor(org.projectnessie.versioned.ResultType resultType) Returnstrueif there are any subscribers for the givenResultType.voidstart(Function<org.projectnessie.events.spi.EventSubscriber, org.projectnessie.events.spi.EventSubscription> subscriptionFactory) Starts all subscribers.
-
Constructor Details
-
EventSubscribers
public EventSubscribers(org.projectnessie.events.spi.EventSubscriber... subscribers) -
EventSubscribers
-
-
Method Details
-
start
public void start(Function<org.projectnessie.events.spi.EventSubscriber, org.projectnessie.events.spi.EventSubscription> subscriptionFactory) Starts all subscribers.- Parameters:
subscriptionFactory- a function that creates a subscription for a subscriber
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
getSubscribers
Returns an unmodifiable list of all subscribers. -
getSubscriptions
public Map<org.projectnessie.events.spi.EventSubscription,org.projectnessie.events.spi.EventSubscriber> getSubscriptions()Returns an unmodifiable map of all active subscriptions with their subscribers. Returns null ifstart(Function)has not been called yet. -
hasSubscribersFor
public boolean hasSubscribersFor(org.projectnessie.events.api.EventType type) Returnstrueif there are any subscribers for the givenEventType. -
hasSubscribersFor
public boolean hasSubscribersFor(org.projectnessie.versioned.ResultType resultType) Returnstrueif there are any subscribers for the givenResultType.
-