[jbosscache-commits] JBoss Cache SVN: r7597 - in core/branches/flat/src: main/java/org/horizon/config and 9 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Jan 26 11:56:02 EST 2009


Author: manik.surtani at jboss.com
Date: 2009-01-26 11:56:02 -0500 (Mon, 26 Jan 2009)
New Revision: 7597

Added:
   core/branches/flat/src/main/java/org/horizon/config/DuplicateCacheNameException.java
   core/branches/flat/src/main/java/org/horizon/config/parsing/GlobalConfigurationParserTest.java
   core/branches/flat/src/main/java/org/horizon/marshall/HorizonMarshaller.java
   core/branches/flat/src/test/java/org/horizon/config/
   core/branches/flat/src/test/java/org/horizon/config/parser/
Removed:
   core/branches/flat/src/main/java/org/horizon/config/XmlParsingConfigurationRegistry.java
   core/branches/flat/src/main/java/org/horizon/config/parsing/CacheConfigsXmlParser.java
   core/branches/flat/src/main/java/org/horizon/config/parsing/ConfigFilesConvertor.java
   core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigurationParserJBC3.java
   core/branches/flat/src/main/java/org/horizon/manager/CacheNameExistsException.java
   core/branches/flat/src/main/java/org/horizon/marshall/CacheMarshallerStarobrno.java
Modified:
   core/branches/flat/src/main/java/org/horizon/Version.java
   core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java
   core/branches/flat/src/main/java/org/horizon/config/parsing/RootElementBuilder.java
   core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigHelper.java
   core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigurationParser.java
   core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigurationParserImpl.java
   core/branches/flat/src/main/java/org/horizon/config/parsing/XmlParserBase.java
   core/branches/flat/src/main/java/org/horizon/manager/CacheManager.java
   core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java
   core/branches/flat/src/main/java/org/horizon/marshall/VersionAwareMarshaller.java
   core/branches/flat/src/main/resources/config-samples/all.xml
   core/branches/flat/src/test/java/org/horizon/UnitTestCacheFactory.java
   core/branches/flat/src/test/java/org/horizon/manager/CacheManagerComponentRegistryTest.java
   core/branches/flat/src/test/java/org/horizon/manager/CacheManagerTest.java
   core/branches/flat/src/test/java/org/horizon/manager/CacheManagerXmlConfigurationTest.java
   core/branches/flat/src/test/java/org/horizon/util/internals/ReplicationListener.java
   core/branches/flat/src/test/resources/configs/named-cache-test.xml
Log:
Started work on parser

Modified: core/branches/flat/src/main/java/org/horizon/Version.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/Version.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/java/org/horizon/Version.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -49,8 +49,7 @@
       System.out.println();
       System.out.println("\nVersion: \t" + version);
       System.out.println("Codename: \t" + codename);
-      //System.out.println("CVS:      \t" + cvs);
-      System.out.println("History:  \t(see http://jira.jboss.com/jira/browse/JBCACHE for details)\n");
+      System.out.println("History:  \t(see http://jira.jboss.org for details)\n");
    }
 
    /**
@@ -104,13 +103,7 @@
       if (versionString == null)
          throw new IllegalArgumentException("versionString is null");
 
-      // Special cases for version prior to 1.2.4.SP2
-      if ("1.2.4".equals(versionString))
-         return 124;
-      else if ("1.2.4.SP1".equals(versionString))
-         return 1241;
-
-      String parts[] = versionString.split("[\\.\\-]");
+      String parts[] = getParts(versionString);
       int a = 0;
       int b = 0;
       int c = 0;
@@ -135,4 +128,13 @@
       int patch = (version & PATCH_MASK);
       return major + "." + minor + "." + patch;
    }
+
+   private static String[] getParts(String versionString) {
+      return versionString.split("[\\.\\-]");
+   }
+
+   public static String getMajorVersion() {
+      String[] parts = getParts(version);
+      return parts[0] + "." + parts[1];
+   }
 }

Added: core/branches/flat/src/main/java/org/horizon/config/DuplicateCacheNameException.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/DuplicateCacheNameException.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/config/DuplicateCacheNameException.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -0,0 +1,25 @@
+package org.horizon.config;
+
+/**
+ * Thrown if a duplicate named cache is detected
+ *
+ * @author Manik Surtani
+ * @since 1.0
+ */
+public class DuplicateCacheNameException extends ConfigurationException {
+   public DuplicateCacheNameException(Exception e) {
+      super(e);
+   }
+
+   public DuplicateCacheNameException(String string) {
+      super(string);
+   }
+
+   public DuplicateCacheNameException(String string, String erroneousAttribute) {
+      super(string, erroneousAttribute);
+   }
+
+   public DuplicateCacheNameException(String string, Throwable throwable) {
+      super(string, throwable);
+   }
+}

Modified: core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -10,6 +10,7 @@
 import org.horizon.factories.annotations.NonVolatile;
 import org.horizon.factories.scopes.Scope;
 import org.horizon.factories.scopes.Scopes;
+import org.horizon.marshall.VersionAwareMarshaller;
 import org.horizon.remoting.transport.jgroups.JGroupsTransport;
 import org.horizon.util.TypedProperties;
 
@@ -28,26 +29,26 @@
    /**
     * Default replication version, from {@link org.horizon.Version#getVersionShort}.
     */
-   public static final short DEFAULT_REPLICATION_VERSION = Version.getVersionShort();
+   public static final short DEFAULT_MARSHALL_VERSION = Version.getVersionShort();
+   private static final TypedProperties EMPTY_PROPERTIES = new TypedProperties();
 
    String asyncListenerExecutorFactoryClass = DefaultExecutorFactory.class.getName();
-   TypedProperties asyncListenerExecutorProperties;
+   TypedProperties asyncListenerExecutorProperties = EMPTY_PROPERTIES;
    String asyncSerializationExecutorFactoryClass = DefaultExecutorFactory.class.getName();
-   TypedProperties asyncSerializationExecutorProperties;
+   TypedProperties asyncSerializationExecutorProperties = EMPTY_PROPERTIES;
    String evictionScheduledExecutorFactoryClass = DefaultScheduledExecutorFactory.class.getName();
-   TypedProperties evictionScheduledExecutorProperties;
+   TypedProperties evictionScheduledExecutorProperties = EMPTY_PROPERTIES;
    String replicationQueueScheduledExecutorFactoryClass = DefaultScheduledExecutorFactory.class.getName();
-   TypedProperties replicationQueueScheduledExecutorProperties;
-   String marshallerClass;
-   String marshallVersion;
-   int objectInputStreamPoolSize;
-   int objectOutputStreamPoolSize;
+   TypedProperties replicationQueueScheduledExecutorProperties = EMPTY_PROPERTIES;
+   String marshallerClass = VersionAwareMarshaller.class.getName(); // the default
+   int objectInputStreamPoolSize = 50; // defaults
+   int objectOutputStreamPoolSize = 50; // defaults
    String transportClass = null; // this defaults to a non-clustered cache.
-   TypedProperties transportProperties;
+   TypedProperties transportProperties = EMPTY_PROPERTIES;
    Configuration defaultConfiguration;
    String clusterName = "Horizon-Cluster";
    ShutdownHookBehavior shutdownHookBehavior = ShutdownHookBehavior.DEFAULT;
-   short replicationVersion = DEFAULT_REPLICATION_VERSION;
+   short marshallVersion = DEFAULT_MARSHALL_VERSION;
 
    private GlobalComponentRegistry gcr;
 
@@ -123,15 +124,6 @@
       this.marshallerClass = marshallerClass;
    }
 
-   public String getMarshallVersion() {
-      return marshallVersion;
-   }
-
-   public void setMarshallVersion(String marshallVersion) {
-      testImmutability("marshallVersion");
-      this.marshallVersion = marshallVersion;
-   }
-
    public int getObjectInputStreamPoolSize() {
       return objectInputStreamPoolSize;
    }
@@ -267,22 +259,26 @@
       this.replicationQueueScheduledExecutorProperties = toTypedProperties(replicationQueueScheduledExecutorPropertiesString);
    }
 
