org.entityfs.lock.impl
Class ReentrantLockAdapter

java.lang.Object
  extended by org.entityfs.lock.impl.ReentrantLockAdapter
All Implemented Interfaces:
LockAdapter
Direct Known Subclasses:
ReadWriteEntityLockAdapter

public class ReentrantLockAdapter
extends Object
implements LockAdapter

This is a LockAdapter that uses ReentrantLock:s that it creates with a EntityLockFactory.

Since:
1.0
Author:
Karl Gustafsson
In_jar:
entityfs-core

Constructor Summary
ReentrantLockAdapter(EntityLockFactory rlf)
           
 
Method Summary
 void createLockForIdentifier(Object identifier)
          Create a lock for the unique (in the lock adapter instance) identifier.
 Lock getLock(Object identifier)
          Get the lock identified by the identifier.
protected  EntityLockFactory getLockFactory()
           
protected  void registerLock(Object identifier, Lock l)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReentrantLockAdapter

public ReentrantLockAdapter(EntityLockFactory rlf)
Method Detail

getLockFactory

protected EntityLockFactory getLockFactory()

registerLock

protected void registerLock(Object identifier,
                            Lock l)

createLockForIdentifier

public void createLockForIdentifier(Object identifier)
Description copied from interface: LockAdapter
Create a lock for the unique (in the lock adapter instance) identifier. How the lock is created is up to the implementation.

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 LockAdapter.getLock(Object).

Specified by:
createLockForIdentifier in interface LockAdapter
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.

getLock

public Lock getLock(Object identifier)
Description copied from interface: LockAdapter
Get the lock identified by the identifier. The lock must have been defined by calling LockAdapter.createLockForIdentifier(Object) before it can be retrieved by this method.

Specified by:
getLock in interface LockAdapter
Parameters:
identifier - The identifier for the lock. The identifier for each defined lock is unique in the lock adapter instance.
Returns:
The lock, or null if no lock is defined for the identifier.