Package de.espirit.firstspirit.agency
Interface IDProviderEventAgent
public interface IDProviderEventAgent
An event agent providing means for
IDProvider
based change events.- Since:
- 5.2.210505
-
Field Summary
Modifier and TypeFieldDescriptionstatic final SpecialistType<IDProviderEventAgent>
Agent providing means forIDProvider
based change events. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addListener
(@NotNull Predicate<EventInfo> filter, @NotNull Consumer<RevisionEvent> listener) Adds aStoreElement
event listener that will receive onlyPredicate.test(Object)
accepted} events.boolean
removeListener
(@NotNull Consumer<RevisionEvent> listener) Removes a previously registered event listener.
-
Field Details
-
TYPE
Agent providing means forIDProvider
based change events.- Since:
- 5.2.210505
-
-
Method Details
-
addListener
boolean addListener(@NotNull @NotNull Predicate<EventInfo> filter, @NotNull @NotNull Consumer<RevisionEvent> listener) Adds aStoreElement
event listener that will receive onlyPredicate.test(Object)
accepted} events.
The listener reference will be heldweakly
, so you have to keep a reference to the listener instance or it will be automatically collected by the GC and de-registered from this agent.
If the filter or listener are implementingCloseable
, theirclose()
method will be called, if the underlyingConnection
is closed. A closedConnection
no longer delivers any events to a listener.
Note: Remember to invokeremoveListener(Consumer)
if the listener is no longer needed.- Parameters:
filter
- A filter that specifies, which events will be accepted and witch won't. The filtering is based on a lightweightEventInfo
object and has to return fast. Filtering out as many events as possible prevents the creation of unnecessary heavyweightRevisionEvent
objects. The filter may be called more than once for one revision event, for each change operation being part of the event. If any of the calls is accepted, the revision event object gets handed to the listener afterwards.listener
- The listener to receive accepted events. The event handling is executed in a separate worker thread and does not block event processing of other listeners.- Returns:
- Returns
true
if the listener and filter were added, returnsfalse
if the listener and filter combination were already present and not added. - Since:
- 5.2.210505
-
removeListener
Removes a previously registered event listener.- Parameters:
listener
- The registered event listener.- Returns:
- Returns
true
if the listener was removed, returnsfalse
if the listener was not registered and therefore not removed. - Since:
- 5.2.210505
-