-   public short getReplicationVersion() {
-      return replicationVersion;
+   public short getMarshallVersion() {
+      return marshallVersion;
    }
 
+   public String getMarshallVersionString() {
+      return Version.decodeVersion(marshallVersion);
+   }
+
    public String getReplicationVersionString() {
-      return Version.decodeVersion(replicationVersion);
+      return Version.decodeVersion(marshallVersion);
    }
 
-   public void setReplicationVersion(short replicationVersion) {
-      testImmutability("replicationVersion");
-      this.replicationVersion = replicationVersion;
+   public void setMarshallVersion(short marshallVersion) {
+      testImmutability("marshallVersion");
+      this.marshallVersion = marshallVersion;
    }
 
-   public void setReplicationVersionString(String replicationVersionString) {
-      testImmutability("replicationVersion");
-      this.replicationVersion = Version.getVersionShort(replicationVersionString);
+   public void setMarshallVersion(String marshallVersion) {
+      testImmutability("marshallVersion");
+      this.marshallVersion = Version.getVersionShort(marshallVersion);
    }
 
    @Override
@@ -294,7 +290,7 @@
 
       if (objectInputStreamPoolSize != that.objectInputStreamPoolSize) return false;
       if (objectOutputStreamPoolSize != that.objectOutputStreamPoolSize) return false;
-      if (replicationVersion != that.replicationVersion) return false;
+      if (marshallVersion != that.marshallVersion) return false;
       if (asyncListenerExecutorFactoryClass != null ? !asyncListenerExecutorFactoryClass.equals(that.asyncListenerExecutorFactoryClass) : that.asyncListenerExecutorFactoryClass != null)
          return false;
       if (asyncListenerExecutorProperties != null ? !asyncListenerExecutorProperties.equals(that.asyncListenerExecutorProperties) : that.asyncListenerExecutorProperties != null)
@@ -310,8 +306,6 @@
          return false;
       if (evictionScheduledExecutorProperties != null ? !evictionScheduledExecutorProperties.equals(that.evictionScheduledExecutorProperties) : that.evictionScheduledExecutorProperties != null)
          return false;
-      if (marshallVersion != null ? !marshallVersion.equals(that.marshallVersion) : that.marshallVersion != null)
-         return false;
       if (marshallerClass != null ? !marshallerClass.equals(that.marshallerClass) : that.marshallerClass != null)
          return false;
       if (replicationQueueScheduledExecutorFactoryClass != null ? !replicationQueueScheduledExecutorFactoryClass.equals(that.replicationQueueScheduledExecutorFactoryClass) : that.replicationQueueScheduledExecutorFactoryClass != null)
@@ -338,7 +332,6 @@
       result = 31 * result + (replicationQueueScheduledExecutorFactoryClass != null ? replicationQueueScheduledExecutorFactoryClass.hashCode() : 0);
       result = 31 * result + (replicationQueueScheduledExecutorProperties != null ? replicationQueueScheduledExecutorProperties.hashCode() : 0);
       result = 31 * result + (marshallerClass != null ? marshallerClass.hashCode() : 0);
-      result = 31 * result + (marshallVersion != null ? marshallVersion.hashCode() : 0);
       result = 31 * result + objectInputStreamPoolSize;
       result = 31 * result + objectOutputStreamPoolSize;
       result = 31 * result + (transportClass != null ? transportClass.hashCode() : 0);
@@ -346,7 +339,7 @@
       result = 31 * result + (defaultConfiguration != null ? defaultConfiguration.hashCode() : 0);
       result = 31 * result + (clusterName != null ? clusterName.hashCode() : 0);
       result = 31 * result + (shutdownHookBehavior != null ? shutdownHookBehavior.hashCode() : 0);
-      result = 31 * result + (int) replicationVersion;
+      result = 31 * result + (int) marshallVersion;
       return result;
    }
 

Deleted: core/branches/flat/src/main/java/org/horizon/config/XmlParsingConfigurationRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/XmlParsingConfigurationRegistry.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/java/org/horizon/config/XmlParsingConfigurationRegistry.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -1,101 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.horizon.config;
-
-import org.horizon.config.parsing.CacheConfigsXmlParser;
-
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * {@link ConfigurationRegistry} that obtains its initial set of configurations by parsing an XML document.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @since 1.0
- */
-public class XmlParsingConfigurationRegistry implements ConfigurationRegistry {
-   private final CacheConfigsXmlParser parser;
-   private final String configResource;
-   private final Map<String, Configuration> configs = new Hashtable<String, Configuration>();
-   private boolean started;
-
-   public XmlParsingConfigurationRegistry(String configResource) {
-      parser = new CacheConfigsXmlParser();
-      this.configResource = configResource;
-   }
-
-   public void start() throws Exception {
-      if (!started) {
-         if (configResource != null)
-            configs.putAll(parser.parseConfigs(configResource));
-         started = true;
-      }
-   }
-
-   public void stop() {
-      if (started) {
-         synchronized (configs) {
-            configs.clear();
-         }
-         started = false;
-      }
-   }
-
-   public String getConfigResource() {
-      return configResource;
-   }
-
-   public Set<String> getConfigurationNames() {
-      return new HashSet<String>(configs.keySet());
-   }
-
-   public void registerConfiguration(String configName, Configuration config)
-         throws CloneNotSupportedException {
-      synchronized (configs) {
-         if (configs.containsKey(configName))
-            throw new IllegalStateException(configName + " already registered");
-         configs.put(configName, config.clone());
-      }
-   }
-
-   public void unregisterConfiguration(String configName) {
-      synchronized (configs) {
-         if (configs.remove(configName) == null)
-            throw new IllegalStateException(configName + " not registered");
-      }
-   }
-
-   public Configuration getConfiguration(String configName) {
-      Configuration config;
-      synchronized (configs) {
-         config = configs.get(configName);
-      }
-
-      if (config == null)
-         throw new IllegalArgumentException("unknown config " + configName);
-
-      // Don't hand out a ref to our master copy
-      return config.clone();
-   }
-}

Deleted: core/branches/flat/src/main/java/org/horizon/config/parsing/CacheConfigsXmlParser.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/parsing/CacheConfigsXmlParser.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/java/org/horizon/config/parsing/CacheConfigsXmlParser.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -1,128 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.horizon.config.parsing;
-
-import org.horizon.config.Configuration;
-import org.horizon.config.ConfigurationException;
-import org.horizon.logging.Log;
-import org.horizon.logging.LogFactory;
-import org.horizon.util.FileLookup;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * 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>
- * @since 1.0
- */
-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";
-   public static final String QUALIFIED_CONFIG_ROOT = "registry: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);
-
-
-   public Map<String, Configuration> parseConfigs(String fileName) throws CloneNotSupportedException {
-      FileLookup fileLookup = new FileLookup();
-      InputStream is = fileLookup.lookupFile(fileName);
-      if (is == null) {
-         throw new ConfigurationException("Unable to find config file " + fileName + " either in classpath or on the filesystem!");
-      }
-
-      return parseConfigs(is);
-   }
-
-   public Map<String, Configuration> parseConfigs(InputStream stream) throws CloneNotSupportedException {
-      // loop through all elements in XML.
-      Element root = getDocumentRoot(stream);
-
-      NodeList list = root.getElementsByTagName(CONFIG_ROOT);
-      if (list == null || list.getLength() == 0) {
-         // try looking for a QUALIFIED_CONFIG_ROOT
-         list = root.getElementsByTagName(QUALIFIED_CONFIG_ROOT);
-         if (list == null || list.getLength() == 0)
-            throw new ConfigurationException("Can't find " + CONFIG_ROOT + " or " + QUALIFIED_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");
-
-         XmlConfigurationParserJBC3 parser = new XmlConfigurationParserJBC3();
-         Configuration c = null;
-         if (parser.isValidElementRoot(element)) {
-            c = parser.parseElementIgnoringRoot(element);
-         }
-
-         // Prove that we can successfully clone it
-         c = c.clone();
-         result.put(name.trim(), c);
-      }
-
-      return result;
-   }
-
-   private Element getDocumentRoot(InputStream stream) {
-      RootElementBuilder rootElementBuilder = new RootElementBuilder(false);
-      return rootElementBuilder.readRoot(stream);
-   }
-}
\ No newline at end of file

Deleted: core/branches/flat/src/main/java/org/horizon/config/parsing/ConfigFilesConvertor.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/parsing/ConfigFilesConvertor.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/java/org/horizon/config/parsing/ConfigFilesConvertor.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -1,128 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.horizon.config.parsing;
-
-import org.horizon.util.FileLookup;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * Class used for converting a config file from from 2.x version to 3.x verison.
- *
- * @author Mircea.Markus at jboss.com
- * @since 1.0
- */
-public class ConfigFilesConvertor {
-   /**
-    * Writes to the <b>os</b> the 3.x configuration file resulted by transforming the 2.x configuration file passed in
-    * as <b>is</b>. Transformation is performed according to the <b>xsltFile</b>. The xslt file is looked up using a
-    * {@link org.horizon.util.FileLookup}
-    */
-   public void parse(InputStream is, OutputStream os, String xsltFile) throws Exception {
-      InputStream xsltInStream = new FileLookup().lookupFile(xsltFile);
-
-      Document document = getInputDocument(is);
-
-      // Use a Transformer for output
-      Transformer transformer = getTransformer(xsltInStream);
-
-      DOMSource source = new DOMSource(document);
-      StreamResult result = new StreamResult(os);
-      transformer.transform(source, result);
-      xsltInStream.close();
-   }
-
-   /**
-    * Writes to the <b>os</b> the 3.x configuration file resulted by transforming the 2.x configuration file passed in
-    * as <b>inputFile</b>. Transformation is performed according to the <b>xsltFile</b>. Both <b>inputFile</b> and he
-    * xslt file are looked up using a {@link org.horizon.util.FileLookup}
-    */
-   public void parse(String inputFile, OutputStream os, String xsltFile) throws Exception {
-      InputStream stream = new FileLookup().lookupFile(inputFile);
-      try {
-         parse(stream, os, xsltFile);
-      }
-      finally {
-         stream.close();
-      }
-   }
-
-   /**
-    * usage : java ConfigFilesConvertor -Dsource=config-2.x.xml -Ddestination=config-3.x.xnl
-    */
-   public static void main(String[] argv) throws Exception {
-      String sourceName = System.getProperty("source");
-      if (sourceName == null) {
-         System.err.println("Missing property 'source'.");
-         System.exit(1);
-      }
-      String destinationName = System.getProperty("destination");
-      if (destinationName == null) {
-         System.err.println("Missing property 'destination'.");
-         System.exit(1);
-      }
-      File oldConfig = new File(sourceName);
-      if (!oldConfig.exists()) {
-         System.err.println("File specified as input ('" + sourceName + ") does not exist.");
-         System.exit(1);
-      }
-      ConfigFilesConvertor convertor = new ConfigFilesConvertor();
-      File destination = new File(destinationName);
-      if (!destination.exists()) destination.createNewFile();
-
-      FileInputStream is = new FileInputStream(oldConfig);
-      FileOutputStream fos = new FileOutputStream(destinationName);
-      convertor.parse(is, fos, "config2to3.xslt");
-      is.close();
-      System.out.println("File successfully created.");
-   }
-
-   private Transformer getTransformer(InputStream xsltInStream)
-         throws TransformerConfigurationException {
-      TransformerFactory tFactory = TransformerFactory.newInstance();
-      StreamSource stylesource = new StreamSource(xsltInStream);
-      return tFactory.newTransformer(stylesource);
-   }
-
-   private Document getInputDocument(InputStream is)
-         throws ParserConfigurationException, SAXException, IOException {
-      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-      DocumentBuilder builder = factory.newDocumentBuilder();
-      return builder.parse(is);
-   }
-}
\ No newline at end of file

Added: core/branches/flat/src/main/java/org/horizon/config/parsing/GlobalConfigurationParserTest.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/parsing/GlobalConfigurationParserTest.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/config/parsing/GlobalConfigurationParserTest.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -0,0 +1,200 @@
+package org.horizon.config.parsing;
+
+import org.horizon.config.GlobalConfiguration;
+import org.horizon.executors.DefaultExecutorFactory;
+import org.horizon.executors.DefaultScheduledExecutorFactory;
+import org.horizon.marshall.HorizonMarshaller;
+import org.horizon.marshall.VersionAwareMarshaller;
+import org.horizon.remoting.transport.jgroups.JGroupsTransport;
+import org.testng.annotations.Test;
+import org.w3c.dom.Element;
+
+
+ at Test(groups = "unit")
+public class GlobalConfigurationParserTest {
+
+   public void testTransport() throws Exception {
+      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
+      String transportClass = "org.blah.Blah";
+      String xml = "<transport transportClass=\"" + transportClass + "\"><property name=\"something\">value</property></transport>";
+      Element e = XmlConfigHelper.stringToElement(xml);
+
+      GlobalConfiguration gc = new GlobalConfiguration();
+      parser.configureTransport(e, gc);
+
+      assert gc.getTransportClass().equals(transportClass);
+      assert gc.getTransportProperties().size() == 1;
+      assert gc.getTransportProperties().getProperty("something").equals("value");
+   }
+
+   public void testDefaultTransport() throws Exception {
+      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
+      String xml = "<transport />";
+      Element e = XmlConfigHelper.stringToElement(xml);
+
+      GlobalConfiguration gc = new GlobalConfiguration();
+      parser.configureTransport(e, gc);
+
+      assert gc.getTransportClass().equals(JGroupsTransport.class.getName());
+      assert gc.getTransportProperties().size() == 0;
+   }
+
+   public void testShutdown() throws Exception {
+      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
+      String xml = "<shutdown hookBehavior=\"REGISTER\" />";
+      Element e = XmlConfigHelper.stringToElement(xml);
+
+      GlobalConfiguration gc = new GlobalConfiguration();
+      parser.configureShutdown(e, gc);
+
+      assert gc.getShutdownHookBehavior() == GlobalConfiguration.ShutdownHookBehavior.REGISTER;
+   }
+
+   public void testDefaultShutdown() throws Exception {
+      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
+      String xml = "<shutdown />";
+      Element e = XmlConfigHelper.stringToElement(xml);
+
+      GlobalConfiguration gc = new GlobalConfiguration();
+      parser.configureShutdown(e, gc);
+
+      assert gc.getShutdownHookBehavior() == GlobalConfiguration.ShutdownHookBehavior.DEFAULT;
+   }
+
+   public void testMarshalling() throws Exception {
+      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
+      String xml = "<serialization marshallerClass=\"org.horizon.marshall.HorizonMarshaller\" version=\"9.2\"\n" +
+            "                     objectInputStreamPoolSize=\"100\" objectOutputStreamPoolSize=\"100\"/>";
+      Element e = XmlConfigHelper.stringToElement(xml);
+
+      GlobalConfiguration gc = new GlobalConfiguration();
+      parser.configureMarshalling(e, gc);
+
+      assert gc.getMarshallerClass().equals(HorizonMarshaller.class.getName());
+      assert gc.getMarshallVersionString().equals("9.2.0");
+      assert gc.getObjectInputStreamPoolSize() == 100;
+      assert gc.getObjectOutputStreamPoolSize() == 100;
+   }
+
+   public void testMarshallingDefaults() throws Exception {
+      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
+      String xml = "<serialization />";
+      Element e = XmlConfigHelper.stringToElement(xml);
+
+      GlobalConfiguration gc = new GlobalConfiguration();
+      parser.configureMarshalling(e, gc);
+
+      assert gc.getMarshallerClass().equals(VersionAwareMarshaller.class.getName());
+      assert gc.getMarshallVersionString().equals("1.0.0");
+      assert gc.getObjectInputStreamPoolSize() == 50;
+      assert gc.getObjectOutputStreamPoolSize() == 50;
+   }
+
+   public void testAsyncListenerExecutor() throws Exception {
+      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
+      String xml = "<asyncListenerExecutor factory=\"com.mycompany.Factory\">\n" +
+            "         <property name=\"maxThreads\" value=\"5\" />" +
+            "      </asyncListenerExecutor>";
+      Element e = XmlConfigHelper.stringToElement(xml);
+
+      GlobalConfiguration gc = new GlobalConfiguration();
+      parser.configureAsyncListenerExecutor(e, gc);
+
+      assert gc.getAsyncListenerExecutorFactoryClass().equals("com.mycompany.Factory");
+      assert gc.getAsyncListenerExecutorProperties().size() == 1;
+      assert gc.getAsyncListenerExecutorProperties().get("maxThreads").equals("5");
+   }
+
+   public void testAsyncSerializationExecutor() throws Exception {
+      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
+      String xml = "<asyncSerializationExecutor factory=\"com.mycompany.Factory\">\n" +
+            "         <property name=\"maxThreads\" value=\"5\" />" +
+            "      </asyncSerializationExecutor>";
+      Element e = XmlConfigHelper.stringToElement(xml);
+
+      GlobalConfiguration gc = new GlobalConfiguration();
+      parser.configureAsyncSerializationExecutor(e, gc);
+
+      assert gc.getAsyncSerializationExecutorFactoryClass().equals("com.mycompany.Factory");
+      assert gc.getAsyncSerializationExecutorProperties().size() == 1;
+      assert gc.getAsyncSerializationExecutorProperties().get("maxThreads").equals("5");
+   }
+
+   public void testEvictionScheduledExecutor() throws Exception {
+      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
+      String xml = "<evictionScheduledExecutor factory=\"com.mycompany.Factory\">\n" +
+            "         <property name=\"maxThreads\" value=\"5\" />" +
+            "      </evictionScheduledExecutor>";
+      Element e = XmlConfigHelper.stringToElement(xml);
+
+      GlobalConfiguration gc = new GlobalConfiguration();
+      parser.configureEvictionScheduledExecutor(e, gc);
+
+      assert gc.getEvictionScheduledExecutorFactoryClass().equals("com.mycompany.Factory");
+      assert gc.getEvictionScheduledExecutorProperties().size() == 1;
+      assert gc.getEvictionScheduledExecutorProperties().get("maxThreads").equals("5");
+   }
+
+   public void testReplicationQueueScheduledExecutor() throws Exception {
+      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
+      String xml = "<replicationQueueScheduledExecutor factory=\"com.mycompany.Factory\">\n" +
+            "         <property name=\"maxThreads\" value=\"5\" />" +
+            "      </replicationQueueScheduledExecutor>";
+      Element e = XmlConfigHelper.stringToElement(xml);
+
+      GlobalConfiguration gc = new GlobalConfiguration();
+      parser.configureReplicationQueueScheduledExecutor(e, gc);
+
+      assert gc.getReplicationQueueScheduledExecutorFactoryClass().equals("com.mycompany.Factory");
+      assert gc.getReplicationQueueScheduledExecutorProperties().size() == 1;
+      assert gc.getReplicationQueueScheduledExecutorProperties().get("maxThreads").equals("5");
+   }
+
+   public void testAsyncListenerExecutorDefaults() throws Exception {
+      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
+      String xml = "<asyncListenerExecutor />";
+      Element e = XmlConfigHelper.stringToElement(xml);
+
+      GlobalConfiguration gc = new GlobalConfiguration();
+      parser.configureAsyncListenerExecutor(e, gc);
+
+      assert gc.getAsyncListenerExecutorFactoryClass().equals(DefaultExecutorFactory.class.getName());
+      assert gc.getAsyncListenerExecutorProperties().size() == 0;
+   }
+
+   public void testAsyncSerializationExecutorDefaults() throws Exception {
+      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
+      String xml = "<asyncSerializationExecutor />";
+      Element e = XmlConfigHelper.stringToElement(xml);
+
+      GlobalConfiguration gc = new GlobalConfiguration();
+      parser.configureAsyncSerializationExecutor(e, gc);
+
+      assert gc.getAsyncSerializationExecutorFactoryClass().equals(DefaultExecutorFactory.class.getName());
+      assert gc.getAsyncSerializationExecutorProperties().size() == 0;
+   }
+
+   public void testEvictionScheduledExecutorDefaults() throws Exception {
+      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
+      String xml = "<evictionScheduledExecutor />";
+      Element e = XmlConfigHelper.stringToElement(xml);
+
+      GlobalConfiguration gc = new GlobalConfiguration();
+      parser.configureEvictionScheduledExecutor(e, gc);
+
+      assert gc.getEvictionScheduledExecutorFactoryClass().equals(DefaultScheduledExecutorFactory.class.getName());
+      assert gc.getEvictionScheduledExecutorProperties().size() == 0;
+   }
+
+   public void testReplicationQueueScheduledExecutorDefaults() throws Exception {
+      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
+      String xml = "<replicationQueueScheduledExecutor />";
+      Element e = XmlConfigHelper.stringToElement(xml);
+
+      GlobalConfiguration gc = new GlobalConfiguration();
+      parser.configureReplicationQueueScheduledExecutor(e, gc);
+
+      assert gc.getReplicationQueueScheduledExecutorFactoryClass().equals(DefaultScheduledExecutorFactory.class.getName());
+      assert gc.getReplicationQueueScheduledExecutorProperties().size() == 0;
+   }
+}

Modified: core/branches/flat/src/main/java/org/horizon/config/parsing/RootElementBuilder.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/parsing/RootElementBuilder.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/java/org/horizon/config/parsing/RootElementBuilder.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -36,8 +36,8 @@
 import java.io.InputStream;
 
 /**
- * Parses an xml files and validates xml elements form {@link RootElementBuilder#JBOSSCACHE_CORE_NS} namespace according
- * to the configured schema.
+ * Parses an xml files and validates xml elements form {@link RootElementBuilder#HORIZON_NS} namespace according to the
+ * configured schema.
  *
  * @author Mircea.Markus at jboss.com
  * @since 1.0
@@ -46,19 +46,17 @@
 
    private static final JBossEntityResolver resolver = new JBossEntityResolver();
 
-   public static final String JBOSSCACHE_CORE_NS = "urn:jboss:starobrno-core:config:1.0";
-   public static final String JBOSSCACHE_REPO_NS = "urn:jboss:starobrno-core:cache-repo:1.0";
+   public static final String HORIZON_NS = "urn:horizon:config:1.0";
 
    static {
       // Globally register this namespace
-      JBossEntityResolver.registerEntity(JBOSSCACHE_CORE_NS, "horizon-config-1.0.xsd");
-      JBossEntityResolver.registerEntity(JBOSSCACHE_REPO_NS, "starobrno-registry-1.0.xsd");
+      JBossEntityResolver.registerEntity(HORIZON_NS, "horizon-config-1.0.xsd");
    }
 
    private static final Log log = LogFactory.getLog(RootElementBuilder.class);
    private ErrorHandler errorHandler;
    private boolean isValidating;
-   public static final String VALIDATING_SYSTEM_PROPERTY = "jbosscache.config.validate";
+   public static final String VALIDATING_SYSTEM_PROPERTY = "horizon.config.validate";
 
    public RootElementBuilder(ErrorHandler errorHandler) {
       this.errorHandler = errorHandler;
@@ -85,7 +83,7 @@
          if (isValidating) {
             docBuilderFactory.setValidating(true);
             docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
-            String[] value = {JBOSSCACHE_CORE_NS, JBOSSCACHE_REPO_NS};
+            String[] value = {HORIZON_NS};
             docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", value);
          }
          DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
@@ -98,7 +96,7 @@
       }
       catch (Exception e) {
          log.error(e);
-         throw new ConfigurationException("Could not parse the config file");
+         throw new ConfigurationException("Could not parse the config file", e);
       }
    }
 
@@ -120,7 +118,7 @@
 
       private void logAndThrowException(SAXParseException exception) {
          log.error("Configuration warning: " + exception.getMessage());
-         throw new ConfigurationException("Incorrect configuration file. Use '-Djbosscache.config.validate=false' to disable validation.", exception);
+         throw new ConfigurationException("Incorrect configuration file. Use '-Dhorizon.config.validate=false' to disable validation.", exception);
       }
    }
 

Modified: core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigHelper.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigHelper.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigHelper.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -25,6 +25,7 @@
 import org.horizon.logging.Log;
 import org.horizon.logging.LogFactory;
 import org.horizon.util.BeanUtils;
+import org.horizon.util.TypedProperties;
 import org.jboss.util.StringPropertyReplacer;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -49,7 +50,6 @@
 import java.io.InputStream;
 import java.io.StringWriter;
 import java.lang.reflect.Method;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 
@@ -63,28 +63,6 @@
    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>
@@ -350,7 +328,7 @@
     * @throws Exception if unable to parse the String or if it doesn't contain valid XML.
     */
    public static Element stringToElementInCoreNS(String xml) throws Exception {
-      xml = "<wrapper xmlns='" + RootElementBuilder.JBOSSCACHE_CORE_NS + "'>" + xml + "</wrapper>";
+      xml = "<wrapper xmlns='" + RootElementBuilder.HORIZON_NS + "'>" + xml + "</wrapper>";
       ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("utf8"));
       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
       factory.setNamespaceAware(true);
@@ -479,7 +457,7 @@
                if (paramTypes.length != 1) {
                   if (log.isTraceEnabled())
                      log.trace("Rejecting setter " + m + " on class " + objectClass + " due to incorrect number of parameters");
-                  continue; // try another param with the same name.                  
+                  continue; // try another param with the same name.
                }
 
                Class parameterType = paramTypes[0];
@@ -508,38 +486,10 @@
       }
    }
 
