public class CaseSynchronizer extends Object implements Synchronizer
A helper class that manages lock objects for cases identified by a string ID.
This implementation manages an integer counter for each synch object, allowing for
situations where the synch object is requested and released in a nested manner.
The first call to get the object allocates a new synch object, the last call to
unlock the object releases the object. Any nested calls simply up- and down
count on the synch object.
<p>
This implementation ensures that at most one thread has access to the synch object. If some other
thread is holding the synch object for a given case Id, the requesting thread calling
getSynchObject will block until the thread holding the lock releases the lock.</p>
<p>
This implementation uses class ReentrantLock
as the lock object.
The blocking feature of this implementation is achieved via the blocking property of the ReentrantLock.
The invocation nesting level counter is implemented by using the hold count feature of ReentrantLock.</p>
Constructor and Description |
---|
CaseSynchronizer() |
CaseSynchronizer(int timeoutSeconds) |
Modifier and Type | Method and Description |
---|---|
HashMap<String,RecursiveLock> |
getCaseSynchronizationMap() |
Object |
getSynchObject(String caseClientId)
Get the synch object identified by <code>caseClientId</code>.
|
int |
getTimeoutSeconds() |
boolean |
releaseSynchObject(String caseClientId)
Release the synch object associated with the passed id.
|
public CaseSynchronizer()
public CaseSynchronizer(int timeoutSeconds)
public Object getSynchObject(String caseClientId)
Get the synch object identified by <code>caseClientId</code>. This call may block until another thread holding the lock for a case has released the lock.
getSynchObject
in interface Synchronizer
public boolean releaseSynchObject(String caseClientId)
Synchronizer
Release the synch object associated with the passed id.
releaseSynchObject
in interface Synchronizer
true
if the resource associated with the passed id has been released. false
if
the current thread is still holding the resource due to a recursive invocation of
Synchronizer.getSynchObject(String)
.public HashMap<String,RecursiveLock> getCaseSynchronizationMap()
public int getTimeoutSeconds()
Copyright © 2010 - 2019 edorasware ag. All Rights Reserved.