Package org.apache.jackrabbit.core.util
Class CooperativeFileLock
- java.lang.Object
-
- org.apache.jackrabbit.core.util.CooperativeFileLock
-
- All Implemented Interfaces:
RepositoryLockMechanism
public class CooperativeFileLock extends Object implements RepositoryLockMechanism
The file lock is used to ensure a resource is only open once at any time. It uses a cooperative locking protocol.
-
-
Constructor Summary
Constructors Constructor Description CooperativeFileLock()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acquire()
Lock the directory if possible.void
init(String path)
Create a new file locking object using the given file name.void
release()
Unlock the directory.
-
-
-
Method Detail
-
init
public void init(String path)
Create a new file locking object using the given file name.- Specified by:
init
in interfaceRepositoryLockMechanism
- Parameters:
path
- basic path to appendFILE_NAME
to.
-
acquire
public void acquire() throws RepositoryException
Lock the directory if possible. This method will also start a background watchdog thread. A file may only be locked once.- Specified by:
acquire
in interfaceRepositoryLockMechanism
- Throws:
RepositoryException
- if locking was not successful
-
release
public void release()
Unlock the directory. The watchdog thread is stopped. This method does nothing if the file is already unlocked.- Specified by:
release
in interfaceRepositoryLockMechanism
-
-