|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.entityfs.lock.EntityLocks
public final class EntityLocks
This class contains static utility methods for working with
EntityLock
:s.
Method Summary | ||
---|---|---|
static Collection<EntityLock> |
lockAll(boolean writeLock,
EntityView... entities)
Lock all provided entities. |
|
static EntityLock |
lockParentForReading(EntityView ev)
Lock the entity's parent for reading and return the lock object. |
|
static EntityLock |
lockParentForWriting(EntityView ev)
Lock the entity's parent for writing and return the lock object. |
|
static EntityLock |
switchReadLocks(EntityView entity,
EntityLock oldLock)
Switch the locked lock for a new read lock on the entity. |
|
static EntityLock |
switchWriteLocks(EntityView entity,
EntityLock oldLock)
Switch the locked lock for a new write lock on the entity. |
|
static void |
unlockAll(Collection<? extends EntityLock> locks)
Unlock all locks in the collection that are locked by the current thread. |
|
static
|
unlockAll(T[] locks)
Unlock all locks in the array that are locked by the current thread. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static EntityLock switchReadLocks(EntityView entity, EntityLock oldLock)
entity
- The entity to lock for reading.oldLock
- The old lock to unlock after acquiring the read lock.
public static EntityLock switchWriteLocks(EntityView entity, EntityLock oldLock)
entity
- The entity to lock for writing.oldLock
- The old lock to unlock after acquiring the write lock.
public static void unlockAll(Collection<? extends EntityLock> locks)
locks
- The locks to unlock. May be null
.public static <T extends EntityLock> void unlockAll(T[] locks)
locks
- The locks to unlock. May be null
.public static Collection<EntityLock> lockAll(boolean writeLock, EntityView... entities)
hashCode
order).
writeLock
- If true
, entities are locked for writing. If
false
, locked for reading.entities
- The entities to lock.
public static EntityLock lockParentForReading(EntityView ev) throws IllegalArgumentException, EntityNotFoundException
EntityView.getParent()
method is
called and when the parent is locked. Once the parent is locked, the
entity is prevented from moving.
This method keeps trying until it manages to lock the entity's parent directory. (By checking that the entity is still in the parent directory after it is locked.)
When this method returns, it is guaranteed that
EntityView.getParent()
on the entity will return the
locked parent.
ev
- The entity whose parent should be locked for reading.
IllegalArgumentException
- If the entity is the root directory of a
file system. A root directory does not have a parent directory.
EntityNotFoundException
- If the entity or the entity's parent are
deleted.lockParentForWriting(EntityView)
public static EntityLock lockParentForWriting(EntityView ev) throws IllegalArgumentException, EntityNotFoundException
EntityView.getParent()
method is
called and when the parent is locked. Once the parent is locked, the
entity is prevented from moving.
This method keeps trying until it manages to lock the entity's parent directory. (By checking that the entity is still in the parent directory after it is locked.)
When this method returns, it is guaranteed that
EntityView.getParent()
on the entity will return the
locked parent.
ev
- The entity whose parent should be locked for writing.
IllegalArgumentException
- If the entity is the root directory of a
file system. A root directory does not have a parent directory.
EntityNotFoundException
- If the entity or the entity's parent are
deleted.lockParentForWriting(EntityView)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |