Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 60   Methods: 4
NCLOC: 30   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LockStrategyReadUncommitted.java - 87.5% 100% 91.7%
coverage coverage
 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.TimeUnit;
 10    import java.util.concurrent.locks.Lock;
 11   
 12    /**
 13    * Transaction isolation level of READ-UNCOMMITTED. Reads always succeed (NullLock), whereas writes are exclusive.
 14    * It prevents none of the dirty read, non-repeatable read, or phantom read.
 15    *
 16    * @author Ben Wang
 17    * @version $Revision: 1.2 $
 18    */
 19    public class LockStrategyReadUncommitted implements LockStrategy
 20    {
 21    private SemaphoreLock wLock_;
 22    private Lock rLock_; // Null lock will always return true
 23   
 24  43 public LockStrategyReadUncommitted()
 25    {
 26  43 wLock_ = new SemaphoreLock(1);
 27  43 rLock_ = new NullLock();
 28    }
 29   
 30    /**
 31    * @see org.jboss.cache.lock.LockStrategy#readLock()
 32    */
 33  180 public Lock readLock()
 34    {
 35  180 return rLock_;
 36    }
 37   
 38    /**
 39    * @see org.jboss.cache.lock.LockStrategy#upgradeLockAttempt(long)
 40    */
 41  2 public Lock upgradeLockAttempt(long msecs) throws UpgradeException
 42    {
 43    // Since write is exclusive, we need to obtain the write lock first
 44    // before we can return the upgrade
 45  2 try {
 46  2 wLock_.tryLock(msecs, TimeUnit.MILLISECONDS);
 47    } catch (InterruptedException e) {
 48  0 throw new UpgradeException("Upgrade failed in " + msecs + " msecs", e);
 49    }
 50  2 return wLock_;
 51    }
 52   
 53    /**
 54    * @see org.jboss.cache.lock.LockStrategy#writeLock()
 55    */
 56  42 public Lock writeLock()
 57    {
 58  42 return wLock_;
 59    }
 60    }