org.littleshoot.util
Class LockedFileWatcher

java.lang.Object
  extended by java.util.TimerTask
      extended by org.littleshoot.util.LockedFileWatcher
All Implemented Interfaces:
Runnable

public abstract class LockedFileWatcher
extends TimerTask

Utility class for detecting file changes. When a change is detected, this class obtains an exclusive read/write lock on the file and notifies subclasses of the change. The subclass MUST read the whole file and truncate it to zero size.


Constructor Summary
LockedFileWatcher(File file)
          Creates a new watcher for the specified file.
 
Method Summary
protected abstract  void onFileChange(FileChannel fc)
           
 void run()
           
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockedFileWatcher

public LockedFileWatcher(File file)
Creates a new watcher for the specified file.

Parameters:
file - The file to watch.
Method Detail

run

public final void run()
Specified by:
run in interface Runnable
Specified by:
run in class TimerTask

onFileChange

protected abstract void onFileChange(FileChannel fc)


Copyright © 2011-2013 LittleShoot. All Rights Reserved.