Interface ResourceEventStore
-
- All Superinterfaces:
Store
- All Known Subinterfaces:
TrsStore
- All Known Implementing Classes:
AbstractTrsStore
,FileTrsStore
public interface ResourceEventStore extends Store
A write-only store forResourceEvent
. This store is to be used by listeners registered in the application to report change events as they occur. An event store instance is to retrieve withTrsStoreSynchronizer.getResourceEventStore()
, which ensures method calls are correctly synchronized across the whole web application.- Since:
- 1.10.0
- See Also:
TrsStoreSynchronizer.getResourceEventStore()
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
deleteResourcesOf(String projectId)
CreatesResourceEvent.Type.DELETED
events for all exposed resources of the given project in the store.boolean
isStoringEventsOf(Optional<String> projectAreaId)
Determines whether the store is currently able to store events and, optionally, for a particular project.void
store(ResourceEvent... resourceEvents)
Stores one or a fewresource events
.void
store(Function<Consumer<ResourceEvent>,?> eventsProvider)
Storesresource events
.-
Methods inherited from interface com.sodius.oslc.server.trs.store.Store
corrupt, isCorrupted
-
-
-
-
Method Detail
-
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.Implementations should use a temporary cache for keeping results for a very brief moment (at most 1s) in order to optimize performance. The intention is just to avoid multiple computations of the result during a single storage request, where it's very likely all events belong to the same project.
- Parameters:
projectAreaId
- the optional project identifier.- Returns:
true
if the given project isTRS exposed
, theTRS store is not corrupted
and the correspondingbase is computed
;false
otherwise.- Since:
- 3.3.0
-
store
void store(ResourceEvent... resourceEvents)
Stores one or a fewresource events
. If a larger volume of events is to send at once, client is recommended to rather use thestore(Function)
method.Implementations must store events only if the
isStoringEventsOf(Optional)
method returnstrue
for each of the givenevent seeds
and must assign properly theevent order
before the saving (resourceEvents
must be provided chronologically sorted as they occurred).This method is intended to avoid raising
TrsStoreException
, if something went wrong preventing the storage of the event, implementations mustcorrupt
the storage silently.- Parameters:
resourceEvents
- events to store.
-
store
void store(Function<Consumer<ResourceEvent>,?> eventsProvider)
Storesresource events
. If only one or a few events are to report at once, client may use the simplerstore(ResourceEvent...)
method.The function implementation must be thread-safe, as the store will call the
Function.apply(Object)
method in a dedicated thread, so that calls to this method are non blocking.Implementations must store events only if the
isStoringEventsOf(Optional)
method returnstrue
for each of the givenevent seeds
and must assign properly theevent order
before the saving (resourceEvents
must be provided chronologically sorted as they occurred).This method is intended to avoid raising
TrsStoreException
, if something went wrong preventing the storage of the event, implementations mustcorrupt
the storage 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 aConsumer
to get notified of events. Implementation is advised to use aBufferedConsumer
for optimal performance.- Parameters:
eventsProvider
- a function that provides access to change events to become part of thetrs:ChangeLog
.- See Also:
BufferedConsumer
,store(ResourceEvent...)
-
deleteResourcesOf
void deleteResourcesOf(String projectId)
CreatesResourceEvent.Type.DELETED
events for all exposed resources of the given project in the store.This method is convenient to un-expose all resources of a deleted project in the hosting application.
Implementations SHOULD store events only if the
isStoringEventsOf(Optional)
method returnstrue
for the given project (at the beginning of the process) and MUST avoid calling it again for each individual resource event seed because the project could not be longer accessible, and therefore, theisStoringEventsOf(Optional)
method could returnfalse
for some events. If implementations decide to do not call theisStoringEventsOf(Optional)
method at all, because the project could not be longer accessible from the beginning, they MUST ensure that: the store is not corrupted, the base is computed and there is a TRS functional user configured before saving events.This method is intended to avoid raising
TrsStoreException
, if something went wrong preventing the storage of the event, implementations mustcorrupt
the storage silently.- Parameters:
projectId
- the project identifier of the resources to un-expose.- Since:
- 3.3.0
-
-