Package edu.byu.hbll.box.internal.core
Class UpdatesNotifier
- java.lang.Object
-
- edu.byu.hbll.box.internal.core.UpdatesNotifier
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Runnable
public class UpdatesNotifier extends Object implements Runnable, Closeable
Gathers signals that there are updates for sources throughtrigger(String)
. When run is called all listeners are also run in an executor.- Author:
- Charles Draper
-
-
Constructor Summary
Constructors Constructor Description UpdatesNotifier(ThreadFactory threadFactory)
Creates a newUpdatesNotifier
with the given thread factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
register(String sourceName, Runnable listener)
Registers a new updates listener.void
run()
void
trigger(String sourceName)
Sets the source that has been updated.void
unregister(String sourceName, Runnable listener)
Unregisters an updates listener.
-
-
-
Constructor Detail
-
UpdatesNotifier
public UpdatesNotifier(ThreadFactory threadFactory)
Creates a newUpdatesNotifier
with the given thread factory.- Parameters:
threadFactory
- the threadFactory to use for the internal executor
-
-
Method Detail
-
register
public void register(String sourceName, Runnable listener)
Registers a new updates listener.- Parameters:
sourceName
- the name of the source to watchlistener
- the listener to register
-
unregister
public void unregister(String sourceName, Runnable listener)
Unregisters an updates listener.- Parameters:
sourceName
- name of the source to watchlistener
- the listener to unregister
-
trigger
public void trigger(String sourceName)
Sets the source that has been updated.- Parameters:
sourceName
- name of the source to trigger
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
-