|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sf.spif.util.Locker
A class for coordinating exclusive access to objects
accross simultaneous threads.
Keeps identified
items locked for a given
time interval (leasing).
Constructor Summary | |
Locker(long lockTimeoutMillis)
Creates a locked with a lock timeout in milliseconds |
Method Summary | |
void |
clear()
Clears all locks |
long |
getLockTimeoutMillis()
Returns the lock timeout of this locked in milliseconds |
boolean |
isLockedBy(Id id,
java.lang.String key)
Returns whether this id is currently locked by this key. |
boolean |
isLockedByOther(Id id,
java.lang.String key)
Returns true if this id is currently locked, but by another key |
void |
lock(Id id,
java.lang.String key)
Locks (or relocks) an item. |
void |
setLockTimeoutMillis(long lockTimeoutMillis)
Sets the lock timeout of this locked in missiseconds |
void |
unlock(Id id,
java.lang.String key)
Unlocks the given id if it is still locked by the given key. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Locker(long lockTimeoutMillis)
Method Detail |
public void lock(Id id, java.lang.String key) throws LockedException
id
- the id of the item to lockkey
- the key to use as lock
LockedException
- if the item was allready locked by another key
Note that the exception will contain the key of the item, change
this if keys are secretspublic void unlock(Id id, java.lang.String key)
public boolean isLockedBy(Id id, java.lang.String key)
public boolean isLockedByOther(Id id, java.lang.String key)
public long getLockTimeoutMillis()
public void setLockTimeoutMillis(long lockTimeoutMillis)
public void clear()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |