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

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Jun 17 11:36:32 EDT 2008


Author: mircea.markus
Date: 2008-06-17 11:36:31 -0400 (Tue, 17 Jun 2008)
New Revision: 5995

Added:
   core/trunk/src/main/java/org/jboss/cache/config/CustomInterceptorConfig.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/
   core/trunk/src/main/java/org/jboss/cache/config/parsing/BuddyReplicationElementParser.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheLoadersElementParser.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/EvictionElementParser.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/ParsedAttributes.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParserOld.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java
   core/trunk/src/test/java/org/jboss/cache/config/XmlConfigurationParserTest.java
   core/trunk/src/test/resources/META-INF/conf-test/all-elements-file-3.x.xml
   core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-2.x.xml
   core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-3.x.xml
Removed:
   core/trunk/src/main/java/org/jboss/cache/factories/CacheConfigsXmlParser.java
   core/trunk/src/main/java/org/jboss/cache/factories/XmlConfigurationParser.java
   core/trunk/src/main/java/org/jboss/cache/xml/XmlHelper.java
Modified:
   core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
   core/trunk/src/main/java/org/jboss/cache/RegionManager.java
   core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
   core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
   core/trunk/src/main/java/org/jboss/cache/config/PluggableConfigurationComponent.java
   core/trunk/src/main/java/org/jboss/cache/config/XmlParsingConfigurationRegistry.java
   core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBase.java
   core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.java
   core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java
   core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java
   core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
   core/trunk/src/test/java/org/jboss/cache/CacheFactoryTest.java
   core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
   core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java
   core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTest.java
   core/trunk/src/test/java/org/jboss/cache/config/StringPropertyReplacementTest.java
   core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurationTest.java
   core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.java
   core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.java
   core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java
   core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java
   core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java
   core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java
   core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java
   core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java
   core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java
   core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
   core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
   core/trunk/src/test/java/org/jboss/cache/jmx/LegacyConfigurationTest.java
   core/trunk/src/test/java/org/jboss/cache/jmx/NotificationTest.java
   core/trunk/src/test/java/org/jboss/cache/loader/AbstractCacheLoaderTestBase.java
   core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java
   core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java
   core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java
   core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java
   core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java
   core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java
   core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java
   core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
   core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java
   core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java
   core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java
   core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java
   core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
   core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java
   core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java
   core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java
   core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java
   core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentTransactionalTest.java
Log:
first draft for new configuration file

Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -8,9 +8,9 @@
 
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.factories.ComponentFactory;
 import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.factories.XmlConfigurationParser;
 import org.jboss.cache.invocation.CacheInvocationDelegate;
 
 import java.io.InputStream;
@@ -62,7 +62,7 @@
 
    public Cache<K, V> createCache(String configFileName, boolean start) throws ConfigurationException
    {
-      XmlConfigurationParser parser = new XmlConfigurationParser();
+      XmlConfigurationParserOld parser = new XmlConfigurationParserOld();
       Configuration c = parser.parseFile(configFileName);
       return createCache(c, start);
    }
@@ -141,14 +141,14 @@
 
    public Cache<K, V> createCache(InputStream is) throws ConfigurationException
    {
-      XmlConfigurationParser parser = new XmlConfigurationParser();
+      XmlConfigurationParserOld parser = new XmlConfigurationParserOld();
       Configuration c = parser.parseStream(is);
       return createCache(c);
    }
 
    public Cache<K, V> createCache(InputStream is, boolean start) throws ConfigurationException
    {
-      XmlConfigurationParser parser = new XmlConfigurationParser();
+      XmlConfigurationParserOld parser = new XmlConfigurationParserOld();
       Configuration c = parser.parseStream(is);
       return createCache(c, start);
    }

Modified: core/trunk/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManager.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManager.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -798,21 +798,7 @@
       // Try to establish a default region if there isn't one already
       boolean needDefault;
       List<EvictionRegionConfig> ercs = evictionConfig.getEvictionRegionConfigs();
-
-      // APPROACH 1: Scan for a default region, try to add if not there.
-      // This will try to add the region if it is missing but seems to break 
-      // some unit tests that configure one or more non-default regions and
-      // no default region (e.g. the eviction.minttl tests). So, doing this 
-      // seems to add a new semantic. For now comment this out and use APPROACH 2
-//      for (EvictionRegionConfig erc : ercs)
-//      {
-//         if (DEFAULT_REGION.equals(erc.getRegionFqn()))
-//         {
-//            needDefault = false;
-//            break;
-//         }
-//      }
-      // APPROACH 2: Only add a default region if there are no regions. This is
+      // Only add a default region if there are no regions. This is
       // contrary to the idea that there *must* be a default region, but some
       // unit tests fail w/ APPROACH 1, so for now we go with this approach.
       needDefault = ercs.size() == 0;
@@ -856,7 +842,7 @@
     */
    public void startEvictionThread()
    {
-      evictionTimerTask.init(evictionConfig.getWakeupIntervalSeconds());
+      evictionTimerTask.init(evictionConfig.getWakeupInterval());
    }
 
    /**

Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/Configuration.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/main/java/org/jboss/cache/config/Configuration.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -7,7 +7,7 @@
 package org.jboss.cache.config;
 
 import org.jboss.cache.Version;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.factories.annotations.NonVolatile;
 import org.jboss.cache.lock.IsolationLevel;
 import org.jboss.cache.marshall.Marshaller;
@@ -15,6 +15,8 @@
 
 import java.net.URL;
 import java.util.Locale;
+import java.util.List;
+import java.util.Collections;
 
 /**
  * Encapsulates the configuration of a Cache.
@@ -194,6 +196,7 @@
    private boolean useLazyDeserialization = false;
    private int objectInputStreamPoolSize = 50;
    private int objectOutputStreamPoolSize = 50;
+   private List<CustomInterceptorConfig> customInterceptors = Collections.EMPTY_LIST;
 
    // ------------------------------------------------------------------------------------------------------------
    //   SETTERS - MAKE SURE ALL SETTERS PERFORM testImmutability()!!!
@@ -204,7 +207,7 @@
     */
    public void setClusterConfig(Element config)
    {
-      setClusterConfig(XmlConfigurationParser.parseClusterConfigXml(config));
+      setClusterConfig(XmlConfigurationParserOld.parseClusterConfigXml(config));
    }
 
    public void setClusterName(String clusterName)
@@ -319,7 +322,6 @@
     * See the user guide for details on how this is handled.
     * <p/>
     */
-   @Deprecated
    public void setUseRegionBasedMarshalling(boolean useRegionBasedMarshalling)
    {
       testImmutability("useRegionBasedMarshalling");
@@ -875,4 +877,25 @@
       return getBuddyReplicationConfig() != null && getBuddyReplicationConfig().isEnabled() &&
             getCacheMode() != Configuration.CacheMode.LOCAL;
    }
+
+   public String getMuxStackName()
+   {
+      return muxStackName;
+   }
+
+   public void setMuxStackName(String muxStackName)
+   {
+      this.muxStackName = muxStackName;
+   }
+
+   public List<CustomInterceptorConfig> getCustomInterceptors()
+   {
+      return customInterceptors;
+   }
+
+   public void setCustomInterceptors(List<CustomInterceptorConfig> customInterceptors)
+   {
+      testImmutability("customInterceptors");
+      this.customInterceptors = customInterceptors;
+   }
 }

Added: core/trunk/src/main/java/org/jboss/cache/config/CustomInterceptorConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/CustomInterceptorConfig.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/CustomInterceptorConfig.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -0,0 +1,132 @@
+package org.jboss.cache.config;
+
+import net.jcip.annotations.Immutable;
+
+import java.io.Serializable;
+import java.util.Properties;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Holds information about the custom interceptors defined in the configuration file.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 3.0
+ */
+ at Immutable 
+public class CustomInterceptorConfig implements Cloneable, Serializable
+{
+   private String interceptorClass;
+   private boolean isFirst;
+   private boolean isLast;
+   private int index = -1;
+   private String afterClass;
+   private String beforeClass;
+   private Map properties;
+
+   public CustomInterceptorConfig(String interceptorClass, boolean first, boolean last, int index, String afterClass, String beforeClass, Properties props)
+   {
+      this.interceptorClass = interceptorClass;
+      isFirst = first;
+      isLast = last;
+      this.index = index;
+      this.afterClass = afterClass;
+      this.beforeClass = beforeClass;
+      this.properties = Collections.unmodifiableMap(props);
+   }
+
+   public String getInterceptorClass()
+   {
+      return interceptorClass;
+   }
+
+   public boolean isFirst()
+   {
+      return isFirst;
+   }
+
+   public boolean isLast()
+   {
+      return isLast;
+   }
+
+   public int getIndex()
+   {
+      return index;
+   }
+
+   public String getAfterClass()
+   {
+      return afterClass;
+   }
+
+   public String getBeforeClass()
+   {
+      return beforeClass;
+   }
+
+   /**
+    * Returns an unmodifiable map of set properties.
+    */
+   public Map getProperties()
+   {
+      return properties;
+   }
+
+   public String toString()
+   {
+      return "CustomInterceptorConfig{" +
+            "interceptorClass='" + interceptorClass + '\'' +
+            ", isFirst=" + isFirst +
+            ", isLast=" + isLast +
+            ", index=" + index +
+            ", afterClass='" + afterClass + '\'' +
+            ", beforeClass='" + beforeClass + '\'' +
+            '}';
+   }
+
+   public boolean equals(Object o)
+   {
+      if (this == o) return true;
+      if (!(o instanceof CustomInterceptorConfig)) return false;
+
+      CustomInterceptorConfig that = (CustomInterceptorConfig) o;
+
+      if (index != that.index) return false;
+      if (isFirst != that.isFirst) return false;
+      if (isLast != that.isLast) return false;
+      if (afterClass != null ? !afterClass.equals(that.afterClass) : that.afterClass != null) return false;
+      if (beforeClass != null ? !beforeClass.equals(that.beforeClass) : that.beforeClass != null) return false;
+      if (interceptorClass != null ? !interceptorClass.equals(that.interceptorClass) : that.interceptorClass != null)
+         return false;
+      if (properties != null ? !properties.equals(that.properties) : that.properties != null) return false;
+
+      return true;
+   }
+
+   public int hashCode()
+   {
+      int result;
+      result = (interceptorClass != null ? interceptorClass.hashCode() : 0);
+      result = 31 * result + (isFirst ? 1 : 0);
+      result = 31 * result + (isLast ? 1 : 0);
+      result = 31 * result + index;
+      result = 31 * result + (afterClass != null ? afterClass.hashCode() : 0);
+      result = 31 * result + (beforeClass != null ? beforeClass.hashCode() : 0);
+      result = 31 * result + (properties != null ? properties.hashCode() : 0);
+      return result;
+   }
+
+   @Override
+   protected Object clone() throws CloneNotSupportedException
+   {
+      CustomInterceptorConfig dolly = (CustomInterceptorConfig) super.clone();
+      dolly.interceptorClass = interceptorClass;
+      dolly.isFirst = isFirst;
+      dolly.isLast = isLast;
+      dolly.afterClass = afterClass;
+      dolly.beforeClass = beforeClass;
+      dolly.properties = properties;
+      return dolly;
+   }
+}

Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -48,8 +48,13 @@
 
    private String defaultEvictionPolicyClass;
 
+   @Deprecated
    private int wakeupIntervalSeconds = WAKEUP_DEFAULT;
 
+   /** value expressed in millis */
+   @Dynamic
+   private long wakeupInterval = WAKEUP_DEFAULT * 1000;
+
    private int defaultEventQueueSize = EVENT_QUEUE_SIZE_DEFAULT;
 
    // Dynamic to support runtime adds/removes of regions
@@ -158,40 +163,65 @@
       this.evictionRegionConfigs = evictionRegionConfigs;
    }
 
+   /** value expressed in millis */
+   public long getWakeupInterval()
+   {
+      return wakeupInterval;
+   }
+
+   /** value expressed in millis */
+   public void setWakeupInterval(long wakeupInterval)
+   {
+      testImmutability("WakeupInterval");
+      this.wakeupInterval = wakeupInterval;
+   }
+
+   /**
+    * Use {@link #getWakeupIntervalSeconds()}.
+    */
+   @Deprecated
    public int getWakeupIntervalSeconds()
    {
       return wakeupIntervalSeconds;
    }
 
+   /**
+    * Use {@link #setWakeupInterval(long)}.
+    */
+   @Deprecated
    public void setWakeupIntervalSeconds(int wakeupIntervalSeconds)
    {
       testImmutability("wakeupIntervalSeconds");
       this.wakeupIntervalSeconds = wakeupIntervalSeconds;
+      setWakeupInterval(wakeupIntervalSeconds * 1000);
    }
 
-   @Override
-   public boolean equals(Object obj)
+   public boolean equals(Object o)
    {
-      if (this == obj)
-         return true;
+      if (this == o) return true;
+      if (!(o instanceof EvictionConfig)) return false;
 
-      if (obj instanceof EvictionConfig)
-      {
-         EvictionConfig other = (EvictionConfig) obj;
-         return (this.wakeupIntervalSeconds == other.wakeupIntervalSeconds)
-               && Util.safeEquals(this.defaultEvictionPolicyClass, other.defaultEvictionPolicyClass)
-               && Util.safeEquals(this.evictionRegionConfigs, other.evictionRegionConfigs);
-      }
-      return false;
+      EvictionConfig that = (EvictionConfig) o;
+
+      if (defaultEventQueueSize != that.defaultEventQueueSize) return false;
+      if (wakeupInterval != that.wakeupInterval) return false;
+      if (wakeupIntervalSeconds != that.wakeupIntervalSeconds) return false;
+      if (defaultEvictionPolicyClass != null ? !defaultEvictionPolicyClass.equals(that.defaultEvictionPolicyClass) : that.defaultEvictionPolicyClass != null)
+         return false;
+      if (evictionRegionConfigs != null ? !evictionRegionConfigs.equals(that.evictionRegionConfigs) : that.evictionRegionConfigs != null)
+         return false;
+
+      return true;
    }
 
-   @Override
    public int hashCode()
    {
-      int result = 17;
-      result = 37 * result + wakeupIntervalSeconds;
-      result = 37 * result + (defaultEvictionPolicyClass == null ? 0 : defaultEvictionPolicyClass.hashCode());
-      result = 37 * result + (evictionRegionConfigs == null ? 0 : evictionRegionConfigs.hashCode());
+      int result;
+      result = (defaultEvictionPolicyClass != null ? defaultEvictionPolicyClass.hashCode() : 0);
+      result = 31 * result + wakeupIntervalSeconds;
+      result = 31 * result + (int) (wakeupInterval ^ (wakeupInterval >>> 32));
+      result = 31 * result + defaultEventQueueSize;
+      result = 31 * result + (evictionRegionConfigs != null ? evictionRegionConfigs.hashCode() : 0);
       return result;
    }
 

Modified: core/trunk/src/main/java/org/jboss/cache/config/PluggableConfigurationComponent.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/PluggableConfigurationComponent.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/main/java/org/jboss/cache/config/PluggableConfigurationComponent.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -1,6 +1,6 @@
 package org.jboss.cache.config;
 
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -47,7 +47,7 @@
       testImmutability("properties");
       // JBCACHE-531: escape all backslash characters
       // replace any "\" that is not preceded by a backslash with "\\"
-      properties = XmlHelper.escapeBackslashes(properties);
+      properties = XmlConfigHelper.escapeBackslashes(properties);
       ByteArrayInputStream is = new ByteArrayInputStream(properties.trim().getBytes("ISO8859_1"));
       this.properties = new Properties();
       this.properties.load(is);

Modified: core/trunk/src/main/java/org/jboss/cache/config/XmlParsingConfigurationRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/XmlParsingConfigurationRegistry.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/main/java/org/jboss/cache/config/XmlParsingConfigurationRegistry.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -7,7 +7,7 @@
 
 package org.jboss.cache.config;
 
-import org.jboss.cache.factories.CacheConfigsXmlParser;
+import org.jboss.cache.config.parsing.CacheConfigsXmlParser;
 
 import java.util.HashSet;
 import java.util.Hashtable;

Added: core/trunk/src/main/java/org/jboss/cache/config/parsing/BuddyReplicationElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/BuddyReplicationElementParser.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/BuddyReplicationElementParser.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -0,0 +1,56 @@
+package org.jboss.cache.config.parsing;
+
+import org.jboss.cache.config.BuddyReplicationConfig;
+import org.w3c.dom.Element;
+
+import java.util.Properties;
+
+/**
+ * Utility class for parsing 'buddyReplication' element in the .xml configuration file.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 3.0
+ */
+public class BuddyReplicationElementParser extends XmlParserBase
+{
+   public BuddyReplicationConfig parseBuddyReplicationElement(Element element)
+   {
+      BuddyReplicationConfig brc = new BuddyReplicationConfig();
+      String enabled = element.getAttribute("enabled");
+      if (existsAttribute(enabled)) brc.setEnabled(getBoolean(enabled));
+      String buddyPoolName = element.getAttribute("buddyPoolName");
+      if (existsAttribute(buddyPoolName)) brc.setBuddyPoolName(buddyPoolName);
+      String buddyCommunicationTimeout = element.getAttribute("buddyCommunicationTimeout");
+      if (existsAttribute(buddyCommunicationTimeout))
+         brc.setBuddyCommunicationTimeout(getInt(buddyCommunicationTimeout));
+
+      parseDataGravitationElement(getSingleElement("dataGravitation", element), brc);
+      BuddyReplicationConfig.BuddyLocatorConfig blc = parseBuddyLocatorConfig(getSingleElement("buddyLocator", element));
+      brc.setBuddyLocatorConfig(blc);
+      return brc;
+   }
+
+   private BuddyReplicationConfig.BuddyLocatorConfig parseBuddyLocatorConfig(Element element)
+   {
+      if (element == null) return null;
+      BuddyReplicationConfig.BuddyLocatorConfig result = new BuddyReplicationConfig.BuddyLocatorConfig();
+      String buddyLocatorClass = element.getAttribute("class");
+      if (existsAttribute(buddyLocatorClass)) result.setBuddyLocatorClass(buddyLocatorClass);
+      Properties props = null;
+      props = XmlConfigHelper.readPropertiesContents(element, "properties");
+      result.setBuddyLocatorClass(buddyLocatorClass);
+      result.setBuddyLocatorProperties(props);
+      return result;
+   }
+
+   private void parseDataGravitationElement(Element element, BuddyReplicationConfig brc)
+   {
+      if (element == null) return;
+      String auto = element.getAttribute("auto");
+      if (existsAttribute(auto)) brc.setAutoDataGravitation(getBoolean(auto));
+      String removeOnFind = element.getAttribute("removeOnFind");
+      if (existsAttribute(removeOnFind)) brc.setDataGravitationRemoveOnFind(getBoolean(removeOnFind));
+      String searchBackupTrees = element.getAttribute("searchBackupTrees");
+      if (existsAttribute(searchBackupTrees)) brc.setDataGravitationSearchBackupTrees(getBoolean(searchBackupTrees));
+   }
+}

