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

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/bdbje  BdbjeCacheLoader.java
  Log:
  [JBCACHE-809] Pojo-style configuration for use by Microcontainer
  
  Revision  Changes    Path
  1.17      +73 -6     JBossCache/src/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BdbjeCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -b -r1.16 -r1.17
  --- BdbjeCacheLoader.java	22 Sep 2006 16:27:55 -0000	1.16
  +++ BdbjeCacheLoader.java	23 Oct 2006 05:46:40 -0000	1.17
  @@ -22,6 +22,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 java.io.File;
  @@ -50,7 +51,7 @@
    *
    * @author Mark Hayes May 16, 2004
    * @author Bela Ban
  - * @version $Id: BdbjeCacheLoader.java,v 1.16 2006/09/22 16:27:55 msurtani Exp $
  + * @version $Id: BdbjeCacheLoader.java,v 1.17 2006/10/23 05:46:40 bstansberry Exp $
    */
   public class BdbjeCacheLoader extends AbstractCacheLoader
   {
  @@ -60,7 +61,7 @@
   
      private static final Log log = LogFactory.getLog(BdbjeCacheLoader.class);
   
  -   private String configStr;
  +   private Config config;
      private Environment env;
      private String cacheDbName;
      private String catalogDbName;
  @@ -122,9 +123,11 @@
            throw new IllegalStateException(
                    "A non-null Cache property (CacheSPI object) is required");
         }
  -      if (configStr == null)
  +      String configStr = config.getLocation();
  +      if (config.getLocation() == null)
         {
            configStr = System.getProperty("java.io.tmpdir");
  +         config.setLocation(configStr);
         }
   
         // test location
  @@ -272,11 +275,25 @@
      /**
       * Sets the configuration string for this cache loader.
       */
  -   public void setConfig(Properties props)
  +   public void setConfig(IndividualCacheLoaderConfig base)
      {
         checkNotOpen();
  -      configStr = props != null ? props.getProperty("location") : null;
  -      if (log.isTraceEnabled()) log.trace("Configuring cache loader with location = " + configStr);
  +      
  +      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;
      }
   
      /**
  @@ -1125,4 +1142,54 @@
                    "Parameter must not be null: " + paramName);
         }
      }
  +   
  +   public static class Config extends IndividualCacheLoaderConfig
  +   {
  +      private static final long serialVersionUID = 4626734068542420865L;
  +      
  +      private String location;
  +
  +      public Config() 
  +      {
  +         setClassName(BdbjeCacheLoader.class.getName());
  +      }
  +      
  +      private Config(IndividualCacheLoaderConfig base)
  +      {
  +         setClassName(BdbjeCacheLoader.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