|
com.im.commons 5.9 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
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 |
|---|
boolean isValid()
void release()
IllegalStateException
String getReason()
|
com.im.commons 5.9 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||