org.apache.commons.transaction.locking
Interface MultiLevelLock

All Known Subinterfaces:
MultiLevelLock2
All Known Implementing Classes:
GenericLock, ReadWriteLock, ReadWriteUpgradeLock

public interface MultiLevelLock

A multi level lock. Depending on the implementation more than one owner may own a certain lock level on the same lock.

Version:
$Revision$
See Also:
LockManager

Method Summary
 boolean acquire(Object ownerId, int targetLockLevel, boolean wait, boolean reentrant, long timeoutMSecs)
          Tries to acquire a certain lock level on this lock.
 int getLockLevel(Object ownerId)
          Retuns the highest lock level the specified owner holds on this lock or 0 if it holds no locks at all.
 boolean release(Object ownerId)
          Releases any lock levels the specified owner may hold on this lock.
 

Method Detail

acquire

boolean acquire(Object ownerId,
                int targetLockLevel,
                boolean wait,
                boolean reentrant,
                long timeoutMSecs)
                throws InterruptedException
Tries to acquire a certain lock level on this lock.

Parameters:
ownerId - a unique id identifying the entity that wants to acquire a certain lock level on this lock
targetLockLevel - the lock level to acquire
wait - true if this method shall block when the desired lock level can not be acquired
reentrant - true if lock levels of the same entity acquired earlier should not restrict compatibility with the lock level desired now
timeoutMSecs - if blocking is enabled by the wait parameter this specifies the maximum wait time in milliseconds
Returns:
true if the lock actually was acquired
Throws:
InterruptedException - when the thread waiting on this method is interrupted

release

boolean release(Object ownerId)
Releases any lock levels the specified owner may hold on this lock.

Parameters:
ownerId - a unique id identifying the entity that wants to release all lock levels
Returns:
true if the lock actually was released, false in case there was no lock held by the owner

getLockLevel

int getLockLevel(Object ownerId)
Retuns the highest lock level the specified owner holds on this lock or 0 if it holds no locks at all.

Parameters:
ownerId - a unique id identifying the entity that wants to know its highest lock level
Returns:
the highest lock level


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