Package com.coditory.sherlock
Class SherlockStub
- java.lang.Object
-
- com.coditory.sherlock.SherlockStub
-
-
Constructor Summary
Constructors Constructor Description SherlockStub()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.coditory.sherlock.DistributedLockBuilder<DistributedLock>createLock()Creates a distributed lock.com.coditory.sherlock.DistributedLockBuilder<DistributedLock>createOverridingLock()Create a distributed overriding lock.com.coditory.sherlock.DistributedLockBuilder<DistributedLock>createReentrantLock()Creates a distributed reentrant lock.booleanforceReleaseAllLocks()Force releases all acquired locks.voidinitialize()Initializes underlying infrastructure.static SherlockStubwithAcquiredLocks()Make the stub produce acquired locks by defaultSherlockStubwithLock(DistributedLock lock)Make the stub produce return a predefined lock.static SherlockStubwithReleasedLocks()Make the stub produce released locks by default-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.coditory.sherlock.Sherlock
createLock, createOverridingLock, createReentrantLock, forceReleaseLock
-
-
-
-
Method Detail
-
withReleasedLocks
public static SherlockStub withReleasedLocks()
Make the stub produce released locks by default- Returns:
- the stub instance
-
withAcquiredLocks
public static SherlockStub withAcquiredLocks()
Make the stub produce acquired locks by default- Returns:
- the stub instance
-
withLock
public SherlockStub withLock(DistributedLock lock)
Make the stub produce return a predefined lock.- Parameters:
lock- returned when creating a lock with the same id- Returns:
- the stub instance
-
initialize
public void initialize()
Description copied from interface:SherlockInitializes underlying infrastructure. If this method is not invoked explicitly then it can be invoked implicitly when acquiring or releasing a lock for the first time.Most often initialization is related with creating indexes and tables.
- Specified by:
initializein interfaceSherlock
-
createLock
public com.coditory.sherlock.DistributedLockBuilder<DistributedLock> createLock()
Description copied from interface:SherlockCreates a distributed lock. Created lock may be acquired only once by the same owner:assert lock.acquire() == true assert lock.acquire() == false- Specified by:
createLockin interfaceSherlock- Returns:
- the lock builder
-
createReentrantLock
public com.coditory.sherlock.DistributedLockBuilder<DistributedLock> createReentrantLock()
Description copied from interface:SherlockCreates a distributed reentrant lock. Reentrant lock may be acquired multiple times by the same owner:assert reentrantLock.acquire() == true assert reentrantLock.acquire() == true- Specified by:
createReentrantLockin interfaceSherlock- Returns:
- the reentrant lock builder
-
createOverridingLock
public com.coditory.sherlock.DistributedLockBuilder<DistributedLock> createOverridingLock()
Description copied from interface:SherlockCreate a distributed overriding lock. Returned lock may acquire or release any other lock without checking its state:assert someLock.acquire() == true assert overridingLock.acquire() == trueIt could be used for administrative actions.
- Specified by:
createOverridingLockin interfaceSherlock- Returns:
- the overriding lock builder
-
forceReleaseAllLocks
public boolean forceReleaseAllLocks()
Description copied from interface:SherlockForce releases all acquired locks.It could be used for administrative actions.
- Specified by:
forceReleaseAllLocksin interfaceSherlock- Returns:
- true if any lock was released
-
-