Copied: core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java (from rev 5987, core/trunk/src/main/java/org/jboss/cache/factories/CacheConfigsXmlParser.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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 java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.ConfigurationException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Parser able to parse a series of cache configurations stored in an
+ * XML document with the following structure:
+ * <pre>
+ * <cache-configs>
+ *    <cache-config name="configA">
+ *     ....
+ *    </cache-config>
+ *    <cache-config name="configB">
+ *     ....
+ *    </cache-config>
+ * </cache-configs>
+ * </pre>
+ * <p/>
+ * The '....' represents the normal content of the mbean element in a 
+ * JBC -service.xml config file.
+ * 
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public class CacheConfigsXmlParser 
+ {
+    /** Name of the root element in a cache configs XML document*/
+    public static final String DOCUMENT_ROOT = "cache-configs";
+    /** 
+     * Name of the element that represents an individual cache configuration 
+     * in a cache configs XML document.
+     */
+    public static final String CONFIG_ROOT = "cache-config";
+    /** 
+     * Name of the attribute in a {@link #CONFIG_ROOT cache-config} element that specifies
+     * the name of the configuration.
+     */
+    public static final String CONFIG_NAME = "name";
+    
+    private static final Log log = LogFactory.getLog(CacheConfigsXmlParser.class);
+    
+    private final XmlConfigurationParserOld parser = new XmlConfigurationParserOld();
+
+    public Map<String, Configuration> parseConfigs(String fileName) throws CloneNotSupportedException 
+    {
+       InputStream is = getAsInputStreamFromClassLoader(fileName);
+       if (is == null)
+       {
+          if (log.isDebugEnabled())
+             log.debug("Unable to find configuration file " + fileName + " in classpath; searching for this file on the filesystem instead.");
+          try
+          {
+             is = new FileInputStream(fileName);
+          }
+          catch (FileNotFoundException e)
+          {
+             throw new ConfigurationException("Unable to find config file " + fileName + " either in classpath or on the filesystem!", e);
+          }
+       }
+
+       return parseConfigs(is);
+    }
+     
+    public Map<String, Configuration> parseConfigs(InputStream stream) throws CloneNotSupportedException 
+    {            
+       // loop through all elements in XML.
+       Element root = XmlConfigHelper.getDocumentRoot(stream);
+       NodeList list = root.getElementsByTagName(CONFIG_ROOT);
+       if (list == null || list.getLength() == 0) 
+          throw new ConfigurationException("Can't find " + CONFIG_ROOT + " tag");
+         
+       Map<String, Configuration> result = new HashMap<String, Configuration>();
+         
+       for (int i = 0; i < list.getLength(); i++)
+       {
+          Node node = list.item(i);
+          if (node.getNodeType() != Node.ELEMENT_NODE)
+          {
+             continue;
+          }
+            
+          Element element = (Element) node;
+          String name = element.getAttribute(CONFIG_NAME);
+          if (name == null || name.trim().length() == 0)
+              throw new ConfigurationException("Element " + element + " has no name attribute");
+            
+          Configuration c = parser.parseConfiguration(element);
+          // Prove that we can successfully clone it
+          c = c.clone();
+          result.put(name.trim(), c);
+       }
+         
+       return result;
+    }
+
+    protected InputStream getAsInputStreamFromClassLoader(String filename)
+    {
+       InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
+       if (is == null)
+       {
+          // check system class loader
+          is = getClass().getClassLoader().getResourceAsStream(filename);
+       }
+       return is;
+    }
+ }
\ No newline at end of file


Property changes on: core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java
___________________________________________________________________
Name: svn:executable
   + *

Added: core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheLoadersElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheLoadersElementParser.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheLoadersElementParser.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -0,0 +1,103 @@
+package org.jboss.cache.config.parsing;
+
+import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.ConfigurationException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.Properties;
+
+/**
+ * Utility class for parsing the 'caceheloaders' element in the .xml configuration file.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 3.0
+ */
+public class CacheLoadersElementParser extends XmlParserBase
+{
+
+   public CacheLoaderConfig parseCacheLoadersElement(Element element)
+   {
+      CacheLoaderConfig cacheLoaderConfig = new CacheLoaderConfig();
+      String passivation = element.getAttribute("passivation");
+      if (existsAttribute(passivation)) cacheLoaderConfig.setPassivation(getBoolean(passivation));
+      String shared = element.getAttribute("shared");
+      if (existsAttribute(shared)) cacheLoaderConfig.setShared(getBoolean(shared));
+      String preload = getPreloadString(getSingleElement("preload", element));
+      if (preload != null) cacheLoaderConfig.setPreload(preload);
+
+      NodeList cacheLoaderNodes = element.getElementsByTagName("cacheLoader");
+      for (int i = 0; i < cacheLoaderNodes.getLength(); i++)
+      {
+         Element indivElement = (Element) cacheLoaderNodes.item(i);
+         CacheLoaderConfig.IndividualCacheLoaderConfig iclc = parseIndividualCacheLoaderConfig(indivElement);
+         cacheLoaderConfig.addIndividualCacheLoaderConfig(iclc);
+      }
+
+      return cacheLoaderConfig;
+   }
+
+   private CacheLoaderConfig.IndividualCacheLoaderConfig parseIndividualCacheLoaderConfig(Element indivElement)
+   {
+      CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new CacheLoaderConfig.IndividualCacheLoaderConfig();
+
+      String async = indivElement.getAttribute("async");
+      if (existsAttribute(async)) iclc.setAsync(getBoolean(async));
+      String fetchPersistentState = indivElement.getAttribute("fetchPersistentState");
+      if (existsAttribute(fetchPersistentState)) iclc.setFetchPersistentState(getBoolean(fetchPersistentState));
+      String ignoreModifications = indivElement.getAttribute("ignoreModifications");
+      if (existsAttribute(ignoreModifications)) iclc.setIgnoreModifications(getBoolean(ignoreModifications));
+      String purgeOnStartup = indivElement.getAttribute("purgeOnStartup");
+      if (existsAttribute(purgeOnStartup)) iclc.setPurgeOnStartup(getBoolean(purgeOnStartup));
+      String clClass = indivElement.getAttribute("class");
+      if (!existsAttribute(clClass)) throw new ConfigurationException("Missing 'class'  attribute for cache loader configuration");
+      iclc.setClassName(clClass);
+         iclc.setProperties(XmlConfigHelper.readPropertiesContents(indivElement, "properties"));
+      CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig ssc = parseSingletonStoreConfig(indivElement);
+      if (ssc != null)
+      {
+         iclc.setSingletonStoreConfig(ssc);
+      }
+      return iclc;
+   }
+
+   private String getPreloadString(Element preloadElement)
+   {
+      if (preloadElement == null) return null; //might be no preload
+      NodeList nodesToPreload = preloadElement.getElementsByTagName("node");
+      StringBuffer result = new StringBuffer();
+      for (int i = 0; i < nodesToPreload.getLength(); i++)
+      {
+         Element node = (Element) nodesToPreload.item(i);
+         String fqn2preload = node.getAttribute("fqn");
+         if (!existsAttribute(fqn2preload)) throw new ConfigurationException("Missing 'fqn' attribute in 'preload\\norde' tag");
+         if (i > 0) result.append(",");
+         result.append(fqn2preload);
+      }
+      return result.toString();
+   }
+
+   static CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig parseSingletonStoreConfig(Element cacheLoaderelement)
+   {
+      /* singletonStore element can only appear once in a cacheloader, so we just take the first one ignoring any
+      subsequent definitions in cacheloader element*/
+      Node singletonStoreNode = cacheLoaderelement.getElementsByTagName("singletonStore").item(0);
+      if (singletonStoreNode != null && singletonStoreNode.getNodeType() == Node.ELEMENT_NODE)
+      {
+         Element singletonStoreElement = (Element) singletonStoreNode;
+         boolean singletonStoreEnabled = XmlConfigHelper.readBooleanContents(singletonStoreElement, "enabled");
+         String singletonStoreClass = XmlConfigHelper.readStringContents(singletonStoreElement, "class");
+         Properties singletonStoreproperties;
+            singletonStoreproperties = XmlConfigHelper.readPropertiesContents(singletonStoreElement, "properties");
+         CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig ssc = new CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig();
+         ssc.setSingletonStoreEnabled(singletonStoreEnabled);
+         ssc.setSingletonStoreClass(singletonStoreClass);
+         ssc.setSingletonStoreproperties(singletonStoreproperties);
+
+         return ssc;
+      }
+
+      return null;
+   }
+}

Added: core/trunk/src/main/java/org/jboss/cache/config/parsing/EvictionElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/EvictionElementParser.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/EvictionElementParser.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -0,0 +1,110 @@
+package org.jboss.cache.config.parsing;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.config.MissingPolicyException;
+import org.jboss.cache.config.EvictionPolicyConfig;
+import org.jboss.cache.eviction.EvictionPolicy;
+import org.jboss.cache.util.Util;
+import org.jboss.cache.RegionManager;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Knows how to parse the <b>eviction</b> element uder a parser.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 3.0
+ */
+public class EvictionElementParser extends XmlParserBase
+{
+   public EvictionConfig getEvictionConfig(Element evictionElement)
+   {
+      EvictionConfig evictionConfig = new EvictionConfig();
+      String wakeUpInterval = evictionElement.getAttribute("wakeUpInterval");
+      if (existsAttribute(wakeUpInterval)) evictionConfig.setWakeupInterval(getInt(wakeUpInterval));
+      String defaultPolicyClass = evictionElement.getAttribute("defaultPolicyClass");
+      if (existsAttribute(defaultPolicyClass)) evictionConfig.setDefaultEvictionPolicyClass(defaultPolicyClass);
+      String defaultEventQueueSize = evictionElement.getAttribute("defaultEventQueueSize");
+      if (existsAttribute(defaultEventQueueSize)) evictionConfig.setDefaultEventQueueSize(getInt(defaultEventQueueSize));
+      List<EvictionRegionConfig> evictionRegionConfigs = new ArrayList<EvictionRegionConfig>(3);
+      Element defaultRegion = getSingleElement("default", evictionElement);
+      if (defaultRegion != null)
+      {
+         EvictionRegionConfig erc = getEvictionRegionConfig(defaultRegion, defaultPolicyClass, getInt(defaultEventQueueSize));
+         erc.setRegionName(RegionManager.DEFAULT_REGION.toString());
+         evictionRegionConfigs.add(erc);
+      }
+      NodeList regions = evictionElement.getElementsByTagName("region");
+      for (int i = 0; i < regions.getLength(); i++)
+      {
+         Element regionConfig = (Element) regions.item(i);
+         EvictionRegionConfig erc = getEvictionRegionConfig(regionConfig, defaultPolicyClass, getInt(defaultEventQueueSize));
+         evictionRegionConfigs.add(erc);
+      }
+      evictionConfig.setEvictionRegionConfigs(evictionRegionConfigs);
+      return evictionConfig;
+   }
+
+   private EvictionRegionConfig getEvictionRegionConfig(Element element, String defaultPolicyClass, int defaultEventQueueSize)
+   {
+      EvictionRegionConfig erc = new EvictionRegionConfig();
+      erc.setRegionName(element.getAttribute("name"));
+      String queueSize = element.getAttribute("eventQueueSize");
+      if (existsAttribute(queueSize))
+      {
+         erc.setEventQueueSize(getInt(queueSize));
+      }
+      else
+      {
+         erc.setEventQueueSize(defaultEventQueueSize);
+      }
+      String policyClass = element.getAttribute("policyClass");
+      if (!existsAttribute(policyClass))
+      {
+         if (defaultPolicyClass == null)
+         {
+            throw new MissingPolicyException("There is no Eviction Policy Class specified on the region or for the entire cache!");
+         }
+         else
+         {
+            policyClass = defaultPolicyClass;
+         }
+      }
+      EvictionPolicy policy;
+      try
+      {
+         policy = (EvictionPolicy) Util.loadClass(policyClass).newInstance();
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Eviction class is not properly loaded in classloader", e);
+      }
+
+      EvictionPolicyConfig epc;
+      try
+      {
+         epc = policy.getEvictionConfigurationClass().newInstance();
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Failed to instantiate eviction configuration of class " +
+               policy.getEvictionConfigurationClass(), e);
+      }
+      parseEvictionPolicyConfig(element, epc);
+      erc.setEvictionPolicyConfig(epc);
+      return erc;
+   }
+
+   public static void parseEvictionPolicyConfig(Element element, EvictionPolicyConfig target)
+   {
+      target.reset();
+      ParsedAttributes attributes = XmlConfigHelper.extractAttributes(element);
+      XmlConfigHelper.setValues(target, attributes.stringAttribs, false);
+      XmlConfigHelper.setValues(target, attributes.xmlAttribs, true);
+      target.validate();
+   }
+}

Added: core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -0,0 +1,70 @@
+package org.jboss.cache.config.parsing;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Attr;
+
+/**
+ * The purpose of this class is to parse the jgroups configuration from the config file into an compact string
+ * that can be passed as a config to the channel.
+ * 
+ * @author Mircea.Markus at jboss.com
+ * @since 3.0
+ */
+public class JGroupsStackParser
+{
+
+   //todo - further refine in smaller methods and make not-static
+   /**
+    * Parses the cluster config which is used to start a JGroups channel
+    *
+    * @param config an old-style JGroups protocol config String
+    */
+   public static 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)
+         {
+            continue;
+         }
+
+         Element tag = (Element) node;
+         String protocol = tag.getTagName();
+         buffer.append(protocol);
+         NamedNodeMap attrs = tag.getAttributes();
+         int attrLength = attrs.getLength();
+         if (attrLength > 0)
+         {
+            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();
+   }
+}

Added: core/trunk/src/main/java/org/jboss/cache/config/parsing/ParsedAttributes.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/ParsedAttributes.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/ParsedAttributes.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -0,0 +1,21 @@
+package org.jboss.cache.config.parsing;
+
+import org.w3c.dom.Element;
+
+import java.util.Map;
+
+/**
+ * @author Mircea.Markus at jboss.com
+* @since 3.0
+*/
+public class ParsedAttributes
+{
+   public final Map<String, String> stringAttribs;
+   public final Map<String, Element> xmlAttribs;
+
+   ParsedAttributes(Map strings, Map elements)
+   {
+      this.stringAttribs = strings;
+      this.xmlAttribs = elements;
+   }
+}

Copied: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java (from rev 5987, core/trunk/src/main/java/org/jboss/cache/xml/XmlHelper.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -0,0 +1,542 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.config.parsing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.util.StringPropertyReplacer;
+import org.jboss.cache.util.BeanUtils;
+import org.jboss.cache.config.ConfigurationException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.Map;
+import java.util.HashMap;
+import java.lang.reflect.Method;
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+
+/**
+ * A simple XML utility class for reading configuration elements
+ *
+ * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
+ */
+public class XmlConfigHelper
+{
+   private static final Log log = LogFactory.getLog(XmlConfigHelper.class);
+
+   /**
+    * The root of a JBoss Cache configuration XML file.  This is the <tt>&lt;mbean&gt;</tt> tag.
+    */
+   public static final String ROOT = "mbean";
+
+   /**
+    * The <tt>&lt;attribute&gt;</tt> tag which forms the bulk of JBoss Cache configuration elements
+    */
+   public static final String ATTR = "attribute";
+
+   /**
+    * The <tt>&lt;config&gt;</tt> tag may be embedded in the contents of an <tt>&lt;attribute&gt;</tt>, to specify more
+    * complex configuration for certain parameters.
+    */
+   public static final String CONFIG_ATTR = "config";
+
+   /**
+    * The <tt>&lt;name&gt;</tt> attribute to an <tt>&lt;attribute&gt;</tt> tag.
+    */
+   public static final String NAME = "name";
+
+
+   /**
+    * Returns the contents of a specific node of given element name, provided a certain attribute exists and is set to value.
+    * E.g., if you have a {@link Element} which represents the following XML snippet:
+    * <pre>
+    *   &lt;ItemQuantity Colour="Red"&gt;100&lt;/ItemQuantity&gt;
+    *   &lt;ItemQuantity Colour="Blue"&gt;30&lt;/ItemQuantity&gt;
+    *   &lt;ItemQuantity Colour="Black"&gt;10&lt;/ItemQuantity&gt;
+    * <pre>
+    * <p/>
+    * The following results could be expected:
+    * </p>
+    * <pre>
+    *    getTagContents(element, "Red", "ItemQuantity", "Colour"); // 100
+    *    getTagContents(element, "Black", "ItemQuantity", "Colour"); // 10
+    *    getTagContents(element, "Blah", "ItemQuantity", "Colour"); // null
+    *    getTagContents(element, "Red", "Blah", "Colour"); // null
+    *    getTagContents(element, "Black", "ItemQuantity", "Blah"); // null
+    * </pre>
+    * <p/>
+    * None of the parameters should be null - otherwise the method may throw a NullPointerException.
+    * </p>
+    *
+    * @param elem          - element to search through.
+    * @param value         - expected value to match against
+    * @param elementName   - element name
+    * @param attributeName - attribute name of the element that would contain the expected value.
+    * @return the contents of the matched element, or null if not found/matched
+    */
+   public static String getTagContents(Element elem, String value, String elementName, String attributeName)
+   {
+      NodeList list = elem.getElementsByTagName(elementName);
+
+      for (int s = 0; s < list.getLength(); s++)
+      {
+         org.w3c.dom.Node node = list.item(s);
+         if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
+            continue;
+
+         Element element = (Element) node;
+         String name = element.getAttribute(attributeName);
+         if (name.equals(value))
+         {
+            return getElementContent(element, true);
+         }
+      }
+      return null;
+   }
+
+   /**
+    * Retrieves the value of a given attribute for the first encountered instance of a tag in an element.
+    * <p/>
+    * E.g., if you have a {@link Element} which represents the following XML snippet:
+    * </p>
+    * <pre>
+    *   &lt;ItemQuantity Colour="Red"&gt;100&lt;/ItemQuantity&gt;
+    *   &lt;ItemQuantity Colour="Blue"&gt;30&lt;/ItemQuantity&gt;
+    *   &lt;ItemQuantity Colour="Black"&gt;10&lt;/ItemQuantity&gt;
+    * <pre>
+    * <p/>
+    * The following results could be expected:
+    * </p>
+    * <pre>
+    *    getAttributeValue(element, "ItemQuantity", "Colour"); // "Red"
+    *    getTagContents(element, "Blah", "Colour"); // null
+    *    getTagContents(element, "ItemQuantity", "Blah"); // null
+    * </pre>
+    * None of the parameters should be null - otherwise the method may throw a NullPointerException.
+    *
+    * @param elem          - element to search through.
+    * @param elementName   - element name
+    * @param attributeName - attribute name of the element that would contain the expected value.
+    * @return the contents of the matched attribute, or null if not found/matched
+    */
+   public static String getAttributeValue(Element elem, String elementName, String attributeName)
+   {
+      NodeList list = elem.getElementsByTagName(elementName);
+
+      for (int s = 0; s < list.getLength(); s++)
+      {
+         org.w3c.dom.Node node = list.item(s);
+         if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
+            continue;
+
+         Element element = (Element) node;
+         String value = element.getAttribute(attributeName);
+         return value == null ? null : StringPropertyReplacer.replaceProperties(value);
+
+      }
+      return null;
+   }
+
+   /**
+    * Convenience method, equivalent to calling <tt>getSubElement(element, "config");</tt>
+    */
+   public static Element getConfigSubElement(Element element)
+   {
+      return getSubElement(element, CONFIG_ATTR);
+   }
+
+   /**
+    * Returns a named sub-element of the current element passed in.
+    * <p/>
+    * None of the parameters should be null - otherwise the method may throw a NullPointerException.
+    *
+    * @param element        - element to search through.
+    * @param subElementName - the name of a sub element to look for
+    * @return the first matching sub element, if found, or null otherwise.
+    */
+   public static Element getSubElement(Element element, String subElementName)
+   {
+      NodeList nl = element.getChildNodes();
+      for (int i = 0; i < nl.getLength(); i++)
+      {
+         Node node = nl.item(i);
+         if (node.getNodeType() == Node.ELEMENT_NODE && subElementName.equals(((Element) node).getTagName()))
+         {
+            return (Element) node;
+         }
+      }
+
+      if (log.isDebugEnabled()) log.debug("getSubElement(): Does not exist for " + subElementName);
+      return null;
+   }
+
+   /**
+    * Reads the contents of the element passed in.
+    * <p/>
+    * None of the parameters should be null - otherwise the method may throw a NullPointerException.
+    *
+    * @param element - element to search through.
+    * @param trim    - if true, whitespace is trimmed before returning
+    * @return the contents of the element passed in.  Will return an empty String if the element is empty.
+    */
+   public static String getElementContent(Element element, boolean trim)
+   {
+      NodeList nl = element.getChildNodes();
+      String attributeText = "";
+      for (int i = 0; i < nl.getLength(); i++)
+      {
+         Node n = nl.item(i);
+         if (n instanceof Text)
+         {
+            attributeText += StringPropertyReplacer.replaceProperties(((Text) n).getData());
+         }
+      } // end of for ()
+      if (trim)
+         attributeText = attributeText.trim();
+      return attributeText;
+   }
+
+   /**
+    * Reads the contents of the first occurence of elementName under the given element, trimming results of whitespace.
+    * <p/>
+    * None of the parameters should be null - otherwise the method may throw a NullPointerException.
+    *
+    * @param element     - element to search through.
+    * @param elementName - name of the element to find within the element passed in
+    * @return may return an empty String of not found.
+    */
+   public static String readStringContents(Element element, String elementName)
+   {
+      NodeList nodes = element.getElementsByTagName(elementName);
+      if (nodes.getLength() > 0)
+      {
+         Node node = nodes.item(0);
+         Element ne = (Element) node;
+         NodeList nl2 = ne.getChildNodes();
+         Node node2 = nl2.item(0);
+         if (node2 != null)
+         {
+            String value = node2.getNodeValue();
+            if (value == null)
+               return "";
+            return StringPropertyReplacer.replaceProperties(value.trim());
+         }
+         else
+         {
+            return "";
+         }
+      }
+      else
+      {
+         return "";
+      }
+   }
+
+   /**
+    * Escapes backslashes ('\') with additional backslashes in a given String, returning a new, escaped String.
+    *
+    * @param value String to escape.   Cannot be null.
+    * @return escaped String.  Never is null.
+    */
+   public static String escapeBackslashes(String value)
+   {
+      StringBuffer buf = new StringBuffer(value);
+      for (int looper = 0; looper < buf.length(); looper++)
+      {
+         char curr = buf.charAt(looper);
+         char next = 0;
+         if (looper + 1 < buf.length())
+            next = buf.charAt(looper + 1);
+
+         if (curr == '\\')
+         {
+            if (next != '\\')
+            {           // only if not already escaped
+               buf.insert(looper, '\\');  // escape backslash
+            }
+            looper++;                    // skip past extra backslash (either the one we added or existing)
+         }
+      }
+      return buf.toString();
+   }
+
+   /**
+    * Reads the contents of a named sub element within a given element, and attempts to parse the contents as a Java
+    * properties file.
+    * <p/>
+    * E.g., if you have a {@link Element} which represents the following XML snippet:
+    * <p/>
+    * <pre>
+    *   &lt;props&gt;
+    *       my.attrib.1 = blah
+    *       my.attrib.2 = blahblah
+    *   &lt;/props&gt;
+    * <pre>
+    * <p/>
+    * The following results could be expected:
+    * <p/>
+    * <pre>
+    *    Properties p = readPropertiesContents(element, "props");
+    *    p.getProperty("my.attrib.1"); // blah
+    *    p.getProperty("my.attrib.2"); // blahblah
+    * </pre>
+    * None of the parameters should be null - otherwise the method may throw a NullPointerException.
+    *
+    * @param element     - element to search through.
+    * @param elementName - name of the element to find within the element passed in
+    * @return a {@link Properties} object, never null.
+    * @throws IOException if unable to parse the contents of the element
+    */
+   public static Properties readPropertiesContents(Element element, String elementName)
+   {
+      String stringContents = readStringContents(element, elementName);
+      if (stringContents == null) return new Properties();
+      // JBCACHE-531: escape all backslash characters
+      stringContents = escapeBackslashes(stringContents);
+      ByteArrayInputStream is = null;
+      Properties properties = null;
+      try
+      {
+         is = new ByteArrayInputStream(stringContents.trim().getBytes("ISO8859_1"));
+         properties = new Properties();
+         properties.load(is);
+         is.close();
+      } catch (IOException e)
+      {
+         log.warn("Unexpected",e);
+         throw new ConfigurationException("Exception occured while reading properties from XML document",e);
+      }
+      return properties;
+   }
+
+   /**
+    * Similar to {@link #readStringContents(org.w3c.dom.Element,String)} except that it returns a boolean.
+    *
+    * @param element     - element to search through.
+    * @param elementName - name of the element to find within the element passed in
+    * @return the contents of the element as a boolean, or false if not found.
+    */
+   public static boolean readBooleanContents(Element element, String elementName)
+   {
+      return readBooleanContents(element, elementName, false);
+   }
+
+   /**
+    * Similar to {@link #readStringContents(org.w3c.dom.Element,String)} except that it returns a boolean.
+    *
+    * @param element      - element to search through.
+    * @param elementName  - name of the element to find within the element passed in
+    * @param defaultValue - value to return if the element is not found or cannot be parsed.
+    * @return the contents of the element as a boolean
+    */
+   public static boolean readBooleanContents(Element element, String elementName, boolean defaultValue)
+   {
+      String val = readStringContents(element, elementName);
+      if (val.equalsIgnoreCase("true") || val.equalsIgnoreCase("false"))
+      {
+         // needs to be done this way because of JBBUILD-351
+         return Boolean.valueOf(val);
+         //return Boolean.parseBoolean(val);
+      }
+      return defaultValue;
+   }
+
+   /**
+    * Converts a String representing an XML snippet into an {@link org.w3c.dom.Element}.
+    *
+    * @param xml snippet as a string
+    * @return a DOM Element
+    * @throws Exception if unable to parse the String or if it doesn't contain valid XML.
+    */
+   public static Element stringToElement(String xml) throws Exception
+   {
+      ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("utf8"));
+      DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+      Document d = builder.parse(bais);
+      bais.close();
+      return d.getDocumentElement();
+   }
+
+   /**
+    * Returns the root element of a given input stream
+    *
+    * @param is stream to parse
+    * @return XML DOM element, or null if unable to parse stream
+    */
+   public static Element getDocumentRoot(InputStream is)
+   {
+      Document doc;
+      try
+      {
+         InputSource xmlInp = new InputSource(is);
+
+         DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+         DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
+         doc = parser.parse(xmlInp);
+         Element root = doc.getDocumentElement();
+         root.normalize();
+         return root;
+      }
+      catch (SAXParseException err)
+      {
+         log.error("Configurator SAXParse error", err);
+      }
+      catch (SAXException e)
+      {
+         log.error("Configurator SAX error", e);
+      }
+      catch (Exception pce)
+      {
+         log.error("Configurator general error", pce);
+      }
+      return null;
+   }
+
+   /**
+    * Retrieves the boolean value of a given attribute for the first encountered instance of elementName
+    *
+    * @param elem          - element to search
+    * @param elementName   - name of element to find
+    * @param attributeName - name of attribute to retrieve the value of
+    * @param defaultValue  - default value to return if not found
+    */
+   public static boolean readBooleanAttribute(Element elem, String elementName, String attributeName, boolean defaultValue)
+   {
+      String val = getAttributeValue(elem, elementName, attributeName);
+      if (val != null)
+      {
+         if (val.equalsIgnoreCase("true") || val.equalsIgnoreCase("false"))
+         {
+            //return Boolean.parseBoolean(val);
+            // needs to be done this way because of JBBUILD-351
+            return Boolean.valueOf(val);
+         }
+      }
+
+      return defaultValue;
+   }
+
+   public static void setValues(Object target, Map<?, ?> attribs, boolean isXmlAttribs)
+   {
+      Class objectClass = target.getClass();
+
+      // go thru simple string setters first.
+      for (Map.Entry entry : attribs.entrySet())
+      {
+         String propName = (String) entry.getKey();
+         String setter = BeanUtils.setterName(propName);
+         Method method;
+
+         try
+         {
+            if (isXmlAttribs)
+            {
+               method = objectClass.getMethod(setter, Element.class);
+               method.invoke(target, entry.getValue());
+            }
+            else
+            {
+               method = objectClass.getMethod(setter, String.class);
+               method.invoke(target, entry.getValue());
+            }
+
+            continue;
+         }
+         catch (NoSuchMethodException me)
+         {
+            // this is ok, but certainly log this as a warning
+            // this is hugely noisy!
+            //if (log.isWarnEnabled()) log.warn("Unrecognised attribute " + propName + ".  Please check your configuration.  Ignoring!!");
+         }
+         catch (Exception e)
+         {
+            throw new ConfigurationException("Unable to invoke setter " + setter + " on " + objectClass, e);
+         }
+
+         // if we get here, we could not find a String or Element setter.
+         for (Method m : objectClass.getMethods())
+         {
+            if (setter.equals(m.getName()))
+            {
+               Class paramTypes[] = m.getParameterTypes();
+               if (paramTypes.length != 1)
+               {
+                  throw new ConfigurationException("Setter " + setter + " does not contain the expected number of params.  Has " + paramTypes.length + " instead of just 1.");
+               }
+
+               Class parameterType = paramTypes[0];
+               PropertyEditor editor = PropertyEditorManager.findEditor(parameterType);
+               if (editor == null)
+               {
+                  throw new ConfigurationException("Couldn't find a property editor for parameter type " + parameterType);
+               }
+
+               editor.setAsText((String) attribs.get(propName));
+
+               Object parameter = editor.getValue();
+               //if (log.isDebugEnabled()) log.debug("Invoking setter method: " + setter + " with parameter \"" + parameter + "\" of type " + parameter.getClass());
+
+               try
+               {
+                  m.invoke(target, parameter);
+               }
+               catch (Exception e)
+               {
+                  throw new ConfigurationException("Unable to invoke setter " + setter + " on " + objectClass, e);
+               }
+            }
+         }
+      }
+   }
+
+   public static ParsedAttributes extractAttributes(Element source)
+   {
+      Map<String, String> stringAttribs = new HashMap<String, String>();
+      Map<String, Element> xmlAttribs = new HashMap<String, Element>();
+      NodeList list = source.getElementsByTagName(ATTR);
+      if (log.isDebugEnabled()) log.debug("Attribute size: " + list.getLength());
+
+      // loop through attributes
+      for (int loop = 0; loop < list.getLength(); loop++)
+      {
+         Node node = list.item(loop);
+         if (node.getNodeType() != Node.ELEMENT_NODE) continue;
+
+         // for each element (attribute) ...
+         Element element = (Element) node;
+         String name = element.getAttribute(NAME);
+         String valueStr = getElementContent(element, true);
+
+         Element valueXml = null;
+         if (valueStr.length() == 0)
+         {
+            // This may be an XML element ...
+            valueXml = getConfigSubElement(element);
+         }
+
+         // add these to the maps.
+
+         if (valueStr.length() > 0) stringAttribs.put(name, valueStr);
+         if (valueXml != null) xmlAttribs.put(name, valueXml);
+      }
+
+      return new ParsedAttributes(stringAttribs, xmlAttribs);
+   }
+}


