net.sourceforge.cobertura.util
Class FileLocker
public
class
FileLocker
extends Object
This class controls access to any file so that multiple JVMs will
not be able to write to the file at the same time.
A file called "filename.lock" is created and Java's FileLock class
is used to lock the file.
The java.nio classes were introduced in Java 1.4, so this class
does a no-op when used with Java 1.3. The class maintains
compatability with Java 1.3 by accessing the java.nio classes
using reflection.
Author: John Lewis Mark Doliner
Field Summary |
Object | lock
An object of type FileLock, created using reflection. |
Object | lockChannel
An object of type FileChannel, created using reflection. |
File | lockFile
A file called "filename.lock" that resides in the same directory
as "filename" |
private Object lock
An object of type FileLock, created using reflection.
private Object lockChannel
An object of type FileChannel, created using reflection.
private File lockFile
A file called "filename.lock" that resides in the same directory
as "filename"
public FileLocker(File file)
private static Object closeChannel(Object channel)
public boolean lock()
Obtains a lock on the file. This blocks until the lock is obtained.
public void release()
Releases the lock on the file.
private static Object releaseFileLock(Object lock)