Methods Summary |
---|
public static imaginary.persist.Lock | createLock(RemoteLockHolder holder, Persistent p)Checks to see if the lock holder already has a lock associated
with it. If so, return it. If not, create a new one.
Either way, spawn a for this persistent.
Lock l;
if( locks.containsKey(holder) ) {
l = (Lock)locks.get(holder);
l.createThread(p);
}
else {
try {
l = new Lock(holder);
}
catch( RemoteException e ) {
throw new LockException(e.getMessage());
}
l.createThread(p);
locks.put(holder, l);
}
return l;
|
public void | createThread(Persistent p)Creates a new LockThread for monitoring a new persistent object
locked by this lock.
if( threads.containsKey(p) ) {
return;
}
else {
LockThread thread = new LockThread(this, p);
threads.put(p, thread);
transaction.addPersistent(p);
}
|
public RemoteLockHolder | getHolder()
return lock_holder;
|
public Transaction | getTransaction()
return transaction;
|
public void | loseLock(Persistent p)If a problem occurs while a thread is monitoring a lock, it
calls this method. This method then triggers loseLock() in both the
thread and persistent so they can clean up after the loss of the lock.
if( !threads.containsKey(p) ) {
return;
}
else {
LockThread thread = (LockThread)threads.get(p);
thread.loseLock();
p.loseLock();
threads.remove(p);
transaction.removePersistent(p);
}
|
public void | monitorLock(Persistent p)This method is triggered periodically by the LockThread
to monitor the lock and make sure the client/server connection
is still there.
p.monitorLock();
if( !threads.containsKey(p) ) {
return;
}
else {
lock_holder.monitorLock(p);
}
|
public void | releaseLock(Persistent p)This method signals a normal end to a lock, normally because
the client saved its objects.
if( !threads.containsKey(p) ) {
return;
}
else {
LockThread thread = (LockThread)threads.get(p);
thread.releaseLock();
threads.remove(p);
}
|
public synchronized void | save()Triggers the save process for all locked objects.
transaction.save();
|