Interface ResourceEventStore

All Known Subinterfaces:
TrsStore
All Known Implementing Classes:
AbstractTrsStore, FileTrsStore

public interface ResourceEventStore
A write-only, and asynchronous, store for ResourceEvent. This store is to be used by listeners registered in the application to report change events as they occur.

Implementations must not block the application while registering events; however, since getting the right order to them requires synchronized access, implementations may opt to store them without an actual order (or any other tag mechanism), so they remain hidden to the TRS feed, up the TrsStore.synchronizeResourceEvents() method is called to assign them the right order.

An event store instance is to retrieve with TrsStoreSynchronizer.getResourceEventStore(), which ensures method calls are correctly non-synchronized across the whole web application.
Since:
1.10.0
See Also:
  • Method Details

    • isStoringEventsOf

      boolean isStoringEventsOf(Optional<String> projectAreaId)
      Determines whether the store is currently able to store events and, optionally, for a particular project.

      This method must not raise any exception, false must be returned silently if any of them occurred while computing the result. Implementation must verify the corresponding base is computed and a functional user is set. If a project is given, it is then recommended to rely on TrsFeedManager.isExposedProjectArea(String).

      Parameters:
      projectAreaId - the optional project identifier.
      Returns:
      true if TRS events should be stored
      Since:
      3.3.0
    • store

      void store(ResourceEvent... resourceEvents)
      Stores one or a few resource events. If a larger volume of events is to send at once, client is recommended to rather use the store(Function) method.

      Implementations MUST store events, without blocking the application, only if the isStoringEventsOf(Optional) method returns true, for each of the given event seeds, and must keep them hidden from the TRS feed up to the TrsStore.synchronizeResourceEvents() method is called.

      This method is intended to avoid raising TrsStoreException, if something went wrong preventing the storage of the event, implementations must handle it silently.

      Parameters:
      resourceEvents - events to store.
    • store

      void store(Function<Consumer<ResourceEvent>,?> eventsProvider)
      Stores resource events. If only one or a few events are to report at once, client may use the simpler store(ResourceEvent...) method.

      Implementations MUST store events, without blocking the application, only if the isStoringEventsOf(Optional) method returns true, for each of the given event seeds, and must keep them hidden from the TRS feed up to the TrsStore.synchronizeResourceEvents() method is called.

      This method is intended to avoid raising TrsStoreException, if something went wrong preventing the storage of the event, implementations must handle it silently.

      The function argument provides access to change events to be added in this store. Implementation must call the apply() method of this function and use, as argument, a Consumer to get notified of events. Implementation is advised to use a BufferedConsumer for optimal performance.

      Parameters:
      eventsProvider - a function that provides access to change events to become part of the trs:ChangeLog.
      See Also: