org.deegree.commons.utils.fam
Class FileAlterationMonitor

java.lang.Object
  extended by org.deegree.commons.utils.fam.FileAlterationMonitor

public class FileAlterationMonitor
extends Object

File alteration monitor for monitoring changes in a directory. Supports recursive scanning and filters.

Version:
$Revision: $, $Date: $
Author:
Markus Schneider, last edited by: $Author: schneider $
See Also:
FileAlterationListener

Constructor Summary
FileAlterationMonitor(File dir, long interval, boolean recurse, FileFilter filter)
          Creates a new FileAlterationMonitor.
 
Method Summary
 void registerListener(FileAlterationListener listener)
          Registers a FileAlterationListener which is notified when changes are detected.
 void removeListener(FileAlterationListener listener)
          Removes a FileAlterationListener.
 void start()
          Starts the file alteration monitor worker thread.
 void stop()
          Stops the file alteration monitor worker thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileAlterationMonitor

public FileAlterationMonitor(File dir,
                             long interval,
                             boolean recurse,
                             FileFilter filter)
Creates a new FileAlterationMonitor.

Parameters:
dir - directory to be monitored
interval - number of milliseconds to wait between checks
recurse - if true, subdirectories (and their subdirectories, ...) are monitored as well
filter - optional filter that allows to specify for which files events should be generated, may be null (report changes on all files)
Method Detail

registerListener

public void registerListener(FileAlterationListener listener)
Registers a FileAlterationListener which is notified when changes are detected.

Parameters:
listener - listener to be registered

removeListener

public void removeListener(FileAlterationListener listener)
Removes a FileAlterationListener.

Parameters:
listener - listener to be removed

start

public void start()
Starts the file alteration monitor worker thread.

Throws:
RuntimeException - if the worker thread is already running

stop

public void stop()
Stops the file alteration monitor worker thread.

Throws:
RuntimeException - if the worker thread wasn't running


Copyright © 2011. All Rights Reserved.