Class FileWatcher


  • public class FileWatcher
    extends java.lang.Object
    Background thread that monitors certain files and perform relevant actions when they change.
    Since:
    7185
    • Constructor Detail

      • FileWatcher

        public FileWatcher()
        Constructs a new FileWatcher.
    • Method Detail

      • start

        public final void start()
        Starts the File Watcher thread.
      • registerSource

        public void registerSource​(SourceEntry src)
                            throws java.io.IOException
        Registers a source for local file changes, allowing dynamic reloading.
        Parameters:
        src - The source to watch
        Throws:
        java.lang.IllegalArgumentException - if rule is null or if it does not provide a local file
        java.lang.IllegalStateException - if the watcher service failed to start
        java.io.IOException - if an I/O error occurs
        Since:
        12825
      • registerLoader

        public static java.util.function.Consumer<SourceEntryregisterLoader​(SourceType type,
                                                                              java.util.function.Consumer<SourceEntry> loader)
        Registers a source loader, allowing dynamic reloading when an entry changes.
        Parameters:
        type - the source type for which the loader operates
        loader - the loader in charge of reloading any source of given type when it changes
        Returns:
        the previous loader registered for this source type, if any
        Since:
        12825
      • processEvents

        private void processEvents()
        Process all events for the key queued to the watcher.