Package com.spotify.dns
Interface ChangeNotifier<T>
-
- Type Parameters:
T- The records type
- All Known Subinterfaces:
ChangeNotifierFactory.RunnableChangeNotifier<T>
public interface ChangeNotifier<T>A change notifier represents a watched lookup from aDnsSrvWatcher.The records can be of any type. Usually something that directly reflects what your application will use the records for.
A
ChangeNotifier.Listenercan be attached to listen to change events on the watched set of records.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceChangeNotifier.ChangeNotification<T>A change event containing the current and previous set of records.static interfaceChangeNotifier.Listener<T>A listener which will be called when the set of records change
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Close thisChangeNotifier, releasing any resources allocated.Set<T>current()Get the current set of records.voidsetListener(ChangeNotifier.Listener<T> listener, boolean fire)Set a listener to be called when the set of records change.
-
-
-
Method Detail
-
setListener
void setListener(ChangeNotifier.Listener<T> listener, boolean fire)
Set a listener to be called when the set of records change.One one listener can be added. Multiple calls to this method is an error.
- Parameters:
listener- The listener to setfire- Fire the notification event immediately. Can be used to ensure that no updates are missed when setting the listener- Throws:
IllegalStateException- if called more than once
-
close
void close()
Close thisChangeNotifier, releasing any resources allocated. Once closed, no moreChangeNotifier.Listenerevents will be fired. Implementations ofChangeNotifierare not allowed to throw checked exceptions from close().
-
-