|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Extended multi level lock. Compared to basic MultiLevelLock
allows for more flexible
locking including preference and more compatibility modes.
LockManager2
,
MultiLevelLock
,
GenericLock
Field Summary | |
static int |
COMPATIBILITY_NONE
Compatibility mode: none reentrant. |
static int |
COMPATIBILITY_REENTRANT
Compatibility mode: reentrant. |
static int |
COMPATIBILITY_REENTRANT_AND_SUPPORT
Compatibility mode: reentrant and supporting. |
static int |
COMPATIBILITY_SUPPORT
Compatibility mode: supporting. |
Method Summary | |
boolean |
acquire(java.lang.Object ownerId,
int targetLockLevel,
boolean wait,
int compatibility,
boolean preferred,
long timeoutMSecs)
Tries to acquire a certain lock level on this lock. |
boolean |
has(java.lang.Object ownerId,
int lockLevel)
Tests if a certain lock level is owned by an owner. |
boolean |
test(java.lang.Object ownerId,
int targetLockLevel,
int compatibility)
Tests if a certain lock level could be acquired. |
Methods inherited from interface org.apache.commons.transaction.locking.MultiLevelLock |
acquire, getLockLevel, release |
Field Detail |
public static final int COMPATIBILITY_NONE
public static final int COMPATIBILITY_REENTRANT
public static final int COMPATIBILITY_SUPPORT
public static final int COMPATIBILITY_REENTRANT_AND_SUPPORT
Method Detail |
public boolean has(java.lang.Object ownerId, int lockLevel)
ownerId
- a unique id identifying the entity that wants to check a
certain lock level on this locklockLevel
- the lock level to test
true
if the lock could be acquired at the time
this method was calledpublic boolean test(java.lang.Object ownerId, int targetLockLevel, int compatibility)
ownerId
- a unique id identifying the entity that wants to test a
certain lock level on this locktargetLockLevel
- the lock level to acquirecompatibility
- COMPATIBILITY_NONE
if no additional compatibility is
desired (same as reentrant set to false) ,
COMPATIBILITY_REENTRANT
if lock level by the same
owner shall not affect compatibility (same as reentrant set to
true), or COMPATIBILITY_SUPPORT
if lock levels that
are the same as the desired shall not affect compatibility, or
finally COMPATIBILITY_REENTRANT_AND_SUPPORT
which is
a combination of reentrant and support
true
if the lock could be acquired at the time
this method was calledpublic boolean acquire(java.lang.Object ownerId, int targetLockLevel, boolean wait, int compatibility, boolean preferred, long timeoutMSecs) throws java.lang.InterruptedException
MultiLevelLock.acquire(java.lang.Object, int, boolean, boolean, long)
except that it allows for different compatibility settings. There is an
additional compatibility mode 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.
ownerId
- a unique id identifying the entity that wants to acquire a certain lock level on this locktargetLockLevel
- the lock level to acquirewait
- true
if this method shall block when the desired lock level can not be acquiredcompatibility
- COMPATIBILITY_NONE
if no additional compatibility is
desired (same as reentrant set to false) ,
COMPATIBILITY_REENTRANT
if lock level by the same
owner shall not affect compatibility (same as reentrant set to
true), or COMPATIBILITY_SUPPORT
if lock levels that
are the same as the desired shall not affect compatibility, or
finally COMPATIBILITY_REENTRANT_AND_SUPPORT
which is
a combination of reentrant and supportpreferred
- in case this lock request is incompatible with existing ones
and we wait, it shall be granted before other waiting requests
that are not preferredtimeoutMSecs
- if blocking is enabled by the wait
parameter this specifies the maximum wait time in milliseconds
true
if the lock actually was acquired
java.lang.InterruptedException
- when the thread waiting on this method is interrupted
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |