org.apache.jackrabbit.core.util
Class CooperativeFileLock

java.lang.Object
  extended by 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
CooperativeFileLock()
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CooperativeFileLock

public CooperativeFileLock()
Method Detail

init

public void init(String path)
Create a new file locking object using the given file name.

Specified by:
init in interface RepositoryLockMechanism
Parameters:
path - basic path to append FILE_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 interface RepositoryLockMechanism
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 interface RepositoryLockMechanism


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.