|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.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.
Field Summary | |
private java.lang.Object |
lock
An object of type FileLock, created using reflection. |
private java.lang.Object |
lockChannel
An object of type FileChannel, created using reflection. |
private java.io.File |
lockFile
A file called "filename.lock" that resides in the same directory as "filename" |
Constructor Summary | |
FileLocker(java.io.File file)
|
Method Summary | |
private static java.lang.Object |
closeChannel(java.lang.Object channel)
|
boolean |
lock()
Obtains a lock on the file. |
void |
release()
Releases the lock on the file. |
private static java.lang.Object |
releaseFileLock(java.lang.Object lock)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private java.lang.Object lock
private java.lang.Object lockChannel
private java.io.File lockFile
Constructor Detail |
public FileLocker(java.io.File file)
Method Detail |
public boolean lock()
public void release()
private static java.lang.Object releaseFileLock(java.lang.Object lock)
private static java.lang.Object closeChannel(java.lang.Object channel)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |