org.entityfs.lock
Class NoObjectDummyLock

java.lang.Object
  extended by org.entityfs.lock.NoObjectDummyLock
All Implemented Interfaces:
Lock, EntityLock
Direct Known Subclasses:
DummyLock

public class NoObjectDummyLock
extends Object
implements EntityLock

This is a dummy EntityLock implementation that is not connected to any particular entity.

Since this object does not contain any mutable internal state, the singleton instance INSTANCE can be used instead of instantiating the class.

Since:
1.0
Author:
Karl Gustafsson

Field Summary
static NoObjectDummyLock INSTANCE
          Singleton instance that may be used instead of instantiating the class.
 
Constructor Summary
NoObjectDummyLock()
           
 
Method Summary
 int getHoldCount()
          Get the hold count of the lock.
 Lockable getLocked()
          Get the locked object.
 boolean isDummy()
          Is this lock a dummy lock.
 boolean isHeldByCurrentThread()
          Is this lock held by the current thread? (This is implemented by ReentrantLock but not specified in the Lock interface.)
 boolean isReadLock()
          Returns true if this lock is a read lock.
 boolean isWriteLock()
          Returns true if this lock is a write lock.
 void lock()
           
 void lockInterruptibly()
           
 Condition newCondition()
           
 boolean tryLock()
           
 boolean tryLock(long timeout, TimeUnit tu)
           
 void unlock()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final NoObjectDummyLock INSTANCE
Singleton instance that may be used instead of instantiating the class.

Constructor Detail

NoObjectDummyLock

public NoObjectDummyLock()
Method Detail

isReadLock

public boolean isReadLock()
Description copied from interface: EntityLock
Returns true if this lock is a read lock.

Specified by:
isReadLock in interface EntityLock
Returns:
true, always.

isWriteLock

public boolean isWriteLock()
Description copied from interface: EntityLock
Returns true if this lock is a write lock.

Specified by:
isWriteLock in interface EntityLock
Returns:
true, always.

getLocked

public Lockable getLocked()
Description copied from interface: EntityLock
Get the locked object. For locks that are not connected to any particular object (dummy locks, mostly), this method returns null.

Specified by:
getLocked in interface EntityLock
Returns:
null, always.

newCondition

public Condition newCondition()
                       throws UnsupportedOperationException
Specified by:
newCondition in interface Lock
Throws:
UnsupportedOperationException - Always.

tryLock

public boolean tryLock()
Specified by:
tryLock in interface Lock
Returns:
true, always.

tryLock

public boolean tryLock(long timeout,
                       TimeUnit tu)
Specified by:
tryLock in interface Lock
Returns:
true, always.

unlock

public void unlock()
Specified by:
unlock in interface Lock

lock

public void lock()
Specified by:
lock in interface Lock

lockInterruptibly

public void lockInterruptibly()
Specified by:
lockInterruptibly in interface Lock

getHoldCount

public int getHoldCount()
Description copied from interface: EntityLock
Get the hold count of the lock. (How many Lock.lock() has been called minus the number of times Lock.unlock() has been called by the current thread.) If the hold count is 0, the lock is unlocked. The hold count can never be less than 0.

Specified by:
getHoldCount in interface EntityLock
Returns:
0, always.

isHeldByCurrentThread

public boolean isHeldByCurrentThread()
Description copied from interface: EntityLock
Is this lock held by the current thread? (This is implemented by ReentrantLock but not specified in the Lock interface.)

Specified by:
isHeldByCurrentThread in interface EntityLock
Returns:
true, always.

isDummy

public boolean isDummy()
Description copied from interface: EntityLock
Is this lock a dummy lock. A dummy lock does not actually do any locking.

Specified by:
isDummy in interface EntityLock
Returns:
true, always.