com.atlassian.crowd.manager.lock
Class DirectoryLockManager

java.lang.Object
  extended by com.atlassian.crowd.manager.lock.DirectoryLockManager

public class DirectoryLockManager
extends Object

Manages locks for synchronisation purposes, one per SynchronisableDirectory. Applies a standard naming strategy for a key and delegates to a LockFactory to construct the particular locks.

See Also:
SynchronisableDirectory

Constructor Summary
DirectoryLockManager()
          Constructs an instance that delegates to a ReentrantLockFactory for lock construction.
DirectoryLockManager(LockFactory lockFactory)
          Constructs an instance that delegates to the provided LockFactory for lock construction.
 
Method Summary
 Lock getLock(long directoryId)
          Returns the lock for the directory with the given ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectoryLockManager

public DirectoryLockManager()
Constructs an instance that delegates to a ReentrantLockFactory for lock construction.


DirectoryLockManager

public DirectoryLockManager(LockFactory lockFactory)
Constructs an instance that delegates to the provided LockFactory for lock construction.

Parameters:
lockFactory - used to construct locks as required for each directory
Method Detail

getLock

public Lock getLock(long directoryId)
Returns the lock for the directory with the given ID. The lock has not been acquired when it is returned, clients still need to do this as normal. For example:


     Lock lock = directoryLockManager.getLock(directory.getId());
     lock.lock();
     try {
         // access the resource protected by this lock
     } finally {
         lock.unlock();
     }
 

Parameters:
directoryId - the ID of the directory to lock
Returns:
the lock for the provided directory ID


Copyright © 2013 Atlassian. All Rights Reserved.