com.im.commons 5.9

com.im.commons.progress
Interface DFLock


public interface DFLock

A lock that can be used to restrict access to a DIF object. The lock should be released when you finish all your changes.

Note 1: Do not keep the lock for long time, release it when possible. During the time you have a DIF object locked, no other action can do anything with this and all actions are disabled.

Node 2: The recommended code for lock obtaining and releasing is:

 DFLock lock = null;
 try {
     lock = someObject.getLockable().obtainLock("doing some change");
     someObject.doTheOperationWithLock(...);
 }
 finally {
     if (lock != null) {
          lock.release();
     }
 }
 
This type of code is pretty safe and always release the lock even if the operation fails.


Method Summary
 String getReason()
          Return the reason of locking (usually the action human readable name)
 boolean isValid()
          When lock is released it become invalid and cannot be used more
 void release()
          Releases the lock.
 

Method Detail

isValid

boolean isValid()
When lock is released it become invalid and cannot be used more


release

void release()
Releases the lock. Further releases will throw IllegalStateException


getReason

String getReason()
Return the reason of locking (usually the action human readable name)


com.im.commons 5.9