public final class FileAlterationMonitor
extends java.lang.Object
implements java.lang.Runnable
FileAlterationObserver
at a specified interval.FileAlterationObserver
Constructor and Description |
---|
FileAlterationMonitor()
Constructs a monitor with a default interval of 10 seconds.
|
FileAlterationMonitor(long intervalMillis)
Constructs a monitor with the specified interval.
|
FileAlterationMonitor(long interval,
java.util.Collection<FileAlterationObserver> observers)
Constructs a monitor with the specified interval and collection of observers.
|
FileAlterationMonitor(long interval,
FileAlterationObserver... observers)
Constructs a monitor with the specified interval and set of observers.
|
Modifier and Type | Method and Description |
---|---|
void |
addObserver(FileAlterationObserver observer)
Adds a file system observer to this monitor.
|
long |
getInterval()
Returns the interval.
|
java.lang.Iterable<FileAlterationObserver> |
getObservers()
Returns the set of
FileAlterationObserver registered with
this monitor. |
void |
removeObserver(FileAlterationObserver observer)
Removes a file system observer from this monitor.
|
void |
run()
Runs this monitor.
|
void |
setThreadFactory(java.util.concurrent.ThreadFactory threadFactory)
Sets the thread factory.
|
void |
start()
Starts monitoring.
|
void |
stop()
Stops monitoring.
|
void |
stop(long stopInterval)
Stops monitoring.
|
public FileAlterationMonitor()
public FileAlterationMonitor(long intervalMillis)
intervalMillis
- The amount of time in milliseconds to wait between
checks of the file system.public FileAlterationMonitor(long interval, java.util.Collection<FileAlterationObserver> observers)
interval
- The amount of time in milliseconds to wait between
checks of the file system.observers
- The collection of observers to add to the monitor.public FileAlterationMonitor(long interval, FileAlterationObserver... observers)
interval
- The amount of time in milliseconds to wait between
checks of the file system.observers
- The set of observers to add to the monitor.public void addObserver(FileAlterationObserver observer)
observer
- The file system observer to addpublic long getInterval()
public java.lang.Iterable<FileAlterationObserver> getObservers()
FileAlterationObserver
registered with
this monitor.FileAlterationObserver
public void removeObserver(FileAlterationObserver observer)
observer
- The file system observer to removepublic void run()
run
in interface java.lang.Runnable
public void setThreadFactory(java.util.concurrent.ThreadFactory threadFactory)
threadFactory
- the thread factorypublic void start() throws java.lang.Exception
java.lang.Exception
- if an error occurs initializing the observerpublic void stop() throws java.lang.Exception
java.lang.Exception
- if an error occurs initializing the observerpublic void stop(long stopInterval) throws java.lang.Exception
stopInterval
- the amount of time in milliseconds to wait for the thread to finish.
A value of zero will wait until the thread is finished (see Thread.join(long)
).java.lang.Exception
- if an error occurs initializing the observerCopyright © 2010 - 2023 Adobe. All Rights Reserved