Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 95   Methods: 7
NCLOC: 56   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DefaultCacheFactory.java 100% 82.4% 100% 88.5%
coverage coverage
 1    /*
 2    * JBoss, Home of Professional Open Source
 3    *
 4    * Distributable under LGPL license.
 5    * See terms of license at gnu.org.
 6    */
 7    package org.jboss.cache;
 8   
 9    import org.jboss.cache.config.Configuration;
 10    import org.jboss.cache.config.ConfigurationException;
 11    import org.jboss.cache.factories.XmlConfigurationParser;
 12   
 13    /**
 14    * Default (singleton) implementation of the {@link org.jboss.cache.CacheFactory} interface.
 15    * Use {@link #getInstance()} to obtain an instance.
 16    *
 17    * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
 18    */
 19    public class DefaultCacheFactory<K, V> implements CacheFactory<K, V>
 20    {
 21    private static CacheFactory singleton = new DefaultCacheFactory();
 22   
 23    /**
 24    * @return a singleton instance of this class.
 25    */
 26  2840 public static <K, V> CacheFactory<K, V> getInstance()
 27    {
 28  2840 return singleton;
 29    }
 30   
 31  10 public Cache<K, V> createCache() throws ConfigurationException
 32    {
 33  10 return createCache(true);
 34    }
 35   
 36  1718 public Cache<K, V> createCache(boolean start) throws ConfigurationException
 37    {
 38  1718 return createCache(new Configuration(), start);
 39    }
 40   
 41  11 public Cache<K, V> createCache(String configFileName) throws ConfigurationException
 42    {
 43  11 return createCache(configFileName, true);
 44    }
 45   
 46  109 public Cache<K, V> createCache(String configFileName, boolean start) throws ConfigurationException
 47    {
 48  109 XmlConfigurationParser parser = new XmlConfigurationParser();
 49  109 Configuration c = parser.parseFile(configFileName);
 50  109 return createCache(c, start);
 51    }
 52   
 53    /**
 54    * This implementation clones the configuration passed in before using it.
 55    *
 56    * @param configuration to use
 57    * @return a cache
 58    * @throws ConfigurationException if there are problems with the cfg
 59    */
 60  124 public Cache<K, V> createCache(Configuration configuration) throws ConfigurationException
 61    {
 62  124 return createCache(configuration, true);
 63    }
 64   
 65    /**
 66    * This implementation clones the configuration passed in before using it.
 67    *
 68    * @param configuration to use
 69    * @param start whether to start the cache
 70    * @return a cache
 71    * @throws ConfigurationException if there are problems with the cfg
 72    */
 73  2860 public Cache<K, V> createCache(Configuration configuration, boolean start) throws ConfigurationException
 74    {
 75  2860 try
 76    {
 77  2860 CacheImpl<K, V> cache = new CacheImpl<K, V>();
 78  2860 cache.setConfiguration(configuration);
 79  171 if (start) cache.start();
 80  2860 return cache;
 81    }
 82    catch (ConfigurationException ce)
 83    {
 84  0 throw ce;
 85    }
 86    catch (RuntimeException re)
 87    {
 88  0 throw re;
 89    }
 90    catch (Exception e)
 91    {
 92  0 throw new RuntimeException(e);
 93    }
 94    }
 95    }