Property changes on: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java (from rev 5987, core/trunk/src/main/java/org/jboss/cache/factories/XmlConfigurationParser.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -0,0 +1,290 @@
+package org.jboss.cache.config.parsing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.config.*;
+import org.jboss.cache.lock.IsolationLevel;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ * @since 3.0
+ */
+public class XmlConfigurationParser extends XmlParserBase
+{
+   private static final Log log = LogFactory.getLog(XmlConfigurationParser.class);
+
+   private Configuration config = new Configuration();
+   private Element root;
+
+
+   /**
+    * Parses an XML file and returns a new configuration.  This method attempts to look for the file name passed in on
+    * the classpath.  If not found, it will search for the file on the file system instead, treating the name as an
+    * absolute path.
+    */
+   public Configuration parseFile(String filename)
+   {
+      InputStream is = getAsInputStreamFromClassLoader(filename);
+      if (is == null)
+      {
+         if (log.isDebugEnabled())
+            log.debug("Unable to find configuration file " + filename + " in classpath; searching for this file on the filesystem instead.");
+         try
+         {
+            is = new FileInputStream(filename);
+         }
+         catch (FileNotFoundException e)
+         {
+            throw new ConfigurationException("Unable to find config file " + filename + " either in classpath or on the filesystem!", e);
+         }
+      }
+
+      return parse(is);
+   }
+
+   protected InputStream getAsInputStreamFromClassLoader(String filename)
+   {
+      ClassLoader cl = Thread.currentThread().getContextClassLoader();
+      InputStream is = cl == null ? null : cl.getResourceAsStream(filename);
+      if (is == null)
+      {
+         // check system class loader
+         is = getClass().getClassLoader().getResourceAsStream(filename);
+      }
+      return is;
+   }
+
+   public Configuration parse(InputStream configStream)
+   {
+      readRoot(configStream);
+      configureLocking(getSingleElement("locking"));
+      configureTransaction(getSingleElement("transaction"));
+      configureReplication(getSingleElement("replication"));
+      configureSerialization(getSingleElement("serialization"));
+      configureInvalidation(getSingleElement("invalidation"));
+      configureStartup(getSingleElement("startup"));
+      configureTransport(getSingleElement("transport"));
+      configureShutdown(getSingleElement("shutdown"));
+      configureJmxStatistics(getSingleElement("jmxStatistics"));
+      configureEviction(getSingleElement("eviction"));
+      configureCacheLoaders(getSingleElement("cacheLoaders"));
+      configureBuddyReplication(getSingleElement("buddyReplication"));
+      configureCustomInterceptors(getSingleElement("customInterceptors"));
+      return config;
+   }
+
+   private void configureTransaction(Element element)
+   {
+      if (element == null) return;
+      String txMngLookupClass = element.getAttribute("transactionManagerLookupClass");
+      if (existsAttribute(txMngLookupClass)) config.setTransactionManagerLookupClass(txMngLookupClass); 
+      String syncRollbackPhase = element.getAttribute("syncRollbackPhase");
+      if (existsAttribute(syncRollbackPhase)) config.setSyncRollbackPhase(getBoolean(syncRollbackPhase));
+      String syncCommitPhase = element.getAttribute("syncCommitPhase");
+      if (existsAttribute(syncCommitPhase)) config.setSyncCommitPhase(getBoolean(syncCommitPhase));
+   }
+
+   private void configureSerialization(Element element)
+   {
+      if (element == null) return;
+      String objectInputStreamPoolSize = element.getAttribute("objectInputStreamPoolSize");
+      if (existsAttribute(objectInputStreamPoolSize)) config.setObjectInputStreamPoolSize(getInt(objectInputStreamPoolSize));
+      String objectOutputStreamPoolSize = element.getAttribute("objectOutputStreamPoolSize");
+      if (existsAttribute(objectOutputStreamPoolSize)) config.setObjectOutputStreamPoolSize(getInt(objectOutputStreamPoolSize));
+      String version = element.getAttribute("version");
+      if (existsAttribute(version)) config.setReplVersionString(version);
+      String marshallerClass = element.getAttribute("marshallerClass");
+      if (existsAttribute(marshallerClass)) config.setMarshallerClass(marshallerClass);
+      String useLazyDeserialization = element.getAttribute("useLazyDeserialization");
+      if (existsAttribute(useLazyDeserialization)) config.setUseLazyDeserialization(getBoolean(useLazyDeserialization));
+      String useRegionBasedMarshalling = element.getAttribute("useRegionBasedMarshalling");
+      if (existsAttribute(useRegionBasedMarshalling)) config.setUseRegionBasedMarshalling(getBoolean(useRegionBasedMarshalling));
+   }
+
+   private void configureCustomInterceptors(Element singleElement)
+   {
+      if (singleElement == null) return; //this element might be missing
+      NodeList interceptorNodes = singleElement.getElementsByTagName("interceptor");
+      List<CustomInterceptorConfig> interceptorConfigs = new ArrayList<CustomInterceptorConfig>(interceptorNodes.getLength());
+      for (int i = 0; i < interceptorNodes.getLength(); i++)
+      {
+         Element interceptorElement = (Element) interceptorNodes.item(i);
+         String interceptorClass = interceptorElement.getAttribute("class");
+         Properties props = XmlConfigHelper.readPropertiesContents(interceptorElement, "properties");
+         Element position = getSingleElement("position", interceptorElement);
+         String firstStr = position.getAttribute("first");
+         boolean first = existsAttribute(firstStr) && getBoolean(firstStr);
+         String lastStr = position.getAttribute("last");
+         boolean last = existsAttribute(lastStr) && getBoolean(lastStr);
+         String indexStr = position.getAttribute("index");
+         int index = existsAttribute(indexStr) ? getInt(indexStr) : -1;
+         String before = position.getAttribute("before");
+         if (!existsAttribute(before)) before = null;
+         String after = position.getAttribute("after");
+         if (!existsAttribute(after)) after = null;
+         CustomInterceptorConfig customInterceptorConfig = new CustomInterceptorConfig(interceptorClass, first, last,
+               index, after, before, props);
+         interceptorConfigs.add(customInterceptorConfig);
+      }
+      config.setCustomInterceptors(interceptorConfigs);
+   }
+
+   private void configureBuddyReplication(Element element)
+   {
+      if (element == null) return;//buddy config might not exist, expect that
+      BuddyReplicationElementParser buddyElementParser = new BuddyReplicationElementParser();
+      BuddyReplicationConfig brConfig = buddyElementParser.parseBuddyReplicationElement(element);
+      config.setBuddyReplicationConfig(brConfig);
+   }
+
+   private void configureCacheLoaders(Element element)
+   {
+      if (element == null) return; //null cache loaders are allowed
+      CacheLoadersElementParser clElementParser = new CacheLoadersElementParser();
+      CacheLoaderConfig cacheLoaderConfig = clElementParser.parseCacheLoadersElement(element);
+      config.setCacheLoaderConfig(cacheLoaderConfig);
+   }
+
+   private void configureEviction(Element evictionElement)
+   {
+      if (evictionElement == null) return; //no eviction might be configured
+      EvictionElementParser evictionElementParser = new EvictionElementParser();
+      config.setEvictionConfig(evictionElementParser.getEvictionConfig(evictionElement));
+   }
+
+
+   private void configureJmxStatistics(Element element)
+   {
+      if (element == null) return; //might not be specified
+      String enabled = element.getAttribute("enabled");
+      if (enabled != null) config.setExposeManagementStatistics(getBoolean(enabled));
+   }
+
+   private void configureShutdown(Element element)
+   {
+      if (element == null) return;
+      String hookBehavior = element.getAttribute("hookBehavior");
+      if (hookBehavior != null) config.setShutdownHookBehavior(hookBehavior);
+   }
+
+   private void configureTransport(Element element)
+   {
+      String clusterName = element.getAttribute("clusterName");
+      config.setClusterName(clusterName);
+      Element multiplexer = getSingleElement("multiplexer", element);
+      if (multiplexer != null)
+      {
+         config.setMultiplexerStack(multiplexer.getAttribute("stack"));
+      }
+      Element clusterConfig = getSingleElement("jgroupsConfig", element);
+      if (clusterConfig != null)
+      {
+         String clusterConfigStr = JGroupsStackParser.parseClusterConfigXml(clusterConfig);
+         config.setClusterConfig(clusterConfigStr);
+      }
+   }
+
+   private void configureStartup(Element element)
+   {
+      if (element == null) return; //we might not have this configured
+      String fetchInMemoryState = element.getAttribute("fetchInMemoryState");
+      if (fetchInMemoryState != null) config.setFetchInMemoryState(getBoolean(fetchInMemoryState));
+      String stateRetrievalTimeout = element.getAttribute("stateRetrievalTimeout");
+      if (stateRetrievalTimeout != null) config.setStateRetrievalTimeout(getLong(stateRetrievalTimeout));
+      String inactiveOnStartup = element.getAttribute("inactiveOnStartup");
+      if (inactiveOnStartup != null) config.setInactiveOnStartup(getBoolean(inactiveOnStartup));
+   }
+
+   private void configureInvalidation(Element element)
+   {
+      if (element == null) return; //might be replication
+      Element async = getSingleElement("async");
+      if (async != null)
+      {
+         config.setCacheMode(Configuration.CacheMode.INVALIDATION_ASYNC);
+         configureAsyncMode(getSingleElement("async", element));
+      }
+      Element sync = getSingleElement("sync");
+      if (sync != null)
+      {
+         config.setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
+         configureSyncMode(getSingleElement("sync", element));
+      }
+   }
+
+   private void configureReplication(Element element)
+   {
+      if (element == null) return; //might be we do not have a replication enabled
+      Element async = getSingleElement("async");
+      if (async != null)
+      {
+         config.setCacheMode(Configuration.CacheMode.REPL_ASYNC);
+         configureAsyncMode(getSingleElement("async", element));
+      }
+      Element sync = getSingleElement("sync");
+      if (sync != null)
+      {
+         config.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+         configureSyncMode(getSingleElement("sync", element));
+      }
+   }
+
+   private void configureSyncMode(Element element)
+   {
+      String replTimeout = element.getAttribute("replTimeout");
+      if (replTimeout != null) config.setSyncReplTimeout(getLong(replTimeout));
+   }
+
+   private void configureAsyncMode(Element element)
+   {
+      String useReplQueue = element.getAttribute("useReplQueue");
+      if (existsAttribute(useReplQueue)) config.setUseReplQueue(getBoolean(useReplQueue));
+      String replQueueInterval = element.getAttribute("replQueueInterval");
+      if (replQueueInterval != null) config.setReplQueueInterval(getLong(replQueueInterval));
+      String replQueueMaxElements = element.getAttribute("replQueueMaxElements");
+      if (replQueueMaxElements != null) config.setReplQueueMaxElements(getInt(replQueueMaxElements));
+   }
+
+   private void configureLocking(Element locking)
+   {
+      String isolationLevel = locking.getAttribute("isolationLevel");
+      if (isolationLevel != null) config.setIsolationLevel(IsolationLevel.valueOf(isolationLevel));
+      String lockParentForChildInsertRemove = locking.getAttribute("lockParentForChildInsertRemove");
+      if (lockParentForChildInsertRemove != null)
+         config.setLockParentForChildInsertRemove(getBoolean(lockParentForChildInsertRemove));
+      String lockAcquisitionTimeout = locking.getAttribute("lockAcquisitionTimeout");
+      if (lockAcquisitionTimeout != null) config.setLockAcquisitionTimeout(getLong(lockAcquisitionTimeout));
+   }
+
+   private Element getSingleElement(String elementName)
+   {
+      return getSingleElement(elementName, root);
+   }
+
+   private void readRoot(InputStream config)
+   {
+      try
+      {
+         DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+         DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
+         Document doc = parser.parse(config);
+         root = doc.getDocumentElement();
+         root.normalize();
+      } catch (Exception e)
+      {
+         throw new ConfigurationException("Could not parse the ");
+      }
+   }
+}


Property changes on: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Copied: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParserOld.java (from rev 5987, core/trunk/src/main/java/org/jboss/cache/factories/XmlConfigurationParser.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParserOld.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParserOld.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -0,0 +1,536 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.config.parsing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.buddyreplication.NextMemberBuddyLocator;
+import org.jboss.cache.config.BuddyReplicationConfig;
+import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
+import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionPolicyConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.config.MissingPolicyException;
+import org.jboss.cache.eviction.EvictionPolicy;
+import org.jboss.cache.util.Util;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+
+/**
+ * Reads in XMLconfiguration files and spits out a {@link org.jboss.cache.config.Configuration} object.  When deployed as a
+ * JBoss MBean, this role is performed by the JBoss Microcontainer.  This class is only used internally in unit tests
+ * or within {@link org.jboss.cache.CacheFactory} implementations for standalone JBoss Cache usage.
+ *
+ * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ * @since 2.00.
+ * @deprecated
+ */
+public class XmlConfigurationParserOld
+{
+   private static final Log log = LogFactory.getLog(XmlConfigurationParserOld.class);
+
+   public static final String ATTR = "attribute";
+   public static final String NAME = "name";
+
+   /**
+    * Parses an XML file and returns a new configuration.  This method attempts to look for the file name passed in on
+    * the classpath.  If not found, it will search for the file on the file system instead, treating the name as an
+    * absolute path.
+    *
+    * @param filename the name of the XML file to parse.
+    * @return a configured Configuration object representing the configuration in the file
+    */
+   public Configuration parseFile(String filename)
+   {
+      InputStream is = getAsInputStreamFromClassLoader(filename);
+      if (is == null)
+      {
+         if (log.isDebugEnabled())
+            log.debug("Unable to find configuration file " + filename + " in classpath; searching for this file on the filesystem instead.");
+         try
+         {
+            is = new FileInputStream(filename);
+         }
+         catch (FileNotFoundException e)
+         {
+            throw new ConfigurationException("Unable to find config file " + filename + " either in classpath or on the filesystem!", e);
+         }
+      }
+
+      return parseStream(is);
+   }
+
+   /**
+    * Parses an input stream containing XML text and returns a new configuration.
+    *
+    * @param stream input stream to parse.  SHould not be null.
+    * @return a configured Configuration object representing the configuration in the stream
+    * @since 2.1.0
+    */
+   public Configuration parseStream(InputStream stream)
+   {
+      // loop through all elements in XML.
+      Element root = XmlConfigHelper.getDocumentRoot(stream);
+      Element mbeanElement = getMBeanElement(root);
+
+      return parseConfiguration(mbeanElement);
+   }
+
+   public Configuration parseConfiguration(Element configurationRoot)
+   {
+      ParsedAttributes attributes = XmlConfigHelper.extractAttributes(configurationRoot);
+
+      // Deal with legacy attributes we no longer support
+      handleRemovedAttributes(attributes);
+
+      // Deal with legacy attributes that we renamed or otherwise altered
+      handleRenamedAttributes(attributes);
+
+      Configuration c = new Configuration();
+      XmlConfigHelper.setValues(c, attributes.stringAttribs, false);
+      // Special handling for XML elements -- we hard code the parsing
+      setXmlValues(c, attributes.xmlAttribs);
+
+      return c;
+   }
+
+   /**
+    * Check for and remove any attributes that were supported in the
+    * 1.x releases and no longer are.  Log a WARN or throw a
+    * {@link ConfigurationException} if any are found. Which is done depends
+    * on the attribute:
+    * <p/>
+    * <ul>
+    * <li><i>MultiplexerService</i> -- throws an Exception</li>
+    * <li><i>ServiceName</i> -- logs a WARN</li>
+    * </ul>
+    *
+    * @param attributes
+    */
+   protected void handleRemovedAttributes(ParsedAttributes attributes)
+   {
+      String evictionPolicy = attributes.stringAttribs.remove("EvictionPolicyClass");
+      if (evictionPolicy != null)
+      {
+         throw new ConfigurationException("XmlConfigurationParser does not " +
+               "support the JBC 1.x attribute EvictionPolicyClass. Set the default " +
+               "eviction policy via the policyClass element in the EvictionConfig section");
+      }
+      String multiplexerService = attributes.stringAttribs.remove("MultiplexerService");
+      if (multiplexerService != null)
+      {
+         throw new ConfigurationException("XmlConfigurationParser does not " +
+               "support the JBC 1.x attribute MultiplexerService. Inject the " +
+               "multiplexer directly using Configuration.getRuntimeConfig().setMuxChannelFactory()");
+      }
+      String serviceName = attributes.stringAttribs.remove("ServiceName");
+      if (serviceName != null)
+      {
+         log.warn("XmlConfigurationParser does not support the deprecated " +
+               "attribute ServiceName. If JMX registration is needed, " +
+               "register a CacheJmxWrapper or PojoCacheJmxWrapper in " +
+               "JMX with the desired name");
+      }
+   }
+
+   /**
+    * Check for any attributes that were supported in the
+    * 1.x releases but whose name has changed.  Log a WARN if any are found, but
+    * convert the attribute to the new name.
+    * <p/>
+    * <ul>
+    * <li><i>UseMbean</i> becomes <i>ExposeManagementStatistics</i></li>
+    * </ul>
+    *
+    * @param attributes
+    */
+   private void handleRenamedAttributes(ParsedAttributes attributes)
+   {
+      String keepStats = attributes.stringAttribs.remove("UseInterceptorMbeans");
+      if (keepStats != null && attributes.stringAttribs.get("ExposeManagementStatistics") == null)
+      {
+         log.warn("Found non-existent JBC 1.x attribute 'UseInterceptorMbeans' and replaced " +
+               "with 'ExposeManagementStatistics'. Please update your config " +
+               "to use the new attribute name");
+         attributes.stringAttribs.put("ExposeManagementStatistics", keepStats);
+      }
+      Element clc = attributes.xmlAttribs.remove("CacheLoaderConfiguration");
+      if (clc != null && attributes.xmlAttribs.get("CacheLoaderConfig") == null)
+      {
+         log.warn("Found non-existent JBC 1.x attribute 'CacheLoaderConfiguration' and replaced " +
+               "with 'CacheLoaderConfig'. Please update your config " +
+               "to use the new attribute name");
+         attributes.xmlAttribs.put("CacheLoaderConfig", clc);
+      }
+   }
+
+   protected InputStream getAsInputStreamFromClassLoader(String filename)
+   {
+      ClassLoader cl = Thread.currentThread().getContextClassLoader();
+      InputStream is = cl == null ? null : cl.getResourceAsStream(filename);
+      if (is == null)
+      {
+         // check system class loader
+         is = getClass().getClassLoader().getResourceAsStream(filename);
+      }
+      return is;
+   }
+
+   protected Element getMBeanElement(Element root)
+   {
+      // This is following JBoss convention.
+      NodeList list = root.getElementsByTagName(XmlConfigHelper.ROOT);
+      if (list == null) throw new ConfigurationException("Can't find " + XmlConfigHelper.ROOT + " tag");
+
+      if (list.getLength() > 1) throw new ConfigurationException("Has multiple " + XmlConfigHelper.ROOT + " tag");
+
+      Node node = list.item(0);
+      Element element;
+      if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
+      {
+         element = (Element) node;
+      }
+      else
+      {
+         throw new ConfigurationException("Can't find " + XmlConfigHelper.ROOT + " element");
+      }
+      return element;
+   }
+
+   protected void setXmlValues(Configuration conf, Map<String, Element> attribs)
+   {
+      for (Entry<String, Element> entry : attribs.entrySet())
+      {
+         String propname = entry.getKey();
+         if ("BuddyReplicationConfiguration".equals(propname)
+               || "BuddyReplicationConfig".equals(propname))
+         {
+            BuddyReplicationConfig brc = parseBuddyReplicationConfig(entry.getValue());
+            conf.setBuddyReplicationConfig(brc);
+         }
+         else if ("CacheLoaderConfiguration".equals(propname)
+               || "CacheLoaderConfig".equals(propname))
+         {
+            CacheLoaderConfig clc = parseCacheLoaderConfig(entry.getValue());
+            conf.setCacheLoaderConfig(clc);
+         }
+         else if ("EvictionPolicyConfiguration".equals(propname)
+               || "EvictionPolicyConfig".equals(propname))
+         {
+            EvictionConfig ec = parseEvictionConfig(entry.getValue());
+            conf.setEvictionConfig(ec);
+         }
+         else if ("ClusterConfig".equals(propname))
+         {
+            String jgc = parseClusterConfigXml(entry.getValue());
+            conf.setClusterConfig(jgc);
+         }
+         else
+         {
+            throw new ConfigurationException("Unknown configuration element " + propname);
+         }
+      }
+   }
+
+   public static BuddyReplicationConfig parseBuddyReplicationConfig(Element element)
+   {
+      BuddyReplicationConfig brc = new BuddyReplicationConfig();
+      brc.setEnabled(XmlConfigHelper.readBooleanContents(element, "buddyReplicationEnabled"));
+      brc.setDataGravitationRemoveOnFind(XmlConfigHelper.readBooleanContents(element, "dataGravitationRemoveOnFind", true));
+      brc.setDataGravitationSearchBackupTrees(XmlConfigHelper.readBooleanContents(element, "dataGravitationSearchBackupTrees", true));
+      brc.setAutoDataGravitation(brc.isEnabled() && XmlConfigHelper.readBooleanContents(element, "autoDataGravitation", false));
+
+      String strBuddyCommunicationTimeout = XmlConfigHelper.readStringContents(element, "buddyCommunicationTimeout");
+      try
+      {
+         brc.setBuddyCommunicationTimeout(Integer.parseInt(strBuddyCommunicationTimeout));
+      }
+      catch (Exception e)
+      {
+      }
+      finally
+      {
+         if (log.isDebugEnabled())
+         {
+            log.debug("Using buddy communication timeout of " + brc.getBuddyCommunicationTimeout() + " millis");
+         }
+      }
+      String buddyPoolName = XmlConfigHelper.readStringContents(element, "buddyPoolName");
+      if ("".equals(buddyPoolName))
+      {
+         buddyPoolName = null;
+      }
+
+      brc.setBuddyPoolName(buddyPoolName);
+
+      // now read the buddy locator details
+
+      String buddyLocatorClass = XmlConfigHelper.readStringContents(element, "buddyLocatorClass");
+      if (buddyLocatorClass == null || buddyLocatorClass.length() == 0)
+      {
+         buddyLocatorClass = NextMemberBuddyLocator.class.getName();
+      }
+      Properties props = null;
+      props = XmlConfigHelper.readPropertiesContents(element, "buddyLocatorProperties");
+      BuddyLocatorConfig blc = new BuddyLocatorConfig();
+      blc.setBuddyLocatorClass(buddyLocatorClass);
+      blc.setBuddyLocatorProperties(props);
+      brc.setBuddyLocatorConfig(blc);
+
+      return brc;
+   }
+
+   public static CacheLoaderConfig parseCacheLoaderConfig(Element element)
+   {
+      CacheLoaderConfig clc = new CacheLoaderConfig();
+      clc.setPassivation(XmlConfigHelper.readBooleanContents(element, "passivation"));
+      clc.setPreload(XmlConfigHelper.readStringContents(element, "preload"));
+      clc.setShared(XmlConfigHelper.readBooleanContents(element, "shared"));
+
+      NodeList cacheLoaderNodes = element.getElementsByTagName("cacheloader");
+      for (int i = 0; i < cacheLoaderNodes.getLength(); i++)
+      {
+         Node node = cacheLoaderNodes.item(i);
+         if (node.getNodeType() == Node.ELEMENT_NODE)
+         {
+            Element indivElement = (Element) node;
+            CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new CacheLoaderConfig.IndividualCacheLoaderConfig();
+            iclc.setAsync(XmlConfigHelper.readBooleanContents(indivElement, "async", false));
+            iclc.setIgnoreModifications(XmlConfigHelper.readBooleanContents(indivElement, "ignoreModifications", false));
+            iclc.setFetchPersistentState(XmlConfigHelper.readBooleanContents(indivElement, "fetchPersistentState", false));
+            iclc.setPurgeOnStartup(XmlConfigHelper.readBooleanContents(indivElement, "purgeOnStartup", false));
+            iclc.setClassName(XmlConfigHelper.readStringContents(indivElement, "class"));
+            iclc.setProperties(XmlConfigHelper.readPropertiesContents(indivElement, "properties"));
+
+            SingletonStoreConfig ssc = CacheLoadersElementParser.parseSingletonStoreConfig(indivElement);
+            if (ssc != null)
+            {
+               iclc.setSingletonStoreConfig(ssc);
+            }
+
+            clc.addIndividualCacheLoaderConfig(iclc);
+         }
+      }
+
+      return clc;
+   }
+
+   public static EvictionConfig parseEvictionConfig(Element element)
+   {
+      EvictionConfig ec = new EvictionConfig();
+
+      if (element != null)
+      {
+         // If they set the default eviction policy in the element, use that
+         // in preference to the external attribute
+         String temp = XmlConfigHelper.getTagContents(element,
+               EvictionConfig.EVICTION_POLICY_CLASS, ATTR, NAME);
+         if (temp != null && temp.length() > 0)
+         {
+            ec.setDefaultEvictionPolicyClass(temp);
+         }
+
+         temp = XmlConfigHelper.getTagContents(element,
+               EvictionConfig.WAKEUP_INTERVAL_SECONDS, ATTR, NAME);
+
+         int wakeupIntervalSeconds = 0;
+         if (temp != null)
+         {
+            wakeupIntervalSeconds = Integer.parseInt(temp);
+         }
+
+         if (wakeupIntervalSeconds <= 0)
+         {
+            wakeupIntervalSeconds = EvictionConfig.WAKEUP_DEFAULT;
+         }
+
+         ec.setWakeupIntervalSeconds(wakeupIntervalSeconds);
+
+         int eventQueueSize = 0;
+         temp = XmlConfigHelper.getTagContents(element,
+               EvictionConfig.EVENT_QUEUE_SIZE, ATTR, NAME);
+
+         if (temp != null)
+         {
+            eventQueueSize = Integer.parseInt(temp);
+         }
+
+         if (eventQueueSize <= 0)
+         {
+            eventQueueSize = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
+         }
+
+         ec.setDefaultEventQueueSize(eventQueueSize);
+
+         NodeList list = element.getElementsByTagName(EvictionRegionConfig.REGION);
+         if (list != null && list.getLength() > 0)
+         {
+            List regionConfigs = new ArrayList(list.getLength());
+            for (int i = 0; i < list.getLength(); i++)
+            {
+               org.w3c.dom.Node node = list.item(i);
+               if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
+               {
+                  continue;
+               }
+               try
+               {
+                  regionConfigs.add(parseEvictionRegionConfig((Element) node, ec.getDefaultEvictionPolicyClass(), eventQueueSize));
+               }
+               catch (MissingPolicyException missingPolicy)
+               {
+                  LogFactory.getLog(EvictionConfig.class).warn(missingPolicy.getLocalizedMessage());
+                  throw missingPolicy;
+               }
+            }
+
+            ec.setEvictionRegionConfigs(regionConfigs);
+         }
+      }
+
+      return ec;
+
+   }
+
+   public static EvictionRegionConfig parseEvictionRegionConfig(Element element,
+                                                                String defaultEvictionClass,
+                                                                int defaultQueueCapacity)
+   {
+      EvictionRegionConfig erc = new EvictionRegionConfig();
+
+      erc.setRegionName(element.getAttribute(EvictionRegionConfig.NAME));
+
+      String temp = element.getAttribute(EvictionRegionConfig.EVENT_QUEUE_SIZE);
+      if (temp != null && temp.length() > 0)
+      {
+         erc.setEventQueueSize(Integer.parseInt(temp));
+      }
+      else
+      {
+         erc.setEventQueueSize(defaultQueueCapacity);
+      }
+      String evictionClass = element.getAttribute(EvictionRegionConfig.REGION_POLICY_CLASS);
+
+      if (evictionClass == null || evictionClass.length() == 0)
+      {
+         evictionClass = defaultEvictionClass;
+         // if it's still null... what do we setCache?
+         if (evictionClass == null || evictionClass.length() == 0)
+         {
+            throw new MissingPolicyException(
+                  "There is no Eviction Policy Class specified on the region or for the entire cache!");
+         }
+      }
+
+      EvictionPolicy policy;
+      try
+      {
+         policy = (EvictionPolicy) Util.loadClass(evictionClass).newInstance();
+      }
+      catch (RuntimeException e)
+      {
+         throw e;
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Eviction class is not properly loaded in classloader", e);
+      }
+
+      EvictionPolicyConfig epc;
+      try
+      {
+         epc = policy.getEvictionConfigurationClass().newInstance();
+      }
+      catch (RuntimeException e)
+      {
+         throw e;
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Failed to instantiate eviction configuration of class " +
+               policy.getEvictionConfigurationClass(), e);
+      }
+
+      EvictionElementParser.parseEvictionPolicyConfig(element, epc);
+
+      erc.setEvictionPolicyConfig(epc);
+      return erc;
+
+   }
+
+   /**
+    * Parses the cluster config which is used to start a JGroups channel
+    *
+    * @param config an old-style JGroups protocol config String
+    */
+   public static 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)
+         {
+            continue;
+         }
+
+         Element tag = (Element) node;
+         String protocol = tag.getTagName();
+         buffer.append(protocol);
+         NamedNodeMap attrs = tag.getAttributes();
+         int attrLength = attrs.getLength();
+         if (attrLength > 0)
+         {
+            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();
+   }
+
+}


