|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.vfs.impl.DefaultFileMonitor
A polling FileMonitor
implementation.
The DefaultFileMonitor is a Thread based polling file system monitor with a 1
second delay.
Design:
FileSystemManager fsManager = VFS.getManager(); FileObject listendir = fsManager.resolveFile("/home/username/monitored/"); DefaultFileMonitor fm = new DefaultFileMonitor(new CustomFileListener()); fm.setRecursive(true); fm.addFile(listendir); fm.start();(where CustomFileListener is a class that implements the FileListener interface.)
Constructor Summary | |
DefaultFileMonitor(FileListener listener)
|
Method Summary | |
void |
addFile(FileObject file)
Adds a file to be monitored. |
int |
getChecksPerRun()
get the number of files to check per run |
long |
getDelay()
Get the delay between runs |
boolean |
isRecursive()
Access method to get the recursive setting when adding files for monitoring. |
protected void |
queueAddFile(FileObject file)
Queues a file for addition to be monitored. |
protected void |
queueRemoveFile(FileObject file)
Queues a file for removal from being monitored. |
void |
removeFile(FileObject file)
Removes a file from being monitored. |
void |
run()
Asks the agent for each file being monitored to check its file for changes. |
void |
setChecksPerRun(int checksPerRun)
set the number of files to check per run. |
void |
setDelay(long delay)
Set the delay between runs |
void |
setRecursive(boolean newRecursive)
Access method to set the recursive setting when adding files for monitoring. |
void |
start()
Starts monitoring the files that have been added. |
void |
stop()
Stops monitoring the files that have been added. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DefaultFileMonitor(FileListener listener)
Method Detail |
public boolean isRecursive()
public void setRecursive(boolean newRecursive)
public void addFile(FileObject file)
addFile
in interface FileMonitor
public void removeFile(FileObject file)
removeFile
in interface FileMonitor
protected void queueRemoveFile(FileObject file)
public long getDelay()
public void setDelay(long delay)
public int getChecksPerRun()
public void setChecksPerRun(int checksPerRun)
checksPerRun
- a value less than 1 will disable this featureprotected void queueAddFile(FileObject file)
public void start()
public void stop()
public void run()
run
in interface Runnable
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |