Class EventSubscribers

java.lang.Object
org.projectnessie.events.service.EventSubscribers
All Implemented Interfaces:
AutoCloseable

public class EventSubscribers extends Object implements 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

    Constructors
    Constructor
    Description
    EventSubscribers(Collection<org.projectnessie.events.spi.EventSubscriber> subscribers)
     
    EventSubscribers(org.projectnessie.events.spi.EventSubscriber... subscribers)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    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.
    boolean
    hasSubscribersFor(org.projectnessie.events.api.EventType type)
    Returns true if there are any subscribers for the given EventType.
    boolean
    hasSubscribersFor(org.projectnessie.versioned.ResultType resultType)
    Returns true if there are any subscribers for the given ResultType.
    void
    start(Function<org.projectnessie.events.spi.EventSubscriber,org.projectnessie.events.spi.EventSubscription> subscriptionFactory)
    Starts all subscribers.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EventSubscribers

      public EventSubscribers(org.projectnessie.events.spi.EventSubscriber... subscribers)
    • EventSubscribers

      public EventSubscribers(Collection<org.projectnessie.events.spi.EventSubscriber> subscribers)
  • 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:
      close in interface AutoCloseable
    • getSubscribers

      public List<org.projectnessie.events.spi.EventSubscriber> 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 if start(Function) has not been called yet.
    • hasSubscribersFor

      public boolean hasSubscribersFor(org.projectnessie.events.api.EventType type)
      Returns true if there are any subscribers for the given EventType.
    • hasSubscribersFor

      public boolean hasSubscribersFor(org.projectnessie.versioned.ResultType resultType)
      Returns true if there are any subscribers for the given ResultType.