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

Galder Zamarreno galder.zamarreno at jboss.com
Tue Jul 17 18:16:48 EDT 2007


  User: gzamarreno
  Date: 07/07/17 18:16:48

  Modified:    src/org/jboss/cache/config  CacheLoaderConfig.java
  Log:
  [JBCACHE-1134] singleton store cache loader class configuration added and changed the way SSCL is configured in the XML. Also migrated push state logic to use java.util.concurrent package. Still missing, changing user guide for the updated configuration and an XML example in etc/
  
  Revision  Changes    Path
  1.22      +115 -39   JBossCache/src/org/jboss/cache/config/CacheLoaderConfig.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheLoaderConfig.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/config/CacheLoaderConfig.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -b -r1.21 -r1.22
  --- CacheLoaderConfig.java	23 May 2007 04:01:46 -0000	1.21
  +++ CacheLoaderConfig.java	17 Jul 2007 22:16:48 -0000	1.22
  @@ -7,6 +7,7 @@
   package org.jboss.cache.config;
   
   import org.jboss.cache.xml.XmlHelper;
  +import org.jboss.cache.loader.SingletonStoreCacheLoader;
   
   import java.io.ByteArrayInputStream;
   import java.io.IOException;
  @@ -20,6 +21,7 @@
    *
    * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
    * @author Brian Stansberry
  + * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
    */
   public class CacheLoaderConfig extends ConfigurationComponent
   {
  @@ -136,6 +138,7 @@
       * Configuration object that holds the confguration of an individual cache loader.
       *
       * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
  +    * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
       */
      public static class IndividualCacheLoaderConfig extends ConfigurationComponent
      {
  @@ -145,13 +148,13 @@
         private boolean async;
         private boolean ignoreModifications;
         private boolean fetchPersistentState;
  -      private boolean singletonStore;
  -      private boolean pushStateWhenCoordinator;
   
         private boolean purgeOnStartup;
   
         private Properties properties;
   
  +      private SingletonStoreConfig singletonStoreConfig;
  +
         public IndividualCacheLoaderConfig()
         {
         }
  @@ -163,12 +166,9 @@
               setAsync(base.isAsync());
               setIgnoreModifications(base.isIgnoreModifications());
               setFetchPersistentState(base.isFetchPersistentState());
  -            setSingletonStore(base.isSingletonStore());
  -            setPushStateWhenCoordinator(base.isPushStateWhenCoordinator());
  +            setSingletonStoreConfig(base.getSingletonStoreConfig());
               setPurgeOnStartup(base.isPurgeOnStartup());
  -            Properties props = base.getProperties();
  -            if (props != null)
  -               setProperties(props);
  +            setProperties(base.getProperties());
            }
         }
   
  @@ -252,34 +252,15 @@
            this.purgeOnStartup = purgeOnStartup;
         }
   
  -      public boolean isSingletonStore()
  -      {
  -         return singletonStore;
  -      }
  -
  -      public void setSingletonStore(boolean singletonStore)
  +      public SingletonStoreConfig getSingletonStoreConfig()
         {
  -         testImmutability("singletonStore");
  -         this.singletonStore = singletonStore;
  +         return singletonStoreConfig;
         }
   
  -      public boolean isPushStateWhenCoordinator()
  +      public void setSingletonStoreConfig(SingletonStoreConfig singletonStoreConfig)
         {
  -         return singletonStore && pushStateWhenCoordinator;
  -      }
  -
  -      public void setPushStateWhenCoordinator(boolean pushStateWhenCoordinator)
  -      {
  -         testImmutability("pushStateWhenCoordinator");
  -         // BES 2207/05/22 -- only setting this if singletonStore == true
  -         // is invalid since you can't control the order in which properties
  -         // are set. Instead control this via an && in the getter
  -//         if (singletonStore)
  -//         {
  -//            /* pushStateWhenCoordinator only makes sense if the cache loader
  -//     has been configured as a singleton store */
  -            this.pushStateWhenCoordinator = pushStateWhenCoordinator;
  -//         }
  +         testImmutability("singletonStoreConfig");         
  +         this.singletonStoreConfig = singletonStoreConfig;
         }
   
         public boolean equals(Object obj)
  @@ -300,8 +281,7 @@
                       && (this.async == other.async)
                       && (this.ignoreModifications == other.ignoreModifications)
                       && (this.fetchPersistentState == other.fetchPersistentState)
  -                    && (this.singletonStore == other.singletonStore)
  -                    && (this.pushStateWhenCoordinator == other.pushStateWhenCoordinator);
  +                    && safeEquals(this.singletonStoreConfig, other.singletonStoreConfig);
            }
            return false;
   
  @@ -319,8 +299,7 @@
            result = 31 * result + (async ? 0 : 1);
            result = 31 * result + (ignoreModifications ? 0 : 1);
            result = 31 * result + (fetchPersistentState ? 0 : 1);
  -         result = 31 * result + (singletonStore ? 0 : 1);
  -         result = 31 * result + (pushStateWhenCoordinator ? 0 : 1);
  +         result = 31 * result + (singletonStoreConfig == null ? 0 : singletonStoreConfig.hashCode());
            result = 31 * result + (purgeOnStartup ? 0 : 1);
            return result;
         }
  @@ -331,11 +310,108 @@
                    .append(", async=").append(async)
                    .append(", ignoreModifications=").append(ignoreModifications)
                    .append(", fetchPersistentState=").append(fetchPersistentState)
  -                 .append(", properties=").append(properties).append('}')
  -                 .append(", purgeOnStartup=").append(purgeOnStartup)
  -                 .append(", singletonStore=").append(singletonStore)
  -                 .append(", singletonStore.pushStateWhenCoordinator=").append(pushStateWhenCoordinator)
  +                 .append(", properties=").append(properties)
  +                 .append(", purgeOnStartup=").append(purgeOnStartup).append("},")
  +                 .append("SingletonStoreConfig{").append(singletonStoreConfig).append('}')
                    .toString();
         }
  +
  +      /**
  +       * Configuration for a SingletonStoreCacheLoader
  +       */
  +      public static class SingletonStoreConfig extends ConfigurationComponent
  +      {
  +         private static final long serialVersionUID = 824251894176131850L;
  +
  +         /**
  +          * Indicates whether the singleton store functionality is enabled or not.
  +          */
  +         private boolean singletonStoreEnabled;
  +
  +         /**
  +          * Class implementing the singleton store functionality.
  +          */
  +         private String singletonStoreClass;
  +
  +         /**
  +          * Properties of the singleton store.
  +          */
  +         private Properties singletonStoreproperties;
  +
  +         public SingletonStoreConfig()
  +         {
  +            singletonStoreClass = SingletonStoreCacheLoader.class.getName();
  +         }
  +
  +         public boolean isSingletonStoreEnabled()
  +         {
  +            return singletonStoreEnabled;
  +         }
  +
  +         public void setSingletonStoreEnabled(boolean singletonStoreEnabled)
  +         {
  +            testImmutability("singletonStoreEnabled");
  +            this.singletonStoreEnabled = singletonStoreEnabled;
  +         }
  +
  +         public String getSingletonStoreClass()
  +         {
  +            return singletonStoreClass;
  +         }
  +
  +         public void setSingletonStoreClass(String singletonStoreClass)
  +         {
  +            testImmutability("singletonStoreClass");
  +            if (!singletonStoreClass.equals(""))
  +            {
  +               this.singletonStoreClass = singletonStoreClass;
  +            }
  +         }
  +
  +         public Properties getSingletonStoreproperties()
  +         {
  +            return singletonStoreproperties;
  +         }
  +
  +         public void setSingletonStoreproperties(Properties singletonStoreproperties)
  +         {
  +            testImmutability("singletonStoreproperties");
  +            this.singletonStoreproperties = singletonStoreproperties;
  +         }
  +
  +         @Override
  +         public boolean equals(Object obj)
  +         {
  +            if (this == obj)
  +               return true;
  +
  +            if (obj instanceof SingletonStoreConfig)
  +            {
  +               SingletonStoreConfig other = (SingletonStoreConfig) obj;
  +               return ((this.singletonStoreEnabled == other.singletonStoreEnabled)
  +                       && safeEquals(this.singletonStoreClass, other.singletonStoreClass)
  +                       && safeEquals(this.singletonStoreproperties, other.singletonStoreproperties));
  +            }
  +            return false;
  +         }
  +
  +         @Override         
  +         public int hashCode()
  +         {
  +            int result = 19;
  +            result = 41 * result + (singletonStoreEnabled ? 0 : 1);
  +            result = 41 * result + (singletonStoreClass == null ? 0 : singletonStoreClass.hashCode());
  +            result = 41 * result + (singletonStoreproperties == null ? 0 : singletonStoreproperties.hashCode());
  +            return result;
  +         }
  +
  +         @Override         
  +         public String toString()
  +         {
  +            return super.toString() + " enabled=" + singletonStoreEnabled +
  +                    " class=" + singletonStoreClass +
  +                    " properties=" + singletonStoreproperties;
  +         }
  +      }
      }
   }
  
  
  



More information about the jboss-cvs-commits mailing list