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

Manik Surtani msurtani at jboss.com
Tue Jul 18 14:28:39 EDT 2006


  User: msurtani
  Date: 06/07/18 14:28:39

  Modified:    src/org/jboss/cache/factories  DefaultCacheFactory.java
  Log:
  Cache construction tests
  
  Revision  Changes    Path
  1.2       +15 -9     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.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- DefaultCacheFactory.java	21 Jun 2006 11:17:25 -0000	1.1
  +++ DefaultCacheFactory.java	18 Jul 2006 18:28:39 -0000	1.2
  @@ -7,10 +7,14 @@
   package org.jboss.cache.factories;
   
   import org.jboss.cache.Cache;
  +import org.jboss.cache.NodeImpl;
   import org.jboss.cache.TreeCache;
  -import org.jboss.cache.PropertyConfigurator;
  -import org.jboss.cache.config.ConfigurationException;
  +import org.jboss.cache.TreeCacheProxyImpl;
   import org.jboss.cache.config.Configuration;
  +import org.jboss.cache.config.ConfigurationException;
  +import org.jboss.cache.config.ConfigurationImpl;
  +
  +import java.io.InputStream;
   
   /**
    * Default implementation of the Cache Factory
  @@ -26,10 +30,8 @@
   
       public Cache createCache(String configFileName, boolean start) throws ConfigurationException
       {
  -        PropertyConfigurator pc = new PropertyConfigurator();
  -        Configuration c = null;
  -        // TODO: modify the PropertyConfigurator to spit out a Configuration object.
  -        //c = pc.createConfiguration(configFileName);
  +        ConfigurationImpl c = new ConfigurationImpl();
  +        c.readConfiguration(getAsInputStreamFromClassLoader(configFileName));
           return createCache(c, start);
       }
   
  @@ -43,10 +45,9 @@
           try
           {
               TreeCache cache = new TreeCache();
  -            // TODO: add capabilities to set cache configuration.
  -            //cache.setConfiguration(configuration);
  +            cache.setConfiguration(configuration);
               if (start) cache.startService();
  -            return (Cache) cache;
  +            return new TreeCacheProxyImpl(cache, (NodeImpl) cache.root);
           }
           catch (Exception e)
           {
  @@ -54,4 +55,9 @@
               throw new ConfigurationException(e.getMessage());
           }
       }
  +
  +    protected InputStream getAsInputStreamFromClassLoader(String filename)
  +    {
  +        return Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
  +    }
   }
  
  
  



More information about the jboss-cvs-commits mailing list