org.apache.commons.transaction.locking
Class GenericLockManager

java.lang.Object
  extended byorg.apache.commons.transaction.locking.GenericLockManager
All Implemented Interfaces:
LockManager

public class GenericLockManager
extends Object
implements LockManager

Manager for GenericLocks on resources.

Version:
$Revision: 1.1 $

Field Summary
protected  Map globalLocks
           
protected  LoggerFacade logger
           
protected  int maxLockLevel
           
 
Constructor Summary
GenericLockManager(int maxLockLevel, LoggerFacade logger)
           
 
Method Summary
 MultiLevelLock atomicGetOrCreateLock(Object resourceId)
          Either gets an existing lock on the specified resource or creates one if none exists.
protected  GenericLock createLock(Object resourceId)
           
 MultiLevelLock getLock(Object resourceId)
          Gets an existing lock on the specified resource.
 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 Map globalLocks

maxLockLevel

protected int maxLockLevel

logger

protected LoggerFacade logger
Constructor Detail

GenericLockManager

public GenericLockManager(int maxLockLevel,
                          LoggerFacade logger)
                   throws IllegalArgumentException
Method Detail

getLock

public MultiLevelLock getLock(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(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 Collection getLocks()
Gets all locks as orignials, no copies.

Returns:
collection holding all locks.

createLock

protected GenericLock createLock(Object resourceId)


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