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
FieldsModifier and TypeFieldDescriptionstatic final SpecialistType<IDProviderEventAgent>Agent providing means forIDProviderbased change events. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddListener(@NotNull Predicate<EventInfo> filter, @NotNull Consumer<RevisionEvent> listener) Adds aStoreElementevent listener that will receive onlyPredicate.test(Object)accepted} events.booleanremoveListener(@NotNull Consumer<RevisionEvent> listener) Removes a previously registered event listener.
-
Field Details
-
TYPE
Agent providing means forIDProviderbased change events.- Since:
- 5.2.210505
-
-
Method Details
-
addListener
boolean addListener(@NotNull @NotNull Predicate<EventInfo> filter, @NotNull @NotNull Consumer<RevisionEvent> listener) Adds aStoreElementevent 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 underlyingConnectionis closed. A closedConnectionno 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 lightweightEventInfoobject and has to return fast. Filtering out as many events as possible prevents the creation of unnecessary heavyweightRevisionEventobjects. 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
trueif the listener and filter were added, returnsfalseif 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
trueif the listener was removed, returnsfalseif the listener was not registered and therefore not removed. - Since:
- 5.2.210505
-