org.apache.jcs.utils.locking
Class ReadWriteLockManager

java.lang.Object
  extended byorg.apache.jcs.utils.locking.ReadWriteLockManager

public class ReadWriteLockManager
extends java.lang.Object

The Generic ReadWriteLock Manager for various resources.

Author:
asmuts

Field Summary
private static RwLockGC gc
          Used to asynchronously remove unused RwLockHolder objects managed ty this manager.
private  java.util.Hashtable locks
          Hashtable of locks managed
private static org.apache.commons.logging.Log log
           
 
Constructor Summary
ReadWriteLockManager()
           
 
Method Summary
 void done(java.lang.String id)
          Release the read/write lock previously placed on the specified resource.
private  void ensureGarbageCollectorCreated()
          Ensures that the lock garbage collector has been created
protected  java.util.Hashtable getLocks()
          Returns the lock table of all the resources managed by the subclass.
private  void lock(java.lang.String id, boolean isWrite)
          Places either a read or write lock on the specified resource.
 void readLock(java.lang.String id)
          Places a read lock on the specified resource.
 void writeLock(java.lang.String id)
          Places a write lock on the specified resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

gc

private static RwLockGC gc
Used to asynchronously remove unused RwLockHolder objects managed ty this manager.


locks

private java.util.Hashtable locks
Hashtable of locks managed

Constructor Detail

ReadWriteLockManager

public ReadWriteLockManager()
Method Detail

readLock

public final void readLock(java.lang.String id)
                    throws java.lang.InterruptedException
Places a read lock on the specified resource.

Throws:
java.lang.InterruptedException

writeLock

public final void writeLock(java.lang.String id)
                     throws java.lang.InterruptedException
Places a write lock on the specified resource.

Throws:
java.lang.InterruptedException

lock

private void lock(java.lang.String id,
                  boolean isWrite)
           throws java.lang.InterruptedException
Places either a read or write lock on the specified resource.

Throws:
java.lang.InterruptedException

ensureGarbageCollectorCreated

private void ensureGarbageCollectorCreated()
Ensures that the lock garbage collector has been created


done

public final void done(java.lang.String id)
Release the read/write lock previously placed on the specified resource.


getLocks

protected java.util.Hashtable getLocks()
Returns the lock table of all the resources managed by the subclass.

Returns:
The locks value