[jboss-cvs] JBossCache/src/org/jboss/cache/loader/jdbm ...

Brian Stansberry brian.stansberry at jboss.com
Mon Oct 23 01:46:40 EDT 2006


  User: bstansberry
  Date: 06/10/23 01:46:40

  Modified:    src/org/jboss/cache/loader/jdbm  JdbmCacheLoader.java
  Log:
  [JBCACHE-809] Pojo-style configuration for use by Microcontainer
  
  Revision  Changes    Path
  1.16      +74 -7     JBossCache/src/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: JdbmCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -b -r1.15 -r1.16
  --- JdbmCacheLoader.java	12 Oct 2006 23:03:58 -0000	1.15
  +++ JdbmCacheLoader.java	23 Oct 2006 05:46:40 -0000	1.16
  @@ -11,6 +11,7 @@
   import org.jboss.cache.CacheSPI;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.Modification;
  +import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
   import org.jboss.cache.loader.AbstractCacheLoader;
   import org.jboss.cache.optimistic.FqnComparator;
   
  @@ -55,7 +56,7 @@
    * plans to fix this.
    *
    * @author Elias Ross
  - * @version $Id: JdbmCacheLoader.java,v 1.15 2006/10/12 23:03:58 msurtani Exp $
  + * @version $Id: JdbmCacheLoader.java,v 1.16 2006/10/23 05:46:40 bstansberry Exp $
    */
   public class JdbmCacheLoader extends AbstractCacheLoader
   {
  @@ -65,7 +66,7 @@
      private static final String NODE = "N";
      private static final String NAME = "JdbmCacheLoader";
   
  -   private String locationStr;
  +   private Config config;
      private String cacheDbName;
      private RecordManager recman;
      private BTree tree;
  @@ -97,9 +98,11 @@
         checkNotOpen();
         checkNonNull(cache, "CacheSPI object is required");
   
  +      String locationStr = config.getLocation();
         if (locationStr == null)
         {
            locationStr = System.getProperty("java.io.tmpdir");
  +         config.setLocation(locationStr);
         }
   
         // test location
  @@ -203,11 +206,25 @@
      /**
       * Sets the configuration string for this cache loader.
       */
  -   public void setConfig(Properties props)
  +   public void setConfig(IndividualCacheLoaderConfig base)
      {
         checkNotOpen();
  -      locationStr = props != null ? props.getProperty("location") : null;
  -      if (log.isTraceEnabled()) log.trace("Configuring cache loader with location = " + locationStr);
  +      
  +      if (base instanceof Config)
  +      {
  +         this.config = (Config) base;
  +      }
  +      else
  +      {
  +         config = new Config(base);
  +      }
  +      
  +      if (log.isTraceEnabled()) log.trace("Configuring cache loader with location = " + config.getLocation());
  +   }
  +   
  +   public IndividualCacheLoaderConfig getConfig()
  +   {
  +      return config;
      }
   
      /**
  @@ -686,8 +703,58 @@
      {
         BTree bt = tree;
         int size = (bt == null) ? -1 : bt.size();
  -      return "JdbmCacheLoader locationStr=" + locationStr +
  +      return "JdbmCacheLoader locationStr=" + config.getLocation() +
                 " size=" + size;
      }
   
  +   public static class Config extends IndividualCacheLoaderConfig
  +   {
  +      private static final long serialVersionUID = 4626734068542420865L;
  +      
  +      private String location;
  +
  +      public Config() 
  +      {
  +         setClassName(JdbmCacheLoader.class.getName());
  +      }
  +      
  +      private Config(IndividualCacheLoaderConfig base)
  +      {
  +         setClassName(JdbmCacheLoader.class.getName());
  +         populateFromBaseConfig(base);
  +      }
  +      
  +      public String getLocation()
  +      {
  +         return location;
  +      }
  +
  +      public void setLocation(String location)
  +      {
  +         testImmutability("location");
  +         this.location = location;
  +      }
  +
  +      public void setProperties(Properties props)
  +      {
  +         super.setProperties(props);
  +         setLocation(props != null ? props.getProperty("location") : null);
  +      }
  +
  +      public boolean equals(Object obj)
  +      {
  +         if (obj instanceof Config && equalsExcludingProperties(obj))
  +         {
  +            return  safeEquals(location, ((Config) obj).location);
  +         }
  +         return false;
  +      }
  +      
  +      public int hashCode()
  +      {
  +         return 31 * hashCodeExcludingProperties() + (location == null ? 0 : location.hashCode());
  +      }     
  +      
  +   }
  +
   }
  
  
  



More information about the jboss-cvs-commits mailing list