org.apache.slide.util.locking.impl
Class GenericLockManager

java.lang.Object
  extended byorg.apache.slide.util.locking.impl.GenericLockManager
All Implemented Interfaces:
LockManager

public class GenericLockManager
extends java.lang.Object
implements LockManager

Manager for GenericLocks on resources.

Author:
Oliver Zeigermann

Field Summary
protected  java.util.Map globalLocks
           
protected  StoreLogger logger
           
protected  int maxLockLevel
           
 
Constructor Summary
GenericLockManager(int maxLockLevel, StoreLogger logger)
           
 
Method Summary
 MultiLevelLock atomicGetOrCreateLock(java.lang.Object resourceId)
          Either gets an existing lock on the specified resource or creates one if none exists.
protected  GenericLock createLock(java.lang.Object resourceId)
           
 MultiLevelLock getLock(java.lang.Object resourceId)
          Gets an existing lock on the specified resource.
 java.util.Collection getLocks()
          Gets all locks as orignials, no copies.
 void removeLock(MultiLevelLock lock)
          Removes the specified lock from the associated resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

globalLocks

protected java.util.Map globalLocks

maxLockLevel

protected int maxLockLevel

logger

protected StoreLogger logger
Constructor Detail

GenericLockManager

public GenericLockManager(int maxLockLevel,
                          StoreLogger logger)
                   throws java.lang.IllegalArgumentException
Method Detail

getLock

public MultiLevelLock getLock(java.lang.Object resourceId)
Description copied from interface: LockManager
Gets an existing lock on the specified resource. If none exists it returns null.

Specified by:
getLock in interface LockManager
Parameters:
resourceId - the resource to get the lock for
Returns:
the lock on the specified resource

atomicGetOrCreateLock

public MultiLevelLock atomicGetOrCreateLock(java.lang.Object resourceId)
Description copied from interface: LockManager
Either gets an existing lock on the specified resource or creates one if none exists. This methods guarantees to do this atomically.

Specified by:
atomicGetOrCreateLock in interface LockManager
Parameters:
resourceId - the resource to get or create the lock on
Returns:
the lock for the specified resource

removeLock

public void removeLock(MultiLevelLock lock)
Description copied from interface: LockManager
Removes the specified lock from the associated resource.

Specified by:
removeLock in interface LockManager
Parameters:
lock - the lock to be removed

getLocks

public java.util.Collection getLocks()
Gets all locks as orignials, no copies.

Returns:
collection holding all locks.

createLock

protected GenericLock createLock(java.lang.Object resourceId)