[jboss-cvs] JBossCache/src/org/jboss/cache/factories ...

Ben Wang bwang at jboss.com
Tue Oct 31 01:57:27 EST 2006


  User: bwang   
  Date: 06/10/31 01:57:27

  Modified:    src/org/jboss/cache/factories   CacheFactoryTest.java
                        DefaultCacheFactory.java
  Log:
  Refactored the DefaultCacheFactory to use the static create methods.
  
  Revision  Changes    Path
  1.4       +5 -7      JBossCache/src/org/jboss/cache/factories/CacheFactoryTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheFactoryTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/factories/CacheFactoryTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- CacheFactoryTest.java	20 Jul 2006 10:59:13 -0000	1.3
  +++ CacheFactoryTest.java	31 Oct 2006 06:57:27 -0000	1.4
  @@ -17,14 +17,12 @@
    */
   public class CacheFactoryTest extends TestCase
   {
  -    DefaultCacheFactory factory;
       Configuration expected;
       String configFile = "META-INF/replSync-service.xml";
       private TreeCacheProxyImpl cache;
   
       protected void setUp()
       {
  -        factory = new DefaultCacheFactory();
           XmlConfigurationParser parser = new XmlConfigurationParser();
           expected = parser.parseFile( configFile );
       }
  @@ -39,7 +37,7 @@
   
       public void testFromConfigFileStarted()
       {
  -        cache = (TreeCacheProxyImpl) factory.createCache(configFile);
  +        cache = (TreeCacheProxyImpl) DefaultCacheFactory.createCache(configFile);
           assertEquals(expected, cache.getConfiguration());
   
           assertTrue("Should have started", cache.isStarted());
  @@ -48,7 +46,7 @@
   
       public void testFromConfigFileUnstarted()
       {
  -        cache = (TreeCacheProxyImpl) factory.createCache(configFile, false);
  +        cache = (TreeCacheProxyImpl) DefaultCacheFactory.createCache(configFile, false);
           assertEquals(expected, cache.getConfiguration());
   
           assertFalse("Should not have started", cache.isStarted());
  @@ -58,7 +56,7 @@
   
       public void testFromConfigObjStarted()
       {
  -        cache = (TreeCacheProxyImpl) factory.createCache(expected);
  +        cache = (TreeCacheProxyImpl) DefaultCacheFactory.createCache(expected);
   
           assertTrue("Should have started", cache.isStarted());
   
  @@ -67,7 +65,7 @@
   
       public void testFromConfigObjUnstarted()
       {
  -        cache = (TreeCacheProxyImpl) factory.createCache(expected, false);
  +        cache = (TreeCacheProxyImpl) DefaultCacheFactory.createCache(expected, false);
   
           assertFalse("Should not have started", cache.isStarted());
   
  @@ -86,7 +84,7 @@
   
       public void testLifecycle() throws Exception
       {
  -        cache = (TreeCacheProxyImpl) factory.createCache(expected, false);
  +        cache = (TreeCacheProxyImpl) DefaultCacheFactory.createCache(expected, false);
           assertFalse(cache.isStarted());
           cache.start();
           assertTrue(cache.isStarted());
  
  
  
  1.11      +7 -7      JBossCache/src/org/jboss/cache/factories/DefaultCacheFactory.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DefaultCacheFactory.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/factories/DefaultCacheFactory.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- DefaultCacheFactory.java	12 Oct 2006 23:03:58 -0000	1.10
  +++ DefaultCacheFactory.java	31 Oct 2006 06:57:27 -0000	1.11
  @@ -12,35 +12,35 @@
   import org.jboss.cache.config.ConfigurationException;
   
   /**
  - * Default implementation of the Cache Factory
  + * Default implementation of the Cache Factory that contains only convenient static methods
    *
    * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
    */
  -public class DefaultCacheFactory implements CacheFactory
  +public class DefaultCacheFactory
   {
  -   public Cache createCache() throws ConfigurationException
  +   public static Cache createCache() throws ConfigurationException
      {
         return createCache(new Configuration());
      }
   
  -   public Cache createCache(String configFileName) throws ConfigurationException
  +   public static Cache createCache(String configFileName) throws ConfigurationException
      {
         return createCache(configFileName, true);
      }
   
  -   public Cache createCache(String configFileName, boolean start) throws ConfigurationException
  +   public static Cache createCache(String configFileName, boolean start) throws ConfigurationException
      {
         XmlConfigurationParser parser = new XmlConfigurationParser();
         Configuration c = parser.parseFile(configFileName);
         return createCache(c, start);
      }
   
  -   public Cache createCache(Configuration configuration) throws ConfigurationException
  +   public static Cache createCache(Configuration configuration) throws ConfigurationException
      {
         return createCache(configuration, true);
      }
   
  -   public Cache createCache(Configuration configuration, boolean start) throws ConfigurationException
  +   public static Cache createCache(Configuration configuration, boolean start) throws ConfigurationException
      {
         try
         {
  
  
  



More information about the jboss-cvs-commits mailing list