org.apache.commons.transaction.locking
Class SimpleLockManager<K,M>

java.lang.Object
  extended by org.apache.commons.transaction.locking.AbstractLockManager<K,M>
      extended by org.apache.commons.transaction.locking.SimpleLockManager<K,M>
All Implemented Interfaces:
LockManager<K,M>

public class SimpleLockManager<K,M>
extends AbstractLockManager<K,M>
implements LockManager<K,M>

Default implementation of LockManager based on ReentrantLock.

This is a minimal implementation that only knows a single type of lock. Read-/Write-locks are not supported. Deadlock detection is not performed. Transferring locks between threads is not possible. These limitations are due to the standard Lock and ReadWriteLock implementations.

This implementation is thread-safe.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.commons.transaction.locking.AbstractLockManager
AbstractLockManager.KeyEntry<K,M>
 
Field Summary
protected  ConcurrentHashMap<AbstractLockManager.KeyEntry<K,M>,ReentrantLock> allLocks
           
 
Fields inherited from class org.apache.commons.transaction.locking.AbstractLockManager
effectiveGlobalTimeouts, locksForThreads
 
Constructor Summary
SimpleLockManager()
           
 
Method Summary
protected  ReentrantLock create()
           
protected  boolean hasTimedOut(Thread thread)
           
protected  void release()
           
protected  void reportTimeout(Thread thread)
           
protected  boolean tryLockInternal(M resourceManager, K key, boolean exclusive, long time, TimeUnit unit)
           
 
Methods inherited from class org.apache.commons.transaction.locking.AbstractLockManager
checkIsStarted, computeRemainingTime, endWork, isWorking, lock, startWork, tryLock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.transaction.locking.LockManager
endWork, lock, startWork, tryLock
 

Field Detail

allLocks

protected ConcurrentHashMap<AbstractLockManager.KeyEntry<K,M>,ReentrantLock> allLocks
Constructor Detail

SimpleLockManager

public SimpleLockManager()
Method Detail

create

protected ReentrantLock create()

tryLockInternal

protected boolean tryLockInternal(M resourceManager,
                                  K key,
                                  boolean exclusive,
                                  long time,
                                  TimeUnit unit)
                           throws LockException
Specified by:
tryLockInternal in class AbstractLockManager<K,M>
Throws:
LockException

reportTimeout

protected void reportTimeout(Thread thread)
                      throws LockException
Overrides:
reportTimeout in class AbstractLockManager<K,M>
Throws:
LockException

hasTimedOut

protected boolean hasTimedOut(Thread thread)
Overrides:
hasTimedOut in class AbstractLockManager<K,M>

release

protected void release()
Specified by:
release in class AbstractLockManager<K,M>


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