Property changes on: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParserOld.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -0,0 +1,45 @@
+package org.jboss.cache.config.parsing;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Contains utility methods that might be useful to most of the parsers.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 3.0
+ */
+public abstract class XmlParserBase
+{
+   protected int getInt(String intStr)
+   {
+      return Integer.parseInt(intStr);
+   }
+
+   protected long getLong(String longStr)
+   {
+      return Long.valueOf(longStr);
+   }
+
+   protected boolean getBoolean(String str)
+   {
+      return Boolean.valueOf(str);
+   }
+
+
+   protected boolean existsAttribute(String attrValue)
+   {
+      return attrValue.length() > 0;
+   }
+
+
+   protected Element getSingleElement(String elementName, Element parent)
+   {
+      NodeList nodeList = parent.getElementsByTagName(elementName);
+      if (nodeList.getLength() == 0)
+      {
+         return null;
+      }
+      return (Element) nodeList.item(0);
+   }
+}

Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBase.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBase.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBase.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -25,9 +25,15 @@
    @Dynamic
    private int maxNodes = 0;
 
+   @Deprecated
    @Dynamic
    private int minTimeToLiveSeconds = 0;
 
+
+   /** value expressed in millis */
+   @Dynamic
+   private long minTimeToLive;
+
    /**
     * Can only be instantiated by a subclass.
     * <p/>
@@ -60,14 +66,35 @@
       this.maxNodes = maxNodes;
    }
 
+   /** value expressed in millis */
+   public long getMinTimeToLive()
+   {
+      return minTimeToLive;
+   }
+
+   /** value expressed in millis */
+   public void setMinTimeToLive(long minTimeToLive)
+   {
+      this.minTimeToLive = minTimeToLive;
+   }
+
+   /**
+    * Use {@link #getMinTimeToLive()}
+    */
+   @Deprecated
    public int getMinTimeToLiveSeconds()
    {
       return this.minTimeToLiveSeconds;
    }
 
+   /**
+    * Use {@link #setMinTimeToLive(long)}
+    */
+   @Deprecated
    public void setMinTimeToLiveSeconds(int minTimeToLiveSeconds)
    {
       this.minTimeToLiveSeconds = minTimeToLiveSeconds;
+      setMinTimeToLive(minTimeToLive * 1000);
    }
 
    public void validate() throws ConfigurationException
@@ -75,30 +102,28 @@
       // no-op
    }
 
-   @Override
-   public boolean equals(Object obj)
+   public boolean equals(Object o)
    {
-      if (this == obj)
-         return true;
+      if (this == o) return true;
+      if (!(o instanceof EvictionPolicyConfigBase)) return false;
 
-      if (obj instanceof EvictionPolicyConfigBase)
-      {
-         EvictionPolicyConfigBase other = (EvictionPolicyConfigBase) obj;
+      EvictionPolicyConfigBase that = (EvictionPolicyConfigBase) o;
 
-         return this.maxNodes == other.maxNodes && this.minTimeToLiveSeconds == other.minTimeToLiveSeconds
-               && Util.safeEquals(this.evictionPolicyClass, other.evictionPolicyClass);
-      }
+      if (maxNodes != that.maxNodes) return false;
+      if (minTimeToLive != that.minTimeToLive) return false;
+      if (evictionPolicyClass != null ? !evictionPolicyClass.equals(that.evictionPolicyClass) : that.evictionPolicyClass != null)
+         return false;
 
-      return false;
+      return true;
    }
 
-   @Override
    public int hashCode()
    {
-      int result = 17;
+      int result;
+      result = (evictionPolicyClass != null ? evictionPolicyClass.hashCode() : 0);
       result = 31 * result + maxNodes;
       result = 31 * result + minTimeToLiveSeconds;
-      result = 31 * result + (evictionPolicyClass == null ? 0 : evictionPolicyClass.hashCode());
+      result = 31 * result + (int) (minTimeToLive ^ (minTimeToLive >>> 32));
       return result;
    }
 
@@ -107,6 +132,7 @@
       setEvictionPolicyClass(null);
       setMaxNodes(0);
       setMinTimeToLiveSeconds(0);
+      setMinTimeToLive(0);
       setEvictionPolicyClassName();
    }
 

Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionTimerTask.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -31,7 +31,7 @@
 
    private final Set<Region> processedRegions;
    private static AtomicInteger tcount = new AtomicInteger();
-   private int wakeupIntervalSeconds;
+   private long wakeupInterval;
    private Timer evictionThread;
 
    public EvictionTimerTask()
@@ -41,11 +41,11 @@
       processedRegions = Collections.synchronizedSet(new HashSet<Region>());
    }
 
-   public void init(int wakeupIntervalSeconds)
+   public void init(long wakeupInterval)
    {
       if (log.isTraceEnabled())
-         log.trace("Creating a new eviction listener with wakeupIntervalSeconds set at " + wakeupIntervalSeconds);
-      this.wakeupIntervalSeconds = wakeupIntervalSeconds;
+         log.trace("Creating a new eviction listener with wakeupInterval millis set at " + wakeupInterval);
+      this.wakeupInterval = wakeupInterval;
       start();
    }
 
@@ -106,7 +106,7 @@
             processRegions();
          }
       };
-      evictionThread.schedule(tt, wakeupIntervalSeconds * 1000, wakeupIntervalSeconds * 1000);
+      evictionThread.schedule(tt, wakeupInterval, wakeupInterval);
    }
 
    private void processRegions()

Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/ExpirationConfiguration.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -24,9 +24,13 @@
    @Dynamic
    private boolean warnNoExpirationKey = true;
 
+   @Deprecated
    @Dynamic
    private int timeToLiveSeconds = 0;
 
+   @Dynamic
+   private long timeToLive = 0;
+
    @Override
    protected void setEvictionPolicyClassName()
    {
@@ -66,14 +70,35 @@
       this.warnNoExpirationKey = warnNoExpirationKey;
    }
 
+   /** value expressed in millis */
+   public long getTimeToLive()
+   {
+      return timeToLive;
+   }
+
+   /** value expressed in millis */
+   public void setTimeToLive(long timeToLive)
+   {
+      this.timeToLive = timeToLive;
+   }
+
+   /**
+    * Use {@link #getTimeToLive()}.
+    */
+   @Deprecated
    public int getTimeToLiveSeconds()
    {
       return timeToLiveSeconds;
    }
 
+   /**
+    * use {@link #setTimeToLive(long)}.
+    */
+   @Deprecated
    public void setTimeToLiveSeconds(int timeToLiveSeconds)
    {
       this.timeToLiveSeconds = timeToLiveSeconds;
+      setTimeToLive(timeToLiveSeconds * 1000);
    }
 
    @Override

Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUConfiguration.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -33,15 +33,26 @@
    private static final long serialVersionUID = -3426716488271559729L;
 
    @Dynamic
+   @Deprecated
    private int timeToLiveSeconds;
    @Dynamic
+   @Deprecated
    private int maxAgeSeconds;
 
+
+   /** value expressed in millis*/
+   @Dynamic
+   private long timeToLive;
+
+   /** value expressed in millis*/
+   @Dynamic
+   private long maxAge;
+
    public LRUConfiguration()
    {
       super();
       // Force config of ttls
-      setTimeToLiveSeconds(-1);
+      setTimeToLive(-1);
    }
 
    @Override
@@ -50,27 +61,72 @@
       setEvictionPolicyClass(LRUPolicy.class.getName());
    }
 
+   /** value expressed in millis*/
+   public long getTimeToLive()
+   {
+      return timeToLive;
+   }
 
+   /** value expressed in millis*/
+   public void setTimeToLive(long timeToLive)
+   {
+      testImmutability("timeToLive");
+      this.timeToLive = timeToLive;
+   }
+
+   /** value expressed in millis*/
+   public long getMaxAge()
+   {
+      return maxAge;
+   }
+
+   /** value expressed in millis*/
+   public void setMaxAge(long maxAge)
+   {
+      testImmutability("maxAge");
+      this.maxAge = maxAge;
+   }
+
+   /**
+    * use {@link #getTimeToLive()}
+    * @return
+    */
+   @Deprecated
    public int getTimeToLiveSeconds()
    {
       return timeToLiveSeconds;
    }
 
+   /**
+    * Use {@link #setTimeToLive(long)}
+    */
+   @Deprecated
    public void setTimeToLiveSeconds(int timeToLiveSeconds)
    {
       testImmutability("timeToLiveSeconds");
       this.timeToLiveSeconds = timeToLiveSeconds;
+      setTimeToLive(timeToLiveSeconds * 1000);
    }
 
+   /**
+    * Use {@link #getMaxAge()}
+    */
+   @Deprecated
    public int getMaxAgeSeconds()
    {
       return maxAgeSeconds;
    }
 
+   /**
+    * Use {@link #getMaxAge()}
+    * @param maxAgeSeconds
+    */
+   @Deprecated
    public void setMaxAgeSeconds(int maxAgeSeconds)
    {
       testImmutability("maxAgeSeconds");
       this.maxAgeSeconds = maxAgeSeconds;
+      setMaxAge(maxAgeSeconds * 1000);
    }
 
    /**
@@ -80,40 +136,42 @@
    @Override
    public void validate() throws ConfigurationException
    {
-      if (timeToLiveSeconds < 0)
+      if (timeToLive < 0)
       {
-         throw new ConfigurationException("timeToLiveSeconds must be " +
+         throw new ConfigurationException("timeToLive must be " +
                "configured to a value greater than or equal to 0");
       }
    }
 
-   @Override
+
    public String toString()
    {
-      StringBuffer str = new StringBuffer();
-      str.append("LRUConfiguration: timeToLiveSeconds = ").append(getTimeToLiveSeconds()).append(" maxAgeSeconds =");
-      str.append(getMaxAgeSeconds()).append(" maxNodes =").append(getMaxNodes());
-      return str.toString();
+      return "LRUConfiguration{" +
+            "timeToLiveSeconds=" + timeToLiveSeconds +
+            ", timeToLive=" + timeToLive +
+            ", maxAge=" + maxAge +
+            '}';
    }
 
-   @Override
-   public boolean equals(Object obj)
+   public boolean equals(Object o)
    {
-      if (obj instanceof LRUConfiguration && super.equals(obj))
-      {
-         LRUConfiguration other = (LRUConfiguration) obj;
-         return maxAgeSeconds == other.maxAgeSeconds
-               && timeToLiveSeconds == other.timeToLiveSeconds;
-      }
-      return false;
+      if (this == o) return true;
+      if (!(o instanceof LRUConfiguration)) return false;
+      if (!super.equals(o)) return false;
+
+      LRUConfiguration that = (LRUConfiguration) o;
+
+      if (maxAge != that.maxAge) return false;
+      if (timeToLive != that.timeToLive) return false;
+
+      return true;
    }
 
-   @Override
    public int hashCode()
    {
       int result = super.hashCode();
-      result = 31 * result + maxAgeSeconds;
-      result = 31 * result + timeToLiveSeconds;
+      result = 31 * result + (int) (timeToLive ^ (timeToLive >>> 32));
+      result = 31 * result + (int) (maxAge ^ (maxAge >>> 32));
       return result;
    }
 
@@ -121,7 +179,7 @@
    public void reset()
    {
       super.reset();
-      setTimeToLiveSeconds(-1);
+      setTimeToLive(-1);
    }
 
    @Override

Deleted: core/trunk/src/main/java/org/jboss/cache/factories/CacheConfigsXmlParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/CacheConfigsXmlParser.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/main/java/org/jboss/cache/factories/CacheConfigsXmlParser.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -1,141 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.factories;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.xml.XmlHelper;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Parser able to parse a series of cache configurations stored in an
- * XML document with the following structure:
- * <pre>
- * <cache-configs>
- *    <cache-config name="configA">
- *     ....
- *    </cache-config>
- *    <cache-config name="configB">
- *     ....
- *    </cache-config>
- * </cache-configs>
- * </pre>
- * <p/>
- * The '....' represents the normal content of the mbean element in a 
- * JBC -service.xml config file.
- * 
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.1 $
- */
-public class CacheConfigsXmlParser 
- {
-    /** Name of the root element in a cache configs XML document*/
-    public static final String DOCUMENT_ROOT = "cache-configs";
-    /** 
-     * Name of the element that represents an individual cache configuration 
-     * in a cache configs XML document.
-     */
-    public static final String CONFIG_ROOT = "cache-config";
-    /** 
-     * Name of the attribute in a {@link #CONFIG_ROOT cache-config} element that specifies
-     * the name of the configuration.
-     */
-    public static final String CONFIG_NAME = "name";
-    
-    private static final Log log = LogFactory.getLog(CacheConfigsXmlParser.class);
-    
-    private final XmlConfigurationParser parser = new XmlConfigurationParser();
-
-    public Map<String, Configuration> parseConfigs(String fileName) throws CloneNotSupportedException 
-    {
-       InputStream is = getAsInputStreamFromClassLoader(fileName);
-       if (is == null)
-       {
-          if (log.isDebugEnabled())
-             log.debug("Unable to find configuration file " + fileName + " in classpath; searching for this file on the filesystem instead.");
-          try
-          {
-             is = new FileInputStream(fileName);
-          }
-          catch (FileNotFoundException e)
-          {
-             throw new ConfigurationException("Unable to find config file " + fileName + " either in classpath or on the filesystem!", e);
-          }
-       }
-
-       return parseConfigs(is);
-    }
-     
-    public Map<String, Configuration> parseConfigs(InputStream stream) throws CloneNotSupportedException 
-    {            
-       // loop through all elements in XML.
-       Element root = XmlHelper.getDocumentRoot(stream);
-       NodeList list = root.getElementsByTagName(CONFIG_ROOT);
-       if (list == null || list.getLength() == 0) 
-          throw new ConfigurationException("Can't find " + CONFIG_ROOT + " tag");
-         
-       Map<String, Configuration> result = new HashMap<String, Configuration>();
-         
-       for (int i = 0; i < list.getLength(); i++)
-       {
-          Node node = list.item(i);
-          if (node.getNodeType() != Node.ELEMENT_NODE)
-          {
-             continue;
-          }
-            
-          Element element = (Element) node;
-          String name = element.getAttribute(CONFIG_NAME);
-          if (name == null || name.trim().length() == 0)
-              throw new ConfigurationException("Element " + element + " has no name attribute");
-            
-          Configuration c = parser.parseConfiguration(element);
-          // Prove that we can successfully clone it
-          c = c.clone();
-          result.put(name.trim(), c);
-       }
-         
-       return result;
-    }
-
-    protected InputStream getAsInputStreamFromClassLoader(String filename)
-    {
-       InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
-       if (is == null)
-       {
-          // check system class loader
-          is = getClass().getClassLoader().getResourceAsStream(filename);
-       }
-       return is;
-    }
- }
\ No newline at end of file

