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 voidacquire()Lock the directory if possible.voidinit(String path)Create a new file locking object using the given file name.voidrelease()Unlock the directory.
-
-
-
Method Detail
-
init
public void init(String path)
Create a new file locking object using the given file name.- Specified by:
initin interfaceRepositoryLockMechanism- Parameters:
path- basic path to appendFILE_NAMEto.
-
acquire
public void acquire() throws RepositoryExceptionLock the directory if possible. This method will also start a background watchdog thread. A file may only be locked once.- Specified by:
acquirein 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:
releasein interfaceRepositoryLockMechanism
-
-