[jbosscache-commits] JBoss Cache SVN: r7315 - in core/branches/flat/src: main/java/org/jboss/starobrno/config/parsing and 2 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Fri Dec 12 06:55:35 EST 2008


Author: manik.surtani at jboss.com
Date: 2008-12-12 06:55:35 -0500 (Fri, 12 Dec 2008)
New Revision: 7315

Added:
   core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java
   core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParserImpl.java
   core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParserJBC3.java
Removed:
   core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java
Modified:
   core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java
   core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/CacheConfigsXmlParser.java
   core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlParserBase.java
   core/branches/flat/src/main/java/org/jboss/starobrno/manager/CacheManager.java
   core/branches/flat/src/test/java/org/jboss/starobrno/UnitTestCacheFactory.java
Log:
configuration parsers that parse named configurations

Modified: core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java	2008-12-12 09:49:01 UTC (rev 7314)
+++ core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java	2008-12-12 11:55:35 UTC (rev 7315)
@@ -28,7 +28,7 @@
 import org.jboss.starobrno.CacheSPI;
 import org.jboss.starobrno.config.Configuration;
 import org.jboss.starobrno.config.ConfigurationException;
-import org.jboss.starobrno.config.parsing.XmlConfigurationParser;
+import org.jboss.starobrno.config.parsing.XmlConfigurationParserJBC3;
 import org.jboss.starobrno.factories.ComponentFactory;
 import org.jboss.starobrno.factories.ComponentRegistry;
 
