net.sourceforge.cobertura.util
Class FileLocker
java.lang.Object
net.sourceforge.cobertura.util.FileLocker
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.
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"
|
lock
private Object lock
An object of type FileLock, created using reflection.
lockChannel
private Object lockChannel
An object of type FileChannel, created using reflection.
lockFile
private File lockFile
A file called "filename.lock" that resides in the same directory
as "filename"
closeChannel
private static Object closeChannel(Object channel)
lock
public boolean lock()
Obtains a lock on the file. This blocks until the lock is obtained.
release
public void release()
Releases the lock on the file.