|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.axonframework.common.lock.IdentifierBasedLock
public class IdentifierBasedLock
Locking mechanism that allows multiple threads to hold a lock, as long as the identifier of the lock they hold is not equal. When released, locks entries are automatically cleaned up.
The lock is re-entrant, meaning each thread can hold the same lock multiple times. The lock will only be released for other threads when the lock has been released as many times as it was obtained. This lock can be used to ensure thread safe access to a number of objects, such as Aggregates and Sagas.
Constructor Summary | |
---|---|
IdentifierBasedLock()
Creates a new IdentifierBasedLock instance. |
Method Summary | |
---|---|
boolean |
hasLock(String identifier)
Indicates whether the current thread hold a lock for the given identifier . |
void |
obtainLock(String identifier)
Obtain a lock on the given identifier . |
void |
releaseLock(String identifier)
Release the lock held on the given identifier . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IdentifierBasedLock()
Method Detail |
---|
public boolean hasLock(String identifier)
identifier
.
identifier
- The identifier of the lock to verify
true
if the current thread holds a lock, otherwise false
public void obtainLock(String identifier)
identifier
. This method will block until a lock was successfully
obtained.
Note: when an exception occurs during the locking process, the lock may or may not have been allocated.
identifier
- the identifier of the lock to obtain.public void releaseLock(String identifier)
identifier
. If no valid lock is held by the current thread, an
exception is thrown.
identifier
- the identifier to release the lock for.
IllegalStateException
- if no lock was ever obtained for this aggregate
IllegalMonitorStateException
- if a lock was obtained, but is not currently held by the current thread
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |