org.entityfs.lock
Interface LockAcquiringStrategy


public interface LockAcquiringStrategy

This interface defines a strategy for how a single lock is locked. All locks that are locked by EntityFS methods (entity locks and internal state locks) use a LockAdapter together with the file system's lock acquiring strategy. This makes it possible for the client creating the file system to set a file system-global policy for how locks should be acquired. The policy can for instance say if locking calls can time out. synchronized is not used anywhere in EntityFS.

Since:
1.0
Author:
Karl Gustafsson
See Also:
LockAdapter

Method Summary
 EntityLock getEntityLock(Object identifier, EntityLockAdapter la, LogAdapter lga)
          Get a custom entity lock for an entity from its lock adapter.
 Lock getLock(Object identifier, LockAdapter la, LogAdapter lga)
          Lock a custom lock that is not tied to any specific entity.
 EntityLock getReadLock(EntityLockAdapter la, LogAdapter lga)
          Get a locked read lock for an entity from its lock adapter.
 EntityLock getWriteLock(EntityLockAdapter la, LogAdapter lga)
          Get a locked write lock for an entity from its lock adapter.
 

Method Detail

getReadLock

EntityLock getReadLock(EntityLockAdapter la,
                       LogAdapter lga)
Get a locked read lock for an entity from its lock adapter.

Parameters:
la - The entity's lock adapter.
lga - The file system's current log adapter.
Returns:
A locked read lock.

getWriteLock

EntityLock getWriteLock(EntityLockAdapter la,
                        LogAdapter lga)
Get a locked write lock for an entity from its lock adapter.

Parameters:
la - The entity's lock adapter.
lga - The file system's current log adapter.
Returns:
A locked write lock.

getEntityLock

EntityLock getEntityLock(Object identifier,
                         EntityLockAdapter la,
                         LogAdapter lga)
Get a custom entity lock for an entity from its lock adapter. The lock must have been registered with the entity lock adapter's createEntityLockForIdentifier(Object, boolean, boolean) method before it can be locked.

Parameters:
identifier - The unique identifier for the lock.
la - The entity's lock adapter
lga - The file system's current log adapter.
Returns:
A locked custom lock.
Throws:
ClassCastException - If the lock was registered with the entity lock adapter's createLockForIdentifier(Object) method...

getLock

Lock getLock(Object identifier,
             LockAdapter la,
             LogAdapter lga)
Lock a custom lock that is not tied to any specific entity. The lock must have been registered with the lock adapter's createLockForIdentifier(Object) method before it can be locked.

Parameters:
identifier - The unique identifier for the lock.
la - The lock adapter.
lga - A log adapter
Returns:
A locked lock