| org.apache.commons.transaction.locking.MultiLevelLock2
All known Subclasses: org.apache.commons.transaction.locking.GenericLock,
MultiLevelLock2 | public interface MultiLevelLock2 extends MultiLevelLock(Code) | | Extended multi level lock. Compared to basic
MultiLevelLock allows for more flexible
locking including preference and more compatibility modes.
version: $Id: MultiLevelLock2.java 493628 2007-01-07 01:42:48Z joerg $ See Also: LockManager2 See Also: MultiLevelLock See Also: GenericLock since: 1.1 |
Method Summary | |
public boolean | acquire(Object ownerId, int targetLockLevel, boolean wait, int compatibility, boolean preferred, long timeoutMSecs) Tries to acquire a certain lock level on this lock. | public boolean | has(Object ownerId, int lockLevel) Tests if a certain lock level is owned by an owner. | public boolean | test(Object ownerId, int targetLockLevel, int compatibility) Tests if a certain lock level could be acquired. |
COMPATIBILITY_NONE | final public static int COMPATIBILITY_NONE(Code) | | Compatibility mode: none reentrant. Lock level by the same owner shall
affect compatibility.
|
COMPATIBILITY_REENTRANT | final public static int COMPATIBILITY_REENTRANT(Code) | | Compatibility mode: reentrant. Lock level by the same owner shall not
affect compatibility.
|
COMPATIBILITY_REENTRANT_AND_SUPPORT | final public static int COMPATIBILITY_REENTRANT_AND_SUPPORT(Code) | | Compatibility mode: reentrant and supporting. Lock levels that are the same as the
desired and lock levels held by the same
owner shall not affect compatibility.
|
COMPATIBILITY_SUPPORT | final public static int COMPATIBILITY_SUPPORT(Code) | | Compatibility mode: supporting. Lock levels that are the same as the
desired shall not affect compatibility, but lock level held by the same
owner shall.
|
acquire | public boolean acquire(Object ownerId, int targetLockLevel, boolean wait, int compatibility, boolean preferred, long timeoutMSecs) throws InterruptedException(Code) | | Tries to acquire a certain lock level on this lock. Does the same as
org.apache.commons.transaction.locking.MultiLevelLock.acquire(java.lang.Objectintbooleanbooleanlong) except that it allows for different compatibility settings. There is an
additional compatibility mode
MultiLevelLock2.COMPATIBILITY_SUPPORT that allows
equal lock levels not to interfere with each other. This is like an
additional shared compatibility and useful when you only want to make
sure not to interfer with lowe levels, but are fine with the same.
Parameters: ownerId - a unique id identifying the entity that wants to acquire a certain lock level on this lock Parameters: targetLockLevel - the lock level to acquire Parameters: wait - true if this method shall block when the desired lock level can not be acquired Parameters: compatibility - MultiLevelLock2.COMPATIBILITY_NONEif no additional compatibility isdesired (same as reentrant set to false) ,MultiLevelLock2.COMPATIBILITY_REENTRANTif lock level by the sameowner shall not affect compatibility (same as reentrant set totrue), or MultiLevelLock2.COMPATIBILITY_SUPPORTif lock levels thatare the same as the desired shall not affect compatibility, orfinally MultiLevelLock2.COMPATIBILITY_REENTRANT_AND_SUPPORTwhich isa combination of reentrant and support Parameters: preferred - in case this lock request is incompatible with existing onesand we wait, it shall be granted before other waiting requeststhat are not preferred Parameters: timeoutMSecs - if blocking is enabled by the wait parameter this specifies the maximum wait time in milliseconds true if the lock actually was acquired throws: InterruptedException - when the thread waiting on this method is interrupted |
has | public boolean has(Object ownerId, int lockLevel)(Code) | | Tests if a certain lock level is owned by an owner.
Parameters: ownerId - a unique id identifying the entity that wants to check acertain lock level on this lock Parameters: lockLevel - the lock level to test true if the lock could be acquired at the timethis method was called |
test | public boolean test(Object ownerId, int targetLockLevel, int compatibility)(Code) | | Tests if a certain lock level could be acquired. This method
tests only and does not actually acquire the lock.
Parameters: ownerId - a unique id identifying the entity that wants to test acertain lock level on this lock Parameters: targetLockLevel - the lock level to acquire Parameters: compatibility - MultiLevelLock2.COMPATIBILITY_NONEif no additional compatibility isdesired (same as reentrant set to false) ,MultiLevelLock2.COMPATIBILITY_REENTRANTif lock level by the sameowner shall not affect compatibility (same as reentrant set totrue), or MultiLevelLock2.COMPATIBILITY_SUPPORTif lock levels thatare the same as the desired shall not affect compatibility, orfinally MultiLevelLock2.COMPATIBILITY_REENTRANT_AND_SUPPORTwhich isa combination of reentrant and support true if the lock could be acquired at the timethis method was called |
|
|