KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > lock > SimpleLock


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.cache.lock;
8
9 import java.util.concurrent.locks.Lock JavaDoc;
10
11 /**
12  * Simple lock that does not differentiate read and write lock. All locks are obtained FIFO.
13  * This class is used as a delegate for LockStrategy
14  * is transaction isolation level.
15  *
16  * @author <a HREF="mailto:bwang00@sourceforge.net">Ben Wang</a> July 15, 2003
17  * @version $Revision: 1.4 $
18  */

19 public class SimpleLock
20 {
21 // Log log=LogFactory.getLog(getClass());
22
private SemaphoreLock sem_;
23
24    public SimpleLock()
25    {
26       sem_ = new SemaphoreLock(1);
27    }
28
29    /**
30     * @see org.jboss.cache.lock.LockStrategy#readLock()
31     */

32    public Lock JavaDoc readLock()
33    {
34       return sem_;
35    }
36
37    /**
38     * @see org.jboss.cache.lock.LockStrategy#upgradeLockAttempt(long)
39     */

40    public Lock JavaDoc upgradeLockAttempt(long msecs)
41    {
42       return sem_;
43    }
44
45    /**
46     * @see org.jboss.cache.lock.LockStrategy#writeLock()
47     */

48    public Lock JavaDoc writeLock()
49    {
50       return sem_;
51    }
52 }
53
Popular Tags