-   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: {0}", 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 = getSubElement(element, CONFIG_ATTR);
-            if (valueXml != null) xmlAttribs.put(name, valueXml);
-         } else {
-            if (valueStr.length() > 0) stringAttribs.put(name, valueStr);
-         }
-      }
-      return new ParsedAttributes(stringAttribs, xmlAttribs);
-   }
-
    public static Properties extractProperties(Element source) {
-      Properties p = new Properties();
+      TypedProperties p = new TypedProperties();
       NodeList list = source.getElementsByTagName("property");
-
+      if (list == null) return null;
       // loop through attributes
       for (int loop = 0; loop < list.getLength(); loop++) {
          Node node = list.item(loop);
@@ -547,7 +497,7 @@
 
          // for each element (attribute) ...
          Element element = (Element) node;
-         String name = element.getAttribute(NAME);
+         String name = element.getAttribute("name");
          String valueStr = element.getAttribute("value");
 
          if (valueStr.length() > 0) {
@@ -556,7 +506,7 @@
             p.put(name, valueStr);
          }
       }
-      return p;
+      return p.isEmpty() ? null : p;
    }
 
    public static String toString(Element e) {

Modified: core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigurationParser.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigurationParser.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigurationParser.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -34,6 +34,14 @@
    void initialize(InputStream inputStream) throws IOException;
 
    /**
+    * Parses the default template configuration.
+    *
+    * @return a configuration instance representing the "default" block in the configuration file
+    * @throws ConfigurationException if there is a problem parsing the configuration XML
+    */
+   Configuration parseDefaultConfiguration() throws ConfigurationException;
+
+   /**
     * Parses and retrieves configuration overrides for named caches.
     *
     * @return a Map of Configuration overrides keyed on cache name

Modified: core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigurationParserImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigurationParserImpl.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigurationParserImpl.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -1,18 +1,24 @@
 package org.horizon.config.parsing;
 
+import org.horizon.config.CacheLoaderConfig;
 import org.horizon.config.Configuration;
 import org.horizon.config.ConfigurationException;
+import org.horizon.config.CustomInterceptorConfig;
 import org.horizon.config.GlobalConfiguration;
+import org.horizon.config.parsing.element.CustomInterceptorsElementParser;
+import org.horizon.config.parsing.element.EvictionElementParser;
+import org.horizon.config.parsing.element.LoadersElementParser;
+import org.horizon.lock.IsolationLevel;
 import org.horizon.util.FileLookup;
 import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
 
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Collections;
-import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
-import java.util.Set;
+import java.util.Properties;
 
 /**
  * The default XML configuration parser
@@ -21,9 +27,16 @@
  * @since 1.0
  */
 public class XmlConfigurationParserImpl extends XmlParserBase implements XmlConfigurationParser {
+
+   // this parser will need to be initialized.
    boolean initialized = false;
+
+   // the root element, representing the <horizon /> tag
    Element rootElement;
 
+   // root element builder that deals with
+   private RootElementBuilder rootElementBuilder;
+
    /**
     * Constructs a new parser
     */
@@ -68,31 +81,339 @@
 
    public Configuration parseDefaultConfiguration() throws ConfigurationException {
       assertInitialized();
-      Element defaultConfiguration = getSingleElementInCoreNS("default", rootElement);
-      return new XmlConfigurationParserJBC3().parseElementIgnoringRoot(defaultConfiguration);
+//      Element defaultConfiguration = getSingleElementInCoreNS("default", rootElement);
+//      rootElementBuilder = new RootElementBuilder();
+//      rootElement = defaultConfiguration;
+//      return parseElementIgnoringRoot();
+      return null;
    }
 
    public Map<String, Configuration> parseNamedConfigurations() throws ConfigurationException {
       assertInitialized();
-      Set<Element> elements = getAllElementsInCoreNS("namedCache", rootElement);
-      if (elements.isEmpty()) return Collections.emptyMap();
-      Map<String, Configuration> namedConfigurations = new HashMap<String, Configuration>(elements.size(), 1.0f);
-      for (Element e : elements) {
-         String configurationName = getAttributeValue(e, "name");
-         if (namedConfigurations.containsKey(configurationName))
-            throw new ConfigurationException("Named cache " + configurationName + " contains duplicate entries!");
-         namedConfigurations.put(configurationName, new XmlConfigurationParserJBC3().parseElementIgnoringRoot(e));
-      }
-
-      return namedConfigurations;
+//      Set<Element> elements = getAllElementsInCoreNS("namedCache", rootElement);
+//      if (elements.isEmpty()) return Collections.emptyMap();
+//      Map<String, Configuration> namedConfigurations = new HashMap<String, Configuration>(elements.size(), 1.0f);
+//      rootElementBuilder = new RootElementBuilder();
+//      for (Element e : elements) {
+//         String configurationName = getAttributeValue(e, "name");
+//         if (namedConfigurations.containsKey(configurationName))
+//            throw new ConfigurationException("Named cache " + configurationName + " contains duplicate entries!");
+//
+//         namedConfigurations.put(configurationName, parseElementIgnoringRoot());
+//      }
+//
+//      return namedConfigurations;
+      return null;
    }
 
    public GlobalConfiguration parseGlobalConfiguration() {
-      throw new RuntimeException("Implement me");
+      assertInitialized();
+      Element globalElement = getSingleElementInCoreNS("global", rootElement);
+      globalElement.normalize();
+
+      return null;
    }
 
    private void assertInitialized() {
       if (!initialized)
          throw new ConfigurationException("Parser not initialized.  Please invoke initialize() first, or use a constructor that initializes the parser.");
    }
+
+   /**
+    * Parses an XML file and returns a new configuration. For looking up the file, {@link org.horizon.util.FileLookup}
+    * is used.
+    *
+    * @see org.horizon.util.FileLookup
+    */
+//   public Configuration parseFile(String filename) {
+//      InputStream is = new FileLookup().lookupFile(filename);
+//      if (is == null) {
+//         throw new ConfigurationException("Unable to find config file " + filename + " either in classpath or on the filesystem!");
+//      }
+//      return parseStream(is);
+//   }
+
+   /**
+    * Similar to {@link #parseFile(String)}, just that it does not create the input stream.
+    */
+//   public Configuration parseStream(InputStream configStream) {
+//      readRoot(configStream);
+//      return processElements(false);
+//   }
+//
+//   public Configuration parseElement() {
+//      rootElement.normalize();
+//      return processElements(false);
+//   }
+//
+//   public Configuration parseElementIgnoringRoot() {
+//      rootElement.normalize();
+//      return processElements(true);
+//   }
+   public boolean isValidating() {
+      return rootElementBuilder.isValidating();
+   }
+
+   void configureClustering(Element e, Configuration config) {
+      if (e == null) return; //we might not have this configured
+      // there are 2 attribs - mode and clusterName
+      boolean repl = true;
+      String mode = getAttributeValue(e, "mode").toUpperCase();
+      if (mode.startsWith("R"))
+         repl = true;
+      else if (mode.startsWith("I"))
+         repl = false;
+
+      Element asyncEl = getSingleElementInCoreNS("async", e);
+      Element syncEl = getSingleElementInCoreNS("sync", e);
+      if (syncEl != null && asyncEl != null)
+         throw new ConfigurationException("Cannot have sync and async elements within the same cluster element!");
+      boolean sync = asyncEl == null; // even if both are null, we default to sync
+      if (sync) {
+         config.setCacheMode(repl ? Configuration.CacheMode.REPL_SYNC : Configuration.CacheMode.INVALIDATION_SYNC);
+         configureSyncMode(syncEl, config);
+      } else {
+         config.setCacheMode(repl ? Configuration.CacheMode.REPL_ASYNC : Configuration.CacheMode.INVALIDATION_ASYNC);
+         configureAsyncMode(asyncEl, config);
+      }
+      String cn = getAttributeValue(e, "clusterName");
+//      if (existsAttribute(cn)) config.setClusterName(cn);
+      configureStateRetrieval(getSingleElementInCoreNS("stateRetrieval", e), config);
+//      configureTransport(getSingleElementInCoreNS("jgroupsConfig", e), config);
+   }
+
+   void configureStateRetrieval(Element element, Configuration config) {
+      if (element == null) return; //we might not have this configured
+      String fetchInMemoryState = getAttributeValue(element, "fetchInMemoryState");
+      if (existsAttribute(fetchInMemoryState)) config.setFetchInMemoryState(getBoolean(fetchInMemoryState));
+      String stateRetrievalTimeout = getAttributeValue(element, "timeout");
+      if (existsAttribute(stateRetrievalTimeout)) config.setStateRetrievalTimeout(getLong(stateRetrievalTimeout));
+
+   }
+
+   void configureTransaction(Element element, Configuration config) {
+      if (element == null) return;
+      String attrName = "transactionManagerLookupClass";
+      String txMngLookupClass = getAttributeValue(element, attrName);
+      if (existsAttribute(txMngLookupClass)) config.setTransactionManagerLookupClass(txMngLookupClass);
+      String syncRollbackPhase = getAttributeValue(element, "syncRollbackPhase");
+      if (existsAttribute(syncRollbackPhase)) config.setSyncRollbackPhase(getBoolean(syncRollbackPhase));
+      String syncCommitPhase = getAttributeValue(element, "syncCommitPhase");
+      if (existsAttribute(syncCommitPhase)) config.setSyncCommitPhase(getBoolean(syncCommitPhase));
+   }
+
+   void configureSerialization(Element element, Configuration config) {
+      if (element == null) return;
+      String objectInputStreamPoolSize = getAttributeValue(element, "objectInputStreamPoolSize");
+//      if (existsAttribute(objectInputStreamPoolSize))
+//         config.setObjectInputStreamPoolSize(getInt(objectInputStreamPoolSize));
+      String objectOutputStreamPoolSize = getAttributeValue(element, "objectOutputStreamPoolSize");
+//      if (existsAttribute(objectOutputStreamPoolSize))
+//         config.setObjectOutputStreamPoolSize(getInt(objectOutputStreamPoolSize));
+      String version = getAttributeValue(element, "version");
+//      if (existsAttribute(version)) config.setReplVersionString(version);
+      String marshallerClass = getAttributeValue(element, "marshallerClass");
+//      if (existsAttribute(marshallerClass)) config.setMarshallerClass(marshallerClass);
+      String useLazyDeserialization = getAttributeValue(element, "useLazyDeserialization");
+      if (existsAttribute(useLazyDeserialization)) config.setUseLazyDeserialization(getBoolean(useLazyDeserialization));
+      String useRegionBasedMarshalling = getAttributeValue(element, "useRegionBasedMarshalling");
+//      if (existsAttribute(useRegionBasedMarshalling))
+//         config.setUseRegionBasedMarshalling(getBoolean(useRegionBasedMarshalling));
+   }
+
+   void configureCustomInterceptors(Element element, Configuration config) {
+      if (element == null) return; //this element might be missing
+      CustomInterceptorsElementParser parser = new CustomInterceptorsElementParser();
+      List<CustomInterceptorConfig> interceptorConfigList = parser.parseCustomInterceptors(element);
+      config.setCustomInterceptors(interceptorConfigList);
+   }
+
+   void configureListeners(Element element, Configuration config) {
+      if (element == null) return; //this element is optional
+      String asyncPoolSizeStr = getAttributeValue(element, "asyncPoolSize");
+//      if (existsAttribute(asyncPoolSizeStr)) config.setListenerAsyncPoolSize(getInt(asyncPoolSizeStr));
+
+      String asyncQueueSizeStr = getAttributeValue(element, "asyncQueueSize");
+//      if (existsAttribute(asyncQueueSizeStr)) config.setListenerAsyncQueueSize(getInt(asyncQueueSizeStr));
+   }
+
+   void configureInvocationBatching(Element element, Configuration config) {
+      if (element == null) return; //this element is optional
+      boolean enabled = getBoolean(getAttributeValue(element, "enabled"));
+      config.setInvocationBatchingEnabled(enabled);
+   }
+
+   void configureCacheLoaders(Element element, Configuration config) {
+      if (element == null) return; //null cache loaders are allowed
+      LoadersElementParser clElementParser = new LoadersElementParser();
+      CacheLoaderConfig cacheLoaderConfig = clElementParser.parseLoadersElement(element);
+      config.setCacheLoaderConfig(cacheLoaderConfig);
+   }
+
+   void configureEviction(Element element, Configuration config) {
+      if (element == null) return; //no eviction might be configured
+      EvictionElementParser evictionElementParser = new EvictionElementParser();
+      //config.setEvictionConfig(evictionElementParser.parseEvictionElement(element));
+   }
+
+   void configureJmxStatistics(Element element, Configuration config) {
+      if (element == null) return; //might not be specified
+      String enabled = getAttributeValue(element, "enabled");
+      config.setExposeManagementStatistics(getBoolean(enabled));
+   }
+
+   void configureInvalidation(Element element, Configuration config) {
+      if (element == null) return; //might be replication
+      Element async = getSingleElement("async");
+      if (async != null) {
+         config.setCacheMode(Configuration.CacheMode.INVALIDATION_ASYNC);
+         configureAsyncMode(getSingleElementInCoreNS("async", element), config);
+      }
+      Element sync = getSingleElement("sync");
+      if (sync != null) {
+         config.setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
+         configureSyncMode(getSingleElementInCoreNS("sync", element), config);
+      }
+   }
+
+   void configureSyncMode(Element element, Configuration config) {
+      String replTimeout = getAttributeValue(element, "replTimeout");
+      if (existsAttribute(replTimeout)) config.setSyncReplTimeout(getLong(replTimeout));
+   }
+
+   void configureAsyncMode(Element element, Configuration config) {
+      String useReplQueue = getAttributeValue(element, "useReplQueue");
+      if (existsAttribute(useReplQueue)) config.setUseReplQueue(getBoolean(useReplQueue));
+      String replQueueInterval = getAttributeValue(element, "replQueueInterval");
+      if (existsAttribute(replQueueInterval)) config.setReplQueueInterval(getLong(replQueueInterval));
+      String replQueueMaxElements = getAttributeValue(element, "replQueueMaxElements");
+
+      if (existsAttribute(replQueueMaxElements)) config.setReplQueueMaxElements(getInt(replQueueMaxElements));
+      String serializationExecutorPoolSize = getAttributeValue(element, "serializationExecutorPoolSize");
+//      if (existsAttribute(serializationExecutorPoolSize))
+//         config.setSerializationExecutorPoolSize(getInt(serializationExecutorPoolSize));
+
+      String serializationExecutorQueueSize = getAttributeValue(element, "serializationExecutorQueueSize");
+//      if (existsAttribute(serializationExecutorQueueSize))
+//         config.setSerializationExecutorQueueSize(getInt(serializationExecutorQueueSize));
+   }
+
+   void configureLocking(Element element, Configuration config) {
+      String isolationLevel = getAttributeValue(element, "isolationLevel");
+      if (existsAttribute(isolationLevel)) config.setIsolationLevel(IsolationLevel.valueOf(isolationLevel));
+      String lockParentForChildInsertRemove = getAttributeValue(element, "lockParentForChildInsertRemove");
+      if (existsAttribute(lockParentForChildInsertRemove))
+         config.setLockParentForChildInsertRemove(getBoolean(lockParentForChildInsertRemove));
+      String lockAcquisitionTimeout = getAttributeValue(element, "lockAcquisitionTimeout");
+      if (existsAttribute(lockAcquisitionTimeout)) config.setLockAcquisitionTimeout(getLong(lockAcquisitionTimeout));
+      String writeSkewCheck = getAttributeValue(element, "writeSkewCheck");
+      if (existsAttribute(writeSkewCheck)) config.setWriteSkewCheck(getBoolean(writeSkewCheck));
+      String concurrencyLevel = getAttributeValue(element, "concurrencyLevel");
+      if (existsAttribute(concurrencyLevel)) config.setConcurrencyLevel(getInt(concurrencyLevel));
+   }
+
+   // ----------------------------------------------------------------------------------------------------------------
+   //      Configure the GlobalConfiguration object
+   // ----------------------------------------------------------------------------------------------------------------
+
+   void configureShutdown(Element element, GlobalConfiguration config) {
+      if (element != null) {
+         String hookBehavior = getAttributeValue(element, "hookBehavior");
+         if (existsAttribute(hookBehavior)) config.setShutdownHookBehavior(hookBehavior);
+      }
+   }
+
+   void configureTransport(Element element, GlobalConfiguration config) {
+//      if (element == null) return; //transport might be missing
+//
+//      // first see if a configFile is provided
+//      String cfgFile = getAttributeValue(element, "configFile");
+//      if (existsAttribute(cfgFile)) {
+//         // try and load this file
+//         URL u = new FileLookup().lookupFileLocation(cfgFile);
+//         config.setJgroupsConfigFile(u);
+//      } else {
+//         String multiplexerStack = getAttributeValue(element, "multiplexerStack");
+//         if (existsAttribute(multiplexerStack)) {
+//            config.setMultiplexerStack(multiplexerStack);
+//         } else {
+//            JGroupsStackParser stackParser = new JGroupsStackParser();
+//            String clusterConfigStr = stackParser.parseClusterConfigXml(element);
+//            if (clusterConfigStr != null && clusterConfigStr.trim().length() > 0)
+//               config.setClusterConfig(clusterConfigStr);
+//         }
+//      }
+   }
+
+   void configureMarshalling(Element e, GlobalConfiguration configuration) {
+      if (e != null) {
+         String tmp = getAttributeValue(e, "marshallerClass");
+         if (existsAttribute(tmp)) configuration.setMarshallerClass(tmp);
+
+         tmp = getAttributeValue(e, "version");
+         if (existsAttribute(tmp)) configuration.setMarshallVersion(tmp);
+
+         tmp = getAttributeValue(e, "objectInputStreamPoolSize");
+         if (existsAttribute(tmp)) configuration.setObjectInputStreamPoolSize(getInt(tmp));
+
+         tmp = getAttributeValue(e, "objectOutputStreamPoolSize");
+         if (existsAttribute(tmp)) configuration.setObjectOutputStreamPoolSize(getInt(tmp));
+      }
+   }
+
+   void configureAsyncListenerExecutor(Element e, GlobalConfiguration gc) {
+      if (e != null) {
+         String tmp = getAttributeValue(e, "factory");
+         if (existsAttribute(tmp)) gc.setAsyncListenerExecutorFactoryClass(tmp);
+         Properties p = XmlConfigHelper.extractProperties(e);
+         if (p != null) gc.setAsyncListenerExecutorProperties(p);
+      }
+   }
+
+   void configureAsyncSerializationExecutor(Element e, GlobalConfiguration gc) {
+      if (e != null) {
+         String tmp = getAttributeValue(e, "factory");
+         if (existsAttribute(tmp)) gc.setAsyncSerializationExecutorFactoryClass(tmp);
+         Properties p = XmlConfigHelper.extractProperties(e);
+         if (p != null) gc.setAsyncSerializationExecutorProperties(p);
+      }
+   }
+
+   void configureEvictionScheduledExecutor(Element e, GlobalConfiguration gc) {
+      if (e != null) {
+         String tmp = getAttributeValue(e, "factory");
+         if (existsAttribute(tmp)) gc.setEvictionScheduledExecutorFactoryClass(tmp);
+         Properties p = XmlConfigHelper.extractProperties(e);
+         if (p != null) gc.setEvictionScheduledExecutorProperties(p);
+      }
+   }
+
+   void configureReplicationQueueScheduledExecutor(Element e, GlobalConfiguration gc) {
+      if (e != null) {
+         String tmp = getAttributeValue(e, "factory");
+         if (existsAttribute(tmp)) gc.setReplicationQueueScheduledExecutorFactoryClass(tmp);
+         Properties p = XmlConfigHelper.extractProperties(e);
+         if (p != null) gc.setReplicationQueueScheduledExecutorProperties(p);
+      }
+   }
+
+   private Element getSingleElement(String elementName) {
+      return getSingleElementInCoreNS(elementName, rootElement);
+   }
+
+   private void readRoot(InputStream config) {
+      rootElement = rootElementBuilder.readRoot(config);
+   }
+
+   /**
+    * Tests whether the element passed in is a modern (3.0) config element rather than a legacy one.
+    *
+    * @param element element to test
+    * @return true of the element is a modern one and can be parsed using the current parser.
+    */
+   public boolean isValidElementRoot(Element element) {
+      // simply test for the "jbosscache" element.
+      NodeList elements = element.getElementsByTagName("jbosscache");
+      return elements != null && elements.getLength() > 0;
+   }
 }

Deleted: core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigurationParserJBC3.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigurationParserJBC3.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/java/org/horizon/config/parsing/XmlConfigurationParserJBC3.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -1,369 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.horizon.config.parsing;
-
-import org.horizon.config.CacheLoaderConfig;
-import org.horizon.config.Configuration;
-import org.horizon.config.Configuration.CacheMode;
-import org.horizon.config.ConfigurationException;
-import org.horizon.config.CustomInterceptorConfig;
-import org.horizon.config.GlobalConfiguration;
-import org.horizon.config.parsing.element.CustomInterceptorsElementParser;
-import org.horizon.config.parsing.element.EvictionElementParser;
-import org.horizon.config.parsing.element.LoadersElementParser;
-import org.horizon.lock.IsolationLevel;
-import org.horizon.util.FileLookup;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.ErrorHandler;
-
-import java.io.InputStream;
-import java.util.List;
-
-/**
- * Reads in XMLconfiguration files and spits out a {@link Configuration} object. By default this class uses a validating
- * parser (configurable).
- * <p/>
- * Following system properties can be used for customizing parser behavior: <ul> <li>
- * <b>-Djbosscache.config.validate=false</b> will make the parser non-validating </li> <li>
- * <b>-Djbosscache.config.schemaLocation=url</b> allows one to specify a validation schema that would override the one
- * specified in the the xml document </li> </ul> This class is stateful and one instance should be used for parsing a
- * single configuration file.
- *
- * @author Mircea.Markus at jboss.com
- * @see RootElementBuilder
- * @since 1.0
- */
-public class XmlConfigurationParserJBC3 extends XmlParserBase {
-   private RootElementBuilder rootElementBuilder;
-
-   /**
-    * the resulting configuration.
-    */
-   private Configuration config = new Configuration();
-   private GlobalConfiguration globalconfig = new GlobalConfiguration();
-   private Element root;
-
-   /**
-    * If validation is on (default) one can specify an error handler for handling validation errors. The default error
-    * handler just logs parsing errors received.
-    */
-   public XmlConfigurationParserJBC3(ErrorHandler errorHandler) {
-      rootElementBuilder = new RootElementBuilder(errorHandler);
-   }
-
-   /**
-    * Same as {@link #XmlConfigurationParserJBC3(org.xml.sax.ErrorHandler)}.
-    *
-    * @param validating should the underlaying parser disable the validation?
-    */
-   public XmlConfigurationParserJBC3(boolean validating, ErrorHandler errorHandler) {
-      rootElementBuilder = new RootElementBuilder(errorHandler, validating);
-   }
-
-   /**
-    * Constructs a parser having validation enabled with a ErrorHandler that only logs the parser errors.
-    */
-   public XmlConfigurationParserJBC3() {
-      rootElementBuilder = new RootElementBuilder();
-   }
-
-   /**
-    * Parses an XML file and returns a new configuration. For looking up the file, {@link org.horizon.util.FileLookup}
-    * is used.
-    *
-    * @see org.horizon.util.FileLookup
-    */
-   public Configuration parseFile(String filename) {
-      InputStream is = new FileLookup().lookupFile(filename);
-      if (is == null) {
-         throw new ConfigurationException("Unable to find config file " + filename + " either in classpath or on the filesystem!");
-      }
-      return parseStream(is);
-   }
-
-   /**
-    * Similar to {@link #parseFile(String)}, just that it does not create the input stream.
-    */
-   public Configuration parseStream(InputStream configStream) {
-      readRoot(configStream);
-      return processElements(false);
-   }
-
-   /**
-    * Root should be the <b>jbosscache</b> element in the configuration file.
-    */
-   public Configuration parseElement(Element root) {
-      this.root = root;
-      this.root.normalize();
-      return processElements(false);
-   }
-
-   public Configuration parseElementIgnoringRoot(Element root) {
-      this.root = root;
-      this.root.normalize();
-      return processElements(true);
-   }
-
-   public boolean isValidating() {
-      return rootElementBuilder.isValidating();
-   }
-
-   private Configuration processElements(boolean ignoreRoot) {
-      if (!ignoreRoot &&
-            (!"jbosscache".equals(root.getLocalName()) || !RootElementBuilder.JBOSSCACHE_CORE_NS.equals(root.getNamespaceURI()))) {
-         throw new ConfigurationException("Expected root element {" + RootElementBuilder.JBOSSCACHE_CORE_NS + "}" + "jbosscache");
-      }
-
-      try {
-         configureLocking(getSingleElement("locking"));
-         configureTransaction(getSingleElement("transaction"));
-         configureClustering(getSingleElement("clustering"));
-         configureSerialization(getSingleElement("serialization"));
-         configureInvalidation(getSingleElement("invalidation"));
-         configureStartup(getSingleElement("startup"));
-         configureShutdown(getSingleElement("shutdown"));
-         configureJmxStatistics(getSingleElement("jmxStatistics"));
-         configureEviction(getSingleElement("eviction"));
-         configureCacheLoaders(getSingleElement("loaders"));
-         configureCustomInterceptors(getSingleElement("customInterceptors"));
-         configureListeners(getSingleElement("listeners"));
-         configureInvocationBatching(getSingleElement("invocationBatching"));
-      }
-      catch (Exception e) {
-         throw new ConfigurationException("Unexpected exception while parsing the configuration file", e);
-      }
-      return config;
-   }
-
-   private void configureClustering(Element e) {
-      if (e == null) return; //we might not have this configured
-      // there are 2 attribs - mode and clusterName
-      boolean repl = true;
-      String mode = getAttributeValue(e, "mode").toUpperCase();
-      if (mode.startsWith("R"))
-         repl = true;
-      else if (mode.startsWith("I"))
-         repl = false;
-
-      Element asyncEl = getSingleElementInCoreNS("async", e);
-      Element syncEl = getSingleElementInCoreNS("sync", e);
-      if (syncEl != null && asyncEl != null)
-         throw new ConfigurationException("Cannot have sync and async elements within the same cluster element!");
-      boolean sync = asyncEl == null; // even if both are null, we default to sync
-      if (sync) {
-         config.setCacheMode(repl ? CacheMode.REPL_SYNC : CacheMode.INVALIDATION_SYNC);
-         configureSyncMode(syncEl);
-      } else {
-         config.setCacheMode(repl ? CacheMode.REPL_ASYNC : CacheMode.INVALIDATION_ASYNC);
-         configureAsyncMode(asyncEl);
-      }
-      String cn = getAttributeValue(e, "clusterName");
-//      if (existsAttribute(cn)) config.setClusterName(cn);
-      configureStateRetrieval(getSingleElementInCoreNS("stateRetrieval", e));
-      configureTransport(getSingleElementInCoreNS("jgroupsConfig", e));
-   }
-
-   private void configureStateRetrieval(Element element) {
-      if (element == null) return; //we might not have this configured
-      String fetchInMemoryState = getAttributeValue(element, "fetchInMemoryState");
-      if (existsAttribute(fetchInMemoryState)) config.setFetchInMemoryState(getBoolean(fetchInMemoryState));
-      String stateRetrievalTimeout = getAttributeValue(element, "timeout");
-      if (existsAttribute(stateRetrievalTimeout)) config.setStateRetrievalTimeout(getLong(stateRetrievalTimeout));
-
-   }
-
-   private void configureTransaction(Element element) {
-      if (element == null) return;
-      String attrName = "transactionManagerLookupClass";
-      String txMngLookupClass = getAttributeValue(element, attrName);
-      if (existsAttribute(txMngLookupClass)) config.setTransactionManagerLookupClass(txMngLookupClass);
-      String syncRollbackPhase = getAttributeValue(element, "syncRollbackPhase");
-      if (existsAttribute(syncRollbackPhase)) config.setSyncRollbackPhase(getBoolean(syncRollbackPhase));
-      String syncCommitPhase = getAttributeValue(element, "syncCommitPhase");
-      if (existsAttribute(syncCommitPhase)) config.setSyncCommitPhase(getBoolean(syncCommitPhase));
-   }
-
-   private void configureSerialization(Element element) {
-      if (element == null) return;
-      String objectInputStreamPoolSize = getAttributeValue(element, "objectInputStreamPoolSize");
-//      if (existsAttribute(objectInputStreamPoolSize))
-//         config.setObjectInputStreamPoolSize(getInt(objectInputStreamPoolSize));
-      String objectOutputStreamPoolSize = getAttributeValue(element, "objectOutputStreamPoolSize");
-//      if (existsAttribute(objectOutputStreamPoolSize))
-//         config.setObjectOutputStreamPoolSize(getInt(objectOutputStreamPoolSize));
-      String version = getAttributeValue(element, "version");
-//      if (existsAttribute(version)) config.setReplVersionString(version);
-      String marshallerClass = getAttributeValue(element, "marshallerClass");
-//      if (existsAttribute(marshallerClass)) config.setMarshallerClass(marshallerClass);
-      String useLazyDeserialization = getAttributeValue(element, "useLazyDeserialization");
-      if (existsAttribute(useLazyDeserialization)) config.setUseLazyDeserialization(getBoolean(useLazyDeserialization));
-      String useRegionBasedMarshalling = getAttributeValue(element, "useRegionBasedMarshalling");
-//      if (existsAttribute(useRegionBasedMarshalling))
-//         config.setUseRegionBasedMarshalling(getBoolean(useRegionBasedMarshalling));
-   }
-
-   private void configureCustomInterceptors(Element element) {
-      if (element == null) return; //this element might be missing
-      CustomInterceptorsElementParser parser = new CustomInterceptorsElementParser();
-      List<CustomInterceptorConfig> interceptorConfigList = parser.parseCustomInterceptors(element);
-      config.setCustomInterceptors(interceptorConfigList);
-   }
-
-   private void configureListeners(Element element) {
-      if (element == null) return; //this element is optional
-      String asyncPoolSizeStr = getAttributeValue(element, "asyncPoolSize");
-//      if (existsAttribute(asyncPoolSizeStr)) config.setListenerAsyncPoolSize(getInt(asyncPoolSizeStr));
-
-      String asyncQueueSizeStr = getAttributeValue(element, "asyncQueueSize");
-//      if (existsAttribute(asyncQueueSizeStr)) config.setListenerAsyncQueueSize(getInt(asyncQueueSizeStr));
-   }
-
-   private void configureInvocationBatching(Element element) {
-      if (element == null) return; //this element is optional
-      boolean enabled = getBoolean(getAttributeValue(element, "enabled"));
-      config.setInvocationBatchingEnabled(enabled);
-   }
-
-   private void configureCacheLoaders(Element element) {
-      if (element == null) return; //null cache loaders are allowed
-      LoadersElementParser clElementParser = new LoadersElementParser();
-      CacheLoaderConfig cacheLoaderConfig = clElementParser.parseLoadersElement(element);
-      config.setCacheLoaderConfig(cacheLoaderConfig);
-   }
-
-   private void configureEviction(Element element) {
-      if (element == null) return; //no eviction might be configured
-      EvictionElementParser evictionElementParser = new EvictionElementParser();
-      //config.setEvictionConfig(evictionElementParser.parseEvictionElement(element));
-   }
-
-   private void configureJmxStatistics(Element element) {
-      if (element == null) return; //might not be specified
-      String enabled = getAttributeValue(element, "enabled");
-      config.setExposeManagementStatistics(getBoolean(enabled));
-   }
-
-   private void configureShutdown(Element element) {
-      if (element == null) return;
-      String hookBehavior = getAttributeValue(element, "hookBehavior");
-//      if (existsAttribute(hookBehavior)) config.setShutdownHookBehavior(hookBehavior);
-   }
-
-   private void configureTransport(Element element) {
-//      if (element == null) return; //transport might be missing
-//
-//      // first see if a configFile is provided
-//      String cfgFile = getAttributeValue(element, "configFile");
-//      if (existsAttribute(cfgFile)) {
-//         // try and load this file
-//         URL u = new FileLookup().lookupFileLocation(cfgFile);
-//         config.setJgroupsConfigFile(u);
-//      } else {
-//         String multiplexerStack = getAttributeValue(element, "multiplexerStack");
-//         if (existsAttribute(multiplexerStack)) {
-//            config.setMultiplexerStack(multiplexerStack);
-//         } else {
-//            JGroupsStackParser stackParser = new JGroupsStackParser();
-//            String clusterConfigStr = stackParser.parseClusterConfigXml(element);
-//            if (clusterConfigStr != null && clusterConfigStr.trim().length() > 0)
-//               config.setClusterConfig(clusterConfigStr);
-//         }
-//      }
-   }
-
-   private void configureStartup(Element element) {
-      if (element == null) return; //we might not have this configured
-      String inactiveOnStartup = getAttributeValue(element, "regionsInactiveOnStartup");
-      if (existsAttribute(inactiveOnStartup)) 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(getSingleElementInCoreNS("async", element));
-      }
-      Element sync = getSingleElement("sync");
-      if (sync != null) {
-         config.setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
-         configureSyncMode(getSingleElementInCoreNS("sync", element));
-      }
-   }
-
-   private void configureSyncMode(Element element) {
-      String replTimeout = getAttributeValue(element, "replTimeout");
-      if (existsAttribute(replTimeout)) config.setSyncReplTimeout(getLong(replTimeout));
-   }
-
-   private void configureAsyncMode(Element element) {
-      String useReplQueue = getAttributeValue(element, "useReplQueue");
-      if (existsAttribute(useReplQueue)) config.setUseReplQueue(getBoolean(useReplQueue));
-      String replQueueInterval = getAttributeValue(element, "replQueueInterval");
-      if (existsAttribute(replQueueInterval)) config.setReplQueueInterval(getLong(replQueueInterval));
-      String replQueueMaxElements = getAttributeValue(element, "replQueueMaxElements");
-
-      if (existsAttribute(replQueueMaxElements)) config.setReplQueueMaxElements(getInt(replQueueMaxElements));
-      String serializationExecutorPoolSize = getAttributeValue(element, "serializationExecutorPoolSize");
-//      if (existsAttribute(serializationExecutorPoolSize))
-//         config.setSerializationExecutorPoolSize(getInt(serializationExecutorPoolSize));
-
-      String serializationExecutorQueueSize = getAttributeValue(element, "serializationExecutorQueueSize");
-//      if (existsAttribute(serializationExecutorQueueSize))
-//         config.setSerializationExecutorQueueSize(getInt(serializationExecutorQueueSize));
-   }
-
-   private void configureLocking(Element element) {
-      String isolationLevel = getAttributeValue(element, "isolationLevel");
-      if (existsAttribute(isolationLevel)) config.setIsolationLevel(IsolationLevel.valueOf(isolationLevel));
-      String lockParentForChildInsertRemove = getAttributeValue(element, "lockParentForChildInsertRemove");
-      if (existsAttribute(lockParentForChildInsertRemove))
-         config.setLockParentForChildInsertRemove(getBoolean(lockParentForChildInsertRemove));
-      String lockAcquisitionTimeout = getAttributeValue(element, "lockAcquisitionTimeout");
-      if (existsAttribute(lockAcquisitionTimeout)) config.setLockAcquisitionTimeout(getLong(lockAcquisitionTimeout));
-      String writeSkewCheck = getAttributeValue(element, "writeSkewCheck");
-      if (existsAttribute(writeSkewCheck)) config.setWriteSkewCheck(getBoolean(writeSkewCheck));
-      String concurrencyLevel = getAttributeValue(element, "concurrencyLevel");
-      if (existsAttribute(concurrencyLevel)) config.setConcurrencyLevel(getInt(concurrencyLevel));
-   }
-
-   private Element getSingleElement(String elementName) {
-      return getSingleElementInCoreNS(elementName, root);
-   }
-
-   private void readRoot(InputStream config) {
-      root = rootElementBuilder.readRoot(config);
-   }
-
-   /**
-    * Tests whether the element passed in is a modern (3.0) config element rather than a legacy one.
-    *
-    * @param element element to test
-    * @return true of the element is a modern one and can be parsed using the current parser.
-    */
-   public boolean isValidElementRoot(Element element) {
-      // simply test for the "jbosscache" element.
-      NodeList elements = element.getElementsByTagName("jbosscache");
-      return elements != null && elements.getLength() > 0;
-   }
-}

