Package org.grails.io.watch
Class DirectoryWatcher
- java.lang.Object
-
- java.lang.Thread
-
- org.grails.io.watch.DirectoryWatcher
-
- All Implemented Interfaces:
java.lang.Runnable
public class DirectoryWatcher extends java.lang.ThreadUtility class to watch directories for changes.- Since:
- 2.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceDirectoryWatcher.FileChangeListenerInterface for FileChangeListeners
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSVN_DIR_NAME
-
Constructor Summary
Constructors Constructor Description DirectoryWatcher()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(DirectoryWatcher.FileChangeListener listener)Adds a file listener that can react to change eventsvoidaddWatchDirectory(java.io.File dir)Adds a directory to watch for the given file.voidaddWatchDirectory(java.io.File dir, java.lang.String extension)Adds a directory to watch for the given file and extensions.voidaddWatchDirectory(java.io.File dir, java.util.List<java.lang.String> fileExtensions)Adds a directory to watch for the given file and extensions.voidaddWatchFile(java.io.File fileToWatch)Adds a file to the watch listvoidremoveListener(DirectoryWatcher.FileChangeListener listener)Removes a file listener from the current listvoidrun()voidsetActive(boolean active)Sets whether to stop the directory watchervoidsetSleepTime(long sleepTime)Sets the amount of time to sleep between checks-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
SVN_DIR_NAME
public static final java.lang.String SVN_DIR_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
setActive
public void setActive(boolean active)
Sets whether to stop the directory watcher- Parameters:
active- False if you want to stop watching
-
setSleepTime
public void setSleepTime(long sleepTime)
Sets the amount of time to sleep between checks- Parameters:
sleepTime- The sleep time
-
addListener
public void addListener(DirectoryWatcher.FileChangeListener listener)
Adds a file listener that can react to change events- Parameters:
listener- The file listener
-
removeListener
public void removeListener(DirectoryWatcher.FileChangeListener listener)
Removes a file listener from the current list- Parameters:
listener- The file listener
-
addWatchFile
public void addWatchFile(java.io.File fileToWatch)
Adds a file to the watch list- Parameters:
fileToWatch- The file to watch
-
addWatchDirectory
public void addWatchDirectory(java.io.File dir, java.util.List<java.lang.String> fileExtensions)Adds a directory to watch for the given file and extensions.- Parameters:
dir- The directoryfileExtensions- The extensions
-
addWatchDirectory
public void addWatchDirectory(java.io.File dir)
Adds a directory to watch for the given file. All files and subdirectories in the directory will be watched.- Parameters:
dir- The directory
-
addWatchDirectory
public void addWatchDirectory(java.io.File dir, java.lang.String extension)Adds a directory to watch for the given file and extensions.- Parameters:
dir- The directoryextension- The extension
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable- Overrides:
runin classjava.lang.Thread
-
-