Deleted: core/trunk/src/main/java/org/jboss/cache/factories/XmlConfigurationParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/XmlConfigurationParser.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/main/java/org/jboss/cache/factories/XmlConfigurationParser.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -1,712 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.factories;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.buddyreplication.NextMemberBuddyLocator;
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionPolicyConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.config.MissingPolicyException;
-import org.jboss.cache.eviction.EvictionPolicy;
-import org.jboss.cache.util.BeanUtils;
-import org.jboss.cache.util.Util;
-import org.jboss.cache.xml.XmlHelper;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-
-/**
- * Reads in XMLconfiguration files and spits out a {@link org.jboss.cache.config.Configuration} object.  When deployed as a
- * JBoss MBean, this role is performed by the JBoss Microcontainer.  This class is only used internally in unit tests
- * or within {@link org.jboss.cache.CacheFactory} implementations for standalone JBoss Cache usage.
- *
- * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
- * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
- * @since 2.00.
- */
-public class XmlConfigurationParser
-{
-   private static final Log log = LogFactory.getLog(XmlConfigurationParser.class);
-
-   public static final String ATTR = "attribute";
-   public static final String NAME = "name";
-
-   /**
-    * Parses an XML file and returns a new configuration.  This method attempts to look for the file name passed in on
-    * the classpath.  If not found, it will search for the file on the file system instead, treating the name as an
-    * absolute path.
-    *
-    * @param filename the name of the XML file to parse.
-    * @return a configured Configuration object representing the configuration in the file
-    */
-   public Configuration parseFile(String filename)
-   {
-      InputStream is = getAsInputStreamFromClassLoader(filename);
-      if (is == null)
-      {
-         if (log.isDebugEnabled())
-            log.debug("Unable to find configuration file " + filename + " in classpath; searching for this file on the filesystem instead.");
-         try
-         {
-            is = new FileInputStream(filename);
-         }
-         catch (FileNotFoundException e)
-         {
-            throw new ConfigurationException("Unable to find config file " + filename + " either in classpath or on the filesystem!", e);
-         }
-      }
-
-      return parseStream(is);
-   }
-
-   /**
-    * Parses an input stream containing XML text and returns a new configuration.
-    *
-    * @param stream input stream to parse.  SHould not be null.
-    * @return a configured Configuration object representing the configuration in the stream
-    * @since 2.1.0
-    */
-   public Configuration parseStream(InputStream stream)
-   {
-      // loop through all elements in XML.
-      Element root = XmlHelper.getDocumentRoot(stream);
-      Element mbeanElement = getMBeanElement(root);
-
-      return parseConfiguration(mbeanElement);
-   }
-
-   public Configuration parseConfiguration(Element configurationRoot)
-   {
-      ParsedAttributes attributes = extractAttributes(configurationRoot);
-
-      // Deal with legacy attributes we no longer support
-      handleRemovedAttributes(attributes);
-
-      // Deal with legacy attributes that we renamed or otherwise altered
-      handleRenamedAttributes(attributes);
-
-      Configuration c = new Configuration();
-      setValues(c, attributes.stringAttribs, false);
-      // Special handling for XML elements -- we hard code the parsing
-      setXmlValues(c, attributes.xmlAttribs);
-
-      return c;
-   }
-
-   /**
-    * Check for and remove any attributes that were supported in the
-    * 1.x releases and no longer are.  Log a WARN or throw a
-    * {@link ConfigurationException} if any are found. Which is done depends
-    * on the attribute:
-    * <p/>
-    * <ul>
-    * <li><i>MultiplexerService</i> -- throws an Exception</li>
-    * <li><i>ServiceName</i> -- logs a WARN</li>
-    * </ul>
-    *
-    * @param attributes
-    */
-   protected void handleRemovedAttributes(ParsedAttributes attributes)
-   {
-      String evictionPolicy = attributes.stringAttribs.remove("EvictionPolicyClass");
-      if (evictionPolicy != null)
-      {
-         throw new ConfigurationException("XmlConfigurationParser does not " +
-               "support the JBC 1.x attribute EvictionPolicyClass. Set the default " +
-               "eviction policy via the policyClass element in the EvictionConfig section");
-      }
-      String multiplexerService = attributes.stringAttribs.remove("MultiplexerService");
-      if (multiplexerService != null)
-      {
-         throw new ConfigurationException("XmlConfigurationParser does not " +
-               "support the JBC 1.x attribute MultiplexerService. Inject the " +
-               "multiplexer directly using Configuration.getRuntimeConfig().setMuxChannelFactory()");
-      }
-      String serviceName = attributes.stringAttribs.remove("ServiceName");
-      if (serviceName != null)
-      {
-         log.warn("XmlConfigurationParser does not support the deprecated " +
-               "attribute ServiceName. If JMX registration is needed, " +
-               "register a CacheJmxWrapper or PojoCacheJmxWrapper in " +
-               "JMX with the desired name");
-      }
-   }
-
-   /**
-    * Check for any attributes that were supported in the
-    * 1.x releases but whose name has changed.  Log a WARN if any are found, but
-    * convert the attribute to the new name.
-    * <p/>
-    * <ul>
-    * <li><i>UseMbean</i> becomes <i>ExposeManagementStatistics</i></li>
-    * </ul>
-    *
-    * @param attributes
-    */
-   private void handleRenamedAttributes(ParsedAttributes attributes)
-   {
-      String keepStats = attributes.stringAttribs.remove("UseInterceptorMbeans");
-      if (keepStats != null && attributes.stringAttribs.get("ExposeManagementStatistics") == null)
-      {
-         log.warn("Found non-existent JBC 1.x attribute 'UseInterceptorMbeans' and replaced " +
-               "with 'ExposeManagementStatistics'. Please update your config " +
-               "to use the new attribute name");
-         attributes.stringAttribs.put("ExposeManagementStatistics", keepStats);
-      }
-      Element clc = attributes.xmlAttribs.remove("CacheLoaderConfiguration");
-      if (clc != null && attributes.xmlAttribs.get("CacheLoaderConfig") == null)
-      {
-         log.warn("Found non-existent JBC 1.x attribute 'CacheLoaderConfiguration' and replaced " +
-               "with 'CacheLoaderConfig'. Please update your config " +
-               "to use the new attribute name");
-         attributes.xmlAttribs.put("CacheLoaderConfig", clc);
-      }
-   }
-
-   protected InputStream getAsInputStreamFromClassLoader(String filename)
-   {
-      ClassLoader cl = Thread.currentThread().getContextClassLoader();
-      InputStream is = cl == null ? null : cl.getResourceAsStream(filename);
-      if (is == null)
-      {
-         // check system class loader
-         is = getClass().getClassLoader().getResourceAsStream(filename);
-      }
-      return is;
-   }
-
-   protected Element getMBeanElement(Element root)
-   {
-      // This is following JBoss convention.
-      NodeList list = root.getElementsByTagName(XmlHelper.ROOT);
-      if (list == null) throw new ConfigurationException("Can't find " + XmlHelper.ROOT + " tag");
-
-      if (list.getLength() > 1) throw new ConfigurationException("Has multiple " + XmlHelper.ROOT + " tag");
-
-      Node node = list.item(0);
-      Element element;
-      if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-      {
-         element = (Element) node;
-      }
-      else
-      {
-         throw new ConfigurationException("Can't find " + XmlHelper.ROOT + " element");
-      }
-      return element;
-   }
-
-   protected static void setValues(Object target, Map<?, ?> attribs, boolean isXmlAttribs)
-   {
-      Class objectClass = target.getClass();
-
-      // go thru simple string setters first.
-      for (Entry entry : attribs.entrySet())
-      {
-         String propName = (String) entry.getKey();
-         String setter = BeanUtils.setterName(propName);
-         Method method;
-
-         try
-         {
-            if (isXmlAttribs)
-            {
-               method = objectClass.getMethod(setter, Element.class);
-               method.invoke(target, entry.getValue());
-            }
-            else
-            {
-               method = objectClass.getMethod(setter, String.class);
-               method.invoke(target, entry.getValue());
-            }
-
-            continue;
-         }
-         catch (NoSuchMethodException me)
-         {
-            // this is ok, but certainly log this as a warning
-            // this is hugely noisy!
-            //if (log.isWarnEnabled()) log.warn("Unrecognised attribute " + propName + ".  Please check your configuration.  Ignoring!!");
-         }
-         catch (Exception e)
-         {
-            throw new ConfigurationException("Unable to invoke setter " + setter + " on " + objectClass, e);
-         }
-
-         // if we get here, we could not find a String or Element setter.
-         for (Method m : objectClass.getMethods())
-         {
-            if (setter.equals(m.getName()))
-            {
-               Class paramTypes[] = m.getParameterTypes();
-               if (paramTypes.length != 1)
-               {
-                  throw new ConfigurationException("Setter " + setter + " does not contain the expected number of params.  Has " + paramTypes.length + " instead of just 1.");
-               }
-
-               Class parameterType = paramTypes[0];
-               PropertyEditor editor = PropertyEditorManager.findEditor(parameterType);
-               if (editor == null)
-               {
-                  throw new ConfigurationException("Couldn't find a property editor for parameter type " + parameterType);
-               }
-
-               editor.setAsText((String) attribs.get(propName));
-
-               Object parameter = editor.getValue();
-               //if (log.isDebugEnabled()) log.debug("Invoking setter method: " + setter + " with parameter \"" + parameter + "\" of type " + parameter.getClass());
-
-               try
-               {
-                  m.invoke(target, parameter);
-               }
-               catch (Exception e)
-               {
-                  throw new ConfigurationException("Unable to invoke setter " + setter + " on " + objectClass, e);
-               }
-            }
-         }
-      }
-   }
-
-   protected void setXmlValues(Configuration conf, Map<String, Element> attribs)
-   {
-      for (Entry<String, Element> entry : attribs.entrySet())
-      {
-         String propname = entry.getKey();
-         if ("BuddyReplicationConfiguration".equals(propname)
-               || "BuddyReplicationConfig".equals(propname))
-         {
-            BuddyReplicationConfig brc = parseBuddyReplicationConfig(entry.getValue());
-            conf.setBuddyReplicationConfig(brc);
-         }
-         else if ("CacheLoaderConfiguration".equals(propname)
-               || "CacheLoaderConfig".equals(propname))
-         {
-            CacheLoaderConfig clc = parseCacheLoaderConfig(entry.getValue());
-            conf.setCacheLoaderConfig(clc);
-         }
-         else if ("EvictionPolicyConfiguration".equals(propname)
-               || "EvictionPolicyConfig".equals(propname))
-         {
-            EvictionConfig ec = parseEvictionConfig(entry.getValue());
-            conf.setEvictionConfig(ec);
-         }
-         else if ("ClusterConfig".equals(propname))
-         {
-            String jgc = parseClusterConfigXml(entry.getValue());
-            conf.setClusterConfig(jgc);
-         }
-         else
-         {
-            throw new ConfigurationException("Unknown configuration element " + propname);
-         }
-      }
-   }
-
-   public static BuddyReplicationConfig parseBuddyReplicationConfig(Element element)
-   {
-      BuddyReplicationConfig brc = new BuddyReplicationConfig();
-      brc.setEnabled(XmlHelper.readBooleanContents(element, "buddyReplicationEnabled"));
-      brc.setDataGravitationRemoveOnFind(XmlHelper.readBooleanContents(element, "dataGravitationRemoveOnFind", true));
-      brc.setDataGravitationSearchBackupTrees(XmlHelper.readBooleanContents(element, "dataGravitationSearchBackupTrees", true));
-      brc.setAutoDataGravitation(brc.isEnabled() && XmlHelper.readBooleanContents(element, "autoDataGravitation", false));
-
-      String strBuddyCommunicationTimeout = XmlHelper.readStringContents(element, "buddyCommunicationTimeout");
-      try
-      {
-         brc.setBuddyCommunicationTimeout(Integer.parseInt(strBuddyCommunicationTimeout));
-      }
-      catch (Exception e)
-      {
-      }
-      finally
-      {
-         if (log.isDebugEnabled())
-         {
-            log.debug("Using buddy communication timeout of " + brc.getBuddyCommunicationTimeout() + " millis");
-         }
-      }
-      String buddyPoolName = XmlHelper.readStringContents(element, "buddyPoolName");
-      if ("".equals(buddyPoolName))
-      {
-         buddyPoolName = null;
-      }
-
-      brc.setBuddyPoolName(buddyPoolName);
-
-      // now read the buddy locator details
-
-      String buddyLocatorClass = XmlHelper.readStringContents(element, "buddyLocatorClass");
-      if (buddyLocatorClass == null || buddyLocatorClass.length() == 0)
-      {
-         buddyLocatorClass = NextMemberBuddyLocator.class.getName();
-      }
-      Properties props = null;
-      try
-      {
-         props = XmlHelper.readPropertiesContents(element, "buddyLocatorProperties");
-      }
-      catch (IOException e)
-      {
-         log.warn("Caught exception reading buddyLocatorProperties", e);
-         log.error("Unable to read buddyLocatorProperties specified!  Using defaults for [" + buddyLocatorClass + "]");
-      }
-      BuddyLocatorConfig blc = new BuddyLocatorConfig();
-      blc.setBuddyLocatorClass(buddyLocatorClass);
-      blc.setBuddyLocatorProperties(props);
-      brc.setBuddyLocatorConfig(blc);
-
-      return brc;
-   }
-
-   public static CacheLoaderConfig parseCacheLoaderConfig(Element element)
-   {
-      CacheLoaderConfig clc = new CacheLoaderConfig();
-      clc.setPassivation(XmlHelper.readBooleanContents(element, "passivation"));
-      clc.setPreload(XmlHelper.readStringContents(element, "preload"));
-      clc.setShared(XmlHelper.readBooleanContents(element, "shared"));
-
-      NodeList cacheLoaderNodes = element.getElementsByTagName("cacheloader");
-      for (int i = 0; i < cacheLoaderNodes.getLength(); i++)
-      {
-         Node node = cacheLoaderNodes.item(i);
-         if (node.getNodeType() == Node.ELEMENT_NODE)
-         {
-            Element indivElement = (Element) node;
-            CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new CacheLoaderConfig.IndividualCacheLoaderConfig();
-            iclc.setAsync(XmlHelper.readBooleanContents(indivElement, "async", false));
-            iclc.setIgnoreModifications(XmlHelper.readBooleanContents(indivElement, "ignoreModifications", false));
-            iclc.setFetchPersistentState(XmlHelper.readBooleanContents(indivElement, "fetchPersistentState", false));
-            iclc.setPurgeOnStartup(XmlHelper.readBooleanContents(indivElement, "purgeOnStartup", false));
-            iclc.setClassName(XmlHelper.readStringContents(indivElement, "class"));
-            try
-            {
-               iclc.setProperties(XmlHelper.readPropertiesContents(indivElement, "properties"));
-            }
-            catch (IOException e)
-            {
-               throw new ConfigurationException("Problem loader cache loader properties", e);
-            }
-
-            SingletonStoreConfig ssc = parseSingletonStoreConfig(indivElement);
-            if (ssc != null)
-            {
-               iclc.setSingletonStoreConfig(ssc);
-            }
-
-            clc.addIndividualCacheLoaderConfig(iclc);
-         }
-      }
-
-      return clc;
-   }
-
-   private static SingletonStoreConfig parseSingletonStoreConfig(Element cacheLoaderelement)
-   {
-      /* singletonStore element can only appear once in a cacheloader, so we just take the first one ignoring any
-      subsequent definitions in cacheloader element*/
-      Node singletonStoreNode = cacheLoaderelement.getElementsByTagName("singletonStore").item(0);
-      if (singletonStoreNode != null && singletonStoreNode.getNodeType() == Node.ELEMENT_NODE)
-      {
-         Element singletonStoreElement = (Element) singletonStoreNode;
-         boolean singletonStoreEnabled = XmlHelper.readBooleanContents(singletonStoreElement, "enabled");
-         String singletonStoreClass = XmlHelper.readStringContents(singletonStoreElement, "class");
-         Properties singletonStoreproperties;
-         try
-         {
-            singletonStoreproperties = XmlHelper.readPropertiesContents(singletonStoreElement, "properties");
-         }
-         catch (IOException e)
-         {
-            throw new ConfigurationException("Problem loading singleton store properties", e);
-         }
-         SingletonStoreConfig ssc = new SingletonStoreConfig();
-         ssc.setSingletonStoreEnabled(singletonStoreEnabled);
-         ssc.setSingletonStoreClass(singletonStoreClass);
-         ssc.setSingletonStoreproperties(singletonStoreproperties);
-
-         return ssc;
-      }
-
-      return null;
-   }
-
-   public static EvictionConfig parseEvictionConfig(Element element)
-   {
-      EvictionConfig ec = new EvictionConfig();
-
-      if (element != null)
-      {
-         // If they set the default eviction policy in the element, use that
-         // in preference to the external attribute
-         String temp = XmlHelper.getTagContents(element,
-               EvictionConfig.EVICTION_POLICY_CLASS, ATTR, NAME);
-         if (temp != null && temp.length() > 0)
-         {
-            ec.setDefaultEvictionPolicyClass(temp);
-         }
-
-         temp = XmlHelper.getTagContents(element,
-               EvictionConfig.WAKEUP_INTERVAL_SECONDS, ATTR, NAME);
-
-         int wakeupIntervalSeconds = 0;
-         if (temp != null)
-         {
-            wakeupIntervalSeconds = Integer.parseInt(temp);
-         }
-
-         if (wakeupIntervalSeconds <= 0)
-         {
-            wakeupIntervalSeconds = EvictionConfig.WAKEUP_DEFAULT;
-         }
-
-         ec.setWakeupIntervalSeconds(wakeupIntervalSeconds);
-
-         int eventQueueSize = 0;
-         temp = XmlHelper.getTagContents(element,
-               EvictionConfig.EVENT_QUEUE_SIZE, ATTR, NAME);
-
-         if (temp != null)
-         {
-            eventQueueSize = Integer.parseInt(temp);
-         }
-
-         if (eventQueueSize <= 0)
-         {
-            eventQueueSize = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
-         }
-
-         ec.setDefaultEventQueueSize(eventQueueSize);
-
-         NodeList list = element.getElementsByTagName(EvictionRegionConfig.REGION);
-         if (list != null && list.getLength() > 0)
-         {
-            List regionConfigs = new ArrayList(list.getLength());
-            for (int i = 0; i < list.getLength(); i++)
-            {
-               org.w3c.dom.Node node = list.item(i);
-               if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
-               {
-                  continue;
-               }
-               try
-               {
-                  regionConfigs.add(parseEvictionRegionConfig((Element) node, ec.getDefaultEvictionPolicyClass(), eventQueueSize));
-               }
-               catch (MissingPolicyException missingPolicy)
-               {
-                  LogFactory.getLog(EvictionConfig.class).warn(missingPolicy.getLocalizedMessage());
-                  throw missingPolicy;
-               }
-            }
-
-            ec.setEvictionRegionConfigs(regionConfigs);
-         }
-      }
-
-      return ec;
-
-   }
-
-   public static EvictionRegionConfig parseEvictionRegionConfig(Element element,
-                                                                String defaultEvictionClass,
-                                                                int defaultQueueCapacity)
-   {
-      EvictionRegionConfig erc = new EvictionRegionConfig();
-
-      erc.setRegionName(element.getAttribute(EvictionRegionConfig.NAME));
-
-      String temp = element.getAttribute(EvictionRegionConfig.EVENT_QUEUE_SIZE);
-      if (temp != null && temp.length() > 0)
-      {
-         erc.setEventQueueSize(Integer.parseInt(temp));
-      }
-      else
-      {
-         erc.setEventQueueSize(defaultQueueCapacity);
-      }
-
-      String evictionClass = element.getAttribute(EvictionRegionConfig.REGION_POLICY_CLASS);
-      if (evictionClass == null || evictionClass.length() == 0)
-      {
-         evictionClass = defaultEvictionClass;
-         // if it's still null... what do we setCache?
-         if (evictionClass == null || evictionClass.length() == 0)
-         {
-            throw new MissingPolicyException(
-                  "There is no Eviction Policy Class specified on the region or for the entire cache!");
-         }
-      }
-
-      EvictionPolicy policy;
-      try
-      {
-         policy = (EvictionPolicy) Util.loadClass(evictionClass).newInstance();
-      }
-      catch (RuntimeException e)
-      {
-         throw e;
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException("Eviction class is not properly loaded in classloader", e);
-      }
-
-      EvictionPolicyConfig epc;
-      try
-      {
-         epc = policy.getEvictionConfigurationClass().newInstance();
-      }
-      catch (RuntimeException e)
-      {
-         throw e;
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException("Failed to instantiate eviction configuration of class " +
-               policy.getEvictionConfigurationClass(), e);
-      }
-
-      parseEvictionPolicyConfig(element, epc);
-
-      erc.setEvictionPolicyConfig(epc);
-
-      return erc;
-   }
-
-   public static void parseEvictionPolicyConfig(Element element, EvictionPolicyConfig target)
-   {
-      target.reset();
-      ParsedAttributes attributes = extractAttributes(element);
-      setValues(target, attributes.stringAttribs, false);
-      setValues(target, attributes.xmlAttribs, true);
-      target.validate();
-   }
-
-   /**
-    * Parses the cluster config which is used to start a JGroups channel
-    *
-    * @param config an old-style JGroups protocol config String
-    */
-   public static 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)
-         {
-            continue;
-         }
-
-         Element tag = (Element) node;
-         String protocol = tag.getTagName();
-         buffer.append(protocol);
-         NamedNodeMap attrs = tag.getAttributes();
-         int attrLength = attrs.getLength();
-         if (attrLength > 0)
-         {
-            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();
-   }
-
-   protected static ParsedAttributes extractAttributes(Element source)
-   {
-      Map<String, String> stringAttribs = new HashMap<String, String>();
-      Map<String, Element> xmlAttribs = new HashMap<String, Element>();
-      NodeList list = source.getElementsByTagName(XmlHelper.ATTR);
-      if (log.isDebugEnabled()) log.debug("Attribute size: " + list.getLength());
-
-      // loop through attributes
-      for (int loop = 0; loop < list.getLength(); loop++)
-      {
-         Node node = list.item(loop);
-         if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE) continue;
-
-         // for each element (attribute) ...
-         Element element = (Element) node;
-         String name = element.getAttribute(XmlHelper.NAME);
-         String valueStr = XmlHelper.getElementContent(element, true);
-
-         Element valueXml = null;
-         if (valueStr.length() == 0)
-         {
-            // This may be an XML element ...
-            valueXml = XmlHelper.getConfigSubElement(element);
-         }
-
-         // add these to the maps.
-
-         if (valueStr.length() > 0) stringAttribs.put(name, valueStr);
-         if (valueXml != null) xmlAttribs.put(name, valueXml);
-      }
-
-      return new ParsedAttributes(stringAttribs, xmlAttribs);
-   }
-
-   static class ParsedAttributes
-   {
-      final Map<String, String> stringAttribs;
-      final Map<String, Element> xmlAttribs;
-
-      ParsedAttributes(Map strings, Map elements)
-      {
-         this.stringAttribs = strings;
-         this.xmlAttribs = elements;
-      }
-   }
-}

Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -35,7 +35,7 @@
 import org.jboss.cache.config.ConfigurationException;
 import org.jboss.cache.config.EvictionConfig;
 import org.jboss.cache.config.RuntimeConfig;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.interceptors.base.CommandInterceptor;
 import org.jboss.cache.util.CachePrinter;
 import org.jgroups.Address;
@@ -374,7 +374,7 @@
       BuddyReplicationConfig brc = null;
       if (config != null)
       {
-         brc = XmlConfigurationParser.parseBuddyReplicationConfig(config);
+         brc = XmlConfigurationParserOld.parseBuddyReplicationConfig(config);
       }
       getConfiguration().setBuddyReplicationConfig(brc);
       this.buddyReplConfig = config;
@@ -385,7 +385,7 @@
       CacheLoaderConfig clc = null;
       if (cache_loader_config != null)
       {
-         clc = XmlConfigurationParser.parseCacheLoaderConfig(cache_loader_config);
+         clc = XmlConfigurationParserOld.parseCacheLoaderConfig(cache_loader_config);
       }
       getConfiguration().setCacheLoaderConfig(clc);
       this.cacheLoaderConfig = cache_loader_config;
@@ -408,7 +408,7 @@
       String props = null;
       if (config != null)
       {
-         props = XmlConfigurationParser.parseClusterConfigXml(config);
+         props = XmlConfigurationParserOld.parseClusterConfigXml(config);
       }
       getConfiguration().setClusterConfig(props);
       this.clusterConfig = config;
@@ -435,7 +435,7 @@
       EvictionConfig ec = null;
       if (config != null)
       {
-         ec = XmlConfigurationParser.parseEvictionConfig(config);
+         ec = XmlConfigurationParserOld.parseEvictionConfig(config);
       }
       getConfiguration().setEvictionConfig(ec);
       this.evictionConfig = config;

Deleted: core/trunk/src/main/java/org/jboss/cache/xml/XmlHelper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/xml/XmlHelper.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/main/java/org/jboss/cache/xml/XmlHelper.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -1,420 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.xml;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.util.StringPropertyReplacer;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * A simple XML utility class for reading configuration elements
- *
- * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
- */
-public class XmlHelper
-{
-   private static final Log log = LogFactory.getLog(XmlHelper.class);
-
-   /**
-    * The root of a JBoss Cache configuration XML file.  This is the <tt>&lt;mbean&gt;</tt> tag.
-    */
-   public static final String ROOT = "mbean";
-
-   /**
-    * The <tt>&lt;attribute&gt;</tt> tag which forms the bulk of JBoss Cache configuration elements
-    */
-   public static final String ATTR = "attribute";
-
-   /**
-    * The <tt>&lt;config&gt;</tt> tag may be embedded in the contents of an <tt>&lt;attribute&gt;</tt>, to specify more
-    * complex configuration for certain parameters.
-    */
-   public static final String CONFIG_ATTR = "config";
-
-   /**
-    * The <tt>&lt;name&gt;</tt> attribute to an <tt>&lt;attribute&gt;</tt> tag.
-    */
-   public static final String NAME = "name";
-
-
-   /**
-    * Returns the contents of a specific node of given element name, provided a certain attribute exists and is set to value.
-    * E.g., if you have a {@link Element} which represents the following XML snippet:
-    * <pre>
-    *   &lt;ItemQuantity Colour="Red"&gt;100&lt;/ItemQuantity&gt;
-    *   &lt;ItemQuantity Colour="Blue"&gt;30&lt;/ItemQuantity&gt;
-    *   &lt;ItemQuantity Colour="Black"&gt;10&lt;/ItemQuantity&gt;
-    * <pre>
-    * <p/>
-    * The following results could be expected:
-    * </p>
-    * <pre>
-    *    getTagContents(element, "Red", "ItemQuantity", "Colour"); // 100
-    *    getTagContents(element, "Black", "ItemQuantity", "Colour"); // 10
-    *    getTagContents(element, "Blah", "ItemQuantity", "Colour"); // null
-    *    getTagContents(element, "Red", "Blah", "Colour"); // null
-    *    getTagContents(element, "Black", "ItemQuantity", "Blah"); // null
-    * </pre>
-    * <p/>
-    * None of the parameters should be null - otherwise the method may throw a NullPointerException.
-    * </p>
-    *
-    * @param elem          - element to search through.
-    * @param value         - expected value to match against
-    * @param elementName   - element name
-    * @param attributeName - attribute name of the element that would contain the expected value.
-    * @return the contents of the matched element, or null if not found/matched
-    */
-   public static String getTagContents(Element elem, String value, String elementName, String attributeName)
-   {
-      NodeList list = elem.getElementsByTagName(elementName);
-
-      for (int s = 0; s < list.getLength(); s++)
-      {
-         org.w3c.dom.Node node = list.item(s);
-         if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
-            continue;
-
-         Element element = (Element) node;
-         String name = element.getAttribute(attributeName);
-         if (name.equals(value))
-         {
-            return getElementContent(element, true);
-         }
-      }
-      return null;
-   }
-
-   /**
-    * Retrieves the value of a given attribute for the first encountered instance of a tag in an element.
-    * <p/>
-    * E.g., if you have a {@link Element} which represents the following XML snippet:
-    * </p>
-    * <pre>
-    *   &lt;ItemQuantity Colour="Red"&gt;100&lt;/ItemQuantity&gt;
-    *   &lt;ItemQuantity Colour="Blue"&gt;30&lt;/ItemQuantity&gt;
-    *   &lt;ItemQuantity Colour="Black"&gt;10&lt;/ItemQuantity&gt;
-    * <pre>
-    * <p/>
-    * The following results could be expected:
-    * </p>
-    * <pre>
-    *    getAttributeValue(element, "ItemQuantity", "Colour"); // "Red"
-    *    getTagContents(element, "Blah", "Colour"); // null
-    *    getTagContents(element, "ItemQuantity", "Blah"); // null
-    * </pre>
-    * None of the parameters should be null - otherwise the method may throw a NullPointerException.
-    *
-    * @param elem          - element to search through.
-    * @param elementName   - element name
-    * @param attributeName - attribute name of the element that would contain the expected value.
-    * @return the contents of the matched attribute, or null if not found/matched
-    */
-   public static String getAttributeValue(Element elem, String elementName, String attributeName)
-   {
-      NodeList list = elem.getElementsByTagName(elementName);
-
-      for (int s = 0; s < list.getLength(); s++)
-      {
-         org.w3c.dom.Node node = list.item(s);
-         if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
-            continue;
-
-         Element element = (Element) node;
-         String value = element.getAttribute(attributeName);
-         return value == null ? null : StringPropertyReplacer.replaceProperties(value);
-
-      }
-      return null;
-   }
-
-   /**
-    * Convenience method, equivalent to calling <tt>getSubElement(element, "config");</tt>
-    */
-   public static Element getConfigSubElement(Element element)
-   {
-      return getSubElement(element, CONFIG_ATTR);
-   }
-
-   /**
-    * Returns a named sub-element of the current element passed in.
-    * <p/>
-    * None of the parameters should be null - otherwise the method may throw a NullPointerException.
-    *
-    * @param element        - element to search through.
-    * @param subElementName - the name of a sub element to look for
-    * @return the first matching sub element, if found, or null otherwise.
-    */
-   public static Element getSubElement(Element element, String subElementName)
-   {
-      NodeList nl = element.getChildNodes();
-      for (int i = 0; i < nl.getLength(); i++)
-      {
-         Node node = nl.item(i);
-         if (node.getNodeType() == Node.ELEMENT_NODE && subElementName.equals(((Element) node).getTagName()))
-         {
-            return (Element) node;
-         }
-      }
-
-      if (log.isDebugEnabled()) log.debug("getSubElement(): Does not exist for " + subElementName);
-      return null;
-   }
-
-   /**
-    * Reads the contents of the element passed in.
-    * <p/>
-    * None of the parameters should be null - otherwise the method may throw a NullPointerException.
-    *
-    * @param element - element to search through.
-    * @param trim    - if true, whitespace is trimmed before returning
-    * @return the contents of the element passed in.  Will return an empty String if the element is empty.
-    */
-   public static String getElementContent(Element element, boolean trim)
-   {
-      NodeList nl = element.getChildNodes();
-      String attributeText = "";
-      for (int i = 0; i < nl.getLength(); i++)
-      {
-         Node n = nl.item(i);
-         if (n instanceof Text)
-         {
-            attributeText += StringPropertyReplacer.replaceProperties(((Text) n).getData());
-         }
-      } // end of for ()
-      if (trim)
-         attributeText = attributeText.trim();
-      return attributeText;
-   }
-
-   /**
-    * Reads the contents of the first occurence of elementName under the given element, trimming results of whitespace.
-    * <p/>
-    * None of the parameters should be null - otherwise the method may throw a NullPointerException.
-    *
-    * @param element     - element to search through.
-    * @param elementName - name of the element to find within the element passed in
-    * @return may return an empty String of not found.
-    */
-   public static String readStringContents(Element element, String elementName)
-   {
-      NodeList nodes = element.getElementsByTagName(elementName);
-      if (nodes.getLength() > 0)
-      {
-         Node node = nodes.item(0);
-         Element ne = (Element) node;
-         NodeList nl2 = ne.getChildNodes();
-         Node node2 = nl2.item(0);
-         if (node2 != null)
-         {
-            String value = node2.getNodeValue();
-            if (value == null)
-               return "";
-            return StringPropertyReplacer.replaceProperties(value.trim());
-         }
-         else
-         {
-            return "";
-         }
-      }
-      else
-      {
-         return "";
-      }
-   }
-
-   /**
-    * Escapes backslashes ('\') with additional backslashes in a given String, returning a new, escaped String.
-    *
-    * @param value String to escape.   Cannot be null.
-    * @return escaped String.  Never is null.
-    */
-   public static String escapeBackslashes(String value)
-   {
-      StringBuffer buf = new StringBuffer(value);
-      for (int looper = 0; looper < buf.length(); looper++)
-      {
-         char curr = buf.charAt(looper);
-         char next = 0;
-         if (looper + 1 < buf.length())
-            next = buf.charAt(looper + 1);
-
-         if (curr == '\\')
-         {
-            if (next != '\\')
-            {           // only if not already escaped
-               buf.insert(looper, '\\');  // escape backslash
-            }
-            looper++;                    // skip past extra backslash (either the one we added or existing)
-         }
-      }
-      return buf.toString();
-   }
-
-   /**
-    * Reads the contents of a named sub element within a given element, and attempts to parse the contents as a Java
-    * properties file.
-    * <p/>
-    * E.g., if you have a {@link Element} which represents the following XML snippet:
-    * <p/>
-    * <pre>
-    *   &lt;props&gt;
-    *       my.attrib.1 = blah
-    *       my.attrib.2 = blahblah
-    *   &lt;/props&gt;
-    * <pre>
-    * <p/>
-    * The following results could be expected:
-    * <p/>
-    * <pre>
-    *    Properties p = readPropertiesContents(element, "props");
-    *    p.getProperty("my.attrib.1"); // blah
-    *    p.getProperty("my.attrib.2"); // blahblah
-    * </pre>
-    * None of the parameters should be null - otherwise the method may throw a NullPointerException.
-    *
-    * @param element     - element to search through.
-    * @param elementName - name of the element to find within the element passed in
-    * @return a {@link Properties} object, never null.
-    * @throws IOException if unable to parse the contents of the element
-    */
-   public static Properties readPropertiesContents(Element element, String elementName) throws IOException
-   {
-      String stringContents = readStringContents(element, elementName);
-      if (stringContents == null) return new Properties();
-      // JBCACHE-531: escape all backslash characters
-      stringContents = escapeBackslashes(stringContents);
-      ByteArrayInputStream is = new ByteArrayInputStream(stringContents.trim().getBytes("ISO8859_1"));
-      Properties properties = new Properties();
-      properties.load(is);
-      is.close();
-      return properties;
-   }
-
-   /**
-    * Similar to {@link #readStringContents(org.w3c.dom.Element,String)} except that it returns a boolean.
-    *
-    * @param element     - element to search through.
-    * @param elementName - name of the element to find within the element passed in
-    * @return the contents of the element as a boolean, or false if not found.
-    */
-   public static boolean readBooleanContents(Element element, String elementName)
-   {
-      return readBooleanContents(element, elementName, false);
-   }
-
-   /**
-    * Similar to {@link #readStringContents(org.w3c.dom.Element,String)} except that it returns a boolean.
-    *
-    * @param element      - element to search through.
-    * @param elementName  - name of the element to find within the element passed in
-    * @param defaultValue - value to return if the element is not found or cannot be parsed.
-    * @return the contents of the element as a boolean
-    */
-   public static boolean readBooleanContents(Element element, String elementName, boolean defaultValue)
-   {
-      String val = readStringContents(element, elementName);
-      if (val.equalsIgnoreCase("true") || val.equalsIgnoreCase("false"))
-      {
-         // needs to be done this way because of JBBUILD-351
-         return Boolean.valueOf(val);
-         //return Boolean.parseBoolean(val);
-      }
-      return defaultValue;
-   }
-
-   /**
-    * Converts a String representing an XML snippet into an {@link org.w3c.dom.Element}.
-    *
-    * @param xml snippet as a string
-    * @return a DOM Element
-    * @throws Exception if unable to parse the String or if it doesn't contain valid XML.
-    */
-   public static Element stringToElement(String xml) throws Exception
-   {
-      ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("utf8"));
-      DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-      Document d = builder.parse(bais);
-      bais.close();
-      return d.getDocumentElement();
-   }
-
-   /**
-    * Returns the root element of a given input stream
-    *
-    * @param is stream to parse
-    * @return XML DOM element, or null if unable to parse stream
-    */
-   public static Element getDocumentRoot(InputStream is)
-   {
-      Document doc;
-      try
-      {
-         InputSource xmlInp = new InputSource(is);
-
-         DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
-         DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
-         doc = parser.parse(xmlInp);
-         Element root = doc.getDocumentElement();
-         root.normalize();
-         return root;
-      }
-      catch (SAXParseException err)
-      {
-         log.error("Configurator SAXParse error", err);
-      }
-      catch (SAXException e)
-      {
-         log.error("Configurator SAX error", e);
-      }
-      catch (Exception pce)
-      {
-         log.error("Configurator general error", pce);
-      }
-      return null;
-   }
-
-   /**
-    * Retrieves the boolean value of a given attribute for the first encountered instance of elementName
-    *
-    * @param elem          - element to search
-    * @param elementName   - name of element to find
-    * @param attributeName - name of attribute to retrieve the value of
-    * @param defaultValue  - default value to return if not found
-    */
-   public static boolean readBooleanAttribute(Element elem, String elementName, String attributeName, boolean defaultValue)
-   {
-      String val = getAttributeValue(elem, elementName, attributeName);
-      if (val != null)
-      {
-         if (val.equalsIgnoreCase("true") || val.equalsIgnoreCase("false"))
-         {
-            //return Boolean.parseBoolean(val);
-            // needs to be done this way because of JBBUILD-351
-            return Boolean.valueOf(val);
-         }
-      }
-
-      return defaultValue;
-   }
-
-}