Modified: core/branches/flat/src/main/java/org/horizon/config/parsing/XmlParserBase.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/parsing/XmlParserBase.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/java/org/horizon/config/parsing/XmlParserBase.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -93,14 +93,14 @@
     * Convenient method for retrieving a single element with the give name, in the core namespace
     */
    protected Element getSingleElementInCoreNS(String elementName, Element parent) {
-      return getSingleElement(RootElementBuilder.JBOSSCACHE_CORE_NS, elementName, parent);
+      return getSingleElement(RootElementBuilder.HORIZON_NS, elementName, parent);
    }
 
    /**
     * Convenience method for retrieving all child elements bearing the same element name, in the core namespace
     */
    protected Set<Element> getAllElementsInCoreNS(String elementName, Element parent) {
-      return getAllElements(RootElementBuilder.JBOSSCACHE_CORE_NS, elementName, parent);
+      return getAllElements(RootElementBuilder.HORIZON_NS, elementName, parent);
    }
 
    /**

Modified: core/branches/flat/src/main/java/org/horizon/manager/CacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/manager/CacheManager.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/java/org/horizon/manager/CacheManager.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -2,6 +2,7 @@
 
 import org.horizon.Cache;
 import org.horizon.config.Configuration;
+import org.horizon.config.DuplicateCacheNameException;
 import org.horizon.factories.scopes.Scope;
 import org.horizon.factories.scopes.Scopes;
 import org.horizon.lifecycle.Lifecycle;
@@ -59,9 +60,9 @@
     *
     * @param cacheName             name of cache to define
     * @param configurationOverride configuration overrides to use
-    * @throws CacheNameExistsException if the name is already in use.
+    * @throws DuplicateCacheNameException if the name is already in use.
     */
-   void defineCache(String cacheName, Configuration configurationOverride) throws CacheNameExistsException;
+   void defineCache(String cacheName, Configuration configurationOverride) throws DuplicateCacheNameException;
 
    /**
     * Retrieves the default cache associated with this cache manager.

Deleted: core/branches/flat/src/main/java/org/horizon/manager/CacheNameExistsException.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/manager/CacheNameExistsException.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/java/org/horizon/manager/CacheNameExistsException.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -1,24 +0,0 @@
-package org.horizon.manager;
-
-/**
- * Thrown if a cache creation is attempted but the name already exists
- *
- * @author (various)
- * @since 1.0
- */
-public class CacheNameExistsException extends Exception {
-   public CacheNameExistsException() {
-   }
-
-   public CacheNameExistsException(String message) {
-      super(message);
-   }
-
-   public CacheNameExistsException(String message, Throwable cause) {
-      super(message, cause);
-   }
-
-   public CacheNameExistsException(Throwable cause) {
-      super(cause);
-   }
-}

Modified: core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -25,6 +25,7 @@
 import org.horizon.CacheSPI;
 import org.horizon.config.Configuration;
 import org.horizon.config.ConfigurationException;
+import org.horizon.config.DuplicateCacheNameException;
 import org.horizon.config.GlobalConfiguration;
 import org.horizon.config.parsing.XmlConfigurationParser;
 import org.horizon.config.parsing.XmlConfigurationParserImpl;
@@ -37,6 +38,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -249,15 +251,15 @@
     *
     * @param cacheName             name of cache to define
     * @param configurationOverride configuration overrides to use
-    * @throws CacheNameExistsException if the name is already in use.
+    * @throws DuplicateCacheNameException if the name is already in use.
     */
-   public void defineCache(String cacheName, Configuration configurationOverride) throws CacheNameExistsException {
+   public void defineCache(String cacheName, Configuration configurationOverride) throws DuplicateCacheNameException {
       if (cacheName == null || configurationOverrides == null)
          throw new NullPointerException("Null arguments not allowed");
       if (cacheName.equals(DEFAULT_CACHE_NAME))
          throw new IllegalArgumentException("Cache name cannot be used as it is a reserved, internal name");
       if (configurationOverrides.putIfAbsent(cacheName, configurationOverride) != null)
-         throw new CacheNameExistsException("Cache name [" + cacheName + "] already in use!");
+         throw new DuplicateCacheNameException("Cache name [" + cacheName + "] already in use!");
    }
 
 
@@ -298,12 +300,16 @@
       return globalConfiguration.getClusterName();
    }
 
