org.jboss.cache.lock
Class LockMap

java.lang.Object
  extended by org.jboss.cache.lock.LockMap

public class LockMap
extends java.lang.Object

Provide lock ownership mapping.

Version:
$Id: LockMap.java,v 1.9 2006/04/08 05:24:38 genman Exp $
Author:
Ben Wang

Field Summary
static int OWNER_ANY
           
static int OWNER_READ
           
static int OWNER_WRITE
           
 
Constructor Summary
LockMap()
           
 
Method Summary
 void addReader(java.lang.Object owner)
          Adding a reader owner.
 boolean isOwner(java.lang.Object caller, int ownership)
          Check whether this owner has reader or writer ownership.
 boolean isReadLocked()
           
 java.lang.String printInfo()
          Debugging information.
 java.util.Set readerOwners()
          Returns an unmodifiable set of reader owner objects.
 void releaseReaderOwners(LockStrategy lock)
           
 void removeAll()
          Remove all ownership.
 void removeReader(java.lang.Object owner)
          Remove reader ownership.
 void removeWriter()
          Remove writer ownership.
 void setWriterIfNotNull(java.lang.Object owner)
          Adding a writer owner.
 boolean upgrade(java.lang.Object owner)
          Upgrading current reader ownership to writer one.
 java.lang.Object writerOwner()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OWNER_ANY

public static final int OWNER_ANY
See Also:
Constant Field Values

OWNER_READ

public static final int OWNER_READ
See Also:
Constant Field Values

OWNER_WRITE

public static final int OWNER_WRITE
See Also:
Constant Field Values
Constructor Detail

LockMap

public LockMap()
Method Detail

isOwner

public boolean isOwner(java.lang.Object caller,
                       int ownership)
Check whether this owner has reader or writer ownership.

Parameters:
caller - the potential owner. Cannot be null.
ownership - Either OWNER_ANY, OWNER_READ, or OWNER_WRITE.
Returns:
Throws:
java.lang.NullPointerException - if caller is null.

addReader

public void addReader(java.lang.Object owner)
Adding a reader owner.

Parameters:
owner -

setWriterIfNotNull

public void setWriterIfNotNull(java.lang.Object owner)
Adding a writer owner.

Parameters:
owner -

upgrade

public boolean upgrade(java.lang.Object owner)
                throws OwnerNotExistedException
Upgrading current reader ownership to writer one.

Parameters:
owner -
Returns:
True if successful.
Throws:
OwnerNotExistedException

readerOwners

public java.util.Set readerOwners()
Returns an unmodifiable set of reader owner objects.


releaseReaderOwners

public void releaseReaderOwners(LockStrategy lock)

writerOwner

public java.lang.Object writerOwner()
Returns:
Writer owner object. Null if none.

removeReader

public void removeReader(java.lang.Object owner)
Remove reader ownership.


removeWriter

public void removeWriter()
Remove writer ownership.


removeAll

public void removeAll()
Remove all ownership.


printInfo

public java.lang.String printInfo()
Debugging information.

Returns:

isReadLocked

public boolean isReadLocked()


Copyright 1998-2005 JBoss Inc . All Rights Reserved.