|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.transaction.locking.AbstractLockManager<K,M>
public abstract class AbstractLockManager<K,M>
Abstract implementation of LockManager. You can use this
implementation as a base for your custom implementations.
This implementation is thread-safe.
| Nested Class Summary | |
|---|---|
protected static class |
AbstractLockManager.KeyEntry<K,M>
|
| Field Summary | |
|---|---|
protected Map<Thread,Long> |
effectiveGlobalTimeouts
|
protected Map<Thread,Set<Lock>> |
locksForThreads
|
| Constructor Summary | |
|---|---|
AbstractLockManager()
|
|
| Method Summary | |
|---|---|
protected void |
checkIsStarted()
|
protected long |
computeRemainingTime(Thread thread)
|
void |
endWork()
Ends a block of work that has been started in LockManager.startWork(long, TimeUnit). |
protected boolean |
hasTimedOut(Thread thread)
|
boolean |
isWorking()
|
void |
lock(M resourceManager,
K key,
boolean exclusive)
Locks a resource denoted by a key and a resource manager. |
protected abstract void |
release()
|
protected void |
reportTimeout(Thread thread)
|
void |
startWork(long timeout,
TimeUnit unit)
Starts a block of work for which a certain set of locks is required. |
boolean |
tryLock(M resourceManager,
K key,
boolean exclusive)
Tries to acquire a lock on a resource denoted by a key and a resource manager. |
protected abstract boolean |
tryLockInternal(M resourceManager,
K key,
boolean exclusive,
long time,
TimeUnit unit)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Map<Thread,Set<Lock>> locksForThreads
protected Map<Thread,Long> effectiveGlobalTimeouts
| Constructor Detail |
|---|
public AbstractLockManager()
| Method Detail |
|---|
public void endWork()
LockManagerLockManager.startWork(long, TimeUnit). All locks acquired will be released.
All registered locks will be unregistered from this lock manager.
endWork in interface LockManager<K,M>protected abstract void release()
public void startWork(long timeout,
TimeUnit unit)
LockManager
startWork in interface LockManager<K,M>timeout - the maximum time for the whole work to take before it times
outunit - the time unit of the timeout argumentprotected void checkIsStarted()
protected long computeRemainingTime(Thread thread)
public boolean isWorking()
public void lock(M resourceManager,
K key,
boolean exclusive)
throws LockException
LockManager
lock in interface LockManager<K,M>resourceManager - resource manager that tries to acquire a lockkey - the key for the resource to be lockedexclusive - true if this lock shall be acquired in
exclusive mode, false if it can be shared by
other threads
LockException - if the lock could not be acquired, possibly because of a
timeout or a deadlock
public boolean tryLock(M resourceManager,
K key,
boolean exclusive)
LockManager
tryLock in interface LockManager<K,M>resourceManager - resource manager that tries to acquire a lockkey - the key for the resource to be lockedexclusive - true if this lock shall be acquired in
exclusive mode, false if it can be shared by
other threads
true if the lock was acquired, false
otherwise
protected abstract boolean tryLockInternal(M resourceManager,
K key,
boolean exclusive,
long time,
TimeUnit unit)
throws LockException
LockException
protected void reportTimeout(Thread thread)
throws LockException
LockExceptionprotected boolean hasTimedOut(Thread thread)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||