Modified: core/trunk/src/test/java/org/jboss/cache/CacheFactoryTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/CacheFactoryTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/CacheFactoryTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -7,7 +7,7 @@
 package org.jboss.cache;
 
 import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.lock.IsolationLevel;
 import org.jboss.cache.util.TestingUtil;
 import org.jboss.cache.transaction.DummyTransactionManagerLookup;
@@ -31,7 +31,7 @@
    @BeforeMethod(alwaysRun = true)
    public void setUp()
    {
-      XmlConfigurationParser parser = new XmlConfigurationParser();
+      XmlConfigurationParserOld parser = new XmlConfigurationParserOld();
       expected = parser.parseFile(configFile);
    }
 

Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -9,10 +9,10 @@
 import org.jboss.cache.NodeNotExistsException;
 import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.loader.DummyInMemoryCacheLoader;
 import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
@@ -544,7 +544,7 @@
             "<purgeOnStartup>" + purgeOnStartup + "</purgeOnStartup>\n" +
             "</cacheloader>\n" +
             "</config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 }

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -12,9 +12,9 @@
 import org.jboss.cache.commands.write.PutKeyValueCommand;
 import org.jboss.cache.config.BuddyReplicationConfig;
 import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.factories.CommandsFactory;
-import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
@@ -43,8 +43,8 @@
       String xmlConfig = "<config><buddyReplicationEnabled>true</buddyReplicationEnabled>\n" +
             "          <buddyLocatorProperties>numBuddies = 3</buddyLocatorProperties>\n" +
             "          <buddyPoolName>groupOne</buddyPoolName></config>";
-      Element element = XmlHelper.stringToElement(xmlConfig);
-      BuddyReplicationConfig config = XmlConfigurationParser.parseBuddyReplicationConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xmlConfig);
+      BuddyReplicationConfig config = XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
       BuddyManager mgr = new BuddyManager(config);
 
       assertTrue(mgr.isEnabled());
@@ -66,8 +66,8 @@
             "          <buddyLocatorClass>org.i.dont.exist.PhantomBuddyLocator</buddyLocatorClass>\n" +
             "          <buddyLocatorProperties>numBuddies = 3</buddyLocatorProperties>\n" +
             "          <buddyPoolName>groupOne</buddyPoolName></config>";
-      Element element = XmlHelper.stringToElement(xmlConfig);
-      BuddyReplicationConfig config = XmlConfigurationParser.parseBuddyReplicationConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xmlConfig);
+      BuddyReplicationConfig config = XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
       BuddyManager mgr = new BuddyManager(config);
 
       assertTrue(mgr.isEnabled());
@@ -89,8 +89,8 @@
    {
       String xmlConfig = "<config><buddyReplicationEnabled>false</buddyReplicationEnabled></config>";
 
-      Element element = XmlHelper.stringToElement(xmlConfig);
-      BuddyReplicationConfig config = XmlConfigurationParser.parseBuddyReplicationConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xmlConfig);
+      BuddyReplicationConfig config = XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
       BuddyManager mgr = new BuddyManager(config);
 
       assertTrue(!mgr.isEnabled());
@@ -105,8 +105,8 @@
    {
       String xmlConfig = "<config><buddyReplicationEnabled>true</buddyReplicationEnabled></config>";
 
-      Element element = XmlHelper.stringToElement(xmlConfig);
-      BuddyReplicationConfig config = XmlConfigurationParser.parseBuddyReplicationConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xmlConfig);
+      BuddyReplicationConfig config = XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
       BuddyManager mgr = new BuddyManager(config);
 
       assertTrue(mgr.isEnabled());
