|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.entityfs.lock.cmd.LockCollection
public class LockCollection
The LockCollection
contains a collection of locked EntityLock
:s. A lock is saved together with the LockCommand
that was used to
lock it, and the LockCommand
can later be used to retrieve the lock.
Objects of this class are not thread safe.
Constructor Summary | |
---|---|
LockCollection()
|
Method Summary | |
---|---|
void |
addLock(LockCommand cmd,
EntityLock l)
Add one (locked) lock for the supplied command. |
void |
addLock(TwoObjects<? extends LockCommand,? extends EntityLock> l)
Add one locked lock and the command that generated it. |
void |
addLocks(Collection<? extends TwoObjects<? extends LockCommand,? extends EntityLock>> locks)
Add all the locks and commands in the supplied collection. |
boolean |
isEmpty()
Is the lock collection empty. |
Set<Map.Entry<LockCommand,Queue<EntityLock>>> |
lockEntrySet()
Get a set containing all entries in the lock collection. |
void |
merge(LockCollection lc)
Merge the contents of the supplied lock collection into this collection. |
EntityLock |
removeLock(LockCommand cmd)
Remove a lock that was locked by the supplied command and return it. |
Collection<TwoObjects<LockCommand,EntityLock>> |
removeLocks(Collection<? extends LockCommand> c)
Remove the locks created by the supplied commands from the collection and return them. |
void |
unlockAll()
Unlock all remaining locks in the collection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LockCollection()
Method Detail |
---|
public void addLock(LockCommand cmd, EntityLock l)
cmd
- The command.l
- The lock.addLock(LockCommand, EntityLock)
,
addLocks(Collection)
public void addLock(TwoObjects<? extends LockCommand,? extends EntityLock> l)
l
- The command and the lock.addLock(LockCommand, EntityLock)
,
addLocks(Collection)
public void addLocks(Collection<? extends TwoObjects<? extends LockCommand,? extends EntityLock>> locks)
locks
- A collection of locks together with the command that locked
them.addLock(LockCommand, EntityLock)
,
addLock(TwoObjects)
public EntityLock removeLock(LockCommand cmd) throws MissingLockException
The lock commands are checked for equality, so the supplied lock command
does not have to be the same lock command instance that produced the
lock; it just has to be equal to that lock command. (Or, rather, the lock
commands have to have equal hash codes, but that should be the same as to
say that the lock commands have to be equal, provided that the lock
command implementations follow the equals
<-> hashCode
contract.)
cmd
- The lock command.
null
if there were no locks for the lock
command in the collection.
MissingLockException
- If a lock locked by the supplied command is
not found.removeLocks(Collection)
public Collection<TwoObjects<LockCommand,EntityLock>> removeLocks(Collection<? extends LockCommand> c) throws MissingLockException
If no lock is found for any of the commands, the method throws an
MissingLockException
and no locks are removed.
See removeLock(LockCommand)
for a discussion on lock command
equality.
c
- The collection of lock commands.
MissingLockException
- If no lock was found for any of the supplied
commands.removeLock(LockCommand)
public Set<Map.Entry<LockCommand,Queue<EntityLock>>> lockEntrySet()
The returned set is read only.
public boolean isEmpty()
true
if the lock collection is empty.public void merge(LockCollection lc)
lc
- The lock collection with contents to be merged into this lock
collection. May be null
.public void unlockAll()
finally
block at the end of the code block where the lock
collection is used to ensure that all locks are released.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |