|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.sourceforge.jemm.client.DelegatingObjectDatabase
org.sourceforge.jemm.client.SynchronousLockDecorator
public class SynchronousLockDecorator
An ObjectDatabase implementation that converts acquireLock calls into synchronous calls that wait for the lock to be acquired. Implementation notes -------------------- This implementation works by each thread registering itself in a Map with its clientThreadId pointing to a lock object on which the thread waits. Once the async listener calls for that particular ID then the lock is notified and the original thread is released. Since a clientThreadId is unique for each thread there is only ever one listener per lock. Note that if the clientThreadId is not unique by thread then acquireLock will return without acquiring the lock and threads could be locked indefinitely.
Constructor Summary | |
---|---|
SynchronousLockDecorator(ClientId clientId,
ObjectDatabase delegate)
|
Method Summary | |
---|---|
void |
acquireLock(ClientThreadId threadId,
ID jemmId)
Acquires a lock by calling onto the delegate database and waiting for an asynchronous response back. |
void |
lockAcquired(ClientThreadId threadId,
ID object)
A listener method implementation that gets the lock and notifies the waiting thread. |
void |
removeLockAcquiredListener(ClientId clientId)
Attempts to change the LockAcquiredListener are ignored. |
void |
setClientLockAcquiredListener(ClientId clientId,
LockAcquiredListener listener)
Attempts to change the LockAcquiredListener are ignored. |
Methods inherited from class org.sourceforge.jemm.client.DelegatingObjectDatabase |
---|
getClassInfo, getEnumInfo, getObject, getRefreshedObject, getRoot, newObject, processTypeRequest, refreshObject, registerClass, registerEnum, releaseLock, setRoot, setRootIfNull, synchroniseObject |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SynchronousLockDecorator(ClientId clientId, ObjectDatabase delegate)
Method Detail |
---|
public void acquireLock(ClientThreadId threadId, ID jemmId)
acquireLock
in interface ObjectDatabase
acquireLock
in class DelegatingObjectDatabase
threadId
- a unique identifier for a Thread (and client). MUST BE UNIQUE
PER THREAD.jemmId
- The ID to lock onpublic void removeLockAcquiredListener(ClientId clientId)
removeLockAcquiredListener
in interface ObjectDatabase
removeLockAcquiredListener
in class DelegatingObjectDatabase
clientId
- The id the the client who is no longer interested in lock events.public void setClientLockAcquiredListener(ClientId clientId, LockAcquiredListener listener)
setClientLockAcquiredListener
in interface ObjectDatabase
setClientLockAcquiredListener
in class DelegatingObjectDatabase
clientId
- The client who is interested in their lock event notifications.listener
- The listener to register.public void lockAcquired(ClientThreadId threadId, ID object)
lockAcquired
in interface LockAcquiredListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |