Class FileSystemWatcher
java.lang.Object
org.springframework.boot.devtools.filewatch.FileSystemWatcher
Watches specific directories for file changes.
- Since:
- 1.3.0
- Author:
- Andy Clement, Phillip Webb
- See Also:
-
Constructor Summary
ConstructorDescriptionCreate a newFileSystemWatcher
instance.FileSystemWatcher
(boolean daemon, Duration pollInterval, Duration quietPeriod) Create a newFileSystemWatcher
instance.FileSystemWatcher
(boolean daemon, Duration pollInterval, Duration quietPeriod, SnapshotStateRepository snapshotStateRepository) Create a newFileSystemWatcher
instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(FileChangeListener fileChangeListener) Add listener for file change events.void
addSourceDirectories
(Iterable<File> directories) Add source directories to monitor.void
addSourceDirectory
(File directory) Add a source directory to monitor.void
setTriggerFilter
(FileFilter triggerFilter) Set an optionalFileFilter
used to limit the files that trigger a change.void
start()
Start monitoring the source directory for changes.void
stop()
Stop monitoring the source directories.
-
Constructor Details
-
FileSystemWatcher
public FileSystemWatcher()Create a newFileSystemWatcher
instance. -
FileSystemWatcher
Create a newFileSystemWatcher
instance.- Parameters:
daemon
- if a daemon thread used to monitor changespollInterval
- the amount of time to wait between checking for changesquietPeriod
- 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 newFileSystemWatcher
instance.- Parameters:
daemon
- if a daemon thread used to monitor changespollInterval
- the amount of time to wait between checking for changesquietPeriod
- the amount of time required after a change has been detected to ensure that updates have completedsnapshotStateRepository
- the snapshot state repository- Since:
- 2.4.0
-
-
Method Details
-
addListener
Add listener for file change events. Cannot be called after the watcher has beenstarted
.- Parameters:
fileChangeListener
- the listener to add
-
addSourceDirectories
Add source directories to monitor. Cannot be called after the watcher has beenstarted
.- Parameters:
directories
- the directories to monitor
-
addSourceDirectory
Add a source directory to monitor. Cannot be called after the watcher has beenstarted
.- Parameters:
directory
- the directory to monitor
-
setTriggerFilter
Set an optionalFileFilter
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.
-