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

Brian Stansberry brian.stansberry at jboss.com
Thu Nov 9 23:40:28 EST 2006


  User: bstansberry
  Date: 06/11/09 23:40:28

  Modified:    src/org/jboss/cache/config  Configuration.java
  Log:
  Support direct injection of TransactionManager and JChannelFactory
  Do the JGroups ClusterConfig parsing in XmlConfigurationParser
  
  Revision  Changes    Path
  1.25      +49 -57    JBossCache/src/org/jboss/cache/config/Configuration.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Configuration.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/config/Configuration.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -b -r1.24 -r1.25
  --- Configuration.java	10 Nov 2006 02:48:45 -0000	1.24
  +++ Configuration.java	10 Nov 2006 04:40:28 -0000	1.25
  @@ -6,13 +6,15 @@
    */
   package org.jboss.cache.config;
   
  +import java.io.IOException;
  +import java.io.ObjectInputStream;
  +import java.io.ObjectOutputStream;
  +
   import org.jboss.cache.TreeCache;
   import org.jboss.cache.Version;
  +import org.jboss.cache.factories.XmlConfigurationParser;
   import org.jboss.cache.lock.IsolationLevel;
  -import org.w3c.dom.Attr;
   import org.w3c.dom.Element;
  -import org.w3c.dom.NamedNodeMap;
  -import org.w3c.dom.NodeList;
   
   /**
    * Encapsulates the configuration of a Cache.
  @@ -82,6 +84,7 @@
      private NodeLockingScheme nodeLockingScheme = NodeLockingScheme.PESSIMISTIC;
      private String muxServiceName = null;
      private String muxStackName = "fc-fast-minimalthreads";
  +   private transient RuntimeConfig runtimeConfig;
   
      // ------------------------------------------------------------------------------------------------------------
      //   CONSTRUCTORS
  @@ -113,7 +116,7 @@
       */
      public void setClusterConfig(Element config)
      {
  -      setClusterConfig(parseClusterConfigXml(config));
  +      setClusterConfig(XmlConfigurationParser.parseClusterConfigXml(config));
      }
   
      public void setClusterName(String clusterName)
  @@ -502,63 +505,25 @@
         return serviceName;
      }
   
  -   // ------------------------------------------------------------------------------------------------------------
  -   //   HELPERS
  -   // ------------------------------------------------------------------------------------------------------------
  -
   
  -   /**
  -    * Parses the cluster config which is used to start a JGroups channel
  -    *
  -    * @param config
  -    */
  -   String parseClusterConfigXml(Element config)
  -   {
  -      StringBuffer buffer = new StringBuffer();
  -      NodeList stack = config.getChildNodes();
  -      int length = stack.getLength();
  -
  -      for (int s = 0; s < length; s++)
  -      {
  -         org.w3c.dom.Node node = stack.item(s);
  -         if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
  +   public RuntimeConfig getRuntimeConfig()
            {
  -            continue;
  +      return runtimeConfig;
            }
   
  -         Element tag = (Element) node;
  -         String protocol = tag.getTagName();
  -         buffer.append(protocol);
  -         NamedNodeMap attrs = tag.getAttributes();
  -         int attrLength = attrs.getLength();
  -         if (attrLength > 0)
  +   public void setRuntimeConfig(RuntimeConfig runtimeConfig)
            {
  -            buffer.append('(');
  -         }
  -         for (int a = 0; a < attrLength; a++)
  -         {
  -            Attr attr = (Attr) attrs.item(a);
  -            String name = attr.getName();
  -            String value = attr.getValue();
  -            buffer.append(name);
  -            buffer.append('=');
  -            buffer.append(value);
  -            if (a < attrLength - 1)
  -            {
  -               buffer.append(';');
  -            }
  -         }
  -         if (attrLength > 0)
  -         {
  -            buffer.append(')');
  -         }
  -         buffer.append(':');
  -      }
  -      // Remove the trailing ':'
  -      buffer.setLength(buffer.length() - 1);
  -      return buffer.toString();
  +      this.runtimeConfig = runtimeConfig;
      }
   
  +   
  +
  +   // ------------------------------------------------------------------------------------------------------------
  +   //   HELPERS
  +   // ------------------------------------------------------------------------------------------------------------
  +
  +   
  +
      // ------------------------------------------------------------------------------------------------------------
      //   OVERRIDDEN METHODS
      // ------------------------------------------------------------------------------------------------------------
  @@ -611,6 +576,8 @@
         {
            return false;
         }
  +      if (!safeEquals(runtimeConfig, that.runtimeConfig))
  +         return false;
   
         return true;
      }
  @@ -643,13 +610,38 @@
         result = 29 * result + (nodeLockingScheme != null ? nodeLockingScheme.hashCode() : 0);
         result = 29 * result + (muxServiceName != null ? muxServiceName.hashCode() : 0);
         result = 29 * result + (muxStackName != null ? muxStackName.hashCode() : 0);
  +      result = 29 * result + (runtimeConfig != null ? runtimeConfig.hashCode() : 0);
         return result;
      }
   
      public Configuration clone() throws CloneNotSupportedException
      {
         Configuration c = (Configuration) super.clone();
  -      c.setTreeCache(null);
  +      if (buddyReplicationConfig != null)
  +      {
  +         c.setBuddyReplicationConfig((BuddyReplicationConfig) buddyReplicationConfig.clone());
  +      }
  +      if (evictionConfig != null)
  +      {
  +         c.setEvictionConfig((EvictionConfig) evictionConfig.clone());
  +      }
  +      if (cacheLoaderConfig != null)
  +      {
  +         c.setCacheLoaderConfig((CacheLoaderConfig) cacheLoaderConfig.clone());
  +      }
         return c;
      }
  +
  +   private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
  +   {
  +      in.defaultReadObject();
  +      runtimeConfig = new RuntimeConfig();
  +   }
  +
  +   private void writeObject(ObjectOutputStream out) throws IOException
  +   {
  +      out.defaultWriteObject();      
  +   }
  +   
  +   
   }
  
  
  



More information about the jboss-cvs-commits mailing list