[jbosscache-commits] JBoss Cache SVN: r7053 - in core/trunk/src: main/java/org/jboss/cache/config and 4 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Nov 3 09:28:51 EST 2008


Author: manik.surtani at jboss.com
Date: 2008-11-03 09:28:51 -0500 (Mon, 03 Nov 2008)
New Revision: 7053

Added:
   core/trunk/src/main/java/org/jboss/cache/config/LegacyConfigurationException.java
Modified:
   core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java
   core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
   core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java
Log:
JBCACHE-1425 - CacheJmxWrapper only accepts new 3.x format config elements

Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java	2008-11-02 18:13:25 UTC (rev 7052)
+++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java	2008-11-03 14:28:51 UTC (rev 7053)
@@ -24,6 +24,7 @@
 import org.jboss.cache.annotations.Compat;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.LegacyConfigurationException;
 import org.jboss.cache.config.parsing.XmlConfigurationParser;
 import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
 import org.jboss.cache.factories.ComponentFactory;
@@ -84,7 +85,7 @@
       {
          c = parser.parseFile(configFileName);
       }
-      catch (ConfigurationException e)
+      catch (LegacyConfigurationException e)
       {
          XmlConfigurationParser2x oldParser = new XmlConfigurationParser2x();
          c = oldParser.parseFile(configFileName);

Added: core/trunk/src/main/java/org/jboss/cache/config/LegacyConfigurationException.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/LegacyConfigurationException.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/LegacyConfigurationException.java	2008-11-03 14:28:51 UTC (rev 7053)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.cache.config;
+
+/**
+ * Thrown when a legacy configuration XML element is passed into a modern 3.0 parser
+ *
+ * @author Manik Surtani (<a href="mailto:manik AT jboss DOT org">manik AT jboss DOT org</a>)
+ * @since 3.0
+ */
+public class LegacyConfigurationException extends ConfigurationException
+{
+   public LegacyConfigurationException(Exception e)
+   {
+      super(e);
+   }
+
+   public LegacyConfigurationException(String string)
+   {
+      super(string);
+   }
+
+   public LegacyConfigurationException(String string, String erroneousAttribute)
+   {
+      super(string, erroneousAttribute);
+   }
+
+   public LegacyConfigurationException(String string, Throwable throwable)
+   {
+      super(string, throwable);
+   }
+}

Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java	2008-11-02 18:13:25 UTC (rev 7052)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java	2008-11-03 14:28:51 UTC (rev 7053)
@@ -1,26 +1,27 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.cache.config.parsing;
 
+import org.jboss.cache.config.LegacyConfigurationException;
 import org.jboss.util.StringPropertyReplacer;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
@@ -33,7 +34,6 @@
  */
 public abstract class XmlParserBase
 {
-
    /**
     * @see Integer#parseInt(String)
     */
@@ -99,4 +99,11 @@
       String value = element.getAttribute(attrName);
       return value == null ? null : StringPropertyReplacer.replaceProperties(value);
    }
+
+   protected void assertNotLegacyElement(Element e)
+   {
+      // is this a legacy element?!?
+      String name = e.getNodeName();
+      if ("config".equals(name)) throw new LegacyConfigurationException("Legacy element encountered when using parser " + getClass().getSimpleName());
+   }
 }

Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java	2008-11-02 18:13:25 UTC (rev 7052)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java	2008-11-03 14:28:51 UTC (rev 7053)
@@ -1,24 +1,24 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.cache.config.parsing.element;
 
 import org.jboss.cache.buddyreplication.NextMemberBuddyLocator;
