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

Brian Stansberry brian.stansberry at jboss.com
Thu Oct 26 15:30:20 EDT 2006


  User: bstansberry
  Date: 06/10/26 15:30:20

  Modified:    src/org/jboss/cache/loader              
                        TcpDelegatingCacheLoader.java JDBCCacheLoader.java
                        ClusteredCacheLoader.java FileCacheLoader.java
                        RpcDelegatingCacheLoader.java AsyncCacheLoader.java
                        RmiDelegatingCacheLoader.java
  Added:       src/org/jboss/cache/loader              
                        JDBCCacheLoaderConfig.java
                        FileCacheLoaderConfig.java
                        TcpDelegatingCacheLoaderConfig.java
                        ClusteredCacheLoaderConfig.java
                        AsynchCacheLoaderConfig.java
                        RmiDelegatingCacheLoaderConfig.java
                        RpcDelegatingCacheLoaderConfig.java
  Log:
  Make cache loader Config classes top level classes
  
  Revision  Changes    Path
  1.6       +6 -96     JBossCache/src/org/jboss/cache/loader/TcpDelegatingCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TcpDelegatingCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/TcpDelegatingCacheLoader.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- TcpDelegatingCacheLoader.java	25 Oct 2006 12:49:31 -0000	1.5
  +++ TcpDelegatingCacheLoader.java	26 Oct 2006 19:30:20 -0000	1.6
  @@ -18,7 +18,6 @@
   import java.net.Socket;
   import java.util.List;
   import java.util.Map;
  -import java.util.Properties;
   import java.util.Set;
   
   /**
  @@ -33,12 +32,12 @@
    * </pre>
    *
    * @author Bela Ban
  - * @version $Id: TcpDelegatingCacheLoader.java,v 1.5 2006/10/25 12:49:31 msurtani Exp $
  + * @version $Id: TcpDelegatingCacheLoader.java,v 1.6 2006/10/26 19:30:20 bstansberry Exp $
    */
   public class TcpDelegatingCacheLoader extends DelegatingCacheLoader
   {
      private Socket sock;
  -   private Config config;
  +   private TcpDelegatingCacheLoaderConfig config;
      ObjectInputStream in;
      ObjectOutputStream out;
   
  @@ -59,7 +58,7 @@
       */
      public TcpDelegatingCacheLoader(String host, int port)
      {
  -      this.config = new Config(host, port);
  +      this.config = new TcpDelegatingCacheLoaderConfig(host, port);
      }
   
      /**
  @@ -69,13 +68,13 @@
       */
      public void setConfig(IndividualCacheLoaderConfig base)
      {
  -      if (base instanceof Config)
  +      if (base instanceof TcpDelegatingCacheLoaderConfig)
         {
  -         this.config = (Config) base;
  +         this.config = (TcpDelegatingCacheLoaderConfig) base;
         }
         else
         {
  -         config = new Config(base);
  +         config = new TcpDelegatingCacheLoaderConfig(base);
         }
      }
   
  @@ -353,93 +352,4 @@
         throw new UnsupportedOperationException("operation is not currently supported - need to define semantics first");
      }
   
  -   public static class Config extends IndividualCacheLoaderConfig
  -   {
  -      /**
  -       * The serialVersionUID
  -       */
  -      private static final long serialVersionUID = -3138555335000168505L;
  -
  -      private String host = "localhost";
  -      private int port = 7500;
  -
  -      public Config()
  -      {
  -         setClassName(TcpDelegatingCacheLoader.class.getName());
  -      }
  -
  -      private Config(IndividualCacheLoaderConfig base)
  -      {
  -         setClassName(TcpDelegatingCacheLoader.class.getName());
  -         populateFromBaseConfig(base);
  -      }
  -
  -      private Config(String host, int port)
  -      {
  -         setClassName(TcpDelegatingCacheLoader.class.getName());
  -         this.host = host;
  -         this.port = port;
  -      }
  -
  -      public String getHost()
  -      {
  -         return host;
  -      }
  -
  -      public void setHost(String host)
  -      {
  -         testImmutability("host");
  -         this.host = host;
  -      }
  -
  -      public int getPort()
  -      {
  -         return port;
  -      }
  -
  -      public void setPort(int port)
  -      {
  -         testImmutability("port");
  -         this.port = port;
  -      }
  -
  -      public void setProperties(Properties props)
  -      {
  -         super.setProperties(props);
  -         String s = props.getProperty("host");
  -         if (s != null && s.length() > 0)
  -         {
  -            this.host = s;
  -         }
  -         s = props.getProperty("port");
  -         if (s != null && s.length() > 0)
  -         {
  -            this.port = Integer.parseInt(s);
  -         }
  -      }
  -
  -      public boolean equals(Object obj)
  -      {
  -         if (obj instanceof Config && equalsExcludingProperties(obj))
  -         {
  -            Config other = (Config) obj;
  -
  -            return safeEquals(host, other.host)
  -                    && (port == other.port);
  -         }
  -         return false;
  -      }
  -
  -      public int hashCode()
  -      {
  -         int result = hashCodeExcludingProperties();
  -         result = 31 * result + (host == null ? 0 : host.hashCode());
  -         result = 31 * result + port;
  -
  -         return result;
  -      }
  -
  -
  -   }
  -
   }
  
  
  
  1.21      +6 -369    JBossCache/src/org/jboss/cache/loader/JDBCCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: JDBCCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/JDBCCacheLoader.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -b -r1.20 -r1.21
  --- JDBCCacheLoader.java	24 Oct 2006 11:35:29 -0000	1.20
  +++ JDBCCacheLoader.java	26 Oct 2006 19:30:20 -0000	1.21
  @@ -81,7 +81,7 @@
    *
    * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
    * @author <a href="mailto:hmesha at novell.com">Hany Mesha </a>
  - * @version <tt>$Revision: 1.20 $</tt>
  + * @version <tt>$Revision: 1.21 $</tt>
    */
   public class JDBCCacheLoader extends AbstractCacheLoader
   {
  @@ -89,19 +89,19 @@
   
      private static final ThreadLocal connection = new ThreadLocal();
   
  -   private Config config;
  +   private JDBCCacheLoaderConfig config;
      private ConnectionFactory cf;
      private String driverName;
   
      public void setConfig(IndividualCacheLoaderConfig base)
      {
  -      if (config instanceof Config)
  +      if (config instanceof JDBCCacheLoaderConfig)
         {
  -         config = (Config) base;
  +         config = (JDBCCacheLoaderConfig) base;
         }
         else
         {
  -         config = new Config(base);
  +         config = new JDBCCacheLoaderConfig(base);
         }
         
         if (config.getDatasourceName() == null)
  @@ -961,7 +961,7 @@
         }
      }
   
  -   private static String getRequiredProperty(Properties props, String name)
  +   static String getRequiredProperty(Properties props, String name)
      {
         String value = props.getProperty(name);
         if (value == null)
  @@ -1312,367 +1312,4 @@
            safeClose(con);
         }
      }
  -   
  -   public static class Config extends IndividualCacheLoaderConfig
  -   {
  -      /** The serialVersionUID */
  -      private static final long serialVersionUID = -5923661816427361643L;
  -      
  -      private boolean createTable;
  -      private String createTableDDL;
  -      private String datasourceName;
  -      private String deleteAllSql;
  -      private String deleteNodeSql;
  -      private boolean dropTable;
  -      private String dropTableDDL;
  -      private String driverClass;
  -      private String insertNodeSql;
  -      private String jdbcURL;
  -      private String jdbcUser;
  -      private String jdbcPassword;
  -      private String selectChildFqnsSql;
  -      private String selectChildNamesSql;
  -      private String selectNodeSql;
  -      private String table;
  -      private String updateNodeSql;
  -      private String updateTableSql;      
  -      
  -      public Config() 
  -      {
  -         setClassName(JDBCCacheLoader.class.getName());         
  -      }
  -      
  -      private Config(IndividualCacheLoaderConfig base)
  -      {
  -         setClassName(JDBCCacheLoader.class.getName());
  -         populateFromBaseConfig(base);
  -      }
  -
  -      public boolean getCreateTable()
  -      {
  -         return createTable;
  -      }
  -
  -      public void setCreateTable(boolean createTable)
  -      {
  -         testImmutability("createTable");
  -         this.createTable = createTable;
  -      }
  -
  -      public String getCreateTableDDL()
  -      {
  -         return createTableDDL;
  -      }
  -
  -      public void setCreateTableDDL(String createTableDDL)
  -      {
  -         testImmutability("createTableDDL");
  -         this.createTableDDL = createTableDDL;
  -      }
  -
  -      public String getDatasourceName()
  -      {
  -         return datasourceName;
  -      }
  -
  -      public void setDatasourceName(String datasourceName)
  -      {
  -         testImmutability("datasourceName");
  -         this.datasourceName = datasourceName;
  -      }
  -
  -      public String getDeleteAllSql()
  -      {
  -         return deleteAllSql;
  -      }
  -
  -      public void setDeleteAllSql(String deleteAllSql)
  -      {
  -         testImmutability("deleteAllSql");
  -         this.deleteAllSql = deleteAllSql;
  -      }
  -
  -      public String getDeleteNodeSql()
  -      {
  -         return deleteNodeSql;
  -      }
  -
  -      public void setDeleteNodeSql(String deleteNodeSql)
  -      {
  -         testImmutability("deleteNodeSql");
  -         this.deleteNodeSql = deleteNodeSql;
  -      }
  -
  -      public String getDriverClass()
  -      {
  -         return driverClass;
  -      }
  -
  -      public void setDriverClass(String driverClass)
  -      {
  -         testImmutability("driverClass");
  -         this.driverClass = driverClass;
  -      }
  -
  -      public boolean getDropTable()
  -      {
  -         return dropTable;
  -      }
  -
  -      public void setDropTable(boolean dropTable)
  -      {
  -         testImmutability("dropTable");
  -         this.dropTable = dropTable;
  -      }
  -
  -      public String getInsertNodeSql()
  -      {
  -         return insertNodeSql;
  -      }
  -
  -      public void setInsertNodeSql(String insertNodeSql)
  -      {
  -         testImmutability("insertNodeSql");
  -         this.insertNodeSql = insertNodeSql;
  -      }
  -
  -      public String getSelectChildFqnsSql()
  -      {
  -         return selectChildFqnsSql;
  -      }
  -
  -      public void setSelectChildFqnsSql(String selectChildFqnsSql)
  -      {
  -         testImmutability("selectChildFqnsSql");
  -         this.selectChildFqnsSql = selectChildFqnsSql;
  -      }
  -
  -      public String getSelectNodeSql()
  -      {
  -         return selectNodeSql;
  -      }
  -
  -      public void setSelectNodeSql(String selectNodeSql)
  -      {
  -         testImmutability("selectNodeSql");
  -         this.selectNodeSql = selectNodeSql;
  -      }
  -
  -      public String getTable()
  -      {
  -         return table;
  -      }
  -
  -      public void setTable(String table)
  -      {
  -         testImmutability("table");
  -         this.table = table;
  -      }
  -
  -      public String getUpdateTableSql()
  -      {
  -         return updateTableSql;
  -      }
  -
  -      public void setUpdateTableSql(String updateTableSql)
  -      {
  -         testImmutability("updateTableSql");
  -         this.updateTableSql = updateTableSql;
  -      }     
  -      
  -      public String getDropTableDDL()
  -      {
  -         return dropTableDDL;
  -      }
  -
  -      public void setDropTableDDL(String dropTableDDL)
  -      {
  -         testImmutability("dropTableDDL");
  -         this.dropTableDDL = dropTableDDL;
  -      }
  -
  -      public String getSelectChildNamesSql()
  -      {
  -         return selectChildNamesSql;
  -      }
  -
  -      public void setSelectChildNamesSql(String selectChildNamesSql)
  -      {
  -         testImmutability("selectChildNamesSql");
  -         this.selectChildNamesSql = selectChildNamesSql;
  -      }
  -
  -      public String getUpdateNodeSql()
  -      {
  -         return updateNodeSql;
  -      }
  -
  -      public void setUpdateNodeSql(String updateNodeSql)
  -      {
  -         testImmutability("updateNodeSql");
  -         this.updateNodeSql = updateNodeSql;
  -      }
  -      
  -      public String getJdbcPassword()
  -      {
  -         return jdbcPassword;
  -      }
  -
  -      public void setJdbcPassword(String jdbcPassword)
  -      {
  -         testImmutability("jdbcPassword");
  -         this.jdbcPassword = jdbcPassword;
  -      }
  -
  -      public String getJdbcURL()
  -      {
  -         return jdbcURL;
  -      }
  -
  -      public void setJdbcURL(String jdbcURL)
  -      {
  -         testImmutability("jdbcURL");
  -         this.jdbcURL = jdbcURL;
  -      }
  -
  -      public String getJdbcUser()
  -      {
  -         return jdbcUser;
  -      }
  -
  -      public void setJdbcUser(String jdbcUser)
  -      {
  -         testImmutability("jdbcUser");
  -         this.jdbcUser = jdbcUser;
  -      }
  -
  -      public void setProperties(Properties props)
  -      {
  -         super.setProperties(props);
  -         datasourceName = props.getProperty("cache.jdbc.datasource");
  -         if (datasourceName == null)
  -         {
  -            this.driverClass = getRequiredProperty(props, "cache.jdbc.driver");
  -            this.jdbcURL = getRequiredProperty(props, "cache.jdbc.url");
  -            this.jdbcUser = getRequiredProperty(props, "cache.jdbc.user");
  -            this.jdbcPassword = getRequiredProperty(props, "cache.jdbc.password");
  -
  -            if (log.isDebugEnabled())
  -            {
  -               log.debug("Properties: " +
  -                       "cache.jdbc.url=" +
  -                       jdbcURL +
  -                       ", cache.jdbc.driver=" +
  -                       driverClass +
  -                       ", cache.jdbc.user=" +
  -                       jdbcUser +
  -                       ", cache.jdbc.password=" +
  -                       jdbcPassword +
  -                       ", cache.jdbc.table=" + table);
  -            }
  -         }
  -
  -         String prop = props.getProperty("cache.jdbc.table.create");
  -         this.createTable = (prop == null || Boolean.valueOf(prop).booleanValue());
  -         prop = props.getProperty("cache.jdbc.table.drop");
  -         this.dropTable = (prop == null || Boolean.valueOf(prop).booleanValue());
  -
  -         this.table = props.getProperty("cache.jdbc.table.name", "jbosscache");
  -         String primaryKey = props.getProperty("cache.jdbc.table.primarykey", "jbosscache_pk");
  -         String fqnColumn = props.getProperty("cache.jdbc.fqn.column", "fqn");
  -         String fqnType = props.getProperty("cache.jdbc.fqn.type", "varchar(255)");
  -         String nodeColumn = props.getProperty("cache.jdbc.node.column", "node");
  -         String nodeType = props.getProperty("cache.jdbc.node.type", "blob");
  -         String parentColumn = props.getProperty("cache.jdbc.parent.column", "parent");
  -
  -         selectChildNamesSql = "select " + fqnColumn + " from " + table + " where " + parentColumn + "=?";
  -         deleteNodeSql = "delete from " + table + " where " + fqnColumn + "=?";
  -         deleteAllSql = "delete from " + table;
  -         selectChildFqnsSql = "select " + fqnColumn + " from " + table + " where " + parentColumn + "=?";
  -         insertNodeSql = "insert into " +
  -                 table +
  -                 " (" +
  -                 fqnColumn +
  -                 ", " +
  -                 nodeColumn +
  -                 ", " +
  -                 parentColumn +
  -                 ") values (?, ?, ?)";
  -         updateNodeSql = "update " + table + " set " + nodeColumn + "=? where " + fqnColumn + "=?";
  -         selectNodeSql = "select " + nodeColumn + " from " + table + " where " + fqnColumn + "=?";
  -
  -         createTableDDL = "create table " +
  -                 table +
  -                 "(" +
  -                 fqnColumn +
  -                 " " +
  -                 fqnType +
  -                 " not null, " +
  -                 nodeColumn +
  -                 " " +
  -                 nodeType +
  -                 ", " +
  -                 parentColumn +
  -                 " " +
  -                 fqnType +
  -                 ", constraint " + primaryKey + " primary key (" + fqnColumn + "))";
  -
  -         dropTableDDL = "drop table " + table;
  -      }
  -
  -      public boolean equals(Object obj)
  -      {
  -         if (obj instanceof Config && equalsExcludingProperties(obj))
  -         {         
  -            Config other = (Config) obj;
  -            
  -            return (this.createTable == other.createTable)
  -                   && safeEquals(createTableDDL, other.createTableDDL)
  -                   && safeEquals(datasourceName, other.datasourceName)
  -                   && safeEquals(deleteAllSql, other.deleteAllSql)
  -                   && safeEquals(deleteNodeSql, other.deleteNodeSql)
  -                   && safeEquals(driverClass, other.driverClass)
  -                   && (dropTable == other.dropTable)
  -                   && safeEquals(dropTableDDL, other.dropTableDDL)
  -                   && safeEquals(insertNodeSql, other.insertNodeSql)
  -                   && safeEquals(jdbcPassword, other.jdbcPassword)
  -                   && safeEquals(jdbcURL, other.jdbcURL)
  -                   && safeEquals(jdbcUser, other.jdbcUser)
  -                   && safeEquals(selectChildFqnsSql, other.selectChildFqnsSql)
  -                   && safeEquals(selectChildNamesSql, other.selectChildNamesSql)
  -                   && safeEquals(selectNodeSql, other.selectNodeSql)
  -                   && safeEquals(table, other.table)
  -                   && safeEquals(updateNodeSql, other.updateNodeSql)
  -                   && safeEquals(updateTableSql, other.updateTableSql);
  -         }
  -         
  -         return false;
  -      }
  -      
  -      public int hashCode()
  -      {
  -         int result = hashCodeExcludingProperties();
  -         result = 31 * result + (createTable ? 0 : 1);
  -         result = 31 * result + (createTableDDL == null ? 0 : createTableDDL.hashCode());
  -         result = 31 * result + (datasourceName == null ? 0 : datasourceName.hashCode());
  -         result = 31 * result + (deleteAllSql == null ? 0 : deleteAllSql.hashCode());
  -         result = 31 * result + (deleteNodeSql == null ? 0 : deleteNodeSql.hashCode());
  -         result = 31 * result + (driverClass == null ? 0 : driverClass.hashCode());
  -         result = 31 * result + (dropTable ? 0 : 1);
  -         result = 31 * result + (dropTableDDL == null ? 0 : dropTableDDL.hashCode());
  -         result = 31 * result + (insertNodeSql == null ? 0 : insertNodeSql.hashCode());
  -         result = 31 * result + (jdbcPassword == null ? 0 : jdbcPassword.hashCode());
  -         result = 31 * result + (jdbcUser == null ? 0 : jdbcUser.hashCode());
  -         result = 31 * result + (jdbcURL == null ? 0 : jdbcURL.hashCode());
  -         result = 31 * result + (selectChildFqnsSql == null ? 0 : selectChildFqnsSql.hashCode());
  -         result = 31 * result + (selectChildNamesSql == null ? 0 : selectChildNamesSql.hashCode());
  -         result = 31 * result + (selectNodeSql == null ? 0 : selectNodeSql.hashCode());
  -         result = 31 * result + (table == null ? 0 : table.hashCode());
  -         result = 31 * result + (updateNodeSql == null ? 0 : updateNodeSql.hashCode());
  -         result = 31 * result + (updateTableSql == null ? 0 : updateTableSql.hashCode());
  -         
  -         return result;
  -      }     
  -      
  -   }
   }
  
  
  
  1.16      +4 -66     JBossCache/src/org/jboss/cache/loader/ClusteredCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ClusteredCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/ClusteredCacheLoader.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -b -r1.15 -r1.16
  --- ClusteredCacheLoader.java	23 Oct 2006 05:46:39 -0000	1.15
  +++ ClusteredCacheLoader.java	26 Oct 2006 19:30:20 -0000	1.16
  @@ -12,7 +12,6 @@
   import org.jboss.cache.Modification;
   import org.jboss.cache.RegionManager;
   import org.jboss.cache.TreeCache;
  -import org.jboss.cache.config.Dynamic;
   import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
   import org.jboss.cache.marshall.MethodCall;
   import org.jboss.cache.marshall.MethodCallFactory;
  @@ -25,7 +24,6 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  -import java.util.Properties;
   import java.util.Set;
   
   /**
  @@ -41,7 +39,7 @@
   {
      private static Log log = LogFactory.getLog(ClusteredCacheLoader.class);
      
  -   private Config config;
  +   private ClusteredCacheLoaderConfig config;
      
      /**
       * Sets the configuration.
  @@ -51,13 +49,13 @@
       */
      public void setConfig(IndividualCacheLoaderConfig base)
      {
  -      if (base instanceof Config)
  +      if (base instanceof ClusteredCacheLoaderConfig)
         {
  -         this.config = (Config) base;
  +         this.config = (ClusteredCacheLoaderConfig) base;
         }
         else
         {
  -         config = new Config(base);
  +         config = new ClusteredCacheLoaderConfig(base);
         }
      }
      
  @@ -248,64 +246,4 @@
      {
      }
      
  -   public static class Config extends IndividualCacheLoaderConfig
  -   {
  -      /** The serialVersionUID */
  -      private static final long serialVersionUID = -3425487656984237468L;
  -      
  -      @Dynamic
  -      private long timeout = 10000;
  -      
  -      public Config() 
  -      {
  -         setClassName(ClusteredCacheLoader.class.getName());
  -      }
  -      
  -      private Config(IndividualCacheLoaderConfig base)
  -      {
  -         setClassName(ClusteredCacheLoader.class.getName());
  -         populateFromBaseConfig(base);
  -      }
  -
  -      public long getTimeout()
  -      {
  -         return timeout;
  -      }
  -
  -      public void setTimeout(long timeout)
  -      {
  -         testImmutability("timeout");
  -         this.timeout = timeout;
  -      }
  -      
  -      public void setProperties(Properties props)
  -      {
  -         super.setProperties(props);
  -         try
  -         {
  -            timeout = Long.valueOf(props.getProperty("timeout")).longValue();
  -         }
  -         catch (Exception e)
  -         {
  -            log.info("Using default value for config property 'timeout' - " + timeout);
  -         }
  -      }
  -
  -      public boolean equals(Object obj)
  -      {
  -         if (obj instanceof Config && equalsExcludingProperties(obj))
  -         {
  -            Config other = (Config) obj;
  -            return (this.timeout == other.timeout);
  -         }
  -         return false;
  -      }
  -
  -      public int hashCode()
  -      {
  -         return 31 * hashCodeExcludingProperties() + (int) timeout;
  -      }
  -      
  -   }
  -
   }
  
  
  
  1.22      +5 -56     JBossCache/src/org/jboss/cache/loader/FileCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: FileCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/FileCacheLoader.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -b -r1.21 -r1.22
  --- FileCacheLoader.java	24 Oct 2006 11:35:29 -0000	1.21
  +++ FileCacheLoader.java	26 Oct 2006 19:30:20 -0000	1.22
  @@ -17,21 +17,20 @@
   import java.util.HashSet;
   import java.util.List;
   import java.util.Map;
  -import java.util.Properties;
   import java.util.Set;
   
   /**
    * Simple file-based CacheLoader implementation. Nodes are directories, attributes of a node is a file in the directory
    *
    * @author Bela Ban
  - * @version $Id: FileCacheLoader.java,v 1.21 2006/10/24 11:35:29 msurtani Exp $
  + * @version $Id: FileCacheLoader.java,v 1.22 2006/10/26 19:30:20 bstansberry Exp $
    */
   public class FileCacheLoader extends AbstractCacheLoader
   {
      File root = null;
      Log log = LogFactory.getLog(getClass());
   
  -   private Config config;
  +   private FileCacheLoaderConfig config;
      
      /**
       * HashMap<Object,List<Modification>>. List of open transactions. Note that this is purely transient, as
  @@ -55,13 +54,13 @@
   
      public void setConfig(IndividualCacheLoaderConfig base)
      {
  -      if (base instanceof Config)
  +      if (base instanceof FileCacheLoaderConfig)
         {
  -         this.config = (Config) base;
  +         this.config = (FileCacheLoaderConfig) base;
         }
         else if (base != null)
         {
  -         this.config = new Config(base);
  +         this.config = new FileCacheLoaderConfig(base);
         }
            
         String location = this.config != null ? this.config.getLocation() : null;
  @@ -365,54 +364,4 @@
         output.writeObject(attrs);
         out.close();
      }
  -   
  -   public static class Config extends IndividualCacheLoaderConfig
  -   {
  -      private static final long serialVersionUID = 4626734068542420865L;
  -      
  -      private String location;
  -
  -      public Config() 
  -      {
  -         setClassName(FileCacheLoader.class.getName());
  -      }
  -      
  -      private Config(IndividualCacheLoaderConfig base)
  -      {
  -         setClassName(FileCacheLoader.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());
  -      }     
  -      
  -   }
   }
  
  
  
  1.13      +5 -64     JBossCache/src/org/jboss/cache/loader/RpcDelegatingCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: RpcDelegatingCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/RpcDelegatingCacheLoader.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- RpcDelegatingCacheLoader.java	23 Oct 2006 05:46:39 -0000	1.12
  +++ RpcDelegatingCacheLoader.java	26 Oct 2006 19:30:20 -0000	1.13
  @@ -10,7 +10,6 @@
   import org.jboss.cache.DataNode;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.TreeCache;
  -import org.jboss.cache.config.Dynamic;
   import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
   import org.jboss.cache.lock.TimeoutException;
   import org.jboss.cache.marshall.MethodCall;
  @@ -22,7 +21,6 @@
   import java.lang.reflect.Method;
   import java.util.List;
   import java.util.Map;
  -import java.util.Properties;
   import java.util.Set;
   import java.util.Vector;
   
  @@ -36,12 +34,12 @@
    * specified, it defaults to <tt>5000</tt>.
    *
    * @author Daniel Gredler
  - * @version $Id: RpcDelegatingCacheLoader.java,v 1.12 2006/10/23 05:46:39 bstansberry Exp $
  + * @version $Id: RpcDelegatingCacheLoader.java,v 1.13 2006/10/26 19:30:20 bstansberry Exp $
    */
   public class RpcDelegatingCacheLoader extends DelegatingCacheLoader
   {
   
  -   private Config config = new Config();
  +   private RpcDelegatingCacheLoaderConfig config = new RpcDelegatingCacheLoaderConfig();
      private Address localAddress;
   
      public static final Method METHOD_GET_STATE;
  @@ -108,13 +106,13 @@
       */
      public void setConfig(IndividualCacheLoaderConfig base)
      {
  -      if (base instanceof Config)
  +      if (base instanceof RpcDelegatingCacheLoaderConfig)
         {
  -         this.config = (Config) base;
  +         this.config = (RpcDelegatingCacheLoaderConfig) base;
         }
         else
         { 
  -         this.config = new Config(base);
  +         this.config = new RpcDelegatingCacheLoaderConfig(base);
         }
      }
      
  @@ -280,61 +278,4 @@
         }
         return response;
      }
  -   
  -   public static class Config extends IndividualCacheLoaderConfig
  -   {
  -      /** The serialVersionUID */
  -      private static final long serialVersionUID = -3425487656984237468L;
  -      
  -      @Dynamic
  -      private int timeout = 5000;
  -      
  -      public Config() 
  -      {
  -         setClassName(RpcDelegatingCacheLoader.class.getName());
  -      }
  -      
  -      private Config(IndividualCacheLoaderConfig base)
  -      {
  -         setClassName(RpcDelegatingCacheLoader.class.getName());
  -         populateFromBaseConfig(base);
  -      }
  -
  -      public int getTimeout()
  -      {
  -         return timeout;
  -      }
  -
  -      public void setTimeout(int timeout)
  -      {
  -         testImmutability("timeout");
  -         this.timeout = timeout;
  -      }
  -      
  -      public void setProperties(Properties props)
  -      {
  -         if (props == null) return;
  -         
  -         super.setProperties(props);
  -         String t = props.getProperty("timeout");
  -         if (t != null && t.length() > 0)
  -            this.timeout = Integer.parseInt(t);
  -      }
  -
  -      public boolean equals(Object obj)
  -      {
  -         if (obj instanceof Config && equalsExcludingProperties(obj))
  -         {
  -            Config other = (Config) obj;
  -            return (this.timeout == other.timeout);
  -         }
  -         return false;
  -      }
  -
  -      public int hashCode()
  -      {
  -         return 31 * hashCodeExcludingProperties() + (int) timeout;
  -      }
  -      
  -   }
   }
  
  
  
  1.22      +4 -151    JBossCache/src/org/jboss/cache/loader/AsyncCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AsyncCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/AsyncCacheLoader.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -b -r1.21 -r1.22
  --- AsyncCacheLoader.java	23 Oct 2006 05:46:39 -0000	1.21
  +++ AsyncCacheLoader.java	26 Oct 2006 19:30:20 -0000	1.22
  @@ -19,7 +19,6 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  -import java.util.Properties;
   
   /**
    * The AsyncCacheLoader is a delegating cache loader that extends
  @@ -89,7 +88,7 @@
       */
      public static final int DEFAULT_QUEUE_SIZE = 10000;
   
  -   private Config config;
  +   private AsynchCacheLoaderConfig config;
      private AsyncProcessor processor;
      private SynchronizedBoolean stopped = new SynchronizedBoolean(true);
      private BoundedLinkedQueue queue = new BoundedLinkedQueue(DEFAULT_QUEUE_SIZE);
  @@ -107,13 +106,13 @@
   
      public void setConfig(IndividualCacheLoaderConfig base)
      {
  -      if (base instanceof Config)
  +      if (base instanceof AsynchCacheLoaderConfig)
         {
  -         config = (Config) base;
  +         config = (AsynchCacheLoaderConfig) base;
         }
         else
         {
  -         config = new Config(base);
  +         config = new AsynchCacheLoaderConfig(base);
         }
   
         if (config.getQueueSize() > 0)
  @@ -394,150 +393,4 @@
                " queue.peek()=" + queue.peek();
      }
      
  -   public static class Config extends IndividualCacheLoaderConfig
  -   {
  -      /** The serialVersionUID */
  -      private static final long serialVersionUID = 5038037589485991681L;
  -      
  -      private int batchSize = 100;
  -      private int pollWait = 100;
  -      private boolean returnOld = true;
  -      private int queueSize = 0;
  -      private boolean useAsyncPut = true;
  -      
  -      public Config()
  -      {
  -         setClassName(AsyncCacheLoader.class.getName());
  -      }
  -      
  -      private Config(IndividualCacheLoaderConfig base)
  -      {         
  -         setClassName(AsyncCacheLoader.class.getName());
  -         populateFromBaseConfig(base);
  -      }
  -
  -      public int getBatchSize()
  -      {
  -         return batchSize;
  -      }
  -
  -      public void setBatchSize(int batchSize)
  -      {
  -         testImmutability("batchSize");
  -         this.batchSize = batchSize;
  -      }
  -
  -      public int getPollWait()
  -      {
  -         return pollWait;
  -      }
  -
  -      public void setPollWait(int pollWait)
  -      {
  -         testImmutability("pollWait");
  -         this.pollWait = pollWait;
  -      }
  -
  -      public int getQueueSize()
  -      {
  -         return queueSize;
  -      }
  -
  -      public void setQueueSize(int queueSize)
  -      {
  -         testImmutability("queueSize");
  -         this.queueSize = queueSize;
  -      }
  -
  -      public boolean getReturnOld()
  -      {
  -         return returnOld;
  -      }
  -
  -      public void setReturnOld(boolean returnOld)
  -      {
  -         testImmutability("returnOld");
  -         this.returnOld = returnOld;
  -      }
  -
  -      public boolean getUseAsyncPut()
  -      {
  -         return useAsyncPut;
  -      }
  -
  -      public void setUseAsyncPut(boolean useAsyncPut)
  -      {
  -         testImmutability("useAsyncPut");
  -         this.useAsyncPut = useAsyncPut;
  -      }
  -
  -      public void setProperties(Properties props)
  -      {
  -         super.setProperties(props);
  -         String s;
  -
  -         s = props.getProperty("cache.async.batchSize");
  -         if (s != null)
  -         {
  -            batchSize = Integer.parseInt(s);
  -         }
  -         if (batchSize <= 0)
  -         {
  -            throw new IllegalArgumentException("Invalid size: " + batchSize);
  -         }
  -
  -         s = props.getProperty("cache.async.pollWait");
  -         if (s != null)
  -         {
  -            pollWait = Integer.parseInt(s);
  -         }
  -
  -         s = props.getProperty("cache.async.returnOld");
  -         if (s != null)
  -         {
  -            returnOld = Boolean.valueOf(s).booleanValue();
  -         }
  -
  -         s = props.getProperty("cache.async.queueSize");
  -         if (s != null)
  -         {
  -            queueSize = Integer.parseInt(s);
  -         }
  -
  -         s = props.getProperty("cache.async.put");
  -         if (s != null)
  -         {
  -            useAsyncPut = Boolean.valueOf(s).booleanValue();
  -         }
  -      }
  -
  -      public boolean equals(Object obj)
  -      {
  -         if (obj instanceof Config && equalsExcludingProperties(obj))
  -         {
  -            Config other = (Config) obj;
  -            return (batchSize == other.batchSize)
  -                     && (pollWait == other.pollWait)
  -                     && (queueSize == other.queueSize)
  -                     && (returnOld == other.returnOld)
  -                     && (useAsyncPut == other.useAsyncPut);
  -         }
  -         return false;
  -      }
  -
  -      public int hashCode()
  -      {
  -         int result = hashCodeExcludingProperties();
  -         result = 31 * result + batchSize;
  -         result = 31 * result + pollWait;
  -         result = 31 * result + queueSize;
  -         result = 31 * result + (returnOld ? 0 : 1);
  -         result = 31 * result + (useAsyncPut ? 0 : 1);
  -         return result;
  -      }
  -      
  -      
  -      
  -   }
  -
   }
  
  
  
  1.14      +5 -101    JBossCache/src/org/jboss/cache/loader/RmiDelegatingCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: RmiDelegatingCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/RmiDelegatingCacheLoader.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -b -r1.13 -r1.14
  --- RmiDelegatingCacheLoader.java	23 Oct 2006 05:46:39 -0000	1.13
  +++ RmiDelegatingCacheLoader.java	26 Oct 2006 19:30:20 -0000	1.14
  @@ -17,7 +17,6 @@
   import java.io.ObjectOutputStream;
   import java.rmi.Naming;
   import java.util.Map;
  -import java.util.Properties;
   import java.util.Set;
   
   /**
  @@ -34,11 +33,11 @@
    * cacheloader's cache's cluster name.
    *
    * @author Daniel Gredler
  - * @version $Id: RmiDelegatingCacheLoader.java,v 1.13 2006/10/23 05:46:39 bstansberry Exp $
  + * @version $Id: RmiDelegatingCacheLoader.java,v 1.14 2006/10/26 19:30:20 bstansberry Exp $
    */
   public class RmiDelegatingCacheLoader extends DelegatingCacheLoader
   {
  -   private Config config = new Config();
  +   private RmiDelegatingCacheLoaderConfig config = new RmiDelegatingCacheLoaderConfig();
      private TreeCache cache;
      private RemoteTreeCache remoteCache;
      private boolean programmaticInit;
  @@ -76,13 +75,13 @@
       */
      public void setConfig(IndividualCacheLoaderConfig base)
      {
  -      if (base instanceof Config)
  +      if (base instanceof RmiDelegatingCacheLoaderConfig)
         {
  -         this.config = (Config) base;
  +         this.config = (RmiDelegatingCacheLoaderConfig) base;
         }
         else
         {
  -         config = new Config(base);
  +         config = new RmiDelegatingCacheLoaderConfig(base);
         }
         this.tryToInitRemoteCache();
      }
  @@ -234,99 +233,4 @@
            log.error("Unable to lookup remote cache at '" + name + "'.", t);
         }
      }
  -   
  -   public static class Config extends IndividualCacheLoaderConfig
  -   {
  -      /** The serialVersionUID */
  -      private static final long serialVersionUID = 4578924632178739084L;
  -      
  -      private String host = "localhost";
  -      private String port = "1098";
  -      private String bindName;
  -      
  -      public Config()
  -      {
  -         setClassName(RmiDelegatingCacheLoader.class.getName());
  -      }
  -      
  -      private Config(IndividualCacheLoaderConfig base)
  -      {
  -         setClassName(RmiDelegatingCacheLoader.class.getName());
  -         populateFromBaseConfig(base);
  -      }
  -
  -      public String getBindName()
  -      {
  -         return bindName;
  -      }
  -
  -      public void setBindName(String bindName)
  -      {
  -         testImmutability("bindName");
  -         this.bindName = bindName;
  -      }
  -
  -      public String getHost()
  -      {
  -         return host;
  -      }
  -
  -      public void setHost(String host)
  -      {
  -         testImmutability("host");
  -         this.host = host;
  -      }
  -
  -      public String getPort()
  -      {
  -         return port;
  -      }
  -
  -      public void setPort(String port)
  -      {
  -         testImmutability("port");
  -         this.port = port;
  -      }
  -
  -      public void setProperties(Properties props)
  -      {
  -         super.setProperties(props);
  -         String s = props.getProperty("host");
  -         if (s != null && s.length() > 0)
  -         {
  -            this.host = s;
  -         }
  -         s = props.getProperty("port");
  -         if (s != null && s.length() > 00)
  -         {
  -            this.port = s;
  -         }
  -         this.bindName = props.getProperty("bindName");
  -      }
  -
  -      public boolean equals(Object obj)
  -      {
  -         if (obj instanceof Config && equalsExcludingProperties(obj))
  -         {
  -            Config other = (Config) obj;
  -            
  -            return safeEquals(host, other.host)
  -                     && safeEquals(port, other.port)
  -                     && safeEquals(bindName, other.bindName);            
  -         }
  -         return false;
  -      }
  -
  -      public int hashCode()
  -      {
  -         int result = hashCodeExcludingProperties();
  -         result = 31 * result + (host == null ? 0 : host.hashCode());
  -         result = 31 * result + (port == null ? 0 : port.hashCode());
  -         result = 31 * result + (bindName == null ? 0 : bindName.hashCode());
  -         
  -         return result;
  -      }
  -      
  -      
  -   }
   }
  
  
  
  1.1      date: 2006/10/26 19:30:20;  author: bstansberry;  state: Exp;JBossCache/src/org/jboss/cache/loader/JDBCCacheLoaderConfig.java
  
  Index: JDBCCacheLoaderConfig.java
  ===================================================================
  package org.jboss.cache.loader;
  
  import java.util.Properties;
  
  import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
  
  public class JDBCCacheLoaderConfig extends IndividualCacheLoaderConfig
  {
     /** The serialVersionUID */
     private static final long serialVersionUID = -5923661816427361643L;
     
     private boolean createTable;
     private String createTableDDL;
     private String datasourceName;
     private String deleteAllSql;
     private String deleteNodeSql;
     private boolean dropTable;
     private String dropTableDDL;
     private String driverClass;
     private String insertNodeSql;
     private String jdbcURL;
     private String jdbcUser;
     private String jdbcPassword;
     private String selectChildFqnsSql;
     private String selectChildNamesSql;
     private String selectNodeSql;
     private String table;
     private String updateNodeSql;
     private String updateTableSql;      
     
     public JDBCCacheLoaderConfig() 
     {
        setClassName(JDBCCacheLoader.class.getName());         
     }
     
     /**
      * For use by {@link JDBCCacheLoader}.
      * 
      * @param base generic config object created by XML parsing.
      */
     JDBCCacheLoaderConfig(IndividualCacheLoaderConfig base)
     {
        setClassName(JDBCCacheLoader.class.getName());
        populateFromBaseConfig(base);
     }
  
     public boolean getCreateTable()
     {
        return createTable;
     }
  
     public void setCreateTable(boolean createTable)
     {
        testImmutability("createTable");
        this.createTable = createTable;
     }
  
     public String getCreateTableDDL()
     {
        return createTableDDL;
     }
  
     public void setCreateTableDDL(String createTableDDL)
     {
        testImmutability("createTableDDL");
        this.createTableDDL = createTableDDL;
     }
  
     public String getDatasourceName()
     {
        return datasourceName;
     }
  
     public void setDatasourceName(String datasourceName)
     {
        testImmutability("datasourceName");
        this.datasourceName = datasourceName;
     }
  
     public String getDeleteAllSql()
     {
        return deleteAllSql;
     }
  
     public void setDeleteAllSql(String deleteAllSql)
     {
        testImmutability("deleteAllSql");
        this.deleteAllSql = deleteAllSql;
     }
  
     public String getDeleteNodeSql()
     {
        return deleteNodeSql;
     }
  
     public void setDeleteNodeSql(String deleteNodeSql)
     {
        testImmutability("deleteNodeSql");
        this.deleteNodeSql = deleteNodeSql;
     }
  
     public String getDriverClass()
     {
        return driverClass;
     }
  
     public void setDriverClass(String driverClass)
     {
        testImmutability("driverClass");
        this.driverClass = driverClass;
     }
  
     public boolean getDropTable()
     {
        return dropTable;
     }
  
     public void setDropTable(boolean dropTable)
     {
        testImmutability("dropTable");
        this.dropTable = dropTable;
     }
  
     public String getInsertNodeSql()
     {
        return insertNodeSql;
     }
  
     public void setInsertNodeSql(String insertNodeSql)
     {
        testImmutability("insertNodeSql");
        this.insertNodeSql = insertNodeSql;
     }
  
     public String getSelectChildFqnsSql()
     {
        return selectChildFqnsSql;
     }
  
     public void setSelectChildFqnsSql(String selectChildFqnsSql)
     {
        testImmutability("selectChildFqnsSql");
        this.selectChildFqnsSql = selectChildFqnsSql;
     }
  
     public String getSelectNodeSql()
     {
        return selectNodeSql;
     }
  
     public void setSelectNodeSql(String selectNodeSql)
     {
        testImmutability("selectNodeSql");
        this.selectNodeSql = selectNodeSql;
     }
  
     public String getTable()
     {
        return table;
     }
  
     public void setTable(String table)
     {
        testImmutability("table");
        this.table = table;
     }
  
     public String getUpdateTableSql()
     {
        return updateTableSql;
     }
  
     public void setUpdateTableSql(String updateTableSql)
     {
        testImmutability("updateTableSql");
        this.updateTableSql = updateTableSql;
     }     
     
     public String getDropTableDDL()
     {
        return dropTableDDL;
     }
  
     public void setDropTableDDL(String dropTableDDL)
     {
        testImmutability("dropTableDDL");
        this.dropTableDDL = dropTableDDL;
     }
  
     public String getSelectChildNamesSql()
     {
        return selectChildNamesSql;
     }
  
     public void setSelectChildNamesSql(String selectChildNamesSql)
     {
        testImmutability("selectChildNamesSql");
        this.selectChildNamesSql = selectChildNamesSql;
     }
  
     public String getUpdateNodeSql()
     {
        return updateNodeSql;
     }
  
     public void setUpdateNodeSql(String updateNodeSql)
     {
        testImmutability("updateNodeSql");
        this.updateNodeSql = updateNodeSql;
     }
     
     public String getJdbcPassword()
     {
        return jdbcPassword;
     }
  
     public void setJdbcPassword(String jdbcPassword)
     {
        testImmutability("jdbcPassword");
        this.jdbcPassword = jdbcPassword;
     }
  
     public String getJdbcURL()
     {
        return jdbcURL;
     }
  
     public void setJdbcURL(String jdbcURL)
     {
        testImmutability("jdbcURL");
        this.jdbcURL = jdbcURL;
     }
  
     public String getJdbcUser()
     {
        return jdbcUser;
     }
  
     public void setJdbcUser(String jdbcUser)
     {
        testImmutability("jdbcUser");
        this.jdbcUser = jdbcUser;
     }
  
     public void setProperties(Properties props)
     {
        super.setProperties(props);
        datasourceName = props.getProperty("cache.jdbc.datasource");
        if (datasourceName == null)
        {
           this.driverClass = JDBCCacheLoader.getRequiredProperty(props, "cache.jdbc.driver");
           this.jdbcURL = JDBCCacheLoader.getRequiredProperty(props, "cache.jdbc.url");
           this.jdbcUser = JDBCCacheLoader.getRequiredProperty(props, "cache.jdbc.user");
           this.jdbcPassword = JDBCCacheLoader.getRequiredProperty(props, "cache.jdbc.password");
  
           if (log.isDebugEnabled())
           {
              log.debug("Properties: " +
                      "cache.jdbc.url=" +
                      jdbcURL +
                      ", cache.jdbc.driver=" +
                      driverClass +
                      ", cache.jdbc.user=" +
                      jdbcUser +
                      ", cache.jdbc.password=" +
                      jdbcPassword +
                      ", cache.jdbc.table=" + table);
           }
        }
  
        String prop = props.getProperty("cache.jdbc.table.create");
        this.createTable = (prop == null || Boolean.valueOf(prop).booleanValue());
        prop = props.getProperty("cache.jdbc.table.drop");
        this.dropTable = (prop == null || Boolean.valueOf(prop).booleanValue());
  
        this.table = props.getProperty("cache.jdbc.table.name", "jbosscache");
        String primaryKey = props.getProperty("cache.jdbc.table.primarykey", "jbosscache_pk");
        String fqnColumn = props.getProperty("cache.jdbc.fqn.column", "fqn");
        String fqnType = props.getProperty("cache.jdbc.fqn.type", "varchar(255)");
        String nodeColumn = props.getProperty("cache.jdbc.node.column", "node");
        String nodeType = props.getProperty("cache.jdbc.node.type", "blob");
        String parentColumn = props.getProperty("cache.jdbc.parent.column", "parent");
  
        selectChildNamesSql = "select " + fqnColumn + " from " + table + " where " + parentColumn + "=?";
        deleteNodeSql = "delete from " + table + " where " + fqnColumn + "=?";
        deleteAllSql = "delete from " + table;
        selectChildFqnsSql = "select " + fqnColumn + " from " + table + " where " + parentColumn + "=?";
        insertNodeSql = "insert into " +
                table +
                " (" +
                fqnColumn +
                ", " +
                nodeColumn +
                ", " +
                parentColumn +
                ") values (?, ?, ?)";
        updateNodeSql = "update " + table + " set " + nodeColumn + "=? where " + fqnColumn + "=?";
        selectNodeSql = "select " + nodeColumn + " from " + table + " where " + fqnColumn + "=?";
  
        createTableDDL = "create table " +
                table +
                "(" +
                fqnColumn +
                " " +
                fqnType +
                " not null, " +
                nodeColumn +
                " " +
                nodeType +
                ", " +
                parentColumn +
                " " +
                fqnType +
                ", constraint " + primaryKey + " primary key (" + fqnColumn + "))";
  
        dropTableDDL = "drop table " + table;
     }
  
     public boolean equals(Object obj)
     {
        if (obj instanceof JDBCCacheLoaderConfig && equalsExcludingProperties(obj))
        {         
           JDBCCacheLoaderConfig other = (JDBCCacheLoaderConfig) obj;
           
           return (this.createTable == other.createTable)
                  && safeEquals(createTableDDL, other.createTableDDL)
                  && safeEquals(datasourceName, other.datasourceName)
                  && safeEquals(deleteAllSql, other.deleteAllSql)
                  && safeEquals(deleteNodeSql, other.deleteNodeSql)
                  && safeEquals(driverClass, other.driverClass)
                  && (dropTable == other.dropTable)
                  && safeEquals(dropTableDDL, other.dropTableDDL)
                  && safeEquals(insertNodeSql, other.insertNodeSql)
                  && safeEquals(jdbcPassword, other.jdbcPassword)
                  && safeEquals(jdbcURL, other.jdbcURL)
                  && safeEquals(jdbcUser, other.jdbcUser)
                  && safeEquals(selectChildFqnsSql, other.selectChildFqnsSql)
                  && safeEquals(selectChildNamesSql, other.selectChildNamesSql)
                  && safeEquals(selectNodeSql, other.selectNodeSql)
                  && safeEquals(table, other.table)
                  && safeEquals(updateNodeSql, other.updateNodeSql)
                  && safeEquals(updateTableSql, other.updateTableSql);
        }
        
        return false;
     }
     
     public int hashCode()
     {
        int result = hashCodeExcludingProperties();
        result = 31 * result + (createTable ? 0 : 1);
        result = 31 * result + (createTableDDL == null ? 0 : createTableDDL.hashCode());
        result = 31 * result + (datasourceName == null ? 0 : datasourceName.hashCode());
        result = 31 * result + (deleteAllSql == null ? 0 : deleteAllSql.hashCode());
        result = 31 * result + (deleteNodeSql == null ? 0 : deleteNodeSql.hashCode());
        result = 31 * result + (driverClass == null ? 0 : driverClass.hashCode());
        result = 31 * result + (dropTable ? 0 : 1);
        result = 31 * result + (dropTableDDL == null ? 0 : dropTableDDL.hashCode());
        result = 31 * result + (insertNodeSql == null ? 0 : insertNodeSql.hashCode());
        result = 31 * result + (jdbcPassword == null ? 0 : jdbcPassword.hashCode());
        result = 31 * result + (jdbcUser == null ? 0 : jdbcUser.hashCode());
        result = 31 * result + (jdbcURL == null ? 0 : jdbcURL.hashCode());
        result = 31 * result + (selectChildFqnsSql == null ? 0 : selectChildFqnsSql.hashCode());
        result = 31 * result + (selectChildNamesSql == null ? 0 : selectChildNamesSql.hashCode());
        result = 31 * result + (selectNodeSql == null ? 0 : selectNodeSql.hashCode());
        result = 31 * result + (table == null ? 0 : table.hashCode());
        result = 31 * result + (updateNodeSql == null ? 0 : updateNodeSql.hashCode());
        result = 31 * result + (updateTableSql == null ? 0 : updateTableSql.hashCode());
        
        return result;
     }     
     
  }
  
  
  1.1      date: 2006/10/26 19:30:20;  author: bstansberry;  state: Exp;JBossCache/src/org/jboss/cache/loader/FileCacheLoaderConfig.java
  
  Index: FileCacheLoaderConfig.java
  ===================================================================
  package org.jboss.cache.loader;
  
  import java.util.Properties;
  
  import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
  
  public class FileCacheLoaderConfig extends IndividualCacheLoaderConfig
  {
     private static final long serialVersionUID = 4626734068542420865L;
     
     private String location;
  
     public FileCacheLoaderConfig() 
     {
        setClassName(FileCacheLoader.class.getName());
     }
     
     /**
      * For use by {@link FileCacheLoader}.
      * 
      * @param base generic config object created by XML parsing.
      */
     FileCacheLoaderConfig(IndividualCacheLoaderConfig base)
     {
        setClassName(FileCacheLoader.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 FileCacheLoaderConfig && equalsExcludingProperties(obj))
        {
           return  safeEquals(location, ((FileCacheLoaderConfig) obj).location);
        }
        return false;
     }
     
     public int hashCode()
     {
        return 31 * hashCodeExcludingProperties() + (location == null ? 0 : location.hashCode());
     }     
     
  }
  
  
  1.1      date: 2006/10/26 19:30:20;  author: bstansberry;  state: Exp;JBossCache/src/org/jboss/cache/loader/TcpDelegatingCacheLoaderConfig.java
  
  Index: TcpDelegatingCacheLoaderConfig.java
  ===================================================================
  package org.jboss.cache.loader;
  
  import java.util.Properties;
  
  import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
  
  public class TcpDelegatingCacheLoaderConfig extends IndividualCacheLoaderConfig
  {
     /**
      * The serialVersionUID
      */
     private static final long serialVersionUID = -3138555335000168505L;
  
     private String host = "localhost";
     private int port = 7500;
  
     public TcpDelegatingCacheLoaderConfig()
     {
        setClassName(TcpDelegatingCacheLoader.class.getName());
     }
  
     /**
      * For use by {@link TcpDelegatingCacheLoader}.
      * 
      * @param base generic config object created by XML parsing.
      */
     TcpDelegatingCacheLoaderConfig(IndividualCacheLoaderConfig base)
     {
        setClassName(TcpDelegatingCacheLoader.class.getName());
        populateFromBaseConfig(base);
     }
  
     /**
      * For use by {@link TcpDelegatingCacheLoader}.
      * 
      * @param host hostname of the delegate
      * @param port port the delegate is listening on
      */
     TcpDelegatingCacheLoaderConfig(String host, int port)
     {
        setClassName(TcpDelegatingCacheLoader.class.getName());
        this.host = host;
        this.port = port;
     }
  
     public String getHost()
     {
        return host;
     }
  
     public void setHost(String host)
     {
        testImmutability("host");
        this.host = host;
     }
  
     public int getPort()
     {
        return port;
     }
  
     public void setPort(int port)
     {
        testImmutability("port");
        this.port = port;
     }
  
     public void setProperties(Properties props)
     {
        super.setProperties(props);
        String s = props.getProperty("host");
        if (s != null && s.length() > 0)
        {
           this.host = s;
        }
        s = props.getProperty("port");
        if (s != null && s.length() > 0)
        {
           this.port = Integer.parseInt(s);
        }
     }
  
     public boolean equals(Object obj)
     {
        if (obj instanceof TcpDelegatingCacheLoaderConfig && equalsExcludingProperties(obj))
        {
           TcpDelegatingCacheLoaderConfig other = (TcpDelegatingCacheLoaderConfig) obj;
  
           return safeEquals(host, other.host)
                   && (port == other.port);
        }
        return false;
     }
  
     public int hashCode()
     {
        int result = hashCodeExcludingProperties();
        result = 31 * result + (host == null ? 0 : host.hashCode());
        result = 31 * result + port;
  
        return result;
     }
  
  
  }
  
  
  1.1      date: 2006/10/26 19:30:20;  author: bstansberry;  state: Exp;JBossCache/src/org/jboss/cache/loader/ClusteredCacheLoaderConfig.java
  
  Index: ClusteredCacheLoaderConfig.java
  ===================================================================
  package org.jboss.cache.loader;
  
  import java.util.Properties;
  
  import org.jboss.cache.config.Dynamic;
  import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
  
  public class ClusteredCacheLoaderConfig extends IndividualCacheLoaderConfig
  {
     /** The serialVersionUID */
     private static final long serialVersionUID = -3425487656984237468L;
     
     @Dynamic
     private long timeout = 10000;
     
     public ClusteredCacheLoaderConfig() 
     {
        setClassName(ClusteredCacheLoader.class.getName());
     }
     
     /**
      * For use by {@link ClusteredCacheLoader}.
      * 
      * @param base generic config object created by XML parsing.
      */
     ClusteredCacheLoaderConfig(IndividualCacheLoaderConfig base)
     {
        setClassName(ClusteredCacheLoader.class.getName());
        populateFromBaseConfig(base);
     }
  
     public long getTimeout()
     {
        return timeout;
     }
  
     public void setTimeout(long timeout)
     {
        testImmutability("timeout");
        this.timeout = timeout;
     }
     
     public void setProperties(Properties props)
     {
        super.setProperties(props);
        try
        {
           timeout = Long.valueOf(props.getProperty("timeout")).longValue();
        }
        catch (Exception e)
        {
           log.info("Using default value for config property 'timeout' - " + timeout);
        }
     }
  
     public boolean equals(Object obj)
     {
        if (obj instanceof ClusteredCacheLoaderConfig && equalsExcludingProperties(obj))
        {
           ClusteredCacheLoaderConfig other = (ClusteredCacheLoaderConfig) obj;
           return (this.timeout == other.timeout);
        }
        return false;
     }
  
     public int hashCode()
     {
        return 31 * hashCodeExcludingProperties() + (int) timeout;
     }
     
  }
  
  
  1.1      date: 2006/10/26 19:30:20;  author: bstansberry;  state: Exp;JBossCache/src/org/jboss/cache/loader/AsynchCacheLoaderConfig.java
  
  Index: AsynchCacheLoaderConfig.java
  ===================================================================
  package org.jboss.cache.loader;
  
  import java.util.Properties;
  
  import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
  
  public class AsynchCacheLoaderConfig extends IndividualCacheLoaderConfig
  {
     /** The serialVersionUID */
     private static final long serialVersionUID = 5038037589485991681L;
     
     private int batchSize = 100;
     private int pollWait = 100;
     private boolean returnOld = true;
     private int queueSize = 0;
     private boolean useAsyncPut = true;
     
     /**
      * Default constructor.
      *
      */
     public AsynchCacheLoaderConfig()
     {
        setClassName(AsyncCacheLoader.class.getName());
     }
     
     /**
      * For use by {@link AsynchCacheLoader}.
      * 
      * @param base generic config object created by XML parsing.
      */
     AsynchCacheLoaderConfig(IndividualCacheLoaderConfig base)
     {         
        setClassName(AsyncCacheLoader.class.getName());
        populateFromBaseConfig(base);
     }
  
     public int getBatchSize()
     {
        return batchSize;
     }
  
     public void setBatchSize(int batchSize)
     {
        testImmutability("batchSize");
        this.batchSize = batchSize;
     }
  
     public int getPollWait()
     {
        return pollWait;
     }
  
     public void setPollWait(int pollWait)
     {
        testImmutability("pollWait");
        this.pollWait = pollWait;
     }
  
     public int getQueueSize()
     {
        return queueSize;
     }
  
     public void setQueueSize(int queueSize)
     {
        testImmutability("queueSize");
        this.queueSize = queueSize;
     }
  
     public boolean getReturnOld()
     {
        return returnOld;
     }
  
     public void setReturnOld(boolean returnOld)
     {
        testImmutability("returnOld");
        this.returnOld = returnOld;
     }
  
     public boolean getUseAsyncPut()
     {
        return useAsyncPut;
     }
  
     public void setUseAsyncPut(boolean useAsyncPut)
     {
        testImmutability("useAsyncPut");
        this.useAsyncPut = useAsyncPut;
     }
  
     public void setProperties(Properties props)
     {
        super.setProperties(props);
        String s;
  
        s = props.getProperty("cache.async.batchSize");
        if (s != null)
        {
           batchSize = Integer.parseInt(s);
        }
        if (batchSize <= 0)
        {
           throw new IllegalArgumentException("Invalid size: " + batchSize);
        }
  
        s = props.getProperty("cache.async.pollWait");
        if (s != null)
        {
           pollWait = Integer.parseInt(s);
        }
  
        s = props.getProperty("cache.async.returnOld");
        if (s != null)
        {
           returnOld = Boolean.valueOf(s).booleanValue();
        }
  
        s = props.getProperty("cache.async.queueSize");
        if (s != null)
        {
           queueSize = Integer.parseInt(s);
        }
  
        s = props.getProperty("cache.async.put");
        if (s != null)
        {
           useAsyncPut = Boolean.valueOf(s).booleanValue();
        }
     }
  
     public boolean equals(Object obj)
     {
        if (obj instanceof AsynchCacheLoaderConfig && equalsExcludingProperties(obj))
        {
           AsynchCacheLoaderConfig other = (AsynchCacheLoaderConfig) obj;
           return (batchSize == other.batchSize)
                    && (pollWait == other.pollWait)
                    && (queueSize == other.queueSize)
                    && (returnOld == other.returnOld)
                    && (useAsyncPut == other.useAsyncPut);
        }
        return false;
     }
  
     public int hashCode()
     {
        int result = hashCodeExcludingProperties();
        result = 31 * result + batchSize;
        result = 31 * result + pollWait;
        result = 31 * result + queueSize;
        result = 31 * result + (returnOld ? 0 : 1);
        result = 31 * result + (useAsyncPut ? 0 : 1);
        return result;
     }
     
     
     
  }
  
  
  1.1      date: 2006/10/26 19:30:20;  author: bstansberry;  state: Exp;JBossCache/src/org/jboss/cache/loader/RmiDelegatingCacheLoaderConfig.java
  
  Index: RmiDelegatingCacheLoaderConfig.java
  ===================================================================
  package org.jboss.cache.loader;
  
  import java.util.Properties;
  
  import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
  
  public class RmiDelegatingCacheLoaderConfig extends IndividualCacheLoaderConfig
  {
     /** The serialVersionUID */
     private static final long serialVersionUID = 4578924632178739084L;
     
     private String host = "localhost";
     private String port = "1098";
     private String bindName;
     
     public RmiDelegatingCacheLoaderConfig()
     {
        setClassName(RmiDelegatingCacheLoader.class.getName());
     }
     
     /**
      * For use by {@link RmiDelegatingCacheLoader}.
      * 
      * @param base generic config object created by XML parsing.
      */
     RmiDelegatingCacheLoaderConfig(IndividualCacheLoaderConfig base)
     {
        setClassName(RmiDelegatingCacheLoader.class.getName());
        populateFromBaseConfig(base);
     }
  
     public String getBindName()
     {
        return bindName;
     }
  
     public void setBindName(String bindName)
     {
        testImmutability("bindName");
        this.bindName = bindName;
     }
  
     public String getHost()
     {
        return host;
     }
  
     public void setHost(String host)
     {
        testImmutability("host");
        this.host = host;
     }
  
     public String getPort()
     {
        return port;
     }
  
     public void setPort(String port)
     {
        testImmutability("port");
        this.port = port;
     }
  
     public void setProperties(Properties props)
     {
        super.setProperties(props);
        String s = props.getProperty("host");
        if (s != null && s.length() > 0)
        {
           this.host = s;
        }
        s = props.getProperty("port");
        if (s != null && s.length() > 00)
        {
           this.port = s;
        }
        this.bindName = props.getProperty("bindName");
     }
  
     public boolean equals(Object obj)
     {
        if (obj instanceof RmiDelegatingCacheLoaderConfig && equalsExcludingProperties(obj))
        {
           RmiDelegatingCacheLoaderConfig other = (RmiDelegatingCacheLoaderConfig) obj;
           
           return safeEquals(host, other.host)
                    && safeEquals(port, other.port)
                    && safeEquals(bindName, other.bindName);            
        }
        return false;
     }
  
     public int hashCode()
     {
        int result = hashCodeExcludingProperties();
        result = 31 * result + (host == null ? 0 : host.hashCode());
        result = 31 * result + (port == null ? 0 : port.hashCode());
        result = 31 * result + (bindName == null ? 0 : bindName.hashCode());
        
        return result;
     }
     
     
  }
  
  
  1.1      date: 2006/10/26 19:30:20;  author: bstansberry;  state: Exp;JBossCache/src/org/jboss/cache/loader/RpcDelegatingCacheLoaderConfig.java
  
  Index: RpcDelegatingCacheLoaderConfig.java
  ===================================================================
  package org.jboss.cache.loader;
  
  import java.util.Properties;
  
  import org.jboss.cache.config.Dynamic;
  import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
  
  public class RpcDelegatingCacheLoaderConfig extends IndividualCacheLoaderConfig
  {
     /** The serialVersionUID */
     private static final long serialVersionUID = -3425487656984237468L;
     
     @Dynamic
     private int timeout = 5000;
     
     public RpcDelegatingCacheLoaderConfig() 
     {
        setClassName(RpcDelegatingCacheLoader.class.getName());
     }
     
     /**
      * For use by {@link RpcDelegatingCacheLoader}.
      * 
      * @param base generic config object created by XML parsing.
      */
     RpcDelegatingCacheLoaderConfig(IndividualCacheLoaderConfig base)
     {
        setClassName(RpcDelegatingCacheLoader.class.getName());
        populateFromBaseConfig(base);
     }
  
     public int getTimeout()
     {
        return timeout;
     }
  
     public void setTimeout(int timeout)
     {
        testImmutability("timeout");
        this.timeout = timeout;
     }
     
     public void setProperties(Properties props)
     {
        if (props == null) return;
        
        super.setProperties(props);
        String t = props.getProperty("timeout");
        if (t != null && t.length() > 0)
           this.timeout = Integer.parseInt(t);
     }
  
     public boolean equals(Object obj)
     {
        if (obj instanceof RpcDelegatingCacheLoaderConfig && equalsExcludingProperties(obj))
        {
           RpcDelegatingCacheLoaderConfig other = (RpcDelegatingCacheLoaderConfig) obj;
           return (this.timeout == other.timeout);
        }
        return false;
     }
  
     public int hashCode()
     {
        return 31 * hashCodeExcludingProperties() + (int) timeout;
     }
     
  }
  
  



More information about the jboss-cvs-commits mailing list