public class PessimisticLockManager extends Object implements LockManager
LockManager
that uses a pessimistic locking strategy. Calls to obtainLock will block
until a lock could be obtained. If a lock is obtained by a thread, that thread has guaranteed unique access.Constructor and Description |
---|
PessimisticLockManager() |
Modifier and Type | Method and Description |
---|---|
void |
obtainLock(Object aggregateIdentifier)
Obtain a lock for an aggregate.
|
void |
releaseLock(Object aggregateIdentifier)
Release the lock held on the aggregate.
|
boolean |
validateLock(AggregateRoot aggregate)
Make sure that the current thread holds a valid lock for the given aggregate.
|
public boolean validateLock(AggregateRoot aggregate)
validateLock
in interface LockManager
aggregate
- the aggregate to validate the lock forpublic void obtainLock(Object aggregateIdentifier)
obtainLock
in interface LockManager
aggregateIdentifier
- the identifier of the aggregate to obtains a lock for.public void releaseLock(Object aggregateIdentifier)
releaseLock
in interface LockManager
aggregateIdentifier
- the identifier of the aggregate to release the lock for.IllegalStateException
- if no lock was ever obtained for this aggregateIllegalMonitorStateException
- if a lock was obtained, but is not currently held by the current threadCopyright © 2010-2014. All Rights Reserved.