@@ -79,7 +79,7 @@
 
    public org.jboss.starobrno.Cache<K, V> createCache(String configFileName, boolean start) throws ConfigurationException
    {
-      XmlConfigurationParser parser = new XmlConfigurationParser();
+      XmlConfigurationParserJBC3 parser = new XmlConfigurationParserJBC3();
       Configuration c;
       c = parser.parseFile(configFileName);
       return createCache(c, start);
@@ -160,7 +160,7 @@
 
    public Cache<K, V> createCache(InputStream is) throws ConfigurationException
    {
-      XmlConfigurationParser parser = new XmlConfigurationParser();
+      XmlConfigurationParserJBC3 parser = new XmlConfigurationParserJBC3();
       Configuration c = null;
       c = parser.parseStream(is);
       return createCache(c);
@@ -168,7 +168,7 @@
 
    public Cache<K, V> createCache(InputStream is, boolean start) throws ConfigurationException
    {
-      XmlConfigurationParser parser = new XmlConfigurationParser();
+      XmlConfigurationParserJBC3 parser = new XmlConfigurationParserJBC3();
       Configuration c = parser.parseStream(is);
       return createCache(c, start);
    }

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/CacheConfigsXmlParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/CacheConfigsXmlParser.java	2008-12-12 09:49:01 UTC (rev 7314)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/CacheConfigsXmlParser.java	2008-12-12 11:55:35 UTC (rev 7315)
@@ -117,7 +117,7 @@
          if (name == null || name.trim().length() == 0)
             throw new ConfigurationException("Element " + element + " has no name attribute");
 
-         XmlConfigurationParser parser = new XmlConfigurationParser();
+         XmlConfigurationParserJBC3 parser = new XmlConfigurationParserJBC3();
          Configuration c = null;
          if (parser.isValidElementRoot(element))
          {

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java	2008-12-12 09:49:01 UTC (rev 7314)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java	2008-12-12 11:55:35 UTC (rev 7315)
@@ -1,421 +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.jboss.starobrno.config.parsing;
-
-import org.jboss.cache.lock.IsolationLevel;
-import org.jboss.starobrno.config.*;
-import org.jboss.starobrno.config.Configuration.CacheMode;
-import org.jboss.starobrno.config.parsing.element.BuddyElementParser;
-import org.jboss.starobrno.config.parsing.element.CustomInterceptorsElementParser;
-import org.jboss.starobrno.config.parsing.element.EvictionElementParser;
-import org.jboss.starobrno.config.parsing.element.LoadersElementParser;
-import org.jboss.starobrno.util.FileLookup;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.ErrorHandler;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.List;
-
-/**
- * Reads in XMLconfiguration files and spits out a {@link org.jboss.cache.config.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 org.jboss.cache.config.parsing.RootElementBuilder
- * @since 3.0
- */
-public class XmlConfigurationParser extends XmlParserBase
-{
-   private RootElementBuilder rootElementBuilder;
-
-   /**
-    * the resulting configuration.
-    */
-   private Configuration config = new Configuration();
-   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 XmlConfigurationParser(ErrorHandler errorHandler)
-   {
-      rootElementBuilder = new RootElementBuilder(errorHandler);
-   }
-
-   /**
-    * Same as {@link #XmlConfigurationParser(org.xml.sax.ErrorHandler)}.
-    *
-    * @param validating should the underlaying parser disable the validation?
-    */
-   public XmlConfigurationParser(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 XmlConfigurationParser()
-   {
-      rootElementBuilder = new RootElementBuilder();
-   }
-
-   /**
-    * Parses an XML file and returns a new configuration.
-    * For looking up the file, {@link org.jboss.starobrno.util.FileLookup} is used.
-    *
-    * @see org.jboss.starobrno.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);
-      configureBuddyReplication(getSingleElementInCoreNS("buddy", e));
-      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 configureBuddyReplication(Element element)
-   {
-      if (element == null) return;//buddy config might not exist, expect that
-      BuddyElementParser buddyElementParser = new BuddyElementParser();
-      BuddyReplicationConfig brConfig = buddyElementParser.parseBuddyElement(element);
-      config.setBuddyReplicationConfig(brConfig);
-   }
-
-   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;
-   }
-}

Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java	2008-12-12 11:55:35 UTC (rev 7315)
@@ -0,0 +1,50 @@
+package org.jboss.starobrno.config.parsing;
+
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+/**
+ * Implementations of this interface are responsible for parsing XML configuration files.
+ *
+ * @author Manik Surtani
+ */
+public interface XmlConfigurationParser
+{
+   /**
+    * Initializes the parser with a String that represents the name of the configuration file to parse.  Parsers would
+    * attempt to find this file on the classpath first, and failing that, treat the String as an absolute path name on
+    * the file system.
+    *
+    * @param fileName name of file that contains the XML configuration
+    * @throws java.io.IOException if there is a problem reading the configuration file
+    */
+   void initialize(String fileName) throws IOException;
+
+   /**
+    * Initializes the parser with a stream that contains the contents of an XML configuration file to parse.
+    *
+    * @param inputStream stream to read from
+    * @throws IOException if there is a problem reading from the stream
+    */
+   void initialize(InputStream inputStream) throws IOException;
+
+   /**
+    * Parses and retrieves the default configuration.  This is typically used to configure the {@link org.jboss.starobrno.manager.CacheManager}.
+    *
+    * @return a Configuration
+    * @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
+    * @throws ConfigurationException if there is a problem parsing the configuration XML
+    */
+   Map<String, Configuration> parseNamedConfigurations() throws ConfigurationException;
+}

Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParserImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParserImpl.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParserImpl.java	2008-12-12 11:55:35 UTC (rev 7315)
@@ -0,0 +1,101 @@
+package org.jboss.starobrno.config.parsing;
+
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.util.FileLookup;
+import org.w3c.dom.Element;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * The default XML configuration parser
+ *
+ * @author Manik Surtani
+ */
+public class XmlConfigurationParserImpl extends XmlParserBase implements XmlConfigurationParser
+{
+   boolean initialized = false;
+   Element rootElement;
+
+   /**
+    * Constructs a new parser
+    */
+   public XmlConfigurationParserImpl()
+   {
+   }
+
+   /**
+    * Constructs a parser and initializes it with the file name passed in, by calling {@link #initialize(String)}.
+    *
+    * @param fileName file name to initialize the parser with
+    * @throws IOException if there is a problem reading or locating the file.
+    */
+   public XmlConfigurationParserImpl(String fileName) throws IOException
+   {
+      initialize(fileName);
+   }
+
+   /**
+    * Constructs a parser and initializes it with the input stream passed in, by calling {@link #initialize(InputStream)}.
+    *
+    * @param inputStream input stream to initialize the parser with
+    * @throws IOException if there is a problem reading the stream
+    */
+   public XmlConfigurationParserImpl(InputStream inputStream) throws IOException
+   {
+      initialize(inputStream);
+   }
+
+   public void initialize(String fileName) throws IOException
+   {
+      if (fileName == null) throw new NullPointerException("File name cannot be null!");
+      FileLookup fileLookup = new FileLookup();
+      InputStream is = fileLookup.lookupFile(fileName);
+      if (is == null)
+         throw new FileNotFoundException("File " + fileName + " could not be found, either on the classpath or on the file system!");
+      initialize(is);
+   }
+
+   public void initialize(InputStream inputStream) throws IOException
+   {
+      if (inputStream == null) throw new NullPointerException("Input stream cannot be null!");
+      initialized = true;
+      rootElement = new RootElementBuilder().readRoot(inputStream);
+   }
+
+   public Configuration parseDefaultConfiguration() throws ConfigurationException
+   {
+      assertInitialized();
+      Element defaultConfiguration = getSingleElementInCoreNS("default", rootElement);
+      return new XmlConfigurationParserJBC3().parseElementIgnoringRoot(defaultConfiguration);
+   }
+
+   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;
+   }
+
+   private void assertInitialized()
+   {
+      if (!initialized)
+         throw new ConfigurationException("Parser not initialized.  Please invoke initialize() first, or use a constructor that initializes the parser.");
+   }
+}

Copied: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParserJBC3.java (from rev 7277, core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParserJBC3.java	                        (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParserJBC3.java	2008-12-12 11:55:35 UTC (rev 7315)
@@ -0,0 +1,421 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.config.parsing;
+
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.starobrno.config.*;
+import org.jboss.starobrno.config.Configuration.CacheMode;
+import org.jboss.starobrno.config.parsing.element.BuddyElementParser;
+import org.jboss.starobrno.config.parsing.element.CustomInterceptorsElementParser;
+import org.jboss.starobrno.config.parsing.element.EvictionElementParser;
+import org.jboss.starobrno.config.parsing.element.LoadersElementParser;
+import org.jboss.starobrno.util.FileLookup;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.ErrorHandler;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+
+/**
+ * Reads in XMLconfiguration files and spits out a {@link org.jboss.cache.config.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 org.jboss.cache.config.parsing.RootElementBuilder
+ * @since 3.0
+ */
+public class XmlConfigurationParserJBC3 extends XmlParserBase
+{
+   private RootElementBuilder rootElementBuilder;
+
+   /**
+    * the resulting configuration.
+    */
+   private Configuration config = new Configuration();
+   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.jboss.starobrno.util.FileLookup} is used.
+    *
+    * @see org.jboss.starobrno.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);
+      configureBuddyReplication(getSingleElementInCoreNS("buddy", e));
+      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 configureBuddyReplication(Element element)
+   {
+      if (element == null) return;//buddy config might not exist, expect that
+      BuddyElementParser buddyElementParser = new BuddyElementParser();
+      BuddyReplicationConfig brConfig = buddyElementParser.parseBuddyElement(element);
+      config.setBuddyReplicationConfig(brConfig);
+   }
+
+   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;
+   }
+}


Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParserJBC3.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlParserBase.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlParserBase.java	2008-12-12 09:49:01 UTC (rev 7314)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlParserBase.java	2008-12-12 11:55:35 UTC (rev 7315)
@@ -23,8 +23,13 @@
 
 import org.jboss.util.StringPropertyReplacer;
 import org.w3c.dom.Element;
+import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * Contains utility methods that might be useful to most of the parsers.
  *
@@ -72,15 +77,28 @@
    protected Element getSingleElement(String namespace, String elementName, Element parent)
    {
       NodeList nodeList = parent.getElementsByTagNameNS(namespace, elementName);
-      if (nodeList.getLength() == 0)
+      if (nodeList.getLength() == 0) return null;
+      return (Element) nodeList.item(0);
+   }
+
+   /**
+    * Convenience method for retrieving all child elements bearing the same element name
+    */
+   protected Set<Element> getAllElements(String namespace, String elementName, Element parent)
+   {
+      NodeList nodeList = parent.getElementsByTagNameNS(namespace, elementName);
+      if (nodeList.getLength() == 0) return Collections.emptySet();
+      Set<Element> elements = new HashSet<Element>();
+      for (int i = 0; i < nodeList.getLength(); i++)
       {
-         return null;
+         Node n = nodeList.item(i);
+         if (n instanceof Element) elements.add((Element) n);
       }
-      return (Element) nodeList.item(0);
+      return elements;
    }
 
    /**
-    * Convenient method for retrieving a single element with the give name.
+    * Convenient method for retrieving a single element with the give name, in the core namespace
     */
    protected Element getSingleElementInCoreNS(String elementName, Element parent)
    {
@@ -88,6 +106,14 @@
    }
 
    /**
+    * 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);
+   }
+
+   /**
     * Beside querying the element for its attribute value, it will look into the value, if any, and replace the
     * jboss properties(e.g. ${someValue:defaultValue}.
     * <p/>

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/manager/CacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/manager/CacheManager.java	2008-12-12 09:49:01 UTC (rev 7314)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/manager/CacheManager.java	2008-12-12 11:55:35 UTC (rev 7315)
@@ -24,7 +24,7 @@
 import org.jboss.starobrno.Cache;
 import org.jboss.starobrno.config.Configuration;
 import org.jboss.starobrno.config.ConfigurationException;
-import org.jboss.starobrno.config.parsing.XmlConfigurationParser;
+import org.jboss.starobrno.config.parsing.XmlConfigurationParserJBC3;
 import org.jboss.starobrno.lifecycle.Lifecycle;
 
 import java.io.InputStream;
@@ -150,7 +150,7 @@
       {
          // todo - need to update parser as per https://docspace.corp.redhat.com/clearspace/docs/DOC-16643
          // todo - need to store named cache overrides
-         XmlConfigurationParser parser = new XmlConfigurationParser();
+         XmlConfigurationParserJBC3 parser = new XmlConfigurationParserJBC3();
          configuration = parser.parseFile(configurationFile);
       }
       catch (ConfigurationException ce)
@@ -190,7 +190,7 @@
       {
          // todo - need to update parser as per https://docspace.corp.redhat.com/clearspace/docs/DOC-16643
          // todo - need to store named cache overrides
-         XmlConfigurationParser parser = new XmlConfigurationParser();
+         XmlConfigurationParserJBC3 parser = new XmlConfigurationParserJBC3();
          configuration = parser.parseStream(configurationStream);
       }
       catch (ConfigurationException ce)

Modified: core/branches/flat/src/test/java/org/jboss/starobrno/UnitTestCacheFactory.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/UnitTestCacheFactory.java	2008-12-12 09:49:01 UTC (rev 7314)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/UnitTestCacheFactory.java	2008-12-12 11:55:35 UTC (rev 7315)
@@ -6,9 +6,15 @@
  */
 package org.jboss.starobrno;
 
-import org.jboss.cache.*;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.parsing.XmlConfigurationParserJBC3;
+import org.jboss.starobrno.util.TestingUtil;
+import org.jgroups.conf.XmlConfigurator;
 
 import java.io.InputStream;
 import java.net.URL;
@@ -17,11 +23,6 @@
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import org.jboss.starobrno.config.Configuration;
-import org.jboss.starobrno.config.ConfigurationException;
-import org.jboss.starobrno.config.parsing.XmlConfigurationParser;
-import org.jboss.starobrno.util.TestingUtil;
-import org.jgroups.conf.XmlConfigurator;
 
 /**
  * @author <a href="mailto:dpospisi at redhat.com">Dominik Pospisil (dpospisi at redhat.com)</a>
@@ -99,7 +100,7 @@
 
    public Cache<K, V> createCache(String configFileName, boolean start) throws ConfigurationException
    {
-      XmlConfigurationParser parser = new XmlConfigurationParser();
+      XmlConfigurationParserJBC3 parser = new XmlConfigurationParserJBC3();
       Configuration c;
       c = parser.parseFile(configFileName);
       return createCache(c, start);
@@ -117,7 +118,7 @@
 
    public Cache<K, V> createCache(InputStream is, boolean start) throws ConfigurationException
    {
-      XmlConfigurationParser parser = new XmlConfigurationParser();
+      XmlConfigurationParserJBC3 parser = new XmlConfigurationParserJBC3();
       Configuration c = parser.parseStream(is);
       return createCache(c, start);
    }
@@ -323,11 +324,12 @@
       }
       return null;
    }
-   
-   private String getDefaultClusterConfiguration() {
+
+   private String getDefaultClusterConfiguration()
+   {
       return getClusterConfigFromFile(new Configuration().getDefaultClusterConfig());
    }
-   
+
    /**
     * Helper method that takes a <b>JGroups</b> configuration file and creates an old-style JGroups config {@link String} that can be used
     * in {@link org.jboss.cache.config.Configuration#setClusterConfig(String)}.  Note that expressions
@@ -355,5 +357,5 @@
          throw new RuntimeException("Problems with url " + url, e);
       }
    }
-   
+
 }




More information about the jbosscache-commits mailing list