+   @SuppressWarnings("unchecked")
    public List<Address> getMembers() {
-      return globalComponentRegistry.getComponent(RPCManager.class).getMembers();
+      RPCManager rpcManager = globalComponentRegistry.getComponent(RPCManager.class);
+      List l = rpcManager == null ? Collections.emptyList() : rpcManager.getMembers();
+      return l;
    }
 
    public Address getAddress() {
-      return globalComponentRegistry.getComponent(RPCManager.class).getAddress();
+      RPCManager rpcManager = globalComponentRegistry.getComponent(RPCManager.class);
+      return rpcManager == null ? null : rpcManager.getAddress();
    }
 
    private Cache createCache(String cacheName) {

Deleted: core/branches/flat/src/main/java/org/horizon/marshall/CacheMarshallerStarobrno.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/marshall/CacheMarshallerStarobrno.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/java/org/horizon/marshall/CacheMarshallerStarobrno.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -1,794 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.horizon.marshall;
-
-import org.horizon.CacheException;
-import org.horizon.atomic.DeltaAware;
-import org.horizon.commands.RemoteCommandFactory;
-import org.horizon.commands.ReplicableCommand;
-import org.horizon.io.ByteBuffer;
-import org.horizon.io.ExposedByteArrayOutputStream;
-import org.horizon.logging.Log;
-import org.horizon.logging.LogFactory;
-import org.horizon.remoting.transport.Address;
-import org.horizon.remoting.transport.jgroups.JGroupsAddress;
-import org.horizon.transaction.GlobalTransaction;
-import org.horizon.util.FastCopyHashMap;
-import org.horizon.util.Immutables;
-import org.jboss.util.NotImplementedException;
-import org.jboss.util.stream.MarshalledValueInputStream;
-
-import java.io.ByteArrayInputStream;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.lang.reflect.Array;
-import java.util.*;
-
-/**
- * Abstract AbstractMarshaller for JBoss Cache.
- *
- * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
- * @since 1.0
- */
-public class CacheMarshallerStarobrno implements Marshaller {
-   // magic numbers
-   protected static final int MAGICNUMBER_METHODCALL = 1;
-   protected static final int MAGICNUMBER_FQN = 2;
-   protected static final int MAGICNUMBER_GTX = 3;
-   protected static final int MAGICNUMBER_JG_ADDRESS = 4;
-   protected static final int MAGICNUMBER_ARRAY_LIST = 5;
-   protected static final int MAGICNUMBER_INTEGER = 6;
-   protected static final int MAGICNUMBER_LONG = 7;
-   protected static final int MAGICNUMBER_BOOLEAN = 8;
-   protected static final int MAGICNUMBER_STRING = 9;
-   protected static final int MAGICNUMBER_DEFAULT_DATA_VERSION = 10;
-   protected static final int MAGICNUMBER_LINKED_LIST = 11;
-   protected static final int MAGICNUMBER_HASH_MAP = 12;
-   protected static final int MAGICNUMBER_TREE_MAP = 13;
-   protected static final int MAGICNUMBER_HASH_SET = 14;
-   protected static final int MAGICNUMBER_TREE_SET = 15;
-   protected static final int MAGICNUMBER_NODEDATA_MARKER = 16;
-   protected static final int MAGICNUMBER_NODEDATA_EXCEPTION_MARKER = 17;
-   protected static final int MAGICNUMBER_NODEDATA = 18;
-   protected static final int MAGICNUMBER_GRAVITATERESULT = 19;
-   protected static final int MAGICNUMBER_SHORT = 20;
-   protected static final int MAGICNUMBER_IMMUTABLE_MAPCOPY = 21;
-   protected static final int MAGICNUMBER_MARSHALLEDVALUE = 22;
-   protected static final int MAGICNUMBER_FASTCOPY_HASHMAP = 23;
-   protected static final int MAGICNUMBER_ARRAY = 24;
-   protected static final int MAGICNUMBER_BYTE = 25;
-   protected static final int MAGICNUMBER_CHAR = 26;
-   protected static final int MAGICNUMBER_FLOAT = 27;
-   protected static final int MAGICNUMBER_DOUBLE = 28;
-   protected static final int MAGICNUMBER_OBJECT = 29;
-   protected static final int MAGICNUMBER_NULL = 99;
-   protected static final int MAGICNUMBER_SERIALIZABLE = 100;
-
-   protected static final int MAGICNUMBER_REF = 101;
-
-   public CacheMarshallerStarobrno() {
-      initLogger();
-      // enabled, since this is always enabled in JBC 2.0.0.
-      useRefs = false;
-   }
-
-   protected Log log;
-   protected boolean trace;
-   private RemoteCommandFactory remoteCommandFactory;
-   protected ClassLoader defaultClassLoader;
-   protected boolean useRefs = false;
-
-   public void init(ClassLoader defaultClassLoader) {
-      this.defaultClassLoader = defaultClassLoader;
-   }
-
-   protected void initLogger() {
-      log = LogFactory.getLog(getClass());
-      trace = log.isTraceEnabled();
-   }
-
-   // implement the basic contract set in RPCDispatcher.AbstractMarshaller
-   public byte[] objectToByteBuffer(Object obj) throws Exception {
-      ByteBuffer b = objectToBuffer(obj);
-      byte[] bytes = new byte[b.getLength()];
-      System.arraycopy(b.getBuf(), b.getOffset(), bytes, 0, b.getLength());
-      return bytes;
-   }
-
-   protected void marshallObject(Object o, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception {
-      if (o != null && o.getClass().isArray() && isKnownType(o.getClass().getComponentType())) {
-         marshallArray(o, out, refMap);
-      } else {
-         if (o == null) {
-            out.writeByte(MAGICNUMBER_NULL);
-         } else if (useRefs && refMap.containsKey(o))// see if this object has been marshalled before.
-         {
-            out.writeByte(MAGICNUMBER_REF);
-            writeReference(out, refMap.get(o));
-         } else if (o instanceof ReplicableCommand) {
-            ReplicableCommand command = (ReplicableCommand) o;
-
-            if (command.getCommandId() > -1) {
-               out.writeByte(MAGICNUMBER_METHODCALL);
-               marshallCommand(command, out, refMap);
-            } else {
-               throw new IllegalArgumentException("MethodCall does not have a valid method id.  Was this method call created with MethodCallFactory?");
-            }
-         } else if (o instanceof MarshalledValue) {
-            out.writeByte(MAGICNUMBER_MARSHALLEDVALUE);
-            ((MarshalledValue) o).writeExternal(out);
-         } else if (o instanceof DeltaAware) {
-            // reading in should be nothing special.
-            out.writeByte(MAGICNUMBER_SERIALIZABLE);
-            // only write the delta for these maps.
-            out.writeObject(((DeltaAware) o).delta());
-         } else if (o instanceof GlobalTransaction) {
-            out.writeByte(MAGICNUMBER_GTX);
-            if (useRefs) writeReference(out, createReference(o, refMap));
-            marshallGlobalTransaction((GlobalTransaction) o, out, refMap);
-         } else if (o instanceof JGroupsAddress) {
-            out.writeByte(MAGICNUMBER_JG_ADDRESS);
-            marshallJGroupsAddress((JGroupsAddress) o, out);
-         } else if (o.getClass().equals(ArrayList.class)) {
-            out.writeByte(MAGICNUMBER_ARRAY_LIST);
-            marshallCollection((Collection) o, out, refMap);
-         } else if (o instanceof LinkedList) {
-            out.writeByte(MAGICNUMBER_LINKED_LIST);
-            marshallCollection((Collection) o, out, refMap);
-         } else if (o.getClass().equals(HashMap.class)) {
-            out.writeByte(MAGICNUMBER_HASH_MAP);
-            marshallMap((Map) o, out, refMap);
-         } else if (o.getClass().equals(TreeMap.class)) {
-            out.writeByte(MAGICNUMBER_TREE_MAP);
-            marshallMap((Map) o, out, refMap);
-         } else if (o.getClass().equals(FastCopyHashMap.class)) {
-            out.writeByte(MAGICNUMBER_FASTCOPY_HASHMAP);
-            marshallMap((Map) o, out, refMap);
-         } else if (o instanceof Map && Immutables.isImmutable(o)) {
-            out.writeByte(MAGICNUMBER_IMMUTABLE_MAPCOPY);
-            marshallMap((Map) o, out, refMap);
-         } else if (o.getClass().equals(HashSet.class)) {
-            out.writeByte(MAGICNUMBER_HASH_SET);
-            marshallCollection((Collection) o, out, refMap);
-         } else if (o.getClass().equals(TreeSet.class)) {
-            out.writeByte(MAGICNUMBER_TREE_SET);
-            marshallCollection((Collection) o, out, refMap);
-         } else if (o instanceof Boolean) {
-            out.writeByte(MAGICNUMBER_BOOLEAN);
-            out.writeBoolean(((Boolean) o).booleanValue());
-         } else if (o instanceof Integer) {
-            out.writeByte(MAGICNUMBER_INTEGER);
-            out.writeInt(((Integer) o).intValue());
-         } else if (o instanceof Long) {
-            out.writeByte(MAGICNUMBER_LONG);
-            out.writeLong(((Long) o).longValue());
-         } else if (o instanceof Short) {
-            out.writeByte(MAGICNUMBER_SHORT);
-            out.writeShort(((Short) o).shortValue());
-         } else if (o instanceof String) {
-            out.writeByte(MAGICNUMBER_STRING);
-            if (useRefs) writeReference(out, createReference(o, refMap));
-            marshallString((String) o, out);
-         } else if (o instanceof NodeDataMarker) {
-            out.writeByte(MAGICNUMBER_NODEDATA_MARKER);
-            ((Externalizable) o).writeExternal(out);
-         } else if (o instanceof NodeDataExceptionMarker) {
-            out.writeByte(MAGICNUMBER_NODEDATA_EXCEPTION_MARKER);
-            ((Externalizable) o).writeExternal(out);
-         } else if (o instanceof NodeData) {
-            out.writeByte(MAGICNUMBER_NODEDATA);
-            ((Externalizable) o).writeExternal(out);
-         } else if (o instanceof Serializable) {
-            if (trace) {
-               log.trace("Warning: using object serialization for " + o.getClass());
-            }
-            out.writeByte(MAGICNUMBER_SERIALIZABLE);
-            if (useRefs) writeReference(out, createReference(o, refMap));
-            out.writeObject(o);
-         } else {
-            throw new Exception("Don't know how to marshall object of type " + o.getClass());
-         }
-      }
-   }
-
-
-   protected void marshallString(String s, ObjectOutputStream out) throws Exception {
-      //StringUtil.saveString(out, s);
-      out.writeObject(s);
-   }
-
-   private void marshallCommand(ReplicableCommand command, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception {
-      out.writeShort(command.getCommandId());
-      Object[] args = command.getParameters();
-      byte numArgs = (byte) (args == null ? 0 : args.length);
-      out.writeByte(numArgs);
-
-      for (int i = 0; i < numArgs; i++) {
-         marshallObject(args[i], out, refMap);
-      }
-   }
-
-   private int createReference(Object o, Map<Object, Integer> refMap) {
-      int reference = refMap.size();
-      refMap.put(o, reference);
-      return reference;
-   }
-
-   private void marshallGlobalTransaction(GlobalTransaction globalTransaction, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception {
-      out.writeLong(globalTransaction.getId());
-      marshallObject(globalTransaction.getAddress(), out, refMap);
-   }
-
-   private void marshallJGroupsAddress(JGroupsAddress address, ObjectOutputStream out) throws Exception {
-      address.writeExternal(out);
-   }
-
-   @SuppressWarnings("unchecked")
-   private void marshallCollection(Collection c, ObjectOutputStream out, Map refMap) throws Exception {
-      writeUnsignedInt(out, c.size());
-      for (Object o : c) {
-         marshallObject(o, out, refMap);
-      }
-   }
-
-   @SuppressWarnings("unchecked")
-   private void marshallMap(Map map, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception {
-      int mapSize = map.size();
-      writeUnsignedInt(out, mapSize);
-      if (mapSize == 0) return;
-
-      for (Map.Entry me : (Set<Map.Entry>) map.entrySet()) {
-         marshallObject(me.getKey(), out, refMap);
-         marshallObject(me.getValue(), out, refMap);
-      }
-   }
-
-   // --------- Unmarshalling methods
-
-   protected Object unmarshallObject(ObjectInputStream in, ClassLoader loader, UnmarshalledReferences refMap, boolean overrideContextClassloaderOnThread) throws Exception {
-      if (loader == null) {
-         return unmarshallObject(in, refMap);
-      } else {
-         Thread currentThread = Thread.currentThread();
-         ClassLoader old = currentThread.getContextClassLoader();
-         try {
-            // only do this if we haven't already set a context class loader elsewhere.
-            if (overrideContextClassloaderOnThread || old == null) currentThread.setContextClassLoader(loader);
-            return unmarshallObject(in, refMap);
-         }
-         finally {
-            if (overrideContextClassloaderOnThread || old == null) currentThread.setContextClassLoader(old);
-         }
-      }
-   }
-
-   protected Object unmarshallObject(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
-      byte magicNumber = in.readByte();
-      int reference = 0;
-      Object retVal;
-      switch (magicNumber) {
-         case MAGICNUMBER_NULL:
-            return null;
-         case MAGICNUMBER_REF:
-            if (useRefs) {
-               reference = readReference(in);
-               return refMap.getReferencedObject(reference);
-            } else break;
-         case MAGICNUMBER_SERIALIZABLE:
-            if (useRefs) reference = readReference(in);
-            retVal = in.readObject();
-            if (useRefs) refMap.putReferencedObject(reference, retVal);
-            return retVal;
-         case MAGICNUMBER_MARSHALLEDVALUE:
-            MarshalledValue mv = new MarshalledValue();
-            mv.readExternal(in);
-            return mv;
-         case MAGICNUMBER_METHODCALL:
-            retVal = unmarshallCommand(in, refMap);
-            return retVal;
-         case MAGICNUMBER_GTX:
-            if (useRefs) reference = readReference(in);
-            retVal = unmarshallGlobalTransaction(in, refMap);
-            if (useRefs) refMap.putReferencedObject(reference, retVal);
-            return retVal;
-         case MAGICNUMBER_JG_ADDRESS:
-            retVal = unmarshallJGroupsAddress(in);
-            return retVal;
-         case MAGICNUMBER_ARRAY:
-            return unmarshallArray(in, refMap);
-         case MAGICNUMBER_ARRAY_LIST:
-            return unmarshallArrayList(in, refMap);
-         case MAGICNUMBER_LINKED_LIST:
-            return unmarshallLinkedList(in, refMap);
-         case MAGICNUMBER_HASH_MAP:
-            return unmarshallHashMap(in, refMap);
-         case MAGICNUMBER_TREE_MAP:
-            return unmarshallTreeMap(in, refMap);
-         case MAGICNUMBER_HASH_SET:
-            return unmarshallHashSet(in, refMap);
-         case MAGICNUMBER_TREE_SET:
-            return unmarshallTreeSet(in, refMap);
-         case MAGICNUMBER_IMMUTABLE_MAPCOPY:
-            return unmarshallMapCopy(in, refMap);
-         case MAGICNUMBER_FASTCOPY_HASHMAP:
-            return unmarshallFastCopyHashMap(in, refMap);
-         case MAGICNUMBER_BOOLEAN:
-            return in.readBoolean() ? Boolean.TRUE : Boolean.FALSE;
-         case MAGICNUMBER_INTEGER:
-            return in.readInt();
-         case MAGICNUMBER_LONG:
-            return in.readLong();
-         case MAGICNUMBER_SHORT:
-            return in.readShort();
-         case MAGICNUMBER_STRING:
-            if (useRefs) reference = readReference(in);
-            retVal = unmarshallString(in);
-            if (useRefs) refMap.putReferencedObject(reference, retVal);
-            return retVal;
-         case MAGICNUMBER_NODEDATA_MARKER:
-            retVal = new NodeDataMarker();
-            ((NodeDataMarker) retVal).readExternal(in);
-            return retVal;
-         case MAGICNUMBER_NODEDATA_EXCEPTION_MARKER:
-            retVal = new NodeDataExceptionMarker();
-            ((NodeDataExceptionMarker) retVal).readExternal(in);
-            return retVal;
-         case MAGICNUMBER_NODEDATA:
-            retVal = new NodeData();
-            ((NodeData) retVal).readExternal(in);
-            return retVal;
-         default:
-            if (log.isErrorEnabled()) {
-               log.error("Unknown Magic Number " + magicNumber);
-            }
-            throw new Exception("Unknown magic number " + magicNumber);
-      }
-      throw new Exception("Unknown magic number " + magicNumber);
-   }
-
-   private FastCopyHashMap unmarshallFastCopyHashMap(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
-      FastCopyHashMap map = new FastCopyHashMap();
-      populateFromStream(in, refMap, map);
-      return map;
-   }
-
-   protected String unmarshallString(ObjectInputStream in) throws Exception {
-      return (String) in.readObject();
-   }
-
-   private ReplicableCommand unmarshallCommand(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
-      short methodId = in.readShort();
-      byte numArgs = in.readByte();
-      Object[] args = null;
-
-      if (numArgs > 0) {
-         args = new Object[numArgs];
-         for (int i = 0; i < numArgs; i++) args[i] = unmarshallObject(in, refMap);
-      }
-
-      return remoteCommandFactory.fromStream((byte) methodId, args);
-   }
-
-
-   private GlobalTransaction unmarshallGlobalTransaction(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
-      GlobalTransaction gtx = new GlobalTransaction();
-      long id = in.readLong();
-      Object address = unmarshallObject(in, refMap);
-      gtx.setId(id);
-      gtx.setAddress((Address) address);
-      return gtx;
-   }
-
-   private JGroupsAddress unmarshallJGroupsAddress(ObjectInputStream in) throws Exception {
-      JGroupsAddress address = new JGroupsAddress();
-      address.readExternal(in);
-      return address;
-   }
-
-   private List unmarshallArrayList(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
-      int listSize = readUnsignedInt(in);
-      List list = new ArrayList(listSize);
-      populateFromStream(in, refMap, list, listSize);
-      return list;
-   }
-
-   private List unmarshallLinkedList(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
-      List list = new LinkedList();
-      populateFromStream(in, refMap, list, readUnsignedInt(in));
-      return list;
-   }
-
-   private Map unmarshallHashMap(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
-      Map map = new HashMap();
-      populateFromStream(in, refMap, map);
-      return map;
-   }
-
-   @SuppressWarnings("unchecked")
-   private Map unmarshallMapCopy(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
-      // read in as a HashMap first
-      Map m = unmarshallHashMap(in, refMap);
-      return Immutables.immutableMapWrap(m);
-   }
-
-   private Map unmarshallTreeMap(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
-      Map map = new TreeMap();
-      populateFromStream(in, refMap, map);
-      return map;
-   }
-
-   private Set unmarshallHashSet(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
-      Set set = new HashSet();
-      populateFromStream(in, refMap, set);
-      return set;
-   }
-
-   private Set unmarshallTreeSet(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
-      Set set = new TreeSet();
-      populateFromStream(in, refMap, set);
-      return set;
-   }
-
-   @SuppressWarnings("unchecked")
-   private void populateFromStream(ObjectInputStream in, UnmarshalledReferences refMap, Map mapToPopulate) throws Exception {
-      int size = readUnsignedInt(in);
-      for (int i = 0; i < size; i++) mapToPopulate.put(unmarshallObject(in, refMap), unmarshallObject(in, refMap));
-   }
-
-   @SuppressWarnings("unchecked")
-   private void populateFromStream(ObjectInputStream in, UnmarshalledReferences refMap, Set setToPopulate) throws Exception {
-      int size = readUnsignedInt(in);
-      for (int i = 0; i < size; i++) setToPopulate.add(unmarshallObject(in, refMap));
-   }
-
-   @SuppressWarnings("unchecked")
-   private void populateFromStream(ObjectInputStream in, UnmarshalledReferences refMap, List listToPopulate, int listSize) throws Exception {
-      for (int i = 0; i < listSize; i++) listToPopulate.add(unmarshallObject(in, refMap));
-   }
-
-   /**
-    * This version of writeReference is written to solve JBCACHE-1211, where references are encoded as ints rather than
-    * shorts.
-    *
-    * @param out       stream to write to
-    * @param reference reference to write
-    * @throws java.io.IOException propagated from OOS
-    * @see <a href="http://jira.jboss.org/jira/browse/JBCACHE-1211">JBCACHE-1211</a>
-    */
-   protected void writeReference(ObjectOutputStream out, int reference) throws IOException {
-      writeUnsignedInt(out, reference);
-   }
-
-   /**
-    * This version of readReference is written to solve JBCACHE-1211, where references are encoded as ints rather than
-    * shorts.
-    *
-    * @param in stream to read from
-    * @return reference
-    * @throws java.io.IOException propagated from OUS
-    * @see <a href="http://jira.jboss.org/jira/browse/JBCACHE-1211">JBCACHE-1211</a>
-    */
-   protected int readReference(ObjectInputStream in) throws IOException {
-      return readUnsignedInt(in);
-   }
-
-   /**
-    * Reads an int stored in variable-length format.  Reads between one and five bytes.  Smaller values take fewer
-    * bytes.  Negative numbers are not supported.
-    */
-   protected int readUnsignedInt(ObjectInputStream in) throws IOException {
-      byte b = in.readByte();
-      int i = b & 0x7F;
-      for (int shift = 7; (b & 0x80) != 0; shift += 7) {
-         b = in.readByte();
-         i |= (b & 0x7FL) << shift;
-      }
-      return i;
-   }
-
-   /**
-    * Writes an int in a variable-length format.  Writes between one and five bytes.  Smaller values take fewer bytes.
-    * Negative numbers are not supported.
-    *
-    * @param i int to write
-    */
-   protected void writeUnsignedInt(ObjectOutputStream out, int i) throws IOException {
-      while ((i & ~0x7F) != 0) {
-         out.writeByte((byte) ((i & 0x7f) | 0x80));
-         i >>>= 7;
-      }
-      out.writeByte((byte) i);
-   }
-
-
-   /**
-    * Reads an int stored in variable-length format.  Reads between one and nine bytes.  Smaller values take fewer
-    * bytes.  Negative numbers are not supported.
-    */
-   protected long readUnsignedLong(ObjectInputStream in) throws IOException {
-      byte b = in.readByte();
-      long i = b & 0x7F;
-      for (int shift = 7; (b & 0x80) != 0; shift += 7) {
-         b = in.readByte();
-         i |= (b & 0x7FL) << shift;
-      }
-      return i;
-   }
-
-   /**
-    * Writes an int in a variable-length format.  Writes between one and nine bytes.  Smaller values take fewer bytes.
-    * Negative numbers are not supported.
-    *
-    * @param i int to write
-    */
-   protected void writeUnsignedLong(ObjectOutputStream out, long i) throws IOException {
-      while ((i & ~0x7F) != 0) {
-         out.writeByte((byte) ((i & 0x7f) | 0x80));
-         i >>>= 7;
-      }
-      out.writeByte((byte) i);
-   }
-
-   protected Object unmarshallArray(ObjectInputStream in, UnmarshalledReferences refs) throws Exception {
-      int sz = readUnsignedInt(in);
-      byte type = in.readByte();
-      switch (type) {
-         case MAGICNUMBER_BOOLEAN: {
-            boolean isPrim = in.readBoolean();
-            if (isPrim) {
-               boolean[] a = new boolean[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readBoolean();
-               return a;
-            } else {
-               Boolean[] a = new Boolean[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readBoolean();
-               return a;
-            }
-         }
-         case MAGICNUMBER_INTEGER: {
-            boolean isPrim = in.readBoolean();
-            if (isPrim) {
-               int[] a = new int[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readInt();
-               return a;
-            } else {
-               Integer[] a = new Integer[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readInt();
-               return a;
-            }
-         }
-         case MAGICNUMBER_LONG: {
-            boolean isPrim = in.readBoolean();
-            if (isPrim) {
-               long[] a = new long[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readLong();
-               return a;
-            } else {
-               Long[] a = new Long[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readLong();
-               return a;
-            }
-         }
-         case MAGICNUMBER_CHAR: {
-            boolean isPrim = in.readBoolean();
-            if (isPrim) {
-               char[] a = new char[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readChar();
-               return a;
-            } else {
-               Character[] a = new Character[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readChar();
-               return a;
-            }
-         }
-         case MAGICNUMBER_BYTE: {
-            boolean isPrim = in.readBoolean();
-            if (isPrim) {
-               byte[] a = new byte[sz];
-               int bsize = 10240;
-               int offset = 0;
-               int bytesLeft = sz;
-               while (bytesLeft > 0) {
-                  int read = in.read(a, offset, Math.min(bsize, bytesLeft));
-                  offset += read;
-                  bytesLeft -= read;
-               }
-               return a;
-            } else {
-               Byte[] a = new Byte[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readByte();
-               return a;
-            }
-         }
-         case MAGICNUMBER_SHORT: {
-            boolean isPrim = in.readBoolean();
-            if (isPrim) {
-               short[] a = new short[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readShort();
-               return a;
-            } else {
-               Short[] a = new Short[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readShort();
-               return a;
-            }
-         }
-         case MAGICNUMBER_FLOAT: {
-            boolean isPrim = in.readBoolean();
-            if (isPrim) {
-               float[] a = new float[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readFloat();
-               return a;
-            } else {
-               Float[] a = new Float[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readFloat();
-               return a;
-            }
-         }
-         case MAGICNUMBER_DOUBLE: {
-            boolean isPrim = in.readBoolean();
-            if (isPrim) {
-               double[] a = new double[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readDouble();
-               return a;
-            } else {
-               Double[] a = new Double[sz];
-               for (int i = 0; i < sz; i++) a[i] = in.readDouble();
-               return a;
-            }
-         }
-         case MAGICNUMBER_OBJECT: {
-            Object[] a = new Object[sz];
-            for (int i = 0; i < sz; i++) a[i] = unmarshallObject(in, refs);
-            return a;
-         }
-         default:
-            throw new CacheException("Unknown array type");
-      }
-   }
-
-   protected void marshallArray(Object o, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception {
-      out.writeByte(MAGICNUMBER_ARRAY);
-      Class arrayTypeClass = o.getClass().getComponentType();
-      int sz = Array.getLength(o);
-      writeUnsignedInt(out, sz);
-      boolean isPrim = arrayTypeClass.isPrimitive();
-
-      if (!isPrim && arrayTypeClass.equals(Object.class)) {
-         out.writeByte(MAGICNUMBER_OBJECT);
-         for (int i = 0; i < sz; i++) marshallObject(Array.get(o, i), out, refMap);
-      } else if (arrayTypeClass.equals(byte.class) || arrayTypeClass.equals(Byte.class)) {
-         out.writeByte(MAGICNUMBER_BYTE);
-         out.writeBoolean(isPrim);
-         if (isPrim)
-            out.write((byte[]) o);
-         else
-            for (int i = 0; i < sz; i++) out.writeByte((Byte) Array.get(o, i));
-      } else if (arrayTypeClass.equals(int.class) || arrayTypeClass.equals(Integer.class)) {
-         out.writeByte(MAGICNUMBER_INTEGER);
-         out.writeBoolean(isPrim);
-         if (isPrim)
-            for (int i = 0; i < sz; i++) out.writeInt(Array.getInt(o, i));
-         else
-            for (int i = 0; i < sz; i++) out.writeInt((Integer) Array.get(o, i));
-      } else if (arrayTypeClass.equals(long.class) || arrayTypeClass.equals(Long.class)) {
-         out.writeByte(MAGICNUMBER_LONG);
-         out.writeBoolean(isPrim);
-         if (isPrim)
-            for (int i = 0; i < sz; i++) out.writeLong(Array.getLong(o, i));
-         else
-            for (int i = 0; i < sz; i++) out.writeLong((Long) Array.get(o, i));
-      } else if (arrayTypeClass.equals(boolean.class) || arrayTypeClass.equals(Boolean.class)) {
-         out.writeByte(MAGICNUMBER_BOOLEAN);
-         out.writeBoolean(isPrim);
-         if (isPrim)
-            for (int i = 0; i < sz; i++) out.writeBoolean(Array.getBoolean(o, i));
-         else
-            for (int i = 0; i < sz; i++) out.writeBoolean((Boolean) Array.get(o, i));
-      } else if (arrayTypeClass.equals(char.class) || arrayTypeClass.equals(Character.class)) {
-         out.writeByte(MAGICNUMBER_CHAR);
-         out.writeBoolean(isPrim);
-         if (isPrim)
-            for (int i = 0; i < sz; i++) out.writeChar(Array.getChar(o, i));
-         else
-            for (int i = 0; i < sz; i++) out.writeChar((Character) Array.get(o, i));
-      } else if (arrayTypeClass.equals(short.class) || arrayTypeClass.equals(Short.class)) {
-         out.writeByte(MAGICNUMBER_SHORT);
-         out.writeBoolean(isPrim);
-         if (isPrim)
-            for (int i = 0; i < sz; i++) out.writeShort(Array.getShort(o, i));
-         else
-            for (int i = 0; i < sz; i++) out.writeShort((Short) Array.get(o, i));
-      } else if (arrayTypeClass.equals(float.class) || arrayTypeClass.equals(Float.class)) {
-         out.writeByte(MAGICNUMBER_FLOAT);
-         out.writeBoolean(isPrim);
-         if (isPrim)
-            for (int i = 0; i < sz; i++) out.writeFloat(Array.getFloat(o, i));
-         else
-            for (int i = 0; i < sz; i++) out.writeFloat((Float) Array.get(o, i));
-      } else if (arrayTypeClass.equals(double.class) || arrayTypeClass.equals(Double.class)) {
-         out.writeByte(MAGICNUMBER_DOUBLE);
-         out.writeBoolean(isPrim);
-         if (isPrim)
-            for (int i = 0; i < sz; i++) out.writeDouble(Array.getDouble(o, i));
-         else
-            for (int i = 0; i < sz; i++) out.writeDouble((Double) Array.get(o, i));
-      } else throw new CacheException("Unknown array type!");
-   }
-
-   protected boolean isKnownType(Class c) {
-      return (c.equals(Object.class) ||
-            c.isPrimitive() || c.equals(Character.class) || c.equals(Integer.class) || c.equals(Long.class) ||
-            c.equals(Byte.class) || c.equals(Boolean.class) || c.equals(Short.class) || c.equals(Float.class) ||
-            c.equals(Double.class));
-   }
-
-   public void objectToObjectStream(Object o, ObjectOutputStream out) throws Exception {
-      Map<Object, Integer> refMap = useRefs ? new IdentityHashMap<Object, Integer>() : null;
-      ClassLoader toUse = defaultClassLoader;
-      Thread current = Thread.currentThread();
-      ClassLoader old = current.getContextClassLoader();
-      if (old != null) toUse = old;
-
-      try {
-         current.setContextClassLoader(toUse);
-         marshallObject(o, out, refMap);
-      }
-      finally {
-         current.setContextClassLoader(old);
-      }
-   }
-
-   public Object objectFromObjectStream(ObjectInputStream in) throws Exception {
-      UnmarshalledReferences refMap = useRefs ? new UnmarshalledReferences() : null;
-      Object retValue = unmarshallObject(in, defaultClassLoader, refMap, false);
-      if (trace) log.trace("Unmarshalled object " + retValue);
-      return retValue;
-   }
-
-   public Object objectFromStream(InputStream is) throws Exception {
-      throw new NotImplementedException("not implemented");
-   }
-
-   public ByteBuffer objectToBuffer(Object o) throws Exception {
-      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(128);
-      ObjectOutputStream out = new ObjectOutputStream(baos);
-
-      //now marshall the contents of the object
-      objectToObjectStream(o, out);
-      out.close();
-      // and return bytes.
-      return new ByteBuffer(baos.getRawBuffer(), 0, baos.size());
-   }
-
-   public Object objectFromByteBuffer(byte[] buf, int offset, int length) throws Exception {
-      ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(buf, offset, length));
-      return objectFromObjectStream(in);
-   }
-
-   public Object objectFromByteBuffer(byte[] bytes) throws Exception {
-      return objectFromByteBuffer(bytes, 0, bytes.length);
-   }
-}
\ No newline at end of file

Copied: core/branches/flat/src/main/java/org/horizon/marshall/HorizonMarshaller.java (from rev 7593, core/branches/flat/src/main/java/org/horizon/marshall/CacheMarshallerStarobrno.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/marshall/HorizonMarshaller.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/marshall/HorizonMarshaller.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -0,0 +1,794 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.horizon.marshall;
+
+import org.horizon.CacheException;
+import org.horizon.atomic.DeltaAware;
+import org.horizon.commands.RemoteCommandFactory;
+import org.horizon.commands.ReplicableCommand;
+import org.horizon.io.ByteBuffer;
+import org.horizon.io.ExposedByteArrayOutputStream;
+import org.horizon.logging.Log;
+import org.horizon.logging.LogFactory;
+import org.horizon.remoting.transport.Address;
+import org.horizon.remoting.transport.jgroups.JGroupsAddress;
+import org.horizon.transaction.GlobalTransaction;
+import org.horizon.util.FastCopyHashMap;
+import org.horizon.util.Immutables;
+import org.jboss.util.NotImplementedException;
+import org.jboss.util.stream.MarshalledValueInputStream;
+
+import java.io.ByteArrayInputStream;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.util.*;
+
+/**
+ * Abstract AbstractMarshaller for JBoss Cache.
+ *
+ * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
+ * @since 1.0
+ */
+public class HorizonMarshaller implements Marshaller {
+   // magic numbers
+   protected static final int MAGICNUMBER_METHODCALL = 1;
+   protected static final int MAGICNUMBER_FQN = 2;
+   protected static final int MAGICNUMBER_GTX = 3;
+   protected static final int MAGICNUMBER_JG_ADDRESS = 4;
+   protected static final int MAGICNUMBER_ARRAY_LIST = 5;
+   protected static final int MAGICNUMBER_INTEGER = 6;
+   protected static final int MAGICNUMBER_LONG = 7;
+   protected static final int MAGICNUMBER_BOOLEAN = 8;
+   protected static final int MAGICNUMBER_STRING = 9;
+   protected static final int MAGICNUMBER_DEFAULT_DATA_VERSION = 10;
+   protected static final int MAGICNUMBER_LINKED_LIST = 11;
+   protected static final int MAGICNUMBER_HASH_MAP = 12;
+   protected static final int MAGICNUMBER_TREE_MAP = 13;
+   protected static final int MAGICNUMBER_HASH_SET = 14;
+   protected static final int MAGICNUMBER_TREE_SET = 15;
+   protected static final int MAGICNUMBER_NODEDATA_MARKER = 16;
+   protected static final int MAGICNUMBER_NODEDATA_EXCEPTION_MARKER = 17;
+   protected static final int MAGICNUMBER_NODEDATA = 18;
+   protected static final int MAGICNUMBER_GRAVITATERESULT = 19;
+   protected static final int MAGICNUMBER_SHORT = 20;
+   protected static final int MAGICNUMBER_IMMUTABLE_MAPCOPY = 21;
+   protected static final int MAGICNUMBER_MARSHALLEDVALUE = 22;
+   protected static final int MAGICNUMBER_FASTCOPY_HASHMAP = 23;
+   protected static final int MAGICNUMBER_ARRAY = 24;
+   protected static final int MAGICNUMBER_BYTE = 25;
+   protected static final int MAGICNUMBER_CHAR = 26;
+   protected static final int MAGICNUMBER_FLOAT = 27;
+   protected static final int MAGICNUMBER_DOUBLE = 28;
+   protected static final int MAGICNUMBER_OBJECT = 29;
+   protected static final int MAGICNUMBER_NULL = 99;
+   protected static final int MAGICNUMBER_SERIALIZABLE = 100;
+
+   protected static final int MAGICNUMBER_REF = 101;
+
+   public HorizonMarshaller() {
+      initLogger();
+      // enabled, since this is always enabled in JBC 2.0.0.
+      useRefs = false;
+   }
+
+   protected Log log;
+   protected boolean trace;
+   private RemoteCommandFactory remoteCommandFactory;
+   protected ClassLoader defaultClassLoader;
+   protected boolean useRefs = false;
+
+   public void init(ClassLoader defaultClassLoader) {
+      this.defaultClassLoader = defaultClassLoader;
+   }
+
+   protected void initLogger() {
+      log = LogFactory.getLog(getClass());
+      trace = log.isTraceEnabled();
+   }
+
+   // implement the basic contract set in RPCDispatcher.AbstractMarshaller
+   public byte[] objectToByteBuffer(Object obj) throws Exception {
+      ByteBuffer b = objectToBuffer(obj);
+      byte[] bytes = new byte[b.getLength()];
+      System.arraycopy(b.getBuf(), b.getOffset(), bytes, 0, b.getLength());
+      return bytes;
+   }
+
+   protected void marshallObject(Object o, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception {
+      if (o != null && o.getClass().isArray() && isKnownType(o.getClass().getComponentType())) {
+         marshallArray(o, out, refMap);
+      } else {
+         if (o == null) {
+            out.writeByte(MAGICNUMBER_NULL);
+         } else if (useRefs && refMap.containsKey(o))// see if this object has been marshalled before.
+         {
+            out.writeByte(MAGICNUMBER_REF);
+            writeReference(out, refMap.get(o));
+         } else if (o instanceof ReplicableCommand) {
+            ReplicableCommand command = (ReplicableCommand) o;
+
+            if (command.getCommandId() > -1) {
+               out.writeByte(MAGICNUMBER_METHODCALL);
+               marshallCommand(command, out, refMap);
+            } else {
+               throw new IllegalArgumentException("MethodCall does not have a valid method id.  Was this method call created with MethodCallFactory?");
+            }
+         } else if (o instanceof MarshalledValue) {
+            out.writeByte(MAGICNUMBER_MARSHALLEDVALUE);
+            ((MarshalledValue) o).writeExternal(out);
+         } else if (o instanceof DeltaAware) {
+            // reading in should be nothing special.
+            out.writeByte(MAGICNUMBER_SERIALIZABLE);
+            // only write the delta for these maps.
+            out.writeObject(((DeltaAware) o).delta());
+         } else if (o instanceof GlobalTransaction) {
+            out.writeByte(MAGICNUMBER_GTX);
+            if (useRefs) writeReference(out, createReference(o, refMap));
+            marshallGlobalTransaction((GlobalTransaction) o, out, refMap);
+         } else if (o instanceof JGroupsAddress) {
+            out.writeByte(MAGICNUMBER_JG_ADDRESS);
+            marshallJGroupsAddress((JGroupsAddress) o, out);
+         } else if (o.getClass().equals(ArrayList.class)) {
+            out.writeByte(MAGICNUMBER_ARRAY_LIST);
+            marshallCollection((Collection) o, out, refMap);
+         } else if (o instanceof LinkedList) {
+            out.writeByte(MAGICNUMBER_LINKED_LIST);
+            marshallCollection((Collection) o, out, refMap);
+         } else if (o.getClass().equals(HashMap.class)) {
+            out.writeByte(MAGICNUMBER_HASH_MAP);
+            marshallMap((Map) o, out, refMap);
+         } else if (o.getClass().equals(TreeMap.class)) {
+            out.writeByte(MAGICNUMBER_TREE_MAP);
+            marshallMap((Map) o, out, refMap);
+         } else if (o.getClass().equals(FastCopyHashMap.class)) {
+            out.writeByte(MAGICNUMBER_FASTCOPY_HASHMAP);
+            marshallMap((Map) o, out, refMap);
+         } else if (o instanceof Map && Immutables.isImmutable(o)) {
+            out.writeByte(MAGICNUMBER_IMMUTABLE_MAPCOPY);
+            marshallMap((Map) o, out, refMap);
+         } else if (o.getClass().equals(HashSet.class)) {
+            out.writeByte(MAGICNUMBER_HASH_SET);
+            marshallCollection((Collection) o, out, refMap);
+         } else if (o.getClass().equals(TreeSet.class)) {
+            out.writeByte(MAGICNUMBER_TREE_SET);
+            marshallCollection((Collection) o, out, refMap);
+         } else if (o instanceof Boolean) {
+            out.writeByte(MAGICNUMBER_BOOLEAN);
+            out.writeBoolean(((Boolean) o).booleanValue());
+         } else if (o instanceof Integer) {
+            out.writeByte(MAGICNUMBER_INTEGER);
+            out.writeInt(((Integer) o).intValue());
+         } else if (o instanceof Long) {
+            out.writeByte(MAGICNUMBER_LONG);
+            out.writeLong(((Long) o).longValue());
+         } else if (o instanceof Short) {
+            out.writeByte(MAGICNUMBER_SHORT);
+            out.writeShort(((Short) o).shortValue());
+         } else if (o instanceof String) {
+            out.writeByte(MAGICNUMBER_STRING);
+            if (useRefs) writeReference(out, createReference(o, refMap));
+            marshallString((String) o, out);
+         } else if (o instanceof NodeDataMarker) {
+            out.writeByte(MAGICNUMBER_NODEDATA_MARKER);
+            ((Externalizable) o).writeExternal(out);
+         } else if (o instanceof NodeDataExceptionMarker) {
+            out.writeByte(MAGICNUMBER_NODEDATA_EXCEPTION_MARKER);
+            ((Externalizable) o).writeExternal(out);
+         } else if (o instanceof NodeData) {
+            out.writeByte(MAGICNUMBER_NODEDATA);
+            ((Externalizable) o).writeExternal(out);
+         } else if (o instanceof Serializable) {
+            if (trace) {
+               log.trace("Warning: using object serialization for " + o.getClass());
+            }
+            out.writeByte(MAGICNUMBER_SERIALIZABLE);
+            if (useRefs) writeReference(out, createReference(o, refMap));
+            out.writeObject(o);
+         } else {
+            throw new Exception("Don't know how to marshall object of type " + o.getClass());
+         }
+      }
+   }
+
+
+   protected void marshallString(String s, ObjectOutputStream out) throws Exception {
+      //StringUtil.saveString(out, s);
+      out.writeObject(s);
+   }
+
+   private void marshallCommand(ReplicableCommand command, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception {
+      out.writeShort(command.getCommandId());
+      Object[] args = command.getParameters();
+      byte numArgs = (byte) (args == null ? 0 : args.length);
+      out.writeByte(numArgs);
+
+      for (int i = 0; i < numArgs; i++) {
+         marshallObject(args[i], out, refMap);
+      }
+   }
+
+   private int createReference(Object o, Map<Object, Integer> refMap) {
+      int reference = refMap.size();
+      refMap.put(o, reference);
+      return reference;
+   }
+
+   private void marshallGlobalTransaction(GlobalTransaction globalTransaction, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception {
+      out.writeLong(globalTransaction.getId());
+      marshallObject(globalTransaction.getAddress(), out, refMap);
+   }
+
+   private void marshallJGroupsAddress(JGroupsAddress address, ObjectOutputStream out) throws Exception {
+      address.writeExternal(out);
+   }
+
+   @SuppressWarnings("unchecked")
+   private void marshallCollection(Collection c, ObjectOutputStream out, Map refMap) throws Exception {
+      writeUnsignedInt(out, c.size());
+      for (Object o : c) {
+         marshallObject(o, out, refMap);
+      }
+   }
+
+   @SuppressWarnings("unchecked")
+   private void marshallMap(Map map, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception {
+      int mapSize = map.size();
+      writeUnsignedInt(out, mapSize);
+      if (mapSize == 0) return;
+
+      for (Map.Entry me : (Set<Map.Entry>) map.entrySet()) {
+         marshallObject(me.getKey(), out, refMap);
+         marshallObject(me.getValue(), out, refMap);
+      }
+   }
+
+   // --------- Unmarshalling methods
+
+   protected Object unmarshallObject(ObjectInputStream in, ClassLoader loader, UnmarshalledReferences refMap, boolean overrideContextClassloaderOnThread) throws Exception {
+      if (loader == null) {
+         return unmarshallObject(in, refMap);
+      } else {
+         Thread currentThread = Thread.currentThread();
+         ClassLoader old = currentThread.getContextClassLoader();
+         try {
+            // only do this if we haven't already set a context class loader elsewhere.
+            if (overrideContextClassloaderOnThread || old == null) currentThread.setContextClassLoader(loader);
+            return unmarshallObject(in, refMap);
+         }
+         finally {
+            if (overrideContextClassloaderOnThread || old == null) currentThread.setContextClassLoader(old);
+         }
+      }
+   }
+
+   protected Object unmarshallObject(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
+      byte magicNumber = in.readByte();
+      int reference = 0;
+      Object retVal;
+      switch (magicNumber) {
+         case MAGICNUMBER_NULL:
+            return null;
+         case MAGICNUMBER_REF:
+            if (useRefs) {
+               reference = readReference(in);
+               return refMap.getReferencedObject(reference);
+            } else break;
+         case MAGICNUMBER_SERIALIZABLE:
+            if (useRefs) reference = readReference(in);
+            retVal = in.readObject();
+            if (useRefs) refMap.putReferencedObject(reference, retVal);
+            return retVal;
+         case MAGICNUMBER_MARSHALLEDVALUE:
+            MarshalledValue mv = new MarshalledValue();
+            mv.readExternal(in);
+            return mv;
+         case MAGICNUMBER_METHODCALL:
+            retVal = unmarshallCommand(in, refMap);
+            return retVal;
+         case MAGICNUMBER_GTX:
+            if (useRefs) reference = readReference(in);
+            retVal = unmarshallGlobalTransaction(in, refMap);
+            if (useRefs) refMap.putReferencedObject(reference, retVal);
+            return retVal;
+         case MAGICNUMBER_JG_ADDRESS:
+            retVal = unmarshallJGroupsAddress(in);
+            return retVal;
+         case MAGICNUMBER_ARRAY:
+            return unmarshallArray(in, refMap);
+         case MAGICNUMBER_ARRAY_LIST:
+            return unmarshallArrayList(in, refMap);
+         case MAGICNUMBER_LINKED_LIST:
+            return unmarshallLinkedList(in, refMap);
+         case MAGICNUMBER_HASH_MAP:
+            return unmarshallHashMap(in, refMap);
+         case MAGICNUMBER_TREE_MAP:
+            return unmarshallTreeMap(in, refMap);
+         case MAGICNUMBER_HASH_SET:
+            return unmarshallHashSet(in, refMap);
+         case MAGICNUMBER_TREE_SET:
+            return unmarshallTreeSet(in, refMap);
+         case MAGICNUMBER_IMMUTABLE_MAPCOPY:
+            return unmarshallMapCopy(in, refMap);
+         case MAGICNUMBER_FASTCOPY_HASHMAP:
+            return unmarshallFastCopyHashMap(in, refMap);
+         case MAGICNUMBER_BOOLEAN:
+            return in.readBoolean() ? Boolean.TRUE : Boolean.FALSE;
+         case MAGICNUMBER_INTEGER:
+            return in.readInt();
+         case MAGICNUMBER_LONG:
+            return in.readLong();
+         case MAGICNUMBER_SHORT:
+            return in.readShort();
+         case MAGICNUMBER_STRING:
+            if (useRefs) reference = readReference(in);
+            retVal = unmarshallString(in);
+            if (useRefs) refMap.putReferencedObject(reference, retVal);
+            return retVal;
+         case MAGICNUMBER_NODEDATA_MARKER:
+            retVal = new NodeDataMarker();
+            ((NodeDataMarker) retVal).readExternal(in);
+            return retVal;
+         case MAGICNUMBER_NODEDATA_EXCEPTION_MARKER:
+            retVal = new NodeDataExceptionMarker();
+            ((NodeDataExceptionMarker) retVal).readExternal(in);
+            return retVal;
+         case MAGICNUMBER_NODEDATA:
+            retVal = new NodeData();
+            ((NodeData) retVal).readExternal(in);
+            return retVal;
+         default:
+            if (log.isErrorEnabled()) {
+               log.error("Unknown Magic Number " + magicNumber);
+            }
+            throw new Exception("Unknown magic number " + magicNumber);
+      }
+      throw new Exception("Unknown magic number " + magicNumber);
+   }
+
+   private FastCopyHashMap unmarshallFastCopyHashMap(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
+      FastCopyHashMap map = new FastCopyHashMap();
+      populateFromStream(in, refMap, map);
+      return map;
+   }
+
+   protected String unmarshallString(ObjectInputStream in) throws Exception {
+      return (String) in.readObject();
+   }
+
+   private ReplicableCommand unmarshallCommand(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
+      short methodId = in.readShort();
+      byte numArgs = in.readByte();
+      Object[] args = null;
+
+      if (numArgs > 0) {
+         args = new Object[numArgs];
+         for (int i = 0; i < numArgs; i++) args[i] = unmarshallObject(in, refMap);
+      }
+
+      return remoteCommandFactory.fromStream((byte) methodId, args);
+   }
+
+
+   private GlobalTransaction unmarshallGlobalTransaction(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
+      GlobalTransaction gtx = new GlobalTransaction();
+      long id = in.readLong();
+      Object address = unmarshallObject(in, refMap);
+      gtx.setId(id);
+      gtx.setAddress((Address) address);
+      return gtx;
+   }
+
+   private JGroupsAddress unmarshallJGroupsAddress(ObjectInputStream in) throws Exception {
+      JGroupsAddress address = new JGroupsAddress();
+      address.readExternal(in);
+      return address;
+   }
+
+   private List unmarshallArrayList(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
+      int listSize = readUnsignedInt(in);
+      List list = new ArrayList(listSize);
+      populateFromStream(in, refMap, list, listSize);
+      return list;
+   }
+
+   private List unmarshallLinkedList(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
+      List list = new LinkedList();
+      populateFromStream(in, refMap, list, readUnsignedInt(in));
+      return list;
+   }
+
+   private Map unmarshallHashMap(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
+      Map map = new HashMap();
+      populateFromStream(in, refMap, map);
+      return map;
+   }
+
+   @SuppressWarnings("unchecked")
+   private Map unmarshallMapCopy(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
+      // read in as a HashMap first
+      Map m = unmarshallHashMap(in, refMap);
+      return Immutables.immutableMapWrap(m);
+   }
+
+   private Map unmarshallTreeMap(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
+      Map map = new TreeMap();
+      populateFromStream(in, refMap, map);
+      return map;
+   }
+
+   private Set unmarshallHashSet(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
+      Set set = new HashSet();
+      populateFromStream(in, refMap, set);
+      return set;
+   }
+
+   private Set unmarshallTreeSet(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception {
+      Set set = new TreeSet();
+      populateFromStream(in, refMap, set);
+      return set;
+   }
+
+   @SuppressWarnings("unchecked")
+   private void populateFromStream(ObjectInputStream in, UnmarshalledReferences refMap, Map mapToPopulate) throws Exception {
+      int size = readUnsignedInt(in);
+      for (int i = 0; i < size; i++) mapToPopulate.put(unmarshallObject(in, refMap), unmarshallObject(in, refMap));
+   }
+
+   @SuppressWarnings("unchecked")
+   private void populateFromStream(ObjectInputStream in, UnmarshalledReferences refMap, Set setToPopulate) throws Exception {
+      int size = readUnsignedInt(in);
+      for (int i = 0; i < size; i++) setToPopulate.add(unmarshallObject(in, refMap));
+   }
+
+   @SuppressWarnings("unchecked")
+   private void populateFromStream(ObjectInputStream in, UnmarshalledReferences refMap, List listToPopulate, int listSize) throws Exception {
+      for (int i = 0; i < listSize; i++) listToPopulate.add(unmarshallObject(in, refMap));
+   }
+
+   /**
+    * This version of writeReference is written to solve JBCACHE-1211, where references are encoded as ints rather than
+    * shorts.
+    *
+    * @param out       stream to write to
+    * @param reference reference to write
+    * @throws java.io.IOException propagated from OOS
+    * @see <a href="http://jira.jboss.org/jira/browse/JBCACHE-1211">JBCACHE-1211</a>
+    */
+   protected void writeReference(ObjectOutputStream out, int reference) throws IOException {
+      writeUnsignedInt(out, reference);
+   }
+
+   /**
+    * This version of readReference is written to solve JBCACHE-1211, where references are encoded as ints rather than
+    * shorts.
+    *
+    * @param in stream to read from
+    * @return reference
+    * @throws java.io.IOException propagated from OUS
+    * @see <a href="http://jira.jboss.org/jira/browse/JBCACHE-1211">JBCACHE-1211</a>
+    */
+   protected int readReference(ObjectInputStream in) throws IOException {
+      return readUnsignedInt(in);
+   }
+
+   /**
+    * Reads an int stored in variable-length format.  Reads between one and five bytes.  Smaller values take fewer
+    * bytes.  Negative numbers are not supported.
+    */
+   protected int readUnsignedInt(ObjectInputStream in) throws IOException {
+      byte b = in.readByte();
+      int i = b & 0x7F;
+      for (int shift = 7; (b & 0x80) != 0; shift += 7) {
+         b = in.readByte();
+         i |= (b & 0x7FL) << shift;
+      }
+      return i;
+   }
+
+   /**
+    * Writes an int in a variable-length format.  Writes between one and five bytes.  Smaller values take fewer bytes.
+    * Negative numbers are not supported.
+    *
+    * @param i int to write
+    */
+   protected void writeUnsignedInt(ObjectOutputStream out, int i) throws IOException {
+      while ((i & ~0x7F) != 0) {
+         out.writeByte((byte) ((i & 0x7f) | 0x80));
+         i >>>= 7;
+      }
+      out.writeByte((byte) i);
+   }
+
+
+   /**
+    * Reads an int stored in variable-length format.  Reads between one and nine bytes.  Smaller values take fewer
+    * bytes.  Negative numbers are not supported.
+    */
+   protected long readUnsignedLong(ObjectInputStream in) throws IOException {
+      byte b = in.readByte();
+      long i = b & 0x7F;
+      for (int shift = 7; (b & 0x80) != 0; shift += 7) {
+         b = in.readByte();
+         i |= (b & 0x7FL) << shift;
+      }
+      return i;
+   }
+
+   /**
+    * Writes an int in a variable-length format.  Writes between one and nine bytes.  Smaller values take fewer bytes.
+    * Negative numbers are not supported.
+    *
+    * @param i int to write
+    */
+   protected void writeUnsignedLong(ObjectOutputStream out, long i) throws IOException {
+      while ((i & ~0x7F) != 0) {
+         out.writeByte((byte) ((i & 0x7f) | 0x80));
+         i >>>= 7;
+      }
+      out.writeByte((byte) i);
+   }
+
+   protected Object unmarshallArray(ObjectInputStream in, UnmarshalledReferences refs) throws Exception {
+      int sz = readUnsignedInt(in);
+      byte type = in.readByte();
+      switch (type) {
+         case MAGICNUMBER_BOOLEAN: {
+            boolean isPrim = in.readBoolean();
+            if (isPrim) {
+               boolean[] a = new boolean[sz];
+               for (int i = 0; i < sz; i++) a[i] = in.readBoolean();
+               return a;
+            } else {
+               Boolean[] a = new Boolean[sz];
+               for (int i = 0; i < sz; i++) a[i] = in.readBoolean();
+               return a;
+            }
+         }
+         case MAGICNUMBER_INTEGER: {
+            boolean isPrim = in.readBoolean();
+            if (isPrim) {
+               int[] a = new int[sz];
+               for (int i = 0; i < sz; i++) a[i] = in.readInt();
+               return a;
+            } else {
+               Integer[] a = new Integer[sz];
+               for (int i = 0; i < sz; i++) a[i] = in.readInt();
+               return a;
+            }
+         }
+         case MAGICNUMBER_LONG: {
+            boolean isPrim = in.readBoolean();
+            if (isPrim) {
+               long[] a = new long[sz];
+               for (int i = 0; i < sz; i++) a[i] = in.readLong();
+               return a;
+            } else {
+               Long[] a = new Long[sz];
+               for (int i = 0; i < sz; i++) a[i] = in.readLong();
+               return a;
+            }
+         }
+         case MAGICNUMBER_CHAR: {
+            boolean isPrim = in.readBoolean();
+            if (isPrim) {
+               char[] a = new char[sz];
+               for (int i = 0; i < sz; i++) a[i] = in.readChar();
+               return a;
+            } else {
+               Character[] a = new Character[sz];
+               for (int i = 0; i < sz; i++) a[i] = in.readChar();
+               return a;
+            }
+         }
+         case MAGICNUMBER_BYTE: {
+            boolean isPrim = in.readBoolean();
+            if (isPrim) {
+               byte[] a = new byte[sz];
+               int bsize = 10240;
+               int offset = 0;
+               int bytesLeft = sz;
+               while (bytesLeft > 0) {
+                  int read = in.read(a, offset, Math.min(bsize, bytesLeft));
+                  offset += read;
+                  bytesLeft -= read;
+               }
+               return a;
+            } else {
+               Byte[] a = new Byte[sz];
+               for (int i = 0; i < sz; i++) a[i] = in.readByte();
+               return a;
+            }
+         }
+         case MAGICNUMBER_SHORT: {
+            boolean isPrim = in.readBoolean();
+            if (isPrim) {
+               short[] a = new short[sz];
+               for (int i = 0; i < sz; i++) a[i] = in.readShort();
+               return a;
+            } else {
+               Short[] a = new Short[sz];
+               for (int i = 0; i < sz; i++) a[i] = in.readShort();
+               return a;
+            }
+         }
+         case MAGICNUMBER_FLOAT: {
+            boolean isPrim = in.readBoolean();
+            if (isPrim) {
+               float[] a = new float[sz];
+               for (int i = 0; i < sz; i++) a[i] = in.readFloat();
+               return a;
+            } else {
+               Float[] a = new Float[sz];
+               for (int i = 0; i < sz; i++) a[i] = in.readFloat();
+               return a;
+            }
+         }
+         case MAGICNUMBER_DOUBLE: {
+            boolean isPrim = in.readBoolean();
+            if (isPrim) {
+               double[] a = new double[sz];
+               for (int i = 0; i < sz; i++) a[i] = in.readDouble();
+               return a;
+            } else {
+               Double[] a = new Double[sz];
+               for (int i = 0; i < sz; i++) a[i] = in.readDouble();
+               return a;
+            }
+         }
+         case MAGICNUMBER_OBJECT: {
+            Object[] a = new Object[sz];
+            for (int i = 0; i < sz; i++) a[i] = unmarshallObject(in, refs);
+            return a;
+         }
+         default:
+            throw new CacheException("Unknown array type");
+      }
+   }
+
+   protected void marshallArray(Object o, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception {
+      out.writeByte(MAGICNUMBER_ARRAY);
+      Class arrayTypeClass = o.getClass().getComponentType();
+      int sz = Array.getLength(o);
+      writeUnsignedInt(out, sz);
+      boolean isPrim = arrayTypeClass.isPrimitive();
+
+      if (!isPrim && arrayTypeClass.equals(Object.class)) {
+         out.writeByte(MAGICNUMBER_OBJECT);
+         for (int i = 0; i < sz; i++) marshallObject(Array.get(o, i), out, refMap);
+      } else if (arrayTypeClass.equals(byte.class) || arrayTypeClass.equals(Byte.class)) {
+         out.writeByte(MAGICNUMBER_BYTE);
+         out.writeBoolean(isPrim);
+         if (isPrim)
+            out.write((byte[]) o);
+         else
+            for (int i = 0; i < sz; i++) out.writeByte((Byte) Array.get(o, i));
+      } else if (arrayTypeClass.equals(int.class) || arrayTypeClass.equals(Integer.class)) {
+         out.writeByte(MAGICNUMBER_INTEGER);
+         out.writeBoolean(isPrim);
+         if (isPrim)
+            for (int i = 0; i < sz; i++) out.writeInt(Array.getInt(o, i));
+         else
+            for (int i = 0; i < sz; i++) out.writeInt((Integer) Array.get(o, i));
+      } else if (arrayTypeClass.equals(long.class) || arrayTypeClass.equals(Long.class)) {
+         out.writeByte(MAGICNUMBER_LONG);
+         out.writeBoolean(isPrim);
+         if (isPrim)
+            for (int i = 0; i < sz; i++) out.writeLong(Array.getLong(o, i));
+         else
+            for (int i = 0; i < sz; i++) out.writeLong((Long) Array.get(o, i));
+      } else if (arrayTypeClass.equals(boolean.class) || arrayTypeClass.equals(Boolean.class)) {
+         out.writeByte(MAGICNUMBER_BOOLEAN);
+         out.writeBoolean(isPrim);
+         if (isPrim)
+            for (int i = 0; i < sz; i++) out.writeBoolean(Array.getBoolean(o, i));
+         else
+            for (int i = 0; i < sz; i++) out.writeBoolean((Boolean) Array.get(o, i));
+      } else if (arrayTypeClass.equals(char.class) || arrayTypeClass.equals(Character.class)) {
+         out.writeByte(MAGICNUMBER_CHAR);
+         out.writeBoolean(isPrim);
+         if (isPrim)
+            for (int i = 0; i < sz; i++) out.writeChar(Array.getChar(o, i));
+         else
+            for (int i = 0; i < sz; i++) out.writeChar((Character) Array.get(o, i));
+      } else if (arrayTypeClass.equals(short.class) || arrayTypeClass.equals(Short.class)) {
+         out.writeByte(MAGICNUMBER_SHORT);
+         out.writeBoolean(isPrim);
+         if (isPrim)
+            for (int i = 0; i < sz; i++) out.writeShort(Array.getShort(o, i));
+         else
+            for (int i = 0; i < sz; i++) out.writeShort((Short) Array.get(o, i));
+      } else if (arrayTypeClass.equals(float.class) || arrayTypeClass.equals(Float.class)) {
+         out.writeByte(MAGICNUMBER_FLOAT);
+         out.writeBoolean(isPrim);
+         if (isPrim)
+            for (int i = 0; i < sz; i++) out.writeFloat(Array.getFloat(o, i));
+         else
+            for (int i = 0; i < sz; i++) out.writeFloat((Float) Array.get(o, i));
+      } else if (arrayTypeClass.equals(double.class) || arrayTypeClass.equals(Double.class)) {
+         out.writeByte(MAGICNUMBER_DOUBLE);
+         out.writeBoolean(isPrim);
+         if (isPrim)
+            for (int i = 0; i < sz; i++) out.writeDouble(Array.getDouble(o, i));
+         else
+            for (int i = 0; i < sz; i++) out.writeDouble((Double) Array.get(o, i));
+      } else throw new CacheException("Unknown array type!");
+   }
+
+   protected boolean isKnownType(Class c) {
+      return (c.equals(Object.class) ||
+            c.isPrimitive() || c.equals(Character.class) || c.equals(Integer.class) || c.equals(Long.class) ||
+            c.equals(Byte.class) || c.equals(Boolean.class) || c.equals(Short.class) || c.equals(Float.class) ||
+            c.equals(Double.class));
+   }
+
+   public void objectToObjectStream(Object o, ObjectOutputStream out) throws Exception {
+      Map<Object, Integer> refMap = useRefs ? new IdentityHashMap<Object, Integer>() : null;
+      ClassLoader toUse = defaultClassLoader;
+      Thread current = Thread.currentThread();
+      ClassLoader old = current.getContextClassLoader();
+      if (old != null) toUse = old;
+
+      try {
+         current.setContextClassLoader(toUse);
+         marshallObject(o, out, refMap);
+      }
+      finally {
+         current.setContextClassLoader(old);
+      }
+   }
+
+   public Object objectFromObjectStream(ObjectInputStream in) throws Exception {
+      UnmarshalledReferences refMap = useRefs ? new UnmarshalledReferences() : null;
+      Object retValue = unmarshallObject(in, defaultClassLoader, refMap, false);
+      if (trace) log.trace("Unmarshalled object " + retValue);
+      return retValue;
+   }
+
+   public Object objectFromStream(InputStream is) throws Exception {
+      throw new NotImplementedException("not implemented");
+   }
+
+   public ByteBuffer objectToBuffer(Object o) throws Exception {
+      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(128);
+      ObjectOutputStream out = new ObjectOutputStream(baos);
+
+      //now marshall the contents of the object
+      objectToObjectStream(o, out);
+      out.close();
+      // and return bytes.
+      return new ByteBuffer(baos.getRawBuffer(), 0, baos.size());
+   }
+
+   public Object objectFromByteBuffer(byte[] buf, int offset, int length) throws Exception {
+      ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(buf, offset, length));
+      return objectFromObjectStream(in);
+   }
+
+   public Object objectFromByteBuffer(byte[] bytes) throws Exception {
+      return objectFromByteBuffer(bytes, 0, bytes.length);
+   }
+}
\ No newline at end of file


Property changes on: core/branches/flat/src/main/java/org/horizon/marshall/HorizonMarshaller.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: core/branches/flat/src/main/java/org/horizon/marshall/VersionAwareMarshaller.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/marshall/VersionAwareMarshaller.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/java/org/horizon/marshall/VersionAwareMarshaller.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -34,9 +34,9 @@
 import java.io.ObjectOutputStream;
 
 /**
- * A delegate to various other marshallers like {@link CacheMarshallerStarobrno}. This delegating marshaller adds
- * versioning information to the stream when marshalling objects and is able to pick the appropriate marshaller to
- * delegate to based on the versioning information when unmarshalling objects.
+ * A delegate to various other marshallers like {@link HorizonMarshaller}. This delegating marshaller adds versioning
+ * information to the stream when marshalling objects and is able to pick the appropriate marshaller to delegate to
+ * based on the versioning information when unmarshalling objects.
  *
  * @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>
@@ -49,13 +49,13 @@
    private static final int VERSION_400 = 40;
    private static final int CUSTOM_MARSHALLER = 999;
 
-   private CacheMarshallerStarobrno defaultMarshaller;
+   private HorizonMarshaller defaultMarshaller;
 
    ClassLoader defaultClassLoader;
 
    @Inject
    public void init(ClassLoader loader) {
-      defaultMarshaller = new CacheMarshallerStarobrno();
+      defaultMarshaller = new HorizonMarshaller();
       defaultMarshaller.init(loader);
    }
 

Modified: core/branches/flat/src/main/resources/config-samples/all.xml
===================================================================
--- core/branches/flat/src/main/resources/config-samples/all.xml	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/main/resources/config-samples/all.xml	2009-01-26 16:56:02 UTC (rev 7597)
@@ -40,7 +40,7 @@
       </transport>
 
       <!-- Again, sensible defaults are used here if this is omitted.  -->
-      <serialization marshallerClass="org.horizon.marshall.CacheMarshallerStarobrno" version="1.0"
+      <serialization marshallerClass="org.horizon.marshall.HorizonMarshaller" version="1.0"
                      objectInputStreamPoolSize="100" objectOutputStreamPoolSize="100"/>
 
       <!--

Modified: core/branches/flat/src/test/java/org/horizon/UnitTestCacheFactory.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/UnitTestCacheFactory.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/test/java/org/horizon/UnitTestCacheFactory.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -8,13 +8,15 @@
 
 import org.horizon.config.Configuration;
 import org.horizon.config.ConfigurationException;
-import org.horizon.config.parsing.XmlConfigurationParserJBC3;
+import org.horizon.config.parsing.XmlConfigurationParser;
+import org.horizon.config.parsing.XmlConfigurationParserImpl;
 import org.horizon.logging.Log;
 import org.horizon.logging.LogFactory;
 import org.horizon.manager.DefaultCacheManager;
 import org.horizon.util.TestingUtil;
 import org.jgroups.conf.XmlConfigurator;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.ArrayList;
@@ -84,29 +86,34 @@
       return createCache(new Configuration(), start);
    }
 
-   public Cache<K, V> createCache(String configFileName) throws ConfigurationException {
+   public Cache<K, V> createCache(String configFileName) throws ConfigurationException, IOException {
       return createCache(configFileName, true);
    }
 
-   public Cache<K, V> createCache(String configFileName, boolean start) throws ConfigurationException {
-      XmlConfigurationParserJBC3 parser = new XmlConfigurationParserJBC3();
+   public Cache<K, V> createCache(String configFileName, boolean start) throws ConfigurationException, IOException {
+      XmlConfigurationParser parser = new XmlConfigurationParserImpl(configFileName);
       Configuration c;
-      c = parser.parseFile(configFileName);
-      return createCache(c, start);
+
+      // TODO: gotta build a proper cache manager here
+      return null;
+
+      //return createCache(c, start);
    }
 
    public Cache<K, V> createCache(Configuration configuration) throws ConfigurationException {
       return createCache(configuration, true);
    }
 
-   public Cache<K, V> createCache(InputStream is) throws ConfigurationException {
+   public Cache<K, V> createCache(InputStream is) throws ConfigurationException, IOException {
       return createCache(is, true);
    }
 
-   public Cache<K, V> createCache(InputStream is, boolean start) throws ConfigurationException {
-      XmlConfigurationParserJBC3 parser = new XmlConfigurationParserJBC3();
-      Configuration c = parser.parseStream(is);
-      return createCache(c, start);
+   public Cache<K, V> createCache(InputStream is, boolean start) throws ConfigurationException, IOException {
+      XmlConfigurationParser parser = new XmlConfigurationParserImpl(is);
+      //Configuration c = parser.parseStream(is);
+      //return createCache(c, start);
+      // TODO: gotta build a proper cache manager here
+      return null;
    }
 
    public Cache<K, V> createCache(Configuration configuration, boolean start) throws ConfigurationException {

Modified: core/branches/flat/src/test/java/org/horizon/manager/CacheManagerComponentRegistryTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/manager/CacheManagerComponentRegistryTest.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/test/java/org/horizon/manager/CacheManagerComponentRegistryTest.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -30,7 +30,7 @@
       if (cm != null) cm.stop();
    }
 
-   public void testForceSharedComponents() throws CacheNameExistsException, NamedCacheNotFoundException {
+   public void testForceSharedComponents() throws NamedCacheNotFoundException {
       Configuration defaultCfg = new Configuration();
       defaultCfg.setCacheMode(Configuration.CacheMode.REPL_SYNC);
 
@@ -56,7 +56,7 @@
       assert TestingUtil.extractComponent(c, RPCManager.class) == TestingUtil.extractComponent(transactional, RPCManager.class);
    }
 
-   public void testForceUnsharedComponents() throws CacheNameExistsException, NamedCacheNotFoundException {
+   public void testForceUnsharedComponents() throws NamedCacheNotFoundException {
       CacheLoaderConfig clc = new CacheLoaderConfig();
       // TODO change this to use a dummy in memory cache loader instead!!
       FileCacheLoaderConfig fc = new FileCacheLoaderConfig();
@@ -83,7 +83,7 @@
       assert TestingUtil.extractComponent(c, CacheLoaderManager.class) != TestingUtil.extractComponent(transactional, CacheLoaderManager.class);
    }
 
-   public void testOverridingComponents() throws CacheNameExistsException, NamedCacheNotFoundException {
+   public void testOverridingComponents() throws NamedCacheNotFoundException {
       Configuration defaultCfg = new Configuration();
       cm = new DefaultCacheManager(defaultCfg);
 

Modified: core/branches/flat/src/test/java/org/horizon/manager/CacheManagerTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/manager/CacheManagerTest.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/test/java/org/horizon/manager/CacheManagerTest.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -3,6 +3,7 @@
 import org.horizon.Cache;
 import org.horizon.ComponentStatus;
 import org.horizon.config.Configuration;
+import org.horizon.config.DuplicateCacheNameException;
 import org.horizon.util.TestingUtil;
 import org.testng.annotations.Test;
 
@@ -12,7 +13,7 @@
  */
 @Test(groups = "functional")
 public class CacheManagerTest {
-   public void testDefaultCache() throws CacheNameExistsException {
+   public void testDefaultCache() {
       CacheManager cm = new DefaultCacheManager();
 
       try {
@@ -32,7 +33,7 @@
       }
    }
 
-   public void testClashingNames() throws CacheNameExistsException {
+   public void testClashingNames() {
       CacheManager cm = new DefaultCacheManager();
       try {
          Configuration c = new Configuration();
@@ -42,7 +43,7 @@
             cm.defineCache("aCache", c);
             assert false : "Should fail";
          }
-         catch (CacheNameExistsException cnee) {
+         catch (DuplicateCacheNameException cnee) {
             // expected
             assert true : "Expected";
          }

Modified: core/branches/flat/src/test/java/org/horizon/manager/CacheManagerXmlConfigurationTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/manager/CacheManagerXmlConfigurationTest.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/test/java/org/horizon/manager/CacheManagerXmlConfigurationTest.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -2,7 +2,7 @@
 
 import org.horizon.Cache;
 import org.horizon.config.Configuration;
-import org.horizon.config.ConfigurationException;
+import org.horizon.config.DuplicateCacheNameException;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.Test;
 
@@ -23,39 +23,8 @@
    }
 
    public void testNamedCacheXML() throws IOException {
-      String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
-            "<jbosscache xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:jboss:starobrno-core:config:1.0\">\n" +
-            "\n" +
-            "    <default>\n" +
-            "        <locking concurrencyLevel=\"100\" lockAcquisitionTimeout=\"1000\" />\n" +
-            "    </default>\n" +
-            "\n" +
-            "    <namedCache name=\"transactional\">\n" +
-            "        <transaction transactionManagerLookupClass=\"org.jboss.starobrno.transaction.GenericTransactionManagerLookup\"/>\n" +
-            "    </namedCache>\n" +
-            "\n" +
-            "    <namedCache name=\"syncRepl\">\n" +
-            "        <clustering>\n" +
-            "            <stateRetrieval fetchInMemoryState=\"true\" timeout=\"15000\"/>\n" +
-            "            <jgroupsConfig configFile=\"udp.xml\"/>\n" +
-            "            <sync replTimeout=\"15000\"/>\n" +
-            "        </clustering>\n" +
-            "    </namedCache>\n" +
-            "\n" +
-            "    <namedCache name=\"txSyncRepl\">\n" +
-            "        <transaction transactionManagerLookupClass=\"org.jboss.starobrno.transaction.GenericTransactionManagerLookup\"/>\n" +
-            "        <clustering>\n" +
-            "            <stateRetrieval fetchInMemoryState=\"true\" timeout=\"15000\"/>\n" +
-            "            <jgroupsConfig configFile=\"udp.xml\"/>\n" +
-            "            <sync replTimeout=\"15000\"/>\n" +
-            "        </clustering>\n" +
-            "    </namedCache>\n" +
-            "    \n" +
-            "</jbosscache>";
+      cm = new DefaultCacheManager("configs/named-cache-test.xml");
 
-      ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
-      cm = new DefaultCacheManager(bais);
-
       // test default cache
       Cache c = cm.getCache();
       assert c.getConfiguration().getConcurrencyLevel() == 100;
@@ -87,49 +56,47 @@
 
    public void testNamedCacheXMLClashingNames() throws IOException {
       String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
-            "<jbosscache xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:jboss:starobrno-core:config:1.0\">\n" +
+            "<horizon xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:horizon:config:1.0\">\n" +
             "\n" +
             "    <default>\n" +
             "        <locking concurrencyLevel=\"100\" lockAcquisitionTimeout=\"1000\" />\n" +
             "    </default>\n" +
             "\n" +
             "    <namedCache name=\"c1\">\n" +
-            "        <transaction transactionManagerLookupClass=\"org.jboss.starobrno.transaction.GenericTransactionManagerLookup\"/>\n" +
+            "        <transaction transactionManagerLookupClass=\"org.horizon.transaction.GenericTransactionManagerLookup\"/>\n" +
             "    </namedCache>\n" +
             "\n" +
             "    <namedCache name=\"c1\">\n" +
             "        <clustering>\n" +
-            "            <stateRetrieval fetchInMemoryState=\"true\" timeout=\"15000\"/>\n" +
-            "            <jgroupsConfig configFile=\"udp.xml\"/>\n" +
             "            <sync replTimeout=\"15000\"/>\n" +
             "        </clustering>\n" +
             "    </namedCache>\n" +
             "    \n" +
-            "</jbosscache>";
+            "</horizon>";
 
       ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
       try {
          cm = new DefaultCacheManager(bais);
          assert false : "Should fail";
       }
-      catch (ConfigurationException expected) {
+      catch (DuplicateCacheNameException expected) {
 
       }
    }
 
    public void testNamedCacheXMLClashingNamesProgrammatic() throws IOException {
       String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
-            "<jbosscache xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:jboss:starobrno-core:config:1.0\">\n" +
+            "<horizon xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:horizon:config:1.0\">\n" +
             "\n" +
             "    <default>\n" +
             "        <locking concurrencyLevel=\"100\" lockAcquisitionTimeout=\"1000\" />\n" +
             "    </default>\n" +
             "\n" +
             "    <namedCache name=\"c1\">\n" +
-            "        <transaction transactionManagerLookupClass=\"org.jboss.starobrno.transaction.GenericTransactionManagerLookup\"/>\n" +
+            "        <transaction transactionManagerLookupClass=\"org.horizon.transaction.GenericTransactionManagerLookup\"/>\n" +
             "    </namedCache>\n" +
             "\n" +
-            "</jbosscache>";
+            "</horizon>";
 
       ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes());
       cm = new DefaultCacheManager(bais);
@@ -140,7 +107,7 @@
          cm.defineCache("c1", new Configuration());
          assert false : "Should fail";
       }
-      catch (CacheNameExistsException expected) {
+      catch (DuplicateCacheNameException expected) {
 
       }
    }

Modified: core/branches/flat/src/test/java/org/horizon/util/internals/ReplicationListener.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/util/internals/ReplicationListener.java	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/test/java/org/horizon/util/internals/ReplicationListener.java	2009-01-26 16:56:02 UTC (rev 7597)
@@ -11,7 +11,7 @@
 import org.horizon.io.ByteBuffer;
 import org.horizon.logging.Log;
 import org.horizon.logging.LogFactory;
-import org.horizon.marshall.CacheMarshallerStarobrno;
+import org.horizon.marshall.HorizonMarshaller;
 import org.horizon.marshall.Marshaller;
 import org.horizon.remoting.RPCManager;
 import org.horizon.remoting.transport.jgroups.CommandAwareRpcDispatcher;
@@ -146,7 +146,7 @@
    /**
     * Needed for region based marshalling.
     */
-   private class RegionMarshallerDelegate extends CacheMarshallerStarobrno {
+   private class RegionMarshallerDelegate extends HorizonMarshaller {
       private Marshaller realOne;
 
       private RegionMarshallerDelegate(Marshaller realOne) {

Modified: core/branches/flat/src/test/resources/configs/named-cache-test.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/named-cache-test.xml	2009-01-26 11:58:54 UTC (rev 7596)
+++ core/branches/flat/src/test/resources/configs/named-cache-test.xml	2009-01-26 16:56:02 UTC (rev 7597)
@@ -23,7 +23,7 @@
 
       <transport transportClass="org.horizon.remoting.transport.jgroups.JGroupsTransport"/>
 
-      <serialization marshallerClass="org.horizon.marshall.CacheMarshallerStarobrno" version="1.0"
+      <serialization marshallerClass="org.horizon.marshall.HorizonMarshaller" version="1.0"
                      objectInputStreamPoolSize="100" objectOutputStreamPoolSize="100"/>
 
    </global>




More information about the jbosscache-commits mailing list