KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Transaction isolation level of Repeatable_Read. It prevents dirty read and non-repeatable read.
13  * <p> Dirty read allows (t1) write and then (t2) read within two separate threads, all without
14  * transaction commit. </p>
15  * <p> Non-repeatable allows read allows (t1) read, (t2) write, and then (t1) read, all without
16  * transaction commit. </p>
17  *
18  * @author Ben Wang
19  * @version $Revision: 1.2 $
20  */

21 public class LockStrategyRepeatableRead implements LockStrategy
22 {
23    private ReadWriteLockWithUpgrade lock_; // Delegate is ReadWriteLockWithUpgrade
24

25    public LockStrategyRepeatableRead()
26    {
27       lock_ = new ReadWriteLockWithUpgrade();
28    }
29
30    /**
31     * @see org.jboss.cache.lock.LockStrategy#readLock()
32     */

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

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

49    public Lock JavaDoc writeLock()
50    {
51       return lock_.writeLock();
52    }
53
54
55    public String JavaDoc toString()
56    {
57       return lock_ != null? lock_.toString() : null;
58    }
59 }
60
Popular Tags