public class OptimisticLockManager extends Object implements LockManager
LockManager that uses an optimistic locking strategy. It uses the sequence number of
the last committed event to detect concurrent access.
Classes that use a repository with this strategy must implement any retry logic themselves. Use the ConcurrencyException to detect concurrent access.EventSourcedAggregateRoot,
ConcurrencyException| Constructor and Description |
|---|
OptimisticLockManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
obtainLock(Object aggregateIdentifier)
Obtain a lock for an aggregate with the given
aggregateIdentifier. |
void |
releaseLock(Object aggregateIdentifier)
Release the lock held for an aggregate with the given
aggregateIdentifier. |
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 LockManageraggregate - the aggregate to validate the lock forpublic void obtainLock(Object aggregateIdentifier)
aggregateIdentifier. Depending on the strategy, this
method may return immediately or block until a lock is held.obtainLock in interface LockManageraggregateIdentifier - the identifier of the aggregate to obtains a lock for.public void releaseLock(Object aggregateIdentifier)
aggregateIdentifier. The caller of this
method must ensure a valid lock was requested using LockManager.obtainLock(Object). If no lock was successfully
obtained, the behavior of this method is undefined.releaseLock in interface LockManageraggregateIdentifier - the identifier of the aggregate to release the lock for.Copyright © 2010-2014. All Rights Reserved.