This interface is used when listeners are added to the file provider for listening for file changes in a directory. It works basically the same way as WatchService but it is backed by an internal thread to the file provider and uses push event handling. The file provider can employ internal caching for avoiding installing multiple native watchers for a directory, and using a common one instead.
public interface | Token interface for installed file event listeners. |
public void | Handle an event for a changed file. |
public default void | Notifies the listener when some events for the installed directory listener have been missed. |
public default void | Notifies the listener that it is no longer valid for the installed directory. |
Implementers should discover the nature of the change by querying its attributes, checking its contents, or in any other way.
This can happen when the event listener fails to handle the events as fast as they arrive and lacks behind. The internal buffers for the file watcher can overflow, and events might be lost.
This can happen when the directory is removed, the underlying drive is removed, or in any other case based on the implementation. The listener will no longer receive events, but should handle gracefully if it does, as they might arrive out of order.
Implementations should requery the state of the directory, and act based on the received information. They might want to reinstall a listener on them if a directory was recreated at the path.