Package io.atomix.utils.event
Class ListenerRegistry<E extends Event,L extends EventListener<E>>
java.lang.Object
io.atomix.utils.event.ListenerRegistry<E,L>
- All Implemented Interfaces:
EventSink<E>,ListenerService<E,L>
public class ListenerRegistry<E extends Event,L extends EventListener<E>>
extends Object
implements ListenerService<E,L>, EventSink<E>
Base implementation of an event sink and a registry capable of tracking listeners and dispatching
events to them as part of event sink processing.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(L listener) Adds the specified listener.voidProcesses the specified event.voidremoveListener(L listener) Removes the specified listener.protected voidreportProblem(E event, Throwable error) Reports a problem encountered while processing an event.
-
Field Details
-
listeners
Set of listeners that have registered.
-
-
Constructor Details
-
ListenerRegistry
public ListenerRegistry()
-
-
Method Details
-
addListener
Description copied from interface:ListenerServiceAdds the specified listener.- Specified by:
addListenerin interfaceListenerService<E extends Event,L extends EventListener<E>> - Parameters:
listener- listener to be added
-
removeListener
Description copied from interface:ListenerServiceRemoves the specified listener.- Specified by:
removeListenerin interfaceListenerService<E extends Event,L extends EventListener<E>> - Parameters:
listener- listener to be removed
-
process
Description copied from interface:EventSinkProcesses the specified event. -
reportProblem
Reports a problem encountered while processing an event.- Parameters:
event- event being processederror- error encountered while processing
-