|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.jcr.value.binary.FileLocks
public final class FileLocks
A utility class that represents read and write lock for files, which internally uses FileLock
to coordinate file locks
with other processes. This class maintains a single file lock per file, since multiple concurrent FileLock
s on the same
file are not allowed by the JVM. It also uses reference counts to remove locks only when a named lock is no longer being used.
Nested Class Summary | |
---|---|
protected class |
FileLocks.LockHolder
|
protected static class |
FileLocks.WrappedLock
|
Method Summary | |
---|---|
static FileLocks |
get()
Obtain the singleton instance for this virtual machine. |
protected FileLocks.WrappedLock |
lock(File file,
boolean writeLock,
boolean block)
|
FileLocks.WrappedLock |
readLock(File file)
Obtain a read lock for the supplied file. |
int |
size()
Get the number of named locks. |
FileLocks.WrappedLock |
tryReadLock(File file)
Try to obtain a read lock for the supplied file. |
FileLocks.WrappedLock |
tryWriteLock(File file)
Try to obtain a write lock for the supplied file. |
protected void |
unlock(FileLocks.LockHolder holder,
Lock rawLock)
|
FileLocks.WrappedLock |
writeLock(File file)
Obtain a write lock for the supplied file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static FileLocks get()
public FileLocks.WrappedLock writeLock(File file) throws IOException
FileLocks.WrappedLock.lock()
, FileLocks.WrappedLock.lockInterruptibly()
,
FileLocks.WrappedLock.tryLock()
or FileLocks.WrappedLock.tryLock(long, TimeUnit)
), as those methods will immediately return.
file
- the file to be locked; may not be null
IOException
- if there is a problem obtaining the file lockpublic FileLocks.WrappedLock readLock(File file) throws IOException
FileLocks.WrappedLock.lock()
, FileLocks.WrappedLock.lockInterruptibly()
,
FileLocks.WrappedLock.tryLock()
or FileLocks.WrappedLock.tryLock(long, TimeUnit)
), as those methods will immediately return.
file
- the file to be locked; may not be null
IOException
- if there is a problem obtaining the file lockpublic FileLocks.WrappedLock tryWriteLock(File file) throws IOException
FileLocks.WrappedLock.lock()
,
FileLocks.WrappedLock.lockInterruptibly()
, FileLocks.WrappedLock.tryLock()
or FileLocks.WrappedLock.tryLock(long, TimeUnit)
), as those methods will
immediately return.
However, if this method returns null
, this method could not obtain the lock.
file
- the file to be locked; may not be null
IOException
- if there is a problem obtaining the file lockpublic FileLocks.WrappedLock tryReadLock(File file) throws IOException
FileLocks.WrappedLock.lock()
,
FileLocks.WrappedLock.lockInterruptibly()
, FileLocks.WrappedLock.tryLock()
or FileLocks.WrappedLock.tryLock(long, TimeUnit)
), as those methods will
immediately return.
However, if this method returns null
, this method could not obtain the lock.
file
- the file to be locked; may not be null
IOException
- if there is a problem obtaining the file lockprotected final FileLocks.WrappedLock lock(File file, boolean writeLock, boolean block) throws IOException
IOException
protected void unlock(FileLocks.LockHolder holder, Lock rawLock)
public int size()
|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |