org.entityfs.lock
Interface EntityLockAdapter

All Superinterfaces:
LockAdapter

public interface EntityLockAdapter
extends LockAdapter

This is an extension of the LockAdapter that is used by entity objects. It contains methods for accessing the entity's read and write locks, and for creating custom locks for an entity object.

This interface is never used by file system clients directly (as a difference to LockAdapter). They use the locking methods defined in EntityView instead. locking methods on

Since:
1.0
Author:
Karl Gustafsson
See Also:
LockAcquiringStrategy, EntityLockAdapterFactory

Method Summary
 void createEntityLockForIdentifier(Object identifier, boolean readLock, boolean writeLock)
          This must be called before using a lock to ensure that it exists in the lock adapter.
 EntityLock getEntityLock(Object identifier)
          Get the lock identified by the identifier.
 EntityLock getReadLock()
          Get the entity's read lock.
 EntityLock getWriteLock()
           
 boolean isReadLockedByCurrentThread()
           
 boolean isWriteLockedByCurrentThread()
           
 
Methods inherited from interface org.entityfs.lock.LockAdapter
createLockForIdentifier, getLock
 

Method Detail

getReadLock

EntityLock getReadLock()
Get the entity's read lock. This may or may not be the same lock as the entity's write lock, depending on the EntityLockAdapterFactory used by the file system.

Returns:
The entity's read lock.

getWriteLock

EntityLock getWriteLock()

isReadLockedByCurrentThread

boolean isReadLockedByCurrentThread()

isWriteLockedByCurrentThread

boolean isWriteLockedByCurrentThread()

createEntityLockForIdentifier

void createEntityLockForIdentifier(Object identifier,
                                   boolean readLock,
                                   boolean writeLock)
This must be called before using a lock to ensure that it exists in the lock adapter. It typically called by the lock-using object's constructor.

Locks created by calling this method can later be retrieved by calling getEntityLock(Object).

Parameters:
identifier - An identifier that is unique for the lock-using object. This may be any kind of object, a static Object constant, for instance.
readLock - Is the lock a read lock? I.e., should the lock's isReadLock() method return true?
writeLock - Is the lock a write lock? I.e., should the lock's isWriteLock() method return true ?

getEntityLock

EntityLock getEntityLock(Object identifier)
Get the lock identified by the identifier. The lock must have been defined by calling createEntityLockForIdentifier(Object, boolean, boolean) before it can be retrieved by this method.

Parameters:
identifier - The identifier for the lock. The identifier for each defined lock is unique in the lock using object.
Returns:
The lock, or null if no lock is defined for the identifier.