Class FileSystemWatcher

java.lang.Object
org.springframework.boot.devtools.filewatch.FileSystemWatcher

public class FileSystemWatcher extends Object
Watches specific directories for file changes.
Since:
1.3.0
Author:
Andy Clement, Phillip Webb
See Also:
  • Constructor Details

    • FileSystemWatcher

      public FileSystemWatcher()
      Create a new FileSystemWatcher instance.
    • FileSystemWatcher

      public FileSystemWatcher(boolean daemon, Duration pollInterval, Duration quietPeriod)
      Create a new FileSystemWatcher instance.
      Parameters:
      daemon - if a daemon thread used to monitor changes
      pollInterval - the amount of time to wait between checking for changes
      quietPeriod - the amount of time required after a change has been detected to ensure that updates have completed
    • FileSystemWatcher

      public FileSystemWatcher(boolean daemon, Duration pollInterval, Duration quietPeriod, SnapshotStateRepository snapshotStateRepository)
      Create a new FileSystemWatcher instance.
      Parameters:
      daemon - if a daemon thread used to monitor changes
      pollInterval - the amount of time to wait between checking for changes
      quietPeriod - the amount of time required after a change has been detected to ensure that updates have completed
      snapshotStateRepository - the snapshot state repository
      Since:
      2.4.0
  • Method Details

    • addListener

      public void addListener(FileChangeListener fileChangeListener)
      Add listener for file change events. Cannot be called after the watcher has been started.
      Parameters:
      fileChangeListener - the listener to add
    • addSourceDirectories

      public void addSourceDirectories(Iterable<File> directories)
      Add source directories to monitor. Cannot be called after the watcher has been started.
      Parameters:
      directories - the directories to monitor
    • addSourceDirectory

      public void addSourceDirectory(File directory)
      Add a source directory to monitor. Cannot be called after the watcher has been started.
      Parameters:
      directory - the directory to monitor
    • setTriggerFilter

      public void setTriggerFilter(FileFilter triggerFilter)
      Set an optional FileFilter used to limit the files that trigger a change.
      Parameters:
      triggerFilter - a trigger filter or null
    • start

      public void start()
      Start monitoring the source directory for changes.
    • stop

      public void stop()
      Stop monitoring the source directories.