com.caucho.cluster
Class AbstractLock

java.lang.Object
  extended by com.caucho.cluster.AbstractLock
All Implemented Interfaces:
java.util.concurrent.locks.Lock
Direct Known Subclasses:
ClusterLock

@Module
public abstract class AbstractLock
extends java.lang.Object
implements java.util.concurrent.locks.Lock

Implements the distributed lock


Constructor Summary
AbstractLock()
           
 
Method Summary
 java.lang.String getName()
          Returns the name of the lock.
 void init()
          Initialize the lock.
 void lock()
           
 void lockInterruptibly()
           
 java.util.concurrent.locks.Condition newCondition()
           
 void setGuid(java.lang.String guid)
           
 void setName(java.lang.String name)
          Assigns the name of the lock.
 java.lang.String toString()
           
 boolean tryLock()
           
 boolean tryLock(long time, java.util.concurrent.TimeUnit unit)
           
 void unlock()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractLock

public AbstractLock()
Method Detail

getName

public java.lang.String getName()
Returns the name of the lock.


setName

@Configurable
public void setName(java.lang.String name)
Assigns the name of the lock. A name is mandatory and must be unique among open locks.


setGuid

public void setGuid(java.lang.String guid)

lock

public void lock()
Specified by:
lock in interface java.util.concurrent.locks.Lock

lockInterruptibly

public void lockInterruptibly()
                       throws java.lang.InterruptedException
Specified by:
lockInterruptibly in interface java.util.concurrent.locks.Lock
Throws:
java.lang.InterruptedException

tryLock

public boolean tryLock()
Specified by:
tryLock in interface java.util.concurrent.locks.Lock

tryLock

public boolean tryLock(long time,
                       java.util.concurrent.TimeUnit unit)
                throws java.lang.InterruptedException
Specified by:
tryLock in interface java.util.concurrent.locks.Lock
Throws:
java.lang.InterruptedException

unlock

public void unlock()
Specified by:
unlock in interface java.util.concurrent.locks.Lock

newCondition

public java.util.concurrent.locks.Condition newCondition()
Specified by:
newCondition in interface java.util.concurrent.locks.Lock

init

@PostConstruct
public void init()
Initialize the lock.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object