@@ -122,8 +122,8 @@
       BuddyManager bm = null;
       try
       {
-         Element element = XmlHelper.stringToElement("<config><buddyReplicationEnabled>true</buddyReplicationEnabled></config>");
-         BuddyReplicationConfig cfg = XmlConfigurationParser.parseBuddyReplicationConfig(element);
+         Element element = XmlConfigHelper.stringToElement("<config><buddyReplicationEnabled>true</buddyReplicationEnabled></config>");
+         BuddyReplicationConfig cfg = XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
          bm = new BuddyManager(cfg);
          bm.injectDependencies(null, null, null, null, null, null, null, null, new BuddyFqnTransformer());
          CommandsFactory commandsFactory = new CommandsFactory();

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -11,10 +11,10 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.config.BuddyReplicationConfig;
 import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.interceptors.DataGravitatorInterceptor;
 import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.Test;
@@ -47,8 +47,8 @@
    public void testDisabledConfig() throws Exception
    {
       String xmlConfig = "<config><buddyReplicationEnabled>false</buddyReplicationEnabled></config>";
-      Element element = XmlHelper.stringToElement(xmlConfig);
-      BuddyReplicationConfig config = XmlConfigurationParser.parseBuddyReplicationConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xmlConfig);
+      BuddyReplicationConfig config = XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
       cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
       cache.getConfiguration().setBuddyReplicationConfig(config);
       assertNull(cache.getBuddyManager());
@@ -57,8 +57,8 @@
    public void testBasicConfig() throws Exception
    {
       String xmlConfig = "<config><buddyReplicationEnabled>true</buddyReplicationEnabled></config>";
-      Element element = XmlHelper.stringToElement(xmlConfig);
-      BuddyReplicationConfig config = XmlConfigurationParser.parseBuddyReplicationConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xmlConfig);
+      BuddyReplicationConfig config = XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
       cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
       cache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
       cache.getConfiguration().setBuddyReplicationConfig(config);
@@ -76,7 +76,7 @@
 
    public void testXmlConfig() throws Exception
    {
-      cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(new XmlConfigurationParser().parseFile("META-INF/buddy-replication-cache-service.xml"), false);
+      cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(new XmlConfigurationParserOld().parseFile("META-INF/buddy-replication-cache-service.xml"), false);
       cache.create();
       cache.start();
       BuddyManager bm = cache.getBuddyManager();
@@ -105,8 +105,8 @@
    public void testLocalModeConfig() throws Exception
    {
       String xmlConfig = "<config><buddyReplicationEnabled>true</buddyReplicationEnabled></config>";
-      Element element = XmlHelper.stringToElement(xmlConfig);
-      BuddyReplicationConfig config = XmlConfigurationParser.parseBuddyReplicationConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xmlConfig);
+      BuddyReplicationConfig config = XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
       cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
       cache.getConfiguration().setBuddyReplicationConfig(config);
       cache.create();

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -13,14 +13,14 @@
 import org.jboss.cache.config.BuddyReplicationConfig;
 import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.config.Configuration.CacheMode;
 import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.factories.XmlConfigurationParser;
 import org.jboss.cache.loader.CacheLoader;
 import org.jboss.cache.loader.CacheLoaderManager;
 import org.jboss.cache.loader.DummyInMemoryCacheLoader;
 import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jgroups.Address;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.AfterMethod;
@@ -139,8 +139,8 @@
 
       if (buddyPoolName != null) xmlString += "<buddyPoolName>" + buddyPoolName + "</buddyPoolName>";
       xmlString += "</config>";
-      Element element = XmlHelper.stringToElement(xmlString);
-      BuddyReplicationConfig config = XmlConfigurationParser.parseBuddyReplicationConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xmlString);
+      BuddyReplicationConfig config = XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
       c.getConfiguration().setBuddyReplicationConfig(config);
 
       c.getConfiguration().setFetchInMemoryState(true);
@@ -236,8 +236,8 @@
             "</cacheloader>\n" +
             "</config>";
 
-      Element element = XmlHelper.stringToElement(cloader);
-      CacheLoaderConfig cfg = XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(cloader);
+      CacheLoaderConfig cfg = XmlConfigurationParserOld.parseCacheLoaderConfig(element);
       cache.getConfiguration().setCacheLoaderConfig(cfg);
       if (start)
       {

Modified: core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/config/ConfigurationCloningTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -22,8 +22,8 @@
 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
 import org.jboss.cache.config.Configuration.CacheMode;
 import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.eviction.LRUPolicy;
-import org.jboss.cache.factories.XmlConfigurationParser;
 import org.testng.annotations.Test;
 
 /**
@@ -42,7 +42,7 @@
    
    public void testClone() throws Exception
    {
-      XmlConfigurationParser parser = new XmlConfigurationParser();
+      XmlConfigurationParserOld parser = new XmlConfigurationParserOld();
       Configuration c = parser.parseFile(DEFAULT_CONFIGURATION_FILE);
       
       try {

Modified: core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -12,7 +12,7 @@
 
 import org.jboss.cache.config.Configuration.CacheMode;
 import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.lock.IsolationLevel;
 import org.jboss.cache.transaction.TransactionSetup;
 import org.testng.annotations.Test;
@@ -47,7 +47,7 @@
 
    public void testMultiplexerStack() throws Exception
    {
-      XmlConfigurationParser parser = new XmlConfigurationParser();
+      XmlConfigurationParserOld parser = new XmlConfigurationParserOld();
       Configuration conf = parser.parseFile("META-INF/conf-test/mux-service.xml");
 
       // test that multiplexer settings have been read in properly.

Modified: core/trunk/src/test/java/org/jboss/cache/config/StringPropertyReplacementTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/StringPropertyReplacementTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/config/StringPropertyReplacementTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -17,7 +17,7 @@
 import org.jboss.cache.config.Configuration.NodeLockingScheme;
 import org.jboss.cache.eviction.LRUConfiguration;
 import org.jboss.cache.eviction.LRUPolicy;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -93,7 +93,7 @@
       System.setProperty(MAX_NODES_PROP, "1000");
       System.setProperty(BUDDY_POOL_PROP, "replaced");
       
-      Configuration cfg = new XmlConfigurationParser().parseFile(STRING_REPLACED_FILE);
+      Configuration cfg = new XmlConfigurationParserOld().parseFile(STRING_REPLACED_FILE);
       
       assertEquals(NodeLockingScheme.OPTIMISTIC, cfg.getNodeLockingScheme());
       assertEquals(CacheMode.REPL_SYNC, cfg.getCacheMode());

Added: core/trunk/src/test/java/org/jboss/cache/config/XmlConfigurationParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/XmlConfigurationParserTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/config/XmlConfigurationParserTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -0,0 +1,226 @@
+package org.jboss.cache.config;
+
+import org.jboss.cache.config.parsing.XmlConfigurationParser;
+import org.jboss.cache.eviction.LRUConfiguration;
+import org.jboss.cache.eviction.MRUConfiguration;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ * @since 3.0
+ */
+ at Test(groups = "unit")
+public class XmlConfigurationParserTest
+{
+   Configuration config;
+
+   @BeforeMethod
+   public void setUp()
+   {
+      XmlConfigurationParser parser = new XmlConfigurationParser();
+      config = parser.parseFile("META-INF/conf-test/parser-test-file-3.x.xml");
+   }
+
+   public void testTransactionManagerLookupClass()
+   {
+      assert config.getTransactionManagerLookupClass().equals("org.jboss.cache.transaction.GenericTransactionManagerLookup");
+   }
+
+   public void testIsolationLevel()
+   {
+      assert config.getIsolationLevel().equals(IsolationLevel.REPEATABLE_READ);
+   }
+
+   public void testCacheMode()
+   {
+      assert config.getCacheMode().equals(Configuration.CacheMode.REPL_SYNC);
+   }
+
+   public void testUseReplQueue()
+   {
+      assert !config.isUseReplQueue();
+   }
+
+   public void testClusterName()
+   {
+      assert config.getClusterName().equals("JBossCache-Cluster");
+   }
+
+   public void testGetClusterConfig()
+   {
+      assert config.getClusterConfig().indexOf("MERGE2") >= 0;
+   }
+
+   public void testFetchInMemoryState()
+   {
+      assert config.isFetchInMemoryState();
+   }
+
+   public void testStateRetrievalTimeout()
+   {
+      assert config.getStateRetrievalTimeout() == 15124;
+   }
+
+   public void testSyncReplTimeout()
+   {
+      assert config.getSyncReplTimeout() == 15421;
+   }
+
+   public void testLockAcquisitionTimeout()
+   {
+      assert config.getLockAcquisitionTimeout() == 10234;
+   }
+
+   public void testUseLazyDeserialization()
+   {
+      assert config.isUseLazyDeserialization();
+   }
+
+   public void testObjectInputStreamPoolSize()
+   {
+      assert 12 == config.getObjectInputStreamPoolSize();
+   }
+
+   public void testObjectOutputStreamPoolSize()
+   {
+      assert 14 == config.getObjectOutputStreamPoolSize();
+   }
+
+   public void testShutdownHookBehavior()
+   {
+      assert Configuration.ShutdownHookBehavior.REGISTER == config.getShutdownHookBehavior();
+   }
+
+   public void testSyncRollbackPhase()
+   {
+      assert config.isSyncRollbackPhase();
+   }
+
+   public void testSyncCommitPhase()
+   {
+      assert config.isSyncCommitPhase();
+   }
+
+   public void testUseReplicationVersion()
+   {
+      assert config.getReplicationVersion() == 124;
+   }
+
+   public void testGetMultiplexerStack()
+   {
+      assert "file_name".equals(config.getMultiplexerStack());
+   }
+
+   public void testMarshallerClass()
+   {
+      assert "some.Clazz".equals(config.getMarshallerClass());
+   }
+
+   public void testLockParentForChildInsertRemove()
+   {
+      assert config.isLockParentForChildInsertRemove();
+   }
+
+   public void testInactiveOnStartup()
+   {
+      assert config.isInactiveOnStartup();
+   }
+
+   public void testExposeManagementStatistics()
+   {
+      assert !config.getExposeManagementStatistics();
+   }
+
+   public void testCacheLoaderConfiguration()
+   {
+      CacheLoaderConfig clc = config.getCacheLoaderConfig();
+      assert null != clc;
+      assert clc.isPassivation();
+      assert clc.isShared();
+      assert "/a/b/c,/f/r/s".equals(clc.getPreload());
+      CacheLoaderConfig.IndividualCacheLoaderConfig first = clc.getFirstCacheLoaderConfig();
+      assert "org.jboss.cache.loader.JDBCCacheLoader".equals(first.getClassName());
+      assert first.isAsync();
+      assert first.isFetchPersistentState();
+      assert first.isIgnoreModifications();
+      assert first.isPurgeOnStartup();
+      assert first.getProperties().get("cache.jdbc.table.name").equals("jbosscache");
+      assert first.getProperties().get("cache.jdbc.table.create").equals("true");
+      assert first.getProperties().get("cache.jdbc.table.drop").equals("true");
+   }
+
+   public void testBuddyReplicationConfig()
+   {
+      BuddyReplicationConfig brConfig = config.getBuddyReplicationConfig();
+      assert brConfig.isEnabled();
+      BuddyReplicationConfig.BuddyLocatorConfig locatorConfig = brConfig.getBuddyLocatorConfig();
+      assert "org.jboss.cache.buddyreplication.NextMemberBuddyLocator".equals(locatorConfig.getBuddyLocatorClass());
+      assert locatorConfig.getBuddyLocatorProperties().get("numBuddies").equals("1");
+      assert locatorConfig.getBuddyLocatorProperties().get("ignoreColocatedBuddies").equals("true");
+      assert brConfig.getBuddyPoolName().equals("myBuddyPoolReplicationGroup");
+      assert brConfig.getBuddyCommunicationTimeout() == 2000;
+      assert brConfig.isAutoDataGravitation();
+      assert brConfig.isDataGravitationRemoveOnFind();
+      assert brConfig.isDataGravitationSearchBackupTrees();
+   }
+
+   public void testUseRegionBasedMarshalling()
+   {
+      assert config.isUseRegionBasedMarshalling();
+   }
+
+   public void testEvictionPolicyConfig()
+   {
+      EvictionConfig evictionConfig = config.getEvictionConfig();
+      assert "org.jboss.cache.eviction.LRUPolicy".equals(evictionConfig.getDefaultEvictionPolicyClass());
+      assert 200000 == evictionConfig.getDefaultEventQueueSize();
+      assert 5 == evictionConfig.getWakeupIntervalSeconds();
+
+      List<EvictionRegionConfig> regionConfigs = evictionConfig.getEvictionRegionConfigs();
+      assert regionConfigs.size() == 3;
+
+      EvictionRegionConfig first = regionConfigs.get(0);
+      assert first.getRegionName().equals("/_default_");
+      assert first.getEvictionPolicyConfig() instanceof LRUConfiguration;
+      LRUConfiguration firstConfiguration = (LRUConfiguration) first.getEvictionPolicyConfig();
+      assert firstConfiguration.getMaxAge() <= 0;
+      assert firstConfiguration.getTimeToLive() == 1000;
+      assert firstConfiguration.getMaxNodes() == 5000;
+
+      EvictionRegionConfig second = regionConfigs.get(1);
+      LRUConfiguration secondConfiguration = (LRUConfiguration) second.getEvictionPolicyConfig();
+      assert secondConfiguration.getMaxAge() == 0;
+      assert secondConfiguration.getTimeToLive() == 1002;
+      assert secondConfiguration.getMaxNodes() == 0;
+
+      EvictionRegionConfig third = regionConfigs.get(2);
+      MRUConfiguration thirdConfiguration = (MRUConfiguration) third.getEvictionPolicyConfig();
+      assert thirdConfiguration.getMaxNodes() == 2103;
+      assert thirdConfiguration.getMinTimeToLive() == 22;
+      assert third.getEventQueueSize() == 21;
+   }
+
+   public void testCustomInterceptors()
+   {
+      List<CustomInterceptorConfig> interceptorConfigs = config.getCustomInterceptors();
+      if (interceptorConfigs.isEmpty()) return; //todo drop this once you drop the old configuration
+      assert interceptorConfigs.size() == 5;
+      assert interceptorConfigs.get(0).getInterceptorClass().equals("com.myCompany.MyInterceptor1");
+      assert interceptorConfigs.get(1).getInterceptorClass().equals("com.myCompany.MyInterceptor2");
+      assert interceptorConfigs.get(2).getInterceptorClass().equals("com.myCompany.MyInterceptor3");
+      assert interceptorConfigs.get(3).getInterceptorClass().equals("com.myCompany.MyInterceptor4");
+      assert interceptorConfigs.get(4).getInterceptorClass().equals("com.myCompany.MyInterceptor5");
+      assert interceptorConfigs.get(0).isFirst();
+      assert !interceptorConfigs.get(0).isLast();
+      assert interceptorConfigs.get(0).getProperties().get("x").equals("y");
+      assert interceptorConfigs.get(0).getProperties().get("i").equals("10");
+      assert interceptorConfigs.get(1).isLast();
+      assert interceptorConfigs.get(2).getIndex() == 3;
+      assert interceptorConfigs.get(3).getBeforeClass().equals("org.jboss.cache.interceptors.CallInterceptor");
+      assert interceptorConfigs.get(4).getAfterClass().equals("org.jboss.cache.interceptors.CallInterceptor");
+   }
+}

Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurationTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeConfigurationTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -11,8 +11,8 @@
 import static org.testng.AssertJUnit.fail;
 
 import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.EvictionElementParser;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
 /**
@@ -30,8 +30,8 @@
                    "<attribute name=\"maxElementsPerNode\">100</attribute>" +
                    "</region>";
 
-      Element element = XmlHelper.stringToElement(xml);
-      XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      EvictionElementParser.parseEvictionPolicyConfig(element, config);
 
       assertEquals(100, config.getMaxElementsPerNode());
       assertEquals(1000, config.getMaxNodes());
@@ -45,10 +45,10 @@
                    "<attribute name=\"maxNodes\">1000</attribute>" +
                    "</region>";
 
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
       try
       {
-         XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+         EvictionElementParser.parseEvictionPolicyConfig(element, config);
       }
       catch (ConfigurationException ce)
       {
@@ -67,9 +67,9 @@
                    "<attribute name=\"maxElementsPerNode\">100</attribute>" +
                    "</region>";
 
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
 
-      XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+      EvictionElementParser.parseEvictionPolicyConfig(element, config);
 
       assertEquals(100, config.getMaxElementsPerNode());
       assertEquals(0, config.getMaxNodes());

Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOConfigurationTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -11,8 +11,8 @@
 import static org.testng.AssertJUnit.fail;
 
 import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.EvictionElementParser;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
 
@@ -33,9 +33,9 @@
             "<attribute name=\"maxNodes\">1000</attribute>" +
             "</region>";
 
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
 
-      XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+      EvictionElementParser.parseEvictionPolicyConfig(element, config);
 
       assertEquals(1000, config.getMaxNodes());
 
@@ -47,11 +47,11 @@
       String xml = "<region name=\"abc\">" +
             "</region>";
 
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
 
       try
       {
-         XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+         EvictionElementParser.parseEvictionPolicyConfig(element, config);
       }
       catch (ConfigurationException ce)
       {
@@ -68,11 +68,11 @@
             "<attribute name=\"maxNodes\">1000</attribute>" +
             "</region>";
 
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
 
       try
       {
-         XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+         EvictionElementParser.parseEvictionPolicyConfig(element, config);
       }
       catch (ConfigurationException ce)
       {

Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUConfigurationTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -8,8 +8,8 @@
 
 import static org.testng.AssertJUnit.assertEquals;
 
-import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.EvictionElementParser;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
 
@@ -32,9 +32,9 @@
             "<attribute name=\"maxNodes\">20</attribute>" +
             "</region>";
 
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
 
-      XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+      EvictionElementParser.parseEvictionPolicyConfig(element, config);
 
       assertEquals(10, config.getMinNodes());
       assertEquals(20, config.getMaxNodes());
@@ -47,9 +47,9 @@
             "<region name=\"abc\">" +
             "<attribute name=\"minNodes\">10</attribute>" +
             "</region>";
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
 
-      XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+      EvictionElementParser.parseEvictionPolicyConfig(element, config);
 
       assertEquals(10, config.getMinNodes());
       assertEquals(0, config.getMaxNodes());
@@ -62,9 +62,9 @@
             "<region name=\"abc\">" +
             "<attribute name=\"maxNodes\">20</attribute>" +
             "</region>";
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
 
-      XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+      EvictionElementParser.parseEvictionPolicyConfig(element, config);
 
       assertEquals(0, config.getMinNodes());
       assertEquals(20, config.getMaxNodes());

Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUConfigurationTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -10,8 +10,8 @@
 import static org.testng.AssertJUnit.assertTrue;
 
 import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.EvictionElementParser;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
 
@@ -34,9 +34,9 @@
                   "<attribute name=\"timeToLiveSeconds\">1000</attribute>\n" +
                   "</region>";
 
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
 
-      XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+      EvictionElementParser.parseEvictionPolicyConfig(element, config);
 
       assertEquals(5000, config.getMaxNodes());
       assertEquals(1000, config.getTimeToLiveSeconds());
@@ -50,9 +50,9 @@
             "<attribute name=\"timeToLiveSeconds\">8</attribute>\n" +
             "<attribute name=\"maxAgeSeconds\">10</attribute>\n" +
             "</region>";
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
 
-      XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+      EvictionElementParser.parseEvictionPolicyConfig(element, config);
 
       assertEquals(10000, config.getMaxNodes());
       assertEquals(8, config.getTimeToLiveSeconds());
@@ -66,11 +66,11 @@
             "<attribute name=\"maxNodes\">10000</attribute>\n" +
             "<attribute name=\"maxAgeSeconds\">10</attribute>\n" +
             "</region>";
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
       boolean caught = false;
       try
       {
-         XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+         EvictionElementParser.parseEvictionPolicyConfig(element, config);
       }
       catch (ConfigurationException ce)
       {
@@ -83,9 +83,9 @@
             "<attribute name=\"maxAgeSeconds\">10</attribute>\n" +
             "</region>";
 
-      element = XmlHelper.stringToElement(xml);
+      element = XmlConfigHelper.stringToElement(xml);
 
-      XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+      EvictionElementParser.parseEvictionPolicyConfig(element, config);
 
       assertEquals(0, config.getMaxNodes());
    }

Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUConfigurationTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -10,8 +10,8 @@
 import static org.testng.AssertJUnit.assertTrue;
 
 import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.EvictionElementParser;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
@@ -39,9 +39,9 @@
             "<region name=\"/org/jboss/data\">\n" +
                   "<attribute name=\"maxNodes\">5000</attribute>\n" +
                   "</region>";
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
 
-      XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+      EvictionElementParser.parseEvictionPolicyConfig(element, config);
 
       assertEquals(5000, config.getMaxNodes());
    }
@@ -51,9 +51,9 @@
       String xml = "<region name=\"/Test/\">\n" +
             "<attribute name=\"maxNodes\">10000</attribute>\n" +
             "</region>";
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
 
-      XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+      EvictionElementParser.parseEvictionPolicyConfig(element, config);
 
       assertEquals(10000, config.getMaxNodes());
    }
@@ -62,11 +62,11 @@
    {
       String xml = "<region name=\"/Test/\">\n" +
             "</region>";
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
       boolean caught = false;
       try
       {
-         XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+         EvictionElementParser.parseEvictionPolicyConfig(element, config);
       }
       catch (ConfigurationException ce)
       {
@@ -78,9 +78,9 @@
             "<attribute name=\"maxNodes\">10000</attribute>\n" +
             "</region>";
 
-      element = XmlHelper.stringToElement(xml);
+      element = XmlConfigHelper.stringToElement(xml);
 
-      XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+      EvictionElementParser.parseEvictionPolicyConfig(element, config);
 
       assertEquals(10000, config.getMaxNodes());
    }

Modified: core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -8,8 +8,8 @@
 
 import static org.testng.AssertJUnit.fail;
 
-import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.EvictionElementParser;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
 
@@ -73,11 +73,11 @@
     */
    private void testConfigBlock(String xml) throws Exception
    {
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
       NullEvictionPolicyConfig config = new NullEvictionPolicyConfig();
       try
       {
-         XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+         EvictionElementParser.parseEvictionPolicyConfig(element, config);
       }
       catch (Exception e)
       {

Modified: core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -5,12 +5,12 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.factories.XmlConfigurationParser;
 import org.jboss.cache.interceptors.EvictionInterceptor;
 import org.jboss.cache.util.TestingUtil;
 import org.jboss.cache.transaction.DummyTransactionManagerLookup;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import static org.testng.AssertJUnit.assertFalse;
 import static org.testng.AssertJUnit.assertTrue;
 import org.testng.annotations.AfterMethod;
@@ -77,8 +77,8 @@
             "            </region>\n" +
             "         </config>\n" +
             "      </attribute>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseEvictionConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseEvictionConfig(element);
    }
 
    @AfterMethod(alwaysRun = true)

Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -31,11 +31,11 @@
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.EvictionConfig;
 import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.factories.XmlConfigurationParser;
 import org.jboss.cache.lock.IsolationLevel;
 import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.xml.XmlHelper;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
@@ -93,10 +93,10 @@
             "<attribute name=\"maxNodes\">10000</attribute>" +
             "<attribute name=\"timeToLiveSeconds\">4</attribute>" +
             "</region>";
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
       RegionManager regionManager = cache_.getRegionManager();
       EvictionConfig topConfig = cache_.getConfiguration().getEvictionConfig();
-      EvictionRegionConfig erc = XmlConfigurationParser.parseEvictionRegionConfig(element, topConfig.getDefaultEvictionPolicyClass(), topConfig.getDefaultEventQueueSize());
+      EvictionRegionConfig erc = XmlConfigurationParserOld.parseEvictionRegionConfig(element, topConfig.getDefaultEvictionPolicyClass(), topConfig.getDefaultEventQueueSize());
       regionManager.setEvictionConfig(topConfig);
       // Fqn is the region name
       regionManager.getRegion("/programmatic", true).setEvictionPolicy(erc.getEvictionPolicyConfig());
@@ -131,10 +131,10 @@
             "<attribute name=\"maxNodes\">10000</attribute>" +
             "<attribute name=\"timeToLiveSeconds\">4</attribute>" +
             "</region>";
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
       RegionManager regionManager = cache_.getRegionManager();
       EvictionConfig topEC = cache_.getConfiguration().getEvictionConfig();
-      EvictionRegionConfig erc = XmlConfigurationParser.parseEvictionRegionConfig(element,
+      EvictionRegionConfig erc = XmlConfigurationParserOld.parseEvictionRegionConfig(element,
             topEC.getDefaultEvictionPolicyClass(),
             topEC.getDefaultEventQueueSize());
       // Fqn is the region name

Modified: core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -6,8 +6,8 @@
 import org.jboss.cache.config.EvictionConfig;
 import org.jboss.cache.config.EvictionPolicyConfig;
 import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -110,10 +110,10 @@
             "<attribute name=\"minNodes\">10</attribute>" +
             "<attribute name=\"maxNodes\">20</attribute>" +
             "</region>";
-      Element element = XmlHelper.stringToElement(xml);
+      Element element = XmlConfigHelper.stringToElement(xml);
       RegionManager regionManager = new RegionManager();
       regionManager.setUsingEvictions(true);
-      EvictionRegionConfig erc = XmlConfigurationParser.parseEvictionRegionConfig(element, null, EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
+      EvictionRegionConfig erc = XmlConfigurationParserOld.parseEvictionRegionConfig(element, null, EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
       Region region = regionManager.getRegion(erc.getRegionFqn(), true);
       region.setEvictionPolicy(erc.getEvictionPolicyConfig());
 
@@ -129,8 +129,8 @@
             "<attribute name=\"minNodes\">10</attribute>" +
             "<attribute name=\"maxNodes\">20</attribute>" +
             "</region>";
-      element = XmlHelper.stringToElement(xml);
-      erc = XmlConfigurationParser.parseEvictionRegionConfig(element, "org.jboss.cache.eviction.LFUPolicy", EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
+      element = XmlConfigHelper.stringToElement(xml);
+      erc = XmlConfigurationParserOld.parseEvictionRegionConfig(element, "org.jboss.cache.eviction.LFUPolicy", EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
       regionManager = new RegionManager();
       regionManager.setUsingEvictions(true);
       region = regionManager.getRegion(erc.getRegionFqn(), true);

Modified: core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -6,10 +6,11 @@
 import org.jboss.cache.config.BuddyReplicationConfig;
 import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jboss.cache.interceptors.*;
 import org.jboss.cache.interceptors.base.CommandInterceptor;
 import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.xml.XmlHelper;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertNotNull;
 import org.testng.annotations.AfterMethod;
@@ -104,8 +105,8 @@
             "                </cacheloader>\n" +
             "                \n" +
             "            </config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 
    public void testSharedCacheLoaderConfig() throws Exception
@@ -392,8 +393,8 @@
 
       xmlString += "<buddyPoolName>buddyPoolName</buddyPoolName>";
       xmlString += "</config>";
-      Element element = XmlHelper.stringToElement(xmlString);
-      BuddyReplicationConfig brc = XmlConfigurationParser.parseBuddyReplicationConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xmlString);
+      BuddyReplicationConfig brc = XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
       cache.getConfiguration().setBuddyReplicationConfig(brc);
 
       cache.getConfiguration().setCacheMode("REPL_SYNC");
@@ -431,8 +432,8 @@
 
       xmlString += "<buddyPoolName>buddyPoolName</buddyPoolName>";
       xmlString += "</config>";
-      Element element = XmlHelper.stringToElement(xmlString);
-      BuddyReplicationConfig brc = XmlConfigurationParser.parseBuddyReplicationConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xmlString);
+      BuddyReplicationConfig brc = XmlConfigurationParserOld.parseBuddyReplicationConfig(element);
       cache.getConfiguration().setBuddyReplicationConfig(brc);
 
       cache.getConfiguration().setCacheMode("REPL_SYNC");

Modified: core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/factories/UnitTestCacheConfigurationFactory.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -11,9 +11,11 @@
 import org.jboss.cache.config.Configuration.CacheMode;
 import org.jboss.cache.config.ConfigurationException;
 import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.ParsedAttributes;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jboss.cache.eviction.LRUConfiguration;
 import org.jboss.cache.transaction.TransactionSetup;
-import org.jboss.cache.xml.XmlHelper;
 import org.jgroups.conf.XmlConfigurator;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
@@ -100,8 +102,8 @@
             "<purgeOnStartup>" + purgeOnStartup + "</purgeOnStartup>\n" +
             "</cacheloader>\n" +
             "</config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 
    /**
@@ -174,7 +176,7 @@
       return erc;
    }
 
-   private static class UnitTestXmlConfigurationParser extends XmlConfigurationParser
+   private static class UnitTestXmlConfigurationParser extends XmlConfigurationParserOld
    {
 
       public Configuration parseFile(String filename, CacheMode mode)
@@ -187,10 +189,10 @@
          // loop through all elements in XML.
          if (stream == null) throw new ConfigurationException("Input stream for configuration xml is null!");
 
-         Element root = XmlHelper.getDocumentRoot(stream);
+         Element root = XmlConfigHelper.getDocumentRoot(stream);
          Element mbeanElement = getMBeanElement(root);
 
-         ParsedAttributes attributes = extractAttributes(mbeanElement);
+         ParsedAttributes attributes = XmlConfigHelper.extractAttributes(mbeanElement);
 
          // Deal with rename of the old property that controlled MBean registration
          String keepStats = attributes.stringAttribs.remove("UseMbean");
@@ -200,7 +202,7 @@
          }
 
          Configuration c = new Configuration();
-         setValues(c, attributes.stringAttribs, false);
+         XmlConfigHelper.setValues(c, attributes.stringAttribs, false);
          // Special handling for XML elements -- we hard code the parsing
          setXmlValues(c, attributes.xmlAttribs);
 

Modified: core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -17,9 +17,9 @@
 import org.jboss.cache.util.internals.ReplicationListener;
 import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.optimistic.DefaultDataVersion;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.Test;
@@ -919,8 +919,8 @@
             "                </cacheloader>\n" +
             "                \n" +
             "            </config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 
    protected void assertHasBeenInvalidated(Node n, String message)

Modified: core/trunk/src/test/java/org/jboss/cache/jmx/LegacyConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/LegacyConfigurationTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/LegacyConfigurationTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -24,6 +24,7 @@
 
 import org.jboss.cache.Version;
 import org.jboss.cache.config.*;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
 import org.jboss.cache.config.Configuration.CacheMode;
@@ -35,12 +36,10 @@
 import org.jboss.cache.lock.IsolationLevel;
 import org.jboss.cache.multiplexer.MultiplexerTestHelper;
 import org.jboss.cache.transaction.BatchModeTransactionManagerLookup;
-import org.jboss.cache.xml.XmlHelper;
 import org.jgroups.ChannelFactory;
 import org.jgroups.JChannelFactory;
 import org.jgroups.jmx.JChannelFactoryMBean;
 import static org.testng.AssertJUnit.*;
-import org.testng.annotations.Test;
 import org.w3c.dom.Element;
 
 import javax.management.MBeanServerInvocationHandler;
@@ -263,7 +262,7 @@
                          "          <dataGravitationRemoveOnFind>false</dataGravitationRemoveOnFind>\n" +
                          "          <dataGravitationSearchBackupTrees>false</dataGravitationSearchBackupTrees>" +
                          "</config>";
-      return XmlHelper.stringToElement(xmlString);
+      return XmlConfigHelper.stringToElement(xmlString);
    }
 
    protected static Element getCacheLoaderConfig() throws Exception
@@ -299,7 +298,7 @@
                    "</singletonStore>" +
                    "</cacheloader>\n" +
                    "</config>";
-      return XmlHelper.stringToElement(xml);
+      return XmlConfigHelper.stringToElement(xml);
    }
 
    protected static Element getEvictionPolicyConfig() throws Exception
@@ -324,7 +323,7 @@
                    "   <attribute name=\"maxAgeSeconds\">10</attribute>\n" +
                    "</region>\n" +
                    " </config>\n";
-      return XmlHelper.stringToElement(xml);
+      return XmlConfigHelper.stringToElement(xml);
    }
 
    protected static Element getClusterConfig() throws Exception
@@ -381,7 +380,7 @@
             "      <pbcast.STREAMING_STATE_TRANSFER use_reading_thread=\"true\"/>\n" +
             "      <pbcast.FLUSH timeout=\"0\"/>\n" +
             "</config>";
-      return XmlHelper.stringToElement(xml);
+      return XmlConfigHelper.stringToElement(xml);
    }
 
    protected String getDefaultProperties()

Modified: core/trunk/src/test/java/org/jboss/cache/jmx/NotificationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/NotificationTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/NotificationTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -6,11 +6,11 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jboss.cache.config.Configuration.CacheMode;
 import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.factories.XmlConfigurationParser;
 import org.jboss.cache.loader.CacheLoader;
-import org.jboss.cache.xml.XmlHelper;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
@@ -333,8 +333,8 @@
             "<ignoreModifications>false</ignoreModifications>\n" +
             "</cacheloader>\n" +
             "</config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 
    private static void validateHealthyListener(MyListener listener)

Modified: core/trunk/src/test/java/org/jboss/cache/loader/AbstractCacheLoaderTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/AbstractCacheLoaderTestBase.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/loader/AbstractCacheLoaderTestBase.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -9,8 +9,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
 
@@ -49,7 +49,7 @@
             "<purgeOnStartup>" + purgeOnStartup + "</purgeOnStartup>\n" +
             "</cacheloader>\n" +
             "</config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 }

Modified: core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -5,10 +5,10 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.util.TestingUtil;
 import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.marshall.NodeData;
 import org.jboss.cache.statetransfer.StateTransferManager;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jboss.util.stream.MarshalledValueInputStream;
 import org.jboss.util.stream.MarshalledValueOutputStream;
 import static org.testng.AssertJUnit.*;
@@ -216,8 +216,8 @@
             "<purgeOnStartup>false</purgeOnStartup>\n" +
             "</cacheloader>\n" +
             "</config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 
    protected Properties getProperties() throws Exception

Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -8,8 +8,8 @@
 
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
@@ -56,7 +56,7 @@
 
    private static Element strToElement(String s) throws Exception
    {
-      return XmlHelper.stringToElement(s);
+      return XmlConfigHelper.stringToElement(s);
    }
 
    public void testSingleCacheLoader() throws Exception
@@ -158,7 +158,7 @@
             "        location=" + getTempDir() +
             "    </properties>" +
             "</cacheloader></config>";
-      CacheLoaderConfig clc = XmlConfigurationParser.parseCacheLoaderConfig(strToElement(conf));
+      CacheLoaderConfig clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
       CacheLoaderManager mgr = new CacheLoaderManager();
       mgr.setConfig(clc, null, null);
       CacheLoader cl = mgr.getCacheLoader();
@@ -194,7 +194,7 @@
             "        location=" + getTempDir() +
             "    </properties>" +
             "</cacheloader></config>";
-      clc = XmlConfigurationParser.parseCacheLoaderConfig(strToElement(conf));
+      clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
       mgr.setConfig(clc, null, null);
       cl = mgr.getCacheLoader();
 
@@ -256,7 +256,7 @@
             "    </properties>" +
             "</cacheloader></config>";
 
-      CacheLoaderConfig clc = XmlConfigurationParser.parseCacheLoaderConfig(strToElement(conf));
+      CacheLoaderConfig clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
       CacheLoaderManager mgr = new CacheLoaderManager();
       mgr.setConfig(clc, null, null);
       CacheLoader cl = mgr.getCacheLoader();
@@ -289,7 +289,7 @@
             "cache.jdbc.driver=com.mysql.jdbc.Driver\ncache.jdbc.url=jdbc:mysql://localhost/test\ncache.jdbc.user=user\ncache.jdbc.password=pwd" +
             "    </properties>" +
             "</cacheloader></config>";
-      clc = XmlConfigurationParser.parseCacheLoaderConfig(strToElement(conf));
+      clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
       mgr.setConfig(clc, null, null);
       cl = mgr.getCacheLoader();
 
@@ -388,7 +388,7 @@
             "cache.jdbc.driver=com.mysql.jdbc.Driver\ncache.jdbc.url=jdbc:mysql://localhost/test\ncache.jdbc.user=user\ncache.jdbc.password=pwd" +
             "    </properties>" +
             "</cacheloader></config>";
-      CacheLoaderConfig clc = XmlConfigurationParser.parseCacheLoaderConfig(strToElement(conf));
+      CacheLoaderConfig clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
       CacheLoaderManager mgr = new CacheLoaderManager();
       mgr.setConfig(clc, null, null);
 
@@ -436,7 +436,7 @@
             "cache.jdbc.driver=com.mysql.jdbc.Driver\ncache.jdbc.url=jdbc:mysql://localhost/test\ncache.jdbc.user=user\ncache.jdbc.password=pwd" +
             "    </properties>" +
             "</cacheloader></config>";
-      clc = XmlConfigurationParser.parseCacheLoaderConfig(strToElement(conf));
+      clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
 
       mgr = new CacheLoaderManager();
       mgr.setConfig(clc, null, null);
@@ -461,7 +461,7 @@
             "    </properties>" +
             "</cacheloader>" +
             "</config>";
-      CacheLoaderConfig clc = XmlConfigurationParser.parseCacheLoaderConfig(strToElement(conf));
+      CacheLoaderConfig clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
       CacheLoaderManager mgr = new CacheLoaderManager();
       mgr.setConfig(clc, null, null);
 
@@ -486,7 +486,7 @@
             "    </singletonStore>" +
             "</cacheloader>" +
             "</config>";
-      clc = XmlConfigurationParser.parseCacheLoaderConfig(strToElement(conf));
+      clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
       mgr = new MockCacheLoaderManager();
       mgr.setConfig(clc, null, null);
 
@@ -512,7 +512,7 @@
             "    </singletonStore>" +
             "</cacheloader>" +
             "</config>";
-      clc = XmlConfigurationParser.parseCacheLoaderConfig(strToElement(conf));
+      clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
       mgr = new MockCacheLoaderManager();
       mgr.setConfig(clc, null, null);
 
@@ -545,7 +545,7 @@
             "    </singletonStore>" +
             "</cacheloader>" +
             "</config>";
-      clc = XmlConfigurationParser.parseCacheLoaderConfig(strToElement(conf));
+      clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
       mgr = new CacheLoaderManager();
       mgr.setConfig(clc, null, null);
 
@@ -576,7 +576,7 @@
             "    </singletonStore>" +
             "</cacheloader>" +
             "</config>";
-      clc = XmlConfigurationParser.parseCacheLoaderConfig(strToElement(conf));
+      clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
       mgr = new CacheLoaderManager();
       mgr.setConfig(clc, null, null);
 
@@ -603,7 +603,7 @@
             "    </singletonStore>" +
             "</cacheloader>" +
             "</config>";
-      clc = XmlConfigurationParser.parseCacheLoaderConfig(strToElement(conf));
+      clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
       mgr = new MockCacheLoaderManager();
       mgr.setConfig(clc, null, null);
 
@@ -636,7 +636,7 @@
             "    </singletonStore>" +
             "</cacheloader>" +
             "</config>";
-      clc = XmlConfigurationParser.parseCacheLoaderConfig(strToElement(conf));
+      clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
       mgr = new MockCacheLoaderManager();
       mgr.setConfig(clc, null, null);
 
@@ -670,7 +670,7 @@
             "    </singletonStore>" +
             "</cacheloader>" +
             "</config>";
-      clc = XmlConfigurationParser.parseCacheLoaderConfig(strToElement(conf));
+      clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
       mgr = new MockCacheLoaderManager();
       mgr.setConfig(clc, null, null);
 
@@ -702,7 +702,7 @@
             "    </singletonStore>" +
             "</cacheloader>" +
             "</config>";
-      clc = XmlConfigurationParser.parseCacheLoaderConfig(strToElement(conf));
+      clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
       mgr = new CacheLoaderManager();
       try
       {
@@ -732,7 +732,7 @@
             "    </singletonStore>" +
             "</cacheloader>" +
             "</config>";
-      clc = XmlConfigurationParser.parseCacheLoaderConfig(strToElement(conf));
+      clc = XmlConfigurationParserOld.parseCacheLoaderConfig(strToElement(conf));
       mgr = new CacheLoaderManager();
 
       try

Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderPurgingTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -11,8 +11,8 @@
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.Test;
@@ -117,8 +117,8 @@
             "</config>";
 
       Configuration c = cache.getConfiguration();
-      Element element = XmlHelper.stringToElement(xml);
-      c.setCacheLoaderConfig(XmlConfigurationParser.parseCacheLoaderConfig(element));
+      Element element = XmlConfigHelper.stringToElement(xml);
+      c.setCacheLoaderConfig(XmlConfigurationParserOld.parseCacheLoaderConfig(element));
       cache.start();
 
       cache.put(fqn, key, value);

Modified: core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderBasicTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -7,9 +7,9 @@
 package org.jboss.cache.loader;
 
 import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.xml.XmlHelper;
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
 
@@ -65,7 +65,7 @@
                    "<fetchPersistentState>false</fetchPersistentState>\n" +
                    "</cacheloader>\n" +
                    "</config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 }

Modified: core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/loader/ChainingCacheLoaderFullTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -11,9 +11,9 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.transaction.DummyTransactionManagerLookup;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertNull;
 import org.testng.annotations.Test;
@@ -86,8 +86,8 @@
             "<ignoreModifications>" + ignoreMods2 + "</ignoreModifications>\n" +
             "</cacheloader>\n" +
             "</config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 
    public void testCruds() throws Exception

Modified: core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/loader/SingletonStoreCacheLoaderTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -13,10 +13,10 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.util.internals.ViewChangeListener;
 import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jboss.cache.config.Configuration.CacheMode;
 import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.xml.XmlHelper;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
@@ -292,8 +292,8 @@
             "  </singletonStore>" +
             "</cacheloader>\n" +
             "</config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 
    private void initSingletonNonPushCache(CacheSPI cache) throws Exception

Modified: core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -7,11 +7,11 @@
 import org.jboss.cache.util.TestingUtil;
 import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.factories.XmlConfigurationParser;
 import org.jboss.cache.jmx.CacheJmxWrapper;
 import org.jboss.cache.loader.tcp.TcpCacheServer;
-import org.jboss.cache.xml.XmlHelper;
 import static org.testng.AssertJUnit.*;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.Test;
@@ -74,8 +74,8 @@
             "<purgeOnStartup>false</purgeOnStartup>\n" +
             "</cacheloader>\n" +
             "</config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 
    @AfterMethod(alwaysRun = true)

Modified: core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/mgmt/MgmtTestBase.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -6,10 +6,10 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.loader.CacheLoader;
 import org.jboss.cache.loader.DummyInMemoryCacheLoader;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -119,7 +119,7 @@
             "<ignoreModifications>false</ignoreModifications>\n" +
             "</cacheloader>\n" +
             "</config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 }

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -13,7 +13,7 @@
 import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.interceptors.CacheMgmtInterceptor;
 import org.jboss.cache.interceptors.CallInterceptor;
 import org.jboss.cache.interceptors.NotificationInterceptor;
@@ -28,7 +28,7 @@
 import org.jboss.cache.transaction.DummyTransactionManagerLookup;
 import org.jboss.cache.transaction.GlobalTransaction;
 import org.jboss.cache.transaction.TransactionSetup;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jgroups.Address;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.Test;
@@ -113,8 +113,8 @@
             "                    <ignoreModifications>false</ignoreModifications>\n" +
             "                </cacheloader>\n" +
             "            </config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 
    protected CacheSPI<Object, Object> createCacheWithLoader(boolean passivationEnabled) throws Exception

Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticWithPassivationTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -8,10 +8,10 @@
 
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.loader.CacheLoader;
 import org.jboss.cache.transaction.DummyTransactionManager;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertNull;
 import org.testng.annotations.Test;
@@ -40,8 +40,8 @@
             "                </cacheloader>\n" +
             "                \n" +
             "            </config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 
    private CacheSPI createLocalCache() throws Exception

Modified: core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/BasicPassivationTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -11,7 +11,7 @@
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.Fqn;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.loader.DummyInMemoryCacheLoader;
 import org.jboss.cache.util.TestingUtil;
 import org.jboss.cache.notifications.annotation.CacheListener;
@@ -59,7 +59,7 @@
    private void initCaches()
    {
       CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
-      cache = (CacheSPI) instance.createCache(new XmlConfigurationParser().parseFile("META-INF/conf-test/local-passivation-service.xml"), false);
+      cache = (CacheSPI) instance.createCache(new XmlConfigurationParserOld().parseFile("META-INF/conf-test/local-passivation-service.xml"), false);
       cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
       Object listener = new TestCacheListener();
       cache.getConfiguration().getCacheLoaderConfig().getFirstCacheLoaderConfig().setClassName(DummyInMemoryCacheLoader.class.getName());

Modified: core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -11,7 +11,7 @@
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.Fqn;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.loader.DummyInMemoryCacheLoader;
 import static org.testng.AssertJUnit.assertNotNull;
 import static org.testng.AssertJUnit.fail;
@@ -47,7 +47,7 @@
    private void initCaches()
    {
       CacheFactory<Integer, String> instance = new DefaultCacheFactory();
-      cache = (CacheSPI) instance.createCache(new XmlConfigurationParser().parseFile("META-INF/conf-test/local-passivation-service.xml"), false);
+      cache = (CacheSPI) instance.createCache(new XmlConfigurationParserOld().parseFile("META-INF/conf-test/local-passivation-service.xml"), false);
       cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
       cache.getConfiguration().getCacheLoaderConfig().getFirstCacheLoaderConfig().setClassName(DummyInMemoryCacheLoader.class.getName());
       cache.start();

Modified: core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/LocalPassivationIntegrationTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -13,7 +13,7 @@
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.Fqn;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.loader.DummyInMemoryCacheLoader;
 import org.jboss.cache.util.TestingUtil;
 import org.jboss.cache.notifications.annotation.CacheListener;
@@ -44,7 +44,7 @@
    public void setUp() throws Exception
    {
       CacheFactory<String, String> instance = new DefaultCacheFactory();
-      cache = (CacheSPI<String, String>) instance.createCache(new XmlConfigurationParser().parseFile("META-INF/conf-test/local-passivation-service.xml"), false);
+      cache = (CacheSPI<String, String>) instance.createCache(new XmlConfigurationParserOld().parseFile("META-INF/conf-test/local-passivation-service.xml"), false);
       cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
       cache.getConfiguration().getCacheLoaderConfig().getFirstCacheLoaderConfig().setClassName(DummyInMemoryCacheLoader.class.getName());
       cache.getConfiguration().setUseRegionBasedMarshalling(true);

Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -10,14 +10,14 @@
 import org.jboss.cache.Node;
 import org.jboss.cache.NodeSPI;
 import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.loader.CacheLoader;
 import org.jboss.cache.loader.SamplePojo;
 import org.jboss.cache.lock.IsolationLevel;
 import org.jboss.cache.util.TestingUtil;
 import org.jboss.cache.statetransfer.StateTransferManager;
 import org.jboss.cache.transaction.DummyTransactionManager;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jboss.util.stream.MarshalledValueInputStream;
 import org.jboss.util.stream.MarshalledValueOutputStream;
 import static org.testng.AssertJUnit.*;
@@ -66,8 +66,8 @@
             "<fetchPersistentState>" + fetchPersistentState + "</fetchPersistentState>\n" +
             "</cacheloader>\n" +
             "</config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 
    @BeforeMethod(alwaysRun = true)

Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToBdbjeCacheLoaderTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -1,8 +1,8 @@
 package org.jboss.cache.passivation;
 
 import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
 
@@ -75,7 +75,7 @@
             "                </cacheloader>\n" +
             "                \n" +
             "            </config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 }

Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToFileCacheLoaderTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -1,8 +1,8 @@
 package org.jboss.cache.passivation;
 
 import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.w3c.dom.Element;
 
 /**
@@ -49,8 +49,8 @@
               "                </cacheloader>\n" +
               "                \n" +
               "            </config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 
 }

Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -7,8 +7,8 @@
 package org.jboss.cache.passivation;
 
 import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.w3c.dom.Element;
 
 import java.util.Properties;
@@ -42,8 +42,8 @@
             "                </cacheloader>\n" +
             "                \n" +
             "            </config>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
    }
 
 

Modified: core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/ReplicatedPassivationIntegrationTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -30,11 +30,11 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.Node;
 import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.EvictionConfig;
 import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
 import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
 import org.jboss.cache.loader.DummyInMemoryCacheLoader;
 import org.jboss.cache.notifications.annotation.CacheListener;
@@ -116,8 +116,8 @@
             "            </cacheloader>\n" +
             "         </config>\n" +
             "      </attribute>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseCacheLoaderConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseCacheLoaderConfig(element);
 
    }
 
@@ -138,8 +138,8 @@
             "            </region>\n" +
             "         </config>\n" +
             "      </attribute>";
-      Element element = XmlHelper.stringToElement(xml);
-      return XmlConfigurationParser.parseEvictionConfig(element);
+      Element element = XmlConfigHelper.stringToElement(xml);
+      return XmlConfigurationParserOld.parseEvictionConfig(element);
 
    }
 

Modified: core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentTransactionalTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentTransactionalTest.java	2008-06-17 11:56:20 UTC (rev 5994)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentTransactionalTest.java	2008-06-17 15:36:31 UTC (rev 5995)
@@ -14,7 +14,6 @@
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.XmlConfigurationParser;
 import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
 import org.jboss.cache.lock.IsolationLevel;
 import static org.testng.AssertJUnit.assertEquals;

Added: core/trunk/src/test/resources/META-INF/conf-test/all-elements-file-3.x.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/conf-test/all-elements-file-3.x.xml	                        (rev 0)
+++ core/trunk/src/test/resources/META-INF/conf-test/all-elements-file-3.x.xml	2008-06-17 15:36:31 UTC (rev 5995)
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbosscache>
+
+   <locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="true" lockAcquisitionTimeout="10234"/>
+
+   <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"
+                syncRollbackPhase="true" syncCommitPhase="true"/>
+
+   <!-- serialization related configuration, used for replication and cache loading -->
+   <serialization objectInputStreamPoolSize="10" objectOutputStreamPoolSize="20" version="5.1.0"
+                  marshallerClass="some.Clazz" useLazyDeserialization="true" useRegionBasedMarshalling="false"/>
+
+   <!-- either replication or invalidation tags will be present, not both -->
+   <replication>
+      <!-- either sync or async will be present, not both -->
+      <async useReplQueue="false" replQueueInterval="12" replQueueMaxElements="12345"/>
+      <sync replTimeout="15421"/>
+   </replication>
+
+   <!-- either replication or invalidation tags will be present, not both -->
+   <invalidation>
+      <!-- either sync or async will be present, not both -->
+      <async useReplQueue="false" replQueueInterval="12" replQueueMaxElements="12345"/>
+      <sync replTimeout="15421"/>
+   </invalidation>
+
+   <startup fetchInMemoryState="true" stateRetrievalTimeout="1524" inactiveOnStartup="true"/>
+   <shutdown hookBehavior="REGISTER"/>
+
+   <transport clusterName="JBossCache-Cluster">
+      <clusterName>JBossCache-Cluster</clusterName>
+      <multiplexer stack="file_name"/>
+      <clusterConfig>
+         <PING timeout="2000" num_initial_members="3"/>
+         <MERGE2 max_interval="30000" min_interval="10000"/>
+         <FD_SOCK/>
+         <FD timeout="10000" max_tries="5" shun="true"/>
+         <VERIFY_SUSPECT timeout="1500"/>
+         <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
+                        retransmit_timeout="300,600,1200,2400,4800"
+                        discard_delivered_msgs="true"/>
+         <UNICAST timeout="300,600,1200,2400,3600"/>
+         <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+                        max_bytes="400000"/>
+         <pbcast.GMS print_local_addr="true" join_timeout="5000" shun="false"
+                     view_bundling="true" view_ack_collection_timeout="5000"/>
+         <FRAG2 frag_size="60000"/>
+         <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+         <pbcast.FLUSH timeout="0"/>
+      </clusterConfig>
+   </transport>
+
+
+   <jmxStatistics enabled="false"/>
+
+   <eviction wakeUpInterval="5" defaultPolicyClass="org.jboss.cache.eviction.LRUPolicy" defaultEventQueueSize="200000">
+      <default>
+         <attribute name="maxNodes">5000</attribute>
+         <attribute name="timeToLive">1000</attribute>
+      </default>
+      <region name="/org/jboss/data">
+         <attribute name="timeToLive">1002</attribute>
+      </region>
+      <region name="/org/jboss/xyz" policyClass="org.jboss.cache.eviction.MRUPolicy" eventQueueSize="21">
+         <attribute name="maxNodes">2103</attribute>
+         <attribute name="minTimeToLive">22</attribute>
+      </region>
+   </eviction>
+
+   <!-- this should be deprecated in 3.0 and should be replaced with CacheLoaderConfig-->
+   <cacheLoaders passivation="false" shared="false">
+      <preload>
+         <node fqn="/a/b/c"/>
+         <node fqn="/f/r/s"/>
+      </preload>
+
+      <!-- we can now have multiple cache loaders, which get chained -->
+      <cacheLoader class="org.jboss.cache.loader.JDBCCacheLoader" async="true" fetchPersistentState="true"
+                   ignoreModifications="true" purgeOnStartup="true">
+         <properties>
+            cache.jdbc.table.name=jbosscache
+            cache.jdbc.table.create=true
+            cache.jdbc.table.drop=true
+         </properties>
+      </cacheLoader>
+   </cacheLoaders>
+
+   <buddyReplication enabled="true" buddyPoolName="myBuddyPoolReplicationGroup" buddyCommunicationTimeout="2000">
+      <dataGravitation auto="true" removeOnFind="true" searchBackupTrees="true"/>
+      <buddyLocator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator">
+         <properties>
+            numBuddies = 1
+            ignoreColocatedBuddies = true
+         </properties>
+      </buddyLocator>
+   </buddyReplication>
+
+   <!-- this is new behavior added within 3.x only. it support configuring custom interceptors through configurations -->
+   <customInterceptors>
+      <interceptor class="com.myCompany.MyInterceptor1">
+         <properties>
+            x=y
+            i=10
+         </properties>
+         <position first="true"/>
+      </interceptor>
+      <interceptor class="com.myCompany.MyInterceptor2">
+         <position last="true"/>
+      </interceptor>
+      <interceptor class="com.myCompany.MyInterceptor3">
+         <position index="3"/>
+      </interceptor>
+      <interceptor class="com.myCompany.MyInterceptor4">
+         <position before="org.jboss.cache.interceptors.CallInterceptor"/>
+      </interceptor>
+      <interceptor class="com.myCompany.MyInterceptor5">
+         <position after="org.jboss.cache.interceptors.CallInterceptor"/>
+      </interceptor>
+   </customInterceptors>
+</jbosscache>

Added: core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-2.x.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-2.x.xml	                        (rev 0)
+++ core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-2.x.xml	2008-06-17 15:36:31 UTC (rev 5995)
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+
+   <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+          name="jboss.cache:service=TreeCache">
+
+      <depends>jboss:service=Naming</depends>
+      <depends>jboss:service=TransactionManager</depends>
+      <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+      </attribute>
+      <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+      <attribute name="CacheMode">REPL_SYNC</attribute>
+      <attribute name="UseReplQueue">false</attribute>
+      <attribute name="ReplQueueInterval">12</attribute>
+
+      <attribute name="ReplQueueMaxElements">12345</attribute>
+
+      <attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+      <attribute name="UseRegionBasedMarshalling">true</attribute>
+
+      <attribute name="ClusterConfig">
+         <config>
+            <PING timeout="2000" num_initial_members="3"/>
+            <MERGE2 max_interval="30000" min_interval="10000"/>
+            <FD_SOCK/>
+            <FD timeout="10000" max_tries="5" shun="true"/>
+            <VERIFY_SUSPECT timeout="1500"/>
+            <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
+                           retransmit_timeout="300,600,1200,2400,4800"
+                           discard_delivered_msgs="true"/>
+            <UNICAST timeout="300,600,1200,2400,3600"/>
+            <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+                           max_bytes="400000"/>
+            <pbcast.GMS print_local_addr="true" join_timeout="5000" shun="false"
+                        view_bundling="true" view_ack_collection_timeout="5000"/>
+            <FRAG2 frag_size="60000"/>
+            <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+            <!-- <pbcast.STATE_TRANSFER/> -->
+            <pbcast.FLUSH timeout="0"/>
+         </config>
+      </attribute>
+
+
+      <attribute name="FetchInMemoryState">true</attribute>
+
+      <attribute name="StateRetrievalTimeout">15124</attribute>
+
+      <attribute name="SyncReplTimeout">15421</attribute>
+
+      <attribute name="LockAcquisitionTimeout">10234</attribute>
+
+      <attribute name="UseLazyDeserialization">true</attribute>
+
+      <attribute name="ObjectInputStreamPoolSize">12</attribute>
+
+      <attribute name="ObjectOutputStreamPoolSize">14</attribute>
+
+      <attribute name="ShutdownHookBehavior">REGISTER</attribute>
+
+      <attribute name="SyncRollbackPhase">true</attribute>
+
+      <attribute name="SyncCommitPhase">true</attribute>
+
+      <attribute name="ReplicationVersion">510</attribute>
+
+      <attribute name="MultiplexerStack">file_name</attribute>
+
+      <attribute name="MarshallerClass">some.Clazz</attribute>
+
+      <attribute name="LockParentForChildInsertRemove">true</attribute>
+
+      <attribute name="InactiveOnStartup">true</attribute>
+
+      <attribute name="ExposeManagementStatistics">false</attribute>
+
+
+      <attribute name="EvictionPolicyConfig">
+         <config>
+            <attribute name="wakeUpIntervalSeconds">5</attribute>
+            <!-- This defaults to 200000 if not specified -->
+            <attribute name="eventQueueSize">200000</attribute>
+            <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
+            <!-- Cache wide default -->
+            <region name="/_default_">
+               <attribute name="maxNodes">5000</attribute>
+               <attribute name="timeToLiveSeconds">1000</attribute>
+            </region>
+            <region name="/org/jboss/data">
+               <attribute name="timeToLiveSeconds">1002</attribute>
+            </region>
+            <region name="/org/jboss/xyz" policyClass="org.jboss.cache.eviction.MRUPolicy" eventQueueSize="21">
+               <attribute name="maxNodes">2103</attribute>
+               <attribute name="minTimeToLiveSeconds">22</attribute>
+            </region>
+         </config>
+      </attribute>
+
+      <!-- this should be deprecated in 3.0 and should be replaced with CacheLoaderConfig-->
+      <attribute name="CacheLoaderConfiguration">
+         <config>
+            <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
+            <passivation>true</passivation>
+            <preload>/a/b/c,/f/r/s</preload>
+            <shared>true</shared>
+
+            <!-- we can now have multiple cache loaders, which get chained -->
+            <cacheloader>
+               <class>org.jboss.cache.loader.JDBCCacheLoader</class>
+               <!-- same as the old CacheLoaderConfig attribute -->
+               <properties>
+                  cache.jdbc.table.name=jbosscache
+                  cache.jdbc.table.create=true
+                  cache.jdbc.table.drop=true
+               </properties>
+               <async>true</async>
+               <fetchPersistentState>true</fetchPersistentState>
+               <ignoreModifications>true</ignoreModifications>
+               <purgeOnStartup>true</purgeOnStartup>
+            </cacheloader>
+         </config>
+      </attribute>
+
+      <attribute name="BuddyReplicationConfig">
+         <config>
+            <buddyReplicationEnabled>true</buddyReplicationEnabled>
+            <buddyLocatorClass>org.jboss.cache.buddyreplication.NextMemberBuddyLocator</buddyLocatorClass>
+            <buddyLocatorProperties>
+               numBuddies = 1
+               ignoreColocatedBuddies = true
+            </buddyLocatorProperties>
+            <buddyPoolName>myBuddyPoolReplicationGroup</buddyPoolName>
+            <buddyCommunicationTimeout>2000</buddyCommunicationTimeout>
+            <autoDataGravitation>true</autoDataGravitation>
+            <dataGravitationRemoveOnFind>true</dataGravitationRemoveOnFind>
+            <dataGravitationSearchBackupTrees>true</dataGravitationSearchBackupTrees>
+         </config>
+      </attribute>
+   </mbean>
+</server>

Added: core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-3.x.xml
===================================================================
--- core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-3.x.xml	                        (rev 0)
+++ core/trunk/src/test/resources/META-INF/conf-test/parser-test-file-3.x.xml	2008-06-17 15:36:31 UTC (rev 5995)
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbosscache>
+
+   <locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="true" lockAcquisitionTimeout="10234"/>
+
+   <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"
+                syncRollbackPhase="true" syncCommitPhase="true"/>
+
+   <!-- serialization related configuration, used for replication and cache loading -->
+   <serialization objectInputStreamPoolSize="12" objectOutputStreamPoolSize="14" version="1.2.4"
+                  marshallerClass="some.Clazz" useLazyDeserialization="true" useRegionBasedMarshalling="true"/>
+
+   <replication>
+      <sync replTimeout="15421"/>
+   </replication>
+
+   <startup fetchInMemoryState="true" stateRetrievalTimeout="15124" inactiveOnStartup="true"/>
+   <shutdown hookBehavior="REGISTER"/>
+
+   <transport clusterName="JBossCache-Cluster">
+      <clusterName>JBossCache-Cluster</clusterName>
+      <multiplexer stack="file_name"/>
+      <jgroupsConfig>
+         <PING timeout="2000" num_initial_members="3"/>
+         <MERGE2 max_interval="30000" min_interval="10000"/>
+         <FD_SOCK/>
+         <FD timeout="10000" max_tries="5" shun="true"/>
+         <VERIFY_SUSPECT timeout="1500"/>
+         <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
+                        retransmit_timeout="300,600,1200,2400,4800"
+                        discard_delivered_msgs="true"/>
+         <UNICAST timeout="300,600,1200,2400,3600"/>
+         <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+                        max_bytes="400000"/>
+         <pbcast.GMS print_local_addr="true" join_timeout="5000" shun="false"
+                     view_bundling="true" view_ack_collection_timeout="5000"/>
+         <FRAG2 frag_size="60000"/>
+         <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+         <!-- <pbcast.STATE_TRANSFER/> -->
+         <pbcast.FLUSH timeout="0"/>
+      </jgroupsConfig>
+   </transport>
+
+
+   <jmxStatistics enabled="false"/>
+
+   <eviction wakeUpInterval="5" defaultPolicyClass="org.jboss.cache.eviction.LRUPolicy" defaultEventQueueSize="200000">
+      <default>
+         <attribute name="maxNodes">5000</attribute>
+         <attribute name="timeToLive">1000</attribute>
+      </default>
+      <region name="/org/jboss/data">
+         <attribute name="timeToLive">1002</attribute>
+      </region>
+      <region name="/org/jboss/xyz" policyClass="org.jboss.cache.eviction.MRUPolicy" eventQueueSize="21">
+         <attribute name="maxNodes">2103</attribute>
+         <attribute name="minTimeToLive">22</attribute>
+      </region>
+   </eviction>
+
+   <!-- this should be deprecated in 3.0 and should be replaced with CacheLoaderConfig-->
+   <cacheLoaders passivation="true" shared="true">
+      <preload>
+         <node fqn="/a/b/c"/>
+         <node fqn="/f/r/s"/>
+      </preload>
+
+      <!-- we can now have multiple cache loaders, which get chained -->
+      <cacheLoader class="org.jboss.cache.loader.JDBCCacheLoader" async="true" fetchPersistentState="true"
+                   ignoreModifications="true" purgeOnStartup="true">
+         <properties>
+            cache.jdbc.table.name=jbosscache
+            cache.jdbc.table.create=true
+            cache.jdbc.table.drop=true
+         </properties>
+      </cacheLoader>
+   </cacheLoaders>
+
+   <buddyReplication enabled="true" buddyPoolName="myBuddyPoolReplicationGroup" buddyCommunicationTimeout="2000">
+      <dataGravitation auto="true" removeOnFind="true" searchBackupTrees="true"/>
+      <buddyLocator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator">
+         <properties>
+            numBuddies = 1
+            ignoreColocatedBuddies = true
+         </properties>
+      </buddyLocator>
+   </buddyReplication>
+
+   <!-- this is new behavior added within 3.x only. it support configuring custom interceptors through configurations -->
+   <customInterceptors>
+      <interceptor class="com.myCompany.MyInterceptor1">
+         <properties>
+            x=y
+            i=10
+         </properties>
+         <position first="true"/>
+      </interceptor>
+      <interceptor class="com.myCompany.MyInterceptor2">
+         <position last="true"/>
+      </interceptor>
+      <interceptor class="com.myCompany.MyInterceptor3">
+         <position index="3"/>
+      </interceptor>
+      <interceptor class="com.myCompany.MyInterceptor4">
+         <position before="org.jboss.cache.interceptors.CallInterceptor"/>
+      </interceptor>
+      <interceptor class="com.myCompany.MyInterceptor5">
+         <position after="org.jboss.cache.interceptors.CallInterceptor"/>
+      </interceptor>
+   </customInterceptors>
+</jbosscache>




More information about the jbosscache-commits mailing list