org.axonframework.repository
Class PessimisticLockManager

java.lang.Object
  extended by org.axonframework.repository.PessimisticLockManager
All Implemented Interfaces:
LockManager

public class PessimisticLockManager
extends Object
implements LockManager

Implementation of the 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.

Since:
0.3
Author:
Allard Buijze

Constructor Summary
PessimisticLockManager()
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PessimisticLockManager

public PessimisticLockManager()
Method Detail

validateLock

public boolean validateLock(AggregateRoot aggregate)
Make sure that the current thread holds a valid lock for the given aggregate.

Specified by:
validateLock in interface LockManager
Parameters:
aggregate - the aggregate to validate the lock for
Returns:
true if a valid lock is held, false otherwise

obtainLock

public void obtainLock(Object aggregateIdentifier)
Obtain a lock for an aggregate. This method will block until a lock was successfully obtained.

Specified by:
obtainLock in interface LockManager
Parameters:
aggregateIdentifier - the identifier of the aggregate to obtains a lock for.

releaseLock

public void releaseLock(Object aggregateIdentifier)
Release the lock held on the aggregate. If no valid lock is held by the current thread, an exception is thrown.

Specified by:
releaseLock in interface LockManager
Parameters:
aggregateIdentifier - the identifier of the aggregate to release the lock for.
Throws:
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


Copyright © 2010-2016. All Rights Reserved.