Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 157   Methods: 17
NCLOC: 97   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LocalDelegatingCacheLoader.java 75% 72% 76.5% 73.9%
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.loader;
 8   
 9    import org.jboss.cache.CacheImpl;
 10    import org.jboss.cache.Fqn;
 11    import org.jboss.cache.NodeSPI;
 12    import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
 13   
 14    import java.io.ObjectInputStream;
 15    import java.io.ObjectOutputStream;
 16    import java.util.HashMap;
 17    import java.util.Map;
 18    import java.util.Set;
 19   
 20    /**
 21    * DelegatingCacheLoader implementation which delegates to a local (in the same VM) CacheImpl. Sample code:
 22    * <pre>
 23    * CacheImpl firstLevel=new CacheImpl();
 24    * CacheImpl secondLevel=new CacheImpl();
 25    * DelegatingCacheLoader l=new DelegatingCacheLoader(secondLevel);
 26    * l.setCache(firstLevel);
 27    * firstLevel.setCacheLoader(l);
 28    * secondLevel.start();
 29    * firstLevel.start();
 30    * </pre>
 31    *
 32    * @author Bela Ban
 33    * @author Daniel Gredler
 34    * @version $Id: LocalDelegatingCacheLoader.java,v 1.16 2007/06/14 15:30:15 msurtani Exp $
 35    */
 36    public class LocalDelegatingCacheLoader extends DelegatingCacheLoader
 37    {
 38   
 39    IndividualCacheLoaderConfig config;
 40    CacheImpl delegate = null;
 41   
 42  106 public LocalDelegatingCacheLoader()
 43    {
 44    }
 45   
 46  106 public LocalDelegatingCacheLoader(CacheImpl delegate)
 47    {
 48  106 this.delegate = delegate;
 49    }
 50   
 51  106 public void setConfig(IndividualCacheLoaderConfig config)
 52    {
 53  106 this.config = config;
 54    }
 55   
 56  106 public IndividualCacheLoaderConfig getConfig()
 57    {
 58  106 return config;
 59    }
 60   
 61  109 protected Set delegateGetChildrenNames(Fqn fqn) throws Exception
 62    {
 63  109 return delegate.getChildrenNames(fqn);
 64    }
 65   
 66    // See http://jira.jboss.com/jira/browse/JBCACHE-118 for why this is commented out.
 67    // protected Object delegateGet(Fqn name, Object key) throws Exception {
 68    // return delegate.get(name, key);
 69    // }
 70   
 71  549 protected Map delegateGet(Fqn name) throws Exception
 72    {
 73  549 NodeSPI n = (NodeSPI) delegate.get(name);
 74  129 if (n == null) return null;
 75    // after this stage we know that the node exists. So never return a null - at worst, an empty map.
 76  420 Map m = n.getDataDirect();
 77  0 if (m == null) m = new HashMap(0);
 78  420 return m;
 79    }
 80   
 81  0 protected void setDelegateCache(CacheImpl delegate)
 82    {
 83  0 this.delegate = delegate;
 84    }
 85   
 86  355 protected boolean delegateExists(Fqn name) throws Exception
 87    {
 88  355 return delegate.exists(name);
 89    }
 90   
 91  160 protected Object delegatePut(Fqn name, Object key, Object value) throws Exception
 92    {
 93  160 return delegate.put(name, key, value);
 94    }
 95   
 96  164 protected void delegatePut(Fqn name, Map attributes) throws Exception
 97    {
 98  164 delegate.put(name, attributes);
 99    }
 100   
 101  46 protected Object delegateRemove(Fqn name, Object key) throws Exception
 102    {
 103  46 return delegate.remove(name, key);
 104    }
 105   
 106  303 protected void delegateRemove(Fqn name) throws Exception
 107    {
 108  303 delegate.remove(name);
 109    }
 110   
 111  10 protected void delegateRemoveData(Fqn name) throws Exception
 112    {
 113  10 delegate.removeData(name);
 114    }
 115   
 116  6 protected void delegateLoadEntireState(ObjectOutputStream os) throws Exception
 117    {
 118  6 try
 119    {
 120    // // We use the lock acquisition timeout rather than the
 121    // // state transfer timeout, otherwise we'd never try
 122    // // to break locks before the requesting node gives up
 123    // return cache._getState(Fqn.fromString(SEPARATOR),
 124    // cache.getLockAcquisitionTimeout(),
 125    // true,
 126    // false);
 127    // Until flush is in place, use the old mechanism
 128    // where we wait the full state retrieval timeout
 129  6 delegate.getStateTransferManager().getState(os, Fqn.ROOT, delegate.getConfiguration().getStateRetrievalTimeout(), true, false);
 130    }
 131    catch (Exception e)
 132    {
 133  0 throw e;
 134    }
 135    catch (Throwable t)
 136    {
 137  0 throw new RuntimeException("Caught exception getting state from delegate", t);
 138    }
 139    }
 140   
 141  0 protected void delegateLoadState(Fqn subtree, ObjectOutputStream os) throws Exception
 142    {
 143  0 throw new UnsupportedOperationException("setting and loading state for specific Fqns not supported");
 144    }
 145   
 146  0 protected void delegateStoreEntireState(ObjectInputStream is) throws Exception
 147    {
 148  0 delegate.getStateTransferManager().setState(is, Fqn.ROOT);
 149   
 150    }
 151   
 152  0 protected void delegateStoreState(Fqn subtree, ObjectInputStream is) throws Exception
 153    {
 154  0 throw new UnsupportedOperationException("setting and loading state for specific Fqns not supported");
 155    }
 156   
 157    }