saker.build Documentation TaskDoc JavaDoc Packages
public interface FileEventListener
Listener interface for consuming file related change events.

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.

Nested types
public interface
Token interface for installed file event listeners.
Methods
public void
changed(String filename)
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.
public abstract void changed(String filename)
Handle an event for a changed file.

Implementers should discover the nature of the change by querying its attributes, checking its contents, or in any other way.

filenameThe name of the changed file. This is relative to the directory which was used for installing this listener.
public default void eventsMissed()
Notifies the listener when some events for the installed directory listener have been missed.

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.

public default void listenerAbandoned()
Notifies the listener that it is no longer valid for the installed directory.

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.