@@ -43,6 +43,8 @@
 {
    public BuddyReplicationConfig parseBuddyElement(Element element)
    {
+      assertNotLegacyElement(element);
+
       BuddyReplicationConfig brc = new BuddyReplicationConfig();
       String enabled = getAttributeValue(element, "enabled");
       brc.setEnabled(getBoolean(enabled));

Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java	2008-11-02 18:13:25 UTC (rev 7052)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java	2008-11-03 14:28:51 UTC (rev 7053)
@@ -51,7 +51,10 @@
 {
    public EvictionConfig parseEvictionElement(Element evictionElement)
    {
+      assertNotLegacyElement(evictionElement);
+      
       EvictionConfig evictionConfig = new EvictionConfig();
+
       String wakeUpInterval = getAttributeValue(evictionElement, "wakeUpInterval");
       if (existsAttribute(wakeUpInterval))
       {

Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java	2008-11-02 18:13:25 UTC (rev 7052)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java	2008-11-03 14:28:51 UTC (rev 7053)
@@ -1,24 +1,24 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.cache.config.parsing.element;
 
 import org.jboss.cache.config.CacheLoaderConfig;
@@ -44,6 +44,8 @@
 {
    public CacheLoaderConfig parseLoadersElement(Element element)
    {
+      assertNotLegacyElement(element);
+      
       CacheLoaderConfig cacheLoaderConfig = new CacheLoaderConfig();
       String passivation = getAttributeValue(element, "passivation");
       if (existsAttribute(passivation)) cacheLoaderConfig.setPassivation(getBoolean(passivation));

Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java	2008-11-02 18:13:25 UTC (rev 7052)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java	2008-11-03 14:28:51 UTC (rev 7053)
@@ -34,8 +34,10 @@
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.ConfigurationException;
 import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.LegacyConfigurationException;
 import org.jboss.cache.config.RuntimeConfig;
 import org.jboss.cache.config.parsing.JGroupsStackParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
 import org.jboss.cache.config.parsing.element.BuddyElementParser;
 import org.jboss.cache.config.parsing.element.EvictionElementParser;
 import org.jboss.cache.config.parsing.element.LoadersElementParser;
@@ -392,7 +394,14 @@
       BuddyReplicationConfig brc = null;
       if (config != null)
       {
-         brc = buddyElementParser.parseBuddyElement(config);
+         try
+         {
+            brc = buddyElementParser.parseBuddyElement(config);
+         }
+         catch (LegacyConfigurationException lce)
+         {
+            brc = XmlConfigurationParser2x.parseBuddyReplicationConfig(config);
+         }
       }
       getConfiguration().setBuddyReplicationConfig(brc);
       this.buddyReplConfig = config;
@@ -403,7 +412,14 @@
       CacheLoaderConfig clc = null;
       if (cacheLoaderConfig != null)
       {
-         clc = loadersElementParser.parseLoadersElement(cacheLoaderConfig);
+         try
+         {
+            clc = loadersElementParser.parseLoadersElement(cacheLoaderConfig);
+         }
+         catch (LegacyConfigurationException lce)
+         {
+            clc = XmlConfigurationParser2x.parseCacheLoaderConfig(cacheLoaderConfig);
+         }
       }
       getConfiguration().setCacheLoaderConfig(clc);
       this.cacheLoaderConfig = cacheLoaderConfig;
@@ -453,7 +469,14 @@
       EvictionConfig ec = null;
       if (config != null)
       {
-         ec = evictionElementParser.parseEvictionElement(config);
+         try
+         {
+            ec = evictionElementParser.parseEvictionElement(config);
+         }
+         catch (LegacyConfigurationException ce)
+         {
+            ec = XmlConfigurationParser2x.parseEvictionConfig(config);
+         }
       }
       getConfiguration().setEvictionConfig(ec);
       this.evictionConfig = config;

Modified: core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java	2008-11-02 18:13:25 UTC (rev 7052)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/deprecated/LegacyConfigurationTest.java	2008-11-03 14:28:51 UTC (rev 7053)
@@ -34,7 +34,12 @@
 import org.jboss.cache.config.EvictionRegionConfig;
 import org.jboss.cache.config.RuntimeConfig;
 import org.jboss.cache.config.parsing.XmlConfigHelper;
-import org.jboss.cache.eviction.*;
+import org.jboss.cache.eviction.FIFOAlgorithm;
+import org.jboss.cache.eviction.FIFOAlgorithmConfig;
+import org.jboss.cache.eviction.LRUAlgorithm;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
+import org.jboss.cache.eviction.MRUAlgorithm;
+import org.jboss.cache.eviction.MRUAlgorithmConfig;
 import org.jboss.cache.jmx.CacheJmxWrapper;
 import org.jboss.cache.jmx.CacheJmxWrapperMBean;
 import org.jboss.cache.loader.FileCacheLoader;
@@ -68,20 +73,30 @@
 @Test(groups = "functional", sequential = true)
 public class LegacyConfigurationTest extends CacheJmxWrapperTestBase
 {
-   @SuppressWarnings({"deprecation", "unchecked"})
    public void testLocalCache() throws Exception
    {
+      doTest(false);
+   }
+
+   public void testLocalCacheWithLegacyXML() throws Exception
+   {
+      doTest(true);
+   }
+
+   @SuppressWarnings({"deprecation", "unchecked"})
+   private void doTest(boolean legacy) throws Exception
+   {
       CacheJmxWrapperMBean<String, String> wrapper = new CacheJmxWrapper();
       registerWrapper(wrapper);
 
       wrapper = (CacheJmxWrapperMBean<String, String>) MBeanServerInvocationHandler.newProxyInstance(mBeanServer, mBeanName, CacheJmxWrapperMBean.class, false);
 
-      wrapper.setBuddyReplicationConfig(getBuddyReplicationConfig());
-      wrapper.setCacheLoaderConfig(getCacheLoaderConfig());
+      wrapper.setBuddyReplicationConfig(getBuddyReplicationConfig(legacy));
+      wrapper.setCacheLoaderConfig(getCacheLoaderConfig(legacy));
       wrapper.setCacheMode("REPL_SYNC");
       wrapper.setClusterName("LocalTest");
       wrapper.setClusterConfig(getClusterConfig());
-      wrapper.setEvictionPolicyConfig(getEvictionPolicyConfig());
+      wrapper.setEvictionPolicyConfig(getEvictionPolicyConfig(legacy));
       wrapper.setFetchInMemoryState(false);
       wrapper.setInitialStateRetrievalTimeout(100);
       wrapper.setInactiveOnStartup(true);
@@ -140,7 +155,7 @@
 
       assertEquals("ClusterConfig", getClusterConfig().toString(), wrapper.getClusterConfig().toString());
 
-      assertEquals("BuddyReplicationConfig", getBuddyReplicationConfig().toString(), wrapper.getBuddyReplicationConfig().toString());
+      assertEquals("BuddyReplicationConfig", getBuddyReplicationConfig(legacy).toString(), wrapper.getBuddyReplicationConfig().toString());
       BuddyReplicationConfig brc = c.getBuddyReplicationConfig();
       assertEquals("BR enabled", true, brc.isEnabled());
       assertEquals("BR auto grav", false, brc.isAutoDataGravitation());
@@ -153,7 +168,7 @@
       Properties props = blc.getBuddyLocatorProperties();
       assertEquals("BR props", "2", props.get("numBuddies"));
 
-      assertEquals("CacheLoaderConfig", getCacheLoaderConfig().toString(), wrapper.getCacheLoaderConfig().toString());
+      assertEquals("CacheLoaderConfig", getCacheLoaderConfig(legacy).toString(), wrapper.getCacheLoaderConfig().toString());
       CacheLoaderConfig clc = c.getCacheLoaderConfig();
       assertEquals("CL passivation", false, clc.isPassivation());
       assertEquals("CL passivation", true, clc.isShared());
@@ -176,7 +191,7 @@
       assertEquals("CL1 singleton", false, iclc.getSingletonStoreConfig().isSingletonStoreEnabled());
       assertEquals("CL1 singleton class", SingletonStoreCacheLoader.class.getName(), iclc.getSingletonStoreConfig().getSingletonStoreClass());
 
-      assertEquals("EvictionPolicyConfig", getEvictionPolicyConfig().toString(), wrapper.getEvictionPolicyConfig().toString());
+      assertEquals("EvictionPolicyConfig", getEvictionPolicyConfig(legacy).toString(), wrapper.getEvictionPolicyConfig().toString());
       EvictionConfig ec = c.getEvictionConfig();
       assertEquals("EC queue size", 1000, ec.getDefaultEvictionRegionConfig().getEventQueueSize());
       assertEquals("EC wakeup", 5000, ec.getWakeupInterval());
@@ -199,8 +214,8 @@
       assertEquals("ERC3 queue size", 1000, erc.getEventQueueSize());
       LRUAlgorithmConfig lru = (LRUAlgorithmConfig) erc.getEvictionAlgorithmConfig();
       assertEquals("EPC3 maxnodes", 10000, lru.getMaxNodes());
-      assertEquals("EPC3 maxage", 10, lru.getMaxAge());
-      assertEquals("EPC3 ttl", 8, lru.getTimeToLive());
+      assertEquals("EPC3 maxage", 10000, lru.getMaxAge());
+      assertEquals("EPC3 ttl", 8000, lru.getTimeToLive());
 
    }
 
@@ -256,10 +271,27 @@
             
    }
 
-   protected static Element getBuddyReplicationConfig() throws Exception
+   protected static Element getBuddyReplicationConfig(boolean legacy) throws Exception
    {
-
-      String xmlStr =
+      if (legacy)
+      {
+         String xmlStr = "<config>\n" +
+               "      <buddyReplicationEnabled>true</buddyReplicationEnabled>\n" +
+               "      <buddyLocatorClass>org.jboss.cache.buddyreplication.TestBuddyLocator</buddyLocatorClass>\n" +
+               "      <buddyLocatorProperties>\n" +
+               "         numBuddies = 2\n" +
+               "      </buddyLocatorProperties>\n" +
+               "      <buddyPoolName>testpool</buddyPoolName>\n" +
+               "      <buddyCommunicationTimeout>600000</buddyCommunicationTimeout>\n" +
+               "      <dataGravitationRemoveOnFind>false</dataGravitationRemoveOnFind>\n" +
+               "      <dataGravitationSearchBackupTrees>false</dataGravitationSearchBackupTrees>\n" +
+               "      <autoDataGravitation>false</autoDataGravitation>\n" +
+               "   </config>";
+         return XmlConfigHelper.stringToElement(xmlStr);
+      }
+      else
+      {
+         String xmlStr =
             "      <buddy enabled=\"true\" poolName=\"testpool\" communicationTimeout=\"600000\">\n" +
                   "         <dataGravitation auto=\"false\" removeOnFind=\"false\" searchBackupTrees=\"false\"/>\n" +
                   "         <locator class=\"org.jboss.cache.buddyreplication.TestBuddyLocator\">\n" +
@@ -268,56 +300,122 @@
                   "            </properties>\n" +
                   "         </locator>\n" +
                   "      </buddy>";
-      return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
+         return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
+      }
    }
 
-   protected static Element getCacheLoaderConfig() throws Exception
+   protected static Element getCacheLoaderConfig(boolean legacy) throws Exception
    {
-      String xmlStr =
-            "   <loaders passivation=\"false\" shared=\"true\">\n" +
-                  "      <preload>\n" +
-                  "         <node fqn=\"/foo\"/>\n" +
-                  "      </preload>\n" +
-                  "      <loader class=\"org.jboss.cache.loader.FileCacheLoader\" async=\"false\" fetchPersistentState=\"true\"\n" +
-                  "                   ignoreModifications=\"true\" purgeOnStartup=\"true\">\n" +
-                  "         <properties>\n" +
-                  "             location=/tmp\n " +
-                  "         </properties>\n" +
-                  "         <singletonStore enabled=\"true\" /> \n" +
-                  "      </loader>\n" +
-                  "      <loader class=\"org.jboss.cache.loader.jdbm.JdbmCacheLoader\" async=\"true\" fetchPersistentState=\"false\"\n" +
-                  "                   ignoreModifications=\"false\" purgeOnStartup=\"false\">\n" +
-                  "         <properties>\n" +
-                  "             location=/home/bstansberry\n" +
-                  "         </properties>\n" +
-                  "         <singletonStore enabled=\"false\" /> \n" +
-                  "      </loader>\n" +
-                  "   </loaders>";
-      return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
+      if (legacy)
+      {
+         String xmlStr = "<config>\n" +
+               "      <passivation>false</passivation>\n" +
+               "      <preload>/foo</preload>\n" +
+               "      <shared>true</shared>\n" +
+               "      <cacheloader>\n" +
+               "         <class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
+               "         <properties>\n" +
+               "            location=/tmp\n " +
+               "         </properties>\n" +
+               "         <async>false</async>\n" +
+               "         <fetchPersistentState>true</fetchPersistentState>\n" +
+               "         <ignoreModifications>true</ignoreModifications>\n" +
+               "         <purgeOnStartup>true</purgeOnStartup>\n" +
+               "         <singletonStore>\n" +
+               "            <enabled>true</enabled>\n" +
+               "         </singletonStore>\n" +
+               "      </cacheloader> \n " +
+               "      <cacheloader>\n" +
+               "         <class>org.jboss.cache.loader.jdbm.JdbmCacheLoader</class>\n" +
+               "         <properties>\n" +
+               "            location=/home/bstansberry\n " +
+               "         </properties>\n" +
+               "         <async>true</async>\n" +
+               "         <fetchPersistentState>false</fetchPersistentState>\n" +
+               "         <ignoreModifications>false</ignoreModifications>\n" +
+               "         <purgeOnStartup>false</purgeOnStartup>\n" +
+               "         <singletonStore>\n" +
+               "            <enabled>false</enabled>\n" +
+               "         </singletonStore>\n" +
+               "      </cacheloader>\n" +
+               "   </config>";
+         return XmlConfigHelper.stringToElement(xmlStr);
+
+      }
+      else
+      {
+         String xmlStr =
+               "   <loaders passivation=\"false\" shared=\"true\">\n" +
+                     "      <preload>\n" +
+                     "         <node fqn=\"/foo\"/>\n" +
+                     "      </preload>\n" +
+                     "      <loader class=\"org.jboss.cache.loader.FileCacheLoader\" async=\"false\" fetchPersistentState=\"true\"\n" +
+                     "                   ignoreModifications=\"true\" purgeOnStartup=\"true\">\n" +
+                     "         <properties>\n" +
+                     "             location=/tmp\n " +
+                     "         </properties>\n" +
+                     "         <singletonStore enabled=\"true\" /> \n" +
+                     "      </loader>\n" +
+                     "      <loader class=\"org.jboss.cache.loader.jdbm.JdbmCacheLoader\" async=\"true\" fetchPersistentState=\"false\"\n" +
+                     "                   ignoreModifications=\"false\" purgeOnStartup=\"false\">\n" +
+                     "         <properties>\n" +
+                     "             location=/home/bstansberry\n" +
+                     "         </properties>\n" +
+                     "         <singletonStore enabled=\"false\" /> \n" +
+                     "      </loader>\n" +
+                     "   </loaders>";
+         return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
+      }
    }
 
-   protected static Element getEvictionPolicyConfig() throws Exception
+   protected static Element getEvictionPolicyConfig(boolean legacy) throws Exception
    {
-
-      String xmlStr =
-            "   <eviction wakeUpInterval=\"5000\">\n" +
-                  "      <default eventQueueSize=\"1000\" algorithmClass=\"org.jboss.cache.eviction.LRUAlgorithm\">\n" +
-                  "         <attribute name=\"maxNodes\">5000</attribute>\n" +
-                  "         <attribute name=\"timeToLive\">1000000</attribute>\n" +
-                  "      </default>\n" +
-                  "<region name=\"/org/jboss/data\" algorithmClass=\"org.jboss.cache.eviction.FIFOAlgorithm\">\n" +
-                  "   <attribute name=\"maxNodes\">5000</attribute>\n" +
-                  "</region>\n" +
-                  "<region name=\"/test/\" algorithmClass=\"org.jboss.cache.eviction.MRUAlgorithm\">\n" +
-                  "   <attribute name=\"maxNodes\">10000</attribute>\n" +
-                  "</region>\n" +
-                  "<region name=\"/maxAgeTest/\">\n" +
-                  "   <attribute name=\"maxNodes\">10000</attribute>\n" +
-                  "   <attribute name=\"timeToLive\">8</attribute>\n" +
-                  "   <attribute name=\"maxAge\">10</attribute>\n" +
-                  "</region>\n" +
-                  "   </eviction>";
-      return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
+      if (legacy)
+      {
+         String xmlStr = "   <config>\n" +
+               "            <attribute name=\"wakeUpIntervalSeconds\">5</attribute>\n" +
+               "            <attribute name=\"eventQueueSize\">1000</attribute>\n" +
+               "            <attribute name=\"policyClass\">org.jboss.cache.eviction.LRUPolicy</attribute>\n" +
+               "            <region name=\"/_default_\">\n" +
+               "               <attribute name=\"maxNodes\">5000</attribute>\n" +
+               "               <attribute name=\"timeToLiveSeconds\">1000</attribute>\n" +
+               "            </region>\n" +
+               "            <region name=\"/org/jboss/data\" policyClass=\"org.jboss.cache.eviction.FIFOPolicy\">\n" +
+               "               <attribute name=\"maxNodes\">5000</attribute>\n" +
+               "            </region>\n" +
+               "            <region name=\"/test\" policyClass=\"org.jboss.cache.eviction.MRUPolicy\">\n" +
+               "               <attribute name=\"maxNodes\">10000</attribute>\n" +
+               "            </region>\n" +
+               "            <region name=\"/maxAgeTest\">\n" +
+               "               <attribute name=\"maxNodes\">10000</attribute>\n" +
+               "               <attribute name=\"timeToLiveSeconds\">8</attribute>\n" +
+               "               <attribute name=\"maxAgeSeconds\">10</attribute>\n" +
+               "            </region>\n" +
+               "         </config>";
+         return XmlConfigHelper.stringToElement(xmlStr);
+      }
+      else
+      {
+         String xmlStr =
+               "   <eviction wakeUpInterval=\"5000\">\n" +
+                     "      <default eventQueueSize=\"1000\" algorithmClass=\"org.jboss.cache.eviction.LRUAlgorithm\">\n" +
+                     "         <property name=\"maxNodes\" value=\"5000\"></property>\n" +
+                     "         <property name=\"timeToLive\" value=\"1000000\"></property>\n" +
+                     "      </default>\n" +
+                     "<region name=\"/org/jboss/data\" algorithmClass=\"org.jboss.cache.eviction.FIFOAlgorithm\">\n" +
+                     "   <property name=\"maxNodes\" value=\"5000\"></property>\n" +
+                     "</region>\n" +
+                     "<region name=\"/test/\" algorithmClass=\"org.jboss.cache.eviction.MRUAlgorithm\">\n" +
+                     "   <property name=\"maxNodes\" value=\"10000\"></property>\n" +
+                     "</region>\n" +
+                     "<region name=\"/maxAgeTest/\">\n" +
+                     "   <property name=\"maxNodes\" value=\"10000\"></property>\n" +
+                     "   <property name=\"timeToLive\" value=\"8000\"></property>\n" +
+                     "   <property name=\"maxAge\" value=\"10000\"></property>\n" +
+                     "</region>\n" +
+                     "   </eviction>";
+         return XmlConfigHelper.stringToElementInCoreNS(xmlStr);
+      }
    }
 
    protected static Element getClusterConfig() throws Exception




More information about the jbosscache-commits mailing list