[infinispan-commits] Infinispan SVN: r652 - in trunk: core/src/main/java/org/infinispan/config/parsing and 2 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Wed Aug 12 02:51:27 EDT 2009


Author: vblagojevic at jboss.com
Date: 2009-08-12 02:51:26 -0400 (Wed, 12 Aug 2009)
New Revision: 652

Removed:
   trunk/core/src/main/java/org/infinispan/config/parsing/AutomatedXmlConfigurationParserImpl.java
   trunk/core/src/main/java/org/infinispan/config/parsing/CacheLoaderManagerConfigReader.java
   trunk/core/src/main/java/org/infinispan/config/parsing/ClusteringConfigReader.java
   trunk/core/src/main/java/org/infinispan/config/parsing/ConfigurationElementReader.java
   trunk/core/src/main/java/org/infinispan/config/parsing/ConfigurationElementWriter.java
   trunk/core/src/main/java/org/infinispan/config/parsing/CustomInterceptorConfigReader.java
   trunk/core/src/main/java/org/infinispan/config/parsing/XmlConfigurationParserImpl.java
   trunk/core/src/main/java/org/infinispan/config/parsing/XmlParserBase.java
   trunk/core/src/main/java/org/infinispan/config/parsing/element/
   trunk/core/src/test/java/org/infinispan/config/parsing/ConfigurationParserTest.java
   trunk/core/src/test/java/org/infinispan/config/parsing/GlobalConfigurationParserTest.java
   trunk/tools/src/main/java/org/infinispan/tools/schema/SchemaGenerator.java
   trunk/tools/src/main/java/org/infinispan/tools/schema/SchemaGeneratorTreeWalker.java
Modified:
   trunk/core/src/main/java/org/infinispan/config/CacheLoaderManagerConfig.java
   trunk/core/src/main/java/org/infinispan/config/Configuration.java
   trunk/core/src/main/java/org/infinispan/config/ConfigurationElement.java
   trunk/core/src/main/java/org/infinispan/config/InfinispanConfiguration.java
   trunk/core/src/main/java/org/infinispan/config/parsing/XmlConfigurationParser.java
   trunk/core/src/test/java/org/infinispan/config/parsing/Jbc2InfinispanTransformerTest.java
Log:
remove old parsers

Modified: trunk/core/src/main/java/org/infinispan/config/CacheLoaderManagerConfig.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/CacheLoaderManagerConfig.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/core/src/main/java/org/infinispan/config/CacheLoaderManagerConfig.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -21,7 +21,6 @@
  */
 package org.infinispan.config;
 
-import org.infinispan.config.parsing.CacheLoaderManagerConfigReader;
 import org.infinispan.loaders.CacheLoaderConfig;
 import org.infinispan.loaders.CacheStoreConfig;
 import org.infinispan.util.Util;
@@ -49,7 +48,7 @@
  * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
  * @since 4.0
  */
- at ConfigurationElement(name="loaders",parent="default",customReader=CacheLoaderManagerConfigReader.class)
+ at ConfigurationElement(name="loaders",parent="default")
 @XmlAccessorType(XmlAccessType.FIELD)
 public class CacheLoaderManagerConfig extends AbstractNamedCacheConfigurationBean {
    private static final long serialVersionUID = 2210349340378984424L;

Modified: trunk/core/src/main/java/org/infinispan/config/Configuration.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/Configuration.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/core/src/main/java/org/infinispan/config/Configuration.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -21,8 +21,6 @@
  */
 package org.infinispan.config;
 
-import org.infinispan.config.parsing.ClusteringConfigReader;
-import org.infinispan.config.parsing.CustomInterceptorConfigReader;
 import org.infinispan.distribution.DefaultConsistentHash;
 import org.infinispan.eviction.EvictionStrategy;
 import org.infinispan.factories.annotations.Inject;
@@ -66,7 +64,7 @@
          @ConfigurationElement(name = "jmxStatistics", parent = "default", description = ""),
          @ConfigurationElement(name = "lazyDeserialization", parent = "default", description = ""),  
          @ConfigurationElement(name = "invocationBatching", parent = "default", description = ""),   
-         @ConfigurationElement(name = "clustering", parent = "default", description = "", customReader=ClusteringConfigReader.class),
+         @ConfigurationElement(name = "clustering", parent = "default", description = ""),
          @ConfigurationElement(name = "stateRetrieval", parent = "clustering"),
          @ConfigurationElement(name = "sync", parent = "clustering"),
          @ConfigurationElement(name = "hash", parent = "clustering"),
@@ -76,8 +74,7 @@
          @ConfigurationElement(name = "expiration", parent = "default", description = ""),
          @ConfigurationElement(name = "unsafe", parent = "default", description = ""),
          @ConfigurationElement(name = "deadlockDetection", parent = "default", description = ""),
-         @ConfigurationElement(name = "customInterceptors", parent = "default",
-                  customReader=CustomInterceptorConfigReader.class)         
+         @ConfigurationElement(name = "customInterceptors", parent = "default")         
 })
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(propOrder={})

Modified: trunk/core/src/main/java/org/infinispan/config/ConfigurationElement.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/ConfigurationElement.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/core/src/main/java/org/infinispan/config/ConfigurationElement.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -22,8 +22,6 @@
 package org.infinispan.config;
 
 import java.lang.annotation.*;
-import org.infinispan.config.parsing.ConfigurationElementReader;
-import org.infinispan.config.parsing.ConfigurationElementWriter;
 
 /**
  * Represents XML element from a valid Infinispan configuration file.
@@ -83,18 +81,4 @@
     */
    String description() default "";
 
-   /**
-    * Returns class of custom parser needed to process this ConfigurationElement
-    * 
-    * @return
-    */
-   Class<? extends ConfigurationElementReader> customReader() default ConfigurationElementReader.class;
-
-   /**
-    * Returns class of custom writer for this ConfigurationElement
-    * 
-    * @return
-    */
-   Class<? extends ConfigurationElementWriter> customWriter() default ConfigurationElementWriter.class;
-
 }

Modified: trunk/core/src/main/java/org/infinispan/config/InfinispanConfiguration.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/InfinispanConfiguration.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/core/src/main/java/org/infinispan/config/InfinispanConfiguration.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -164,13 +164,6 @@
       super();
    }
   
-   public void initialize(String fileName) throws IOException {
-   }
-   
-   public void initialize(InputStream configuration) throws IOException {
-    
-   }
-
    private static InputStream findInputStream(String fileName) throws FileNotFoundException {
       if (fileName == null)
          throw new NullPointerException("File name cannot be null!");

Deleted: trunk/core/src/main/java/org/infinispan/config/parsing/AutomatedXmlConfigurationParserImpl.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/parsing/AutomatedXmlConfigurationParserImpl.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/core/src/main/java/org/infinispan/config/parsing/AutomatedXmlConfigurationParserImpl.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -1,388 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.infinispan.config.parsing;
-
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.infinispan.config.AbstractConfigurationBean;
-import org.infinispan.config.Configuration;
-import org.infinispan.config.ConfigurationAttribute;
-import org.infinispan.config.ConfigurationElement;
-import org.infinispan.config.ConfigurationElements;
-import org.infinispan.config.ConfigurationException;
-import org.infinispan.config.ConfigurationProperties;
-import org.infinispan.config.ConfigurationProperty;
-import org.infinispan.config.DuplicateCacheNameException;
-import org.infinispan.config.GlobalConfiguration;
-import org.infinispan.util.ClassFinder;
-import org.infinispan.util.FileLookup;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * XML configuration parser that uses reflection API and annotations to read Infinispan configuration files.
- *
- * @author Vladimir Blagojevic
- * @since 4.0
- */
-public class AutomatedXmlConfigurationParserImpl extends XmlParserBase implements XmlConfigurationParser {   
-   private static  List<Class<?>> CONFIG_BEANS =null;
-   
-   static {
-      String path = ClassFinder.PATH;
-      try {         
-         CONFIG_BEANS = ClassFinder.isAssignableFrom(ClassFinder.infinispanClasses(),AbstractConfigurationBean.class);
-      } catch (Exception e) {
-         throw new ConfigurationException(
-                  "Exception while searching for Infinispan configuration beans, path is " + path,
-                  e);
-      }
-      if (CONFIG_BEANS == null || CONFIG_BEANS.isEmpty())
-         throw new ConfigurationException("Could not find Infinispan configuration beans, path is "
-                  + path);
-   }
-
-   // this parser will need to be initialized.
-   boolean initialized = false;
-
-   // the root element, representing the <infinispan /> tag
-   Element rootElement;
-
-   GlobalConfiguration gc;
-   Map<String, Configuration> namedCaches;
-
-   /**
-    * Constructs a new parser
-    */
-   public AutomatedXmlConfigurationParserImpl() {}
-
-   /**
-    * 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 AutomatedXmlConfigurationParserImpl(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 AutomatedXmlConfigurationParserImpl(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();
-      if (gc == null) {
-         Element defaultElement = getSingleElementInCoreNS("default", rootElement);
-         // there may not be a <default /> element!
-         if (defaultElement == null) {
-            return new Configuration();
-         } else {
-            defaultElement.normalize();            
-            AbstractConfigurationBean bean = findAndInstantiateBean(defaultElement);
-            visitElement(defaultElement, bean);
-            return (Configuration) bean;
-         }
-      } else {
-         return gc.getDefaultConfiguration();
-      }
-   }
-
-   public Map<String, Configuration> parseNamedConfigurations() throws ConfigurationException {
-      assertInitialized();
-      // there may not be any namedCache elements!
-      if (namedCaches == null) {
-         Set<Element> elements = getAllElementsInCoreNS("namedCache", rootElement);
-         if (elements.isEmpty()) return Collections.emptyMap();
-         namedCaches = new HashMap<String, Configuration>(elements.size(), 1.0f);
-         for (Element e : elements) {
-            String configurationName = getAttributeValue(e, "name");
-            if (namedCaches.containsKey(configurationName)) {
-               namedCaches = null;
-               throw new DuplicateCacheNameException("Named cache " + configurationName + " is declared more than once!");
-            }
-            try {
-               AbstractConfigurationBean bean = findAndInstantiateBean(e);
-               visitElement(e, bean);               
-               namedCaches.put(configurationName,(Configuration) bean);
-            } catch (ConfigurationException ce) {
-               throw new ConfigurationException("Problems configuring named cache '" + configurationName + "'", ce);
-            }
-         }
-      }
-
-      return namedCaches;
-   }
-
-   public GlobalConfiguration parseGlobalConfiguration() {
-      assertInitialized();
-      if (gc == null) {
-         Configuration defaultConfiguration = parseDefaultConfiguration();
-         Element globalElement = getSingleElementInCoreNS("global", rootElement);         
-         AbstractConfigurationBean bean = findAndInstantiateBean(globalElement);
-         visitElement(globalElement, bean);
-         gc = (GlobalConfiguration) bean;
-         gc.setDefaultConfiguration(defaultConfiguration);
-      }
-      return gc;
-   }
-   
-   AbstractConfigurationBean findAndInstantiateBean(List<Class<?>> b, Element e) throws ConfigurationException {
-      String name = e.getTagName();
-      String parentName = ((Element) e.getParentNode()).getTagName();
-      if (parentName.equals("namedCache"))
-         parentName = "default";
-      for (Class<?> clazz : b) {
-         ConfigurationElements elements = clazz.getAnnotation(ConfigurationElements.class);
-         try {
-            if (elements != null) {
-               for (ConfigurationElement ce : elements.elements()) {
-                  if (ce.name().equals(name) && ce.parent().equals(parentName)) {
-                     return (AbstractConfigurationBean) clazz.newInstance();
-                  }
-               }
-            } else {
-               ConfigurationElement ce = clazz.getAnnotation(ConfigurationElement.class);
-               if (ce != null && (ce.name().equals(name) && ce.parent().equals(parentName))) {
-                  return (AbstractConfigurationBean) clazz.newInstance();
-               }
-            }
-         } catch (Exception e1) {
-            throw new ConfigurationException("Could not instantiate class " + clazz, e1);
-         }
-      }
-      return null;
-   }
-   
-   AbstractConfigurationBean findAndInstantiateBean(Element e) throws ConfigurationException {
-      return findAndInstantiateBean(CONFIG_BEANS,e);
-   }
-   
-   private ConfigurationElement findConfigurationElement(Element e, Class<?> bean) {
-      ConfigurationElement result = null;
-      ConfigurationElement ces[] = null;
-      ConfigurationElements configurationElements = bean.getAnnotation(ConfigurationElements.class);
-      ConfigurationElement configurationElement = bean.getAnnotation(ConfigurationElement.class);
-      String parentName = ((Element)e.getParentNode()).getTagName();
-      if(parentName.equals("namedCache"))
-         parentName = "default";
-
-      if (configurationElement != null) {
-         ces = new ConfigurationElement[] { configurationElement };
-      }
-      if (configurationElements != null) {
-         ces = configurationElements.elements();
-      }
-      if (ces != null) {
-         for (ConfigurationElement el : ces) {
-            if (el.name().equals(e.getNodeName()) && el.parent().equals(parentName)) {
-               result = el;
-               break;
-            }
-         }
-      }
-      return result;
-   }
-   
-   private Class<? extends ConfigurationElementReader> customReader(Element e, Class<?> bean) {
-      Class<? extends ConfigurationElementReader> clazz = null;
-      ConfigurationElement ce = findConfigurationElement(e, bean);
-      if (ce == null) {
-         for (Class<?> beanClass : CONFIG_BEANS) {
-            ce = findConfigurationElement(e, beanClass);
-            if (ce != null)
-               break;
-         }
-      }
-      if (ce != null && !ce.customReader().equals(ConfigurationElementReader.class)) {
-         clazz = ce.customReader();
-      }
-      return clazz;
-   }
-   
-   void visitElement(Element e, AbstractConfigurationBean bean) throws ConfigurationException {     
-      Class<? extends ConfigurationElementReader> readerClass = customReader(e, bean.getClass());      
-      //has custom reader? if so, use it
-      if (readerClass != null) {         
-         ConfigurationElementReader reader = null;
-         try {            
-            reader = readerClass.newInstance();
-            reader.setParser(this);
-            reader.process(e, bean);
-         } catch (Exception e1) {
-            throw new ConfigurationException("Exception while using custom reader " + readerClass
-                     + " for element " + e.getNodeName(), e1);
-         }
-      } else {
-         //normal processing
-         visitElementDefault(e, bean);
-      }
-   }
-
-   void visitElementDefault(Element e, AbstractConfigurationBean bean) {
-      for (Method m : bean.getClass().getMethods()) {
-         boolean setter = m.getName().startsWith("set") && m.getParameterTypes().length == 1;
-         if (setter) {
-            reflectAndInvokeAttribute(bean, m, e);
-            reflectAndInvokeProperties(bean, m, e);              
-         }
-      }
-      NodeList nodeList = e.getChildNodes();
-      for (int numChildren = nodeList.getLength(), i = 0; i < numChildren; i++) {
-         Node child = nodeList.item(i);
-         if (child instanceof Element) {               
-            // recursive step
-            visitElement((Element) child, bean);
-         }
-      }
-   }
-   
-   void reflectAndInvokeAttribute(AbstractConfigurationBean bean, Method m, Element node) {     
-      Class<?> parameterType = m.getParameterTypes()[0];
-      // is there a ConfigurationAttribute matching the current node iterated?
-      ConfigurationAttribute a = m.getAnnotation(ConfigurationAttribute.class);
-      boolean matchedAttributeToSetter = a != null && a.containingElement().equals(node.getNodeName());
-      boolean isConfigBean = AbstractConfigurationBean.class.isAssignableFrom(parameterType);
-      if (matchedAttributeToSetter) {
-         String attValue = getAttributeValue(node, a.name());
-         Object methodAttributeValue = null;
-         if (attValue != null && attValue.length() > 0) {
-            PropertyEditor editor = PropertyEditorManager.findEditor(parameterType);
-            if (editor == null) {
-               throw new ConfigurationException("Could not find property editor, type="
-                        + parameterType + ",method=" + m + ",attribute=" + a.name());
-            }
-            editor.setAsText(attValue);
-            methodAttributeValue = editor.getValue();
-         } else if (a.defaultValue().length() > 0) {
-            methodAttributeValue = a.defaultValue();
-         }
-         if (methodAttributeValue != null) {
-            try {
-               m.invoke(bean, methodAttributeValue);
-            } catch (Exception ae) {
-               throw new ConfigurationException("Illegal attribute value " + attValue + ",type="
-                        + parameterType + ",method=" + m + ",attribute=" + a.name(), ae);
-            }
-         }
-      } else if (isConfigBean) {
-         AbstractConfigurationBean childBean = findAndInstantiateBean(node);
-         boolean foundMatchingChild = childBean != null
-                  && !bean.getClass().equals(childBean.getClass())
-                  && parameterType.isInstance(childBean);
-         if (foundMatchingChild) {  
-            //recurse into child
-            visitElement(node,childBean);
-            try {
-               //and finally invoke setter on father bean
-               m.invoke(bean, childBean);
-            } catch (Exception ae) {
-               throw new ConfigurationException("Illegal bean value " + childBean + ",type="
-                        + parameterType + ", method=" + m, ae);
-            }
-         }
-      }
-   }
-   
-   boolean reflectAndInvokeProperties(AbstractConfigurationBean bean, Method m, Element node){
-      Class<?> parameterType = m.getParameterTypes()[0];
-      
-      //how about ConfigurationProperties or ConfigurationProperty matching the current node iterated?
-      ConfigurationProperty[] cprops = null;
-      ConfigurationProperties cp = m.getAnnotation(ConfigurationProperties.class);               
-      if (cp != null) {
-         cprops = cp.elements();
-      } else {
-         ConfigurationProperty p = null;
-         p = m.getAnnotation(ConfigurationProperty.class);
-         if (p != null) {
-            cprops = new ConfigurationProperty[] { p };
-         }
-      }
-      boolean matchedPropertyToSetter  = cprops != null && cprops.length >0;
-      if(matchedPropertyToSetter){
-         String parentElement = cprops[0].parentElement();         
-         if(parentElement.equals(node.getParentNode().getNodeName())){           
-            if(node.getNodeName().equals("property")){
-               Properties props = XmlConfigHelper.extractProperties((Element) node.getParentNode());
-               //special case where setter argument is Properties object
-               if (Properties.class.isAssignableFrom(parameterType)) {
-                  try {
-                     m.invoke(bean, props);
-                  } catch (Exception ae) {
-                     throw new ConfigurationException("Illegal props " + props + ",type="
-                              + parameterType + ", method=" + m, ae);
-                  }
-               } else {
-                  //regular case where setter argument are primitives and String
-                  //follow bean conventions
-                  XmlConfigHelper.setValues(bean, props, false, true);
-               }
-               //we assume that all other siblings of <property> element are also <property> elements 
-               // there no need to iterate them as we have extracted them all using the  method above
-               // therefore skip them by returning
-               return true;
-            }
-         }         
-      }
-      return false;
-   }
-   
-   private void assertInitialized() {
-      if (!initialized)
-         throw new ConfigurationException("Parser not initialized.  Please invoke initialize() first, or use a constructor that initializes the parser.");
-   }
-}
\ No newline at end of file

Deleted: trunk/core/src/main/java/org/infinispan/config/parsing/CacheLoaderManagerConfigReader.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/parsing/CacheLoaderManagerConfigReader.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/core/src/main/java/org/infinispan/config/parsing/CacheLoaderManagerConfigReader.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -1,87 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.infinispan.config.parsing;
-
-import java.lang.reflect.Method;
-import java.util.Set;
-
-import org.infinispan.config.AbstractConfigurationBean;
-import org.infinispan.config.CacheLoaderManagerConfig;
-import org.infinispan.config.ConfigurationException;
-import org.infinispan.config.Configuration;
-import org.infinispan.loaders.CacheLoader;
-import org.infinispan.loaders.CacheLoaderConfig;
-import org.infinispan.util.Util;
-import org.w3c.dom.Element;
-
-public class CacheLoaderManagerConfigReader implements ConfigurationElementReader {
-
-   private AutomatedXmlConfigurationParserImpl parser;
-
-   public CacheLoaderManagerConfigReader() {
-      super();
-   }
-
-   public void setParser(AutomatedXmlConfigurationParserImpl parser) {
-      this.parser = parser;
-   }
-
-   public void process(Element e, AbstractConfigurationBean bean) {      
-      CacheLoaderManagerConfig cBean = (CacheLoaderManagerConfig) parser.findAndInstantiateBean(e);
-      
-      //set attributes of <loaders/>
-      for (Method m : cBean.getClass().getMethods()) {
-         boolean setter = m.getName().startsWith("set") && m.getParameterTypes().length == 1;
-         if (setter) {
-            parser.reflectAndInvokeAttribute(cBean, m, e);
-            parser.reflectAndInvokeProperties(cBean, m, e);              
-         }
-      }
-      
-      Set<Element> elements = parser.getAllElementsInCoreNS("loader", e);
-      if (elements.isEmpty())
-         throw new ConfigurationException("No loader elements found!");
-
-      for (Element element : elements) {
-         String clClass = parser.getAttributeValue(element, "class");
-         if (!parser.existsAttribute(clClass))
-            throw new ConfigurationException("Missing 'class'  attribute for cache loader configuration");
-
-         CacheLoader cl;
-         CacheLoaderConfig clc;
-         try {
-            cl = (CacheLoader) Util.getInstance(clClass);
-            clc = Util.getInstance(cl.getConfigurationClass());
-         } catch (Exception ex) {
-            throw new ConfigurationException("Unable to instantiate cache loader or configuration",ex);
-         }
-
-         clc.setCacheLoaderClassName(clClass);
-         Element propertiesElement = parser.getSingleElementInCoreNS("properties", element);
-         if (propertiesElement == null)
-            throw new ConfigurationException("loader " + clClass + " is missing properties element");
-         parser.visitElement(element, (AbstractConfigurationBean) clc);
-         cBean.addCacheLoaderConfig(clc);
-      }
-      ((Configuration)bean).setCacheLoaderManagerConfig(cBean);
-   }
-}

Deleted: trunk/core/src/main/java/org/infinispan/config/parsing/ClusteringConfigReader.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/parsing/ClusteringConfigReader.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/core/src/main/java/org/infinispan/config/parsing/ClusteringConfigReader.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.infinispan.config.parsing;
-
-import org.infinispan.config.AbstractConfigurationBean;
-import org.infinispan.config.Configuration;
-import org.infinispan.config.ConfigurationException;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class ClusteringConfigReader implements ConfigurationElementReader {
-
-   private AutomatedXmlConfigurationParserImpl parser;
-
-   public ClusteringConfigReader() {
-      super();
-   }
-
-   public void setParser(AutomatedXmlConfigurationParserImpl parser) {
-      this.parser = parser;
-   }
-
-   public void process(Element e, AbstractConfigurationBean bean) {
-      if (e == null) return; //we might not have this configured
-
-      Configuration config = (Configuration) bean;
-      Configuration.CacheMode cacheMode;
-      String mode = parser.getAttributeValue(e, "mode").toUpperCase();
-      if (mode.startsWith("R"))
-         cacheMode = Configuration.CacheMode.REPL_SYNC;
-      else if (mode.startsWith("I"))
-         cacheMode = Configuration.CacheMode.INVALIDATION_SYNC;
-      else
-         cacheMode = Configuration.CacheMode.DIST_SYNC; // the default
-
-      Element asyncEl = parser.getSingleElementInCoreNS("async", e);
-      Element syncEl = parser.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(cacheMode);        
-      } else {
-         cacheMode = cacheMode.toAsync(); // get the async version of this mode
-         config.setCacheMode(cacheMode);
-      }
-      
-      NodeList nodeList = e.getChildNodes();
-      for (int numChildren = nodeList.getLength(), i = 0; i < numChildren; i++) {
-         Node node = nodeList.item(i);
-         if (node instanceof Element) {
-            Element childNode = (Element) node;
-            // recursive step
-            parser.visitElement(childNode, bean);
-         }
-      }    
-   }
-}

Deleted: trunk/core/src/main/java/org/infinispan/config/parsing/ConfigurationElementReader.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/parsing/ConfigurationElementReader.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/core/src/main/java/org/infinispan/config/parsing/ConfigurationElementReader.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.infinispan.config.parsing;
-
-import org.infinispan.config.AbstractConfigurationBean;
-import org.w3c.dom.Element;
-
-public interface ConfigurationElementReader {
-   
-   public void process(Element e, AbstractConfigurationBean c);   
-   public void setParser(AutomatedXmlConfigurationParserImpl parser);
-
-}

Deleted: trunk/core/src/main/java/org/infinispan/config/parsing/ConfigurationElementWriter.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/parsing/ConfigurationElementWriter.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/core/src/main/java/org/infinispan/config/parsing/ConfigurationElementWriter.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -1,30 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.infinispan.config.parsing;
-
-import org.w3c.dom.Document;
-
-public interface ConfigurationElementWriter {
-   
-   public void process(TreeNode node, Document c);     
-
-}

Deleted: trunk/core/src/main/java/org/infinispan/config/parsing/CustomInterceptorConfigReader.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/parsing/CustomInterceptorConfigReader.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/core/src/main/java/org/infinispan/config/parsing/CustomInterceptorConfigReader.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -1,93 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.infinispan.config.parsing;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import org.infinispan.config.AbstractConfigurationBean;
-import org.infinispan.config.Configuration;
-import org.infinispan.config.ConfigurationException;
-import org.infinispan.config.CustomInterceptorConfig;
-import org.infinispan.interceptors.base.CommandInterceptor;
-import org.infinispan.util.Util;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-public class CustomInterceptorConfigReader implements ConfigurationElementReader {
-
-   private AutomatedXmlConfigurationParserImpl parser;
-
-   public CustomInterceptorConfigReader() {
-      super();
-   }
-
-   public void setParser(AutomatedXmlConfigurationParserImpl parser) {
-      this.parser = parser;
-   }
-
-   public void process(Element e, AbstractConfigurationBean bean) {
-      NodeList interceptorNodes = e.getElementsByTagName("interceptor");
-      List<CustomInterceptorConfig> interceptorConfigs = new ArrayList<CustomInterceptorConfig>(interceptorNodes.getLength());
-      for (int i = 0; i < interceptorNodes.getLength(); i++) {                        
-         Element interceptorElement = (Element) interceptorNodes.item(i);
-         CustomInterceptorConfig customInterceptorConfig = new CustomInterceptorConfig();
-         String position = parser.getAttributeValue(interceptorElement, "position");
-         if (parser.existsAttribute(position)) {
-            customInterceptorConfig.setPosition(position);
-         }         
-         String indexStr = parser.getAttributeValue(interceptorElement, "index");
-         int index = parser.existsAttribute(indexStr) ? parser.getInt(indexStr) : -1;
-         customInterceptorConfig.setIndex(index);
-         String before = parser.getAttributeValue(interceptorElement, "before");
-         if (parser.existsAttribute(before)){
-            customInterceptorConfig.setBeforeInterceptor(before);
-         }
-         String after = parser.getAttributeValue(interceptorElement, "after");
-         if (parser.existsAttribute(after)){
-            customInterceptorConfig.setAfterInterceptor(before);
-         }            
-         
-         String interceptorClass = parser.getAttributeValue(interceptorElement, "class");
-         if (!parser.existsAttribute(interceptorClass))
-            throw new ConfigurationException("Interceptor class cannot be empty!");
-         
-         customInterceptorConfig.setClassName(interceptorClass);
-         
-         CommandInterceptor interceptor;
-         try {
-            interceptor = (CommandInterceptor) Util.loadClass(interceptorClass).newInstance();
-         } catch (Exception ex) {
-            throw new ConfigurationException(
-                     "CommandInterceptor class is not properly loaded in classloader", ex);
-         }
-         Properties p = XmlConfigHelper.extractProperties(interceptorElement);
-         if (p != null)
-            XmlConfigHelper.setValues(interceptor, p, false, true);
-         customInterceptorConfig.setInterceptor(interceptor); 
-         
-         interceptorConfigs.add(customInterceptorConfig);
-      }
-      ((Configuration) bean).setCustomInterceptors(interceptorConfigs);
-   }   
-}

Modified: trunk/core/src/main/java/org/infinispan/config/parsing/XmlConfigurationParser.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/parsing/XmlConfigurationParser.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/core/src/main/java/org/infinispan/config/parsing/XmlConfigurationParser.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -4,8 +4,6 @@
 import org.infinispan.config.ConfigurationException;
 import org.infinispan.config.GlobalConfiguration;
 
-import java.io.IOException;
-import java.io.InputStream;
 import java.util.Map;
 
 /**
@@ -16,24 +14,6 @@
  */
 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 the default template configuration.
     *
     * @return a configuration instance representing the "default" block in the configuration file

Deleted: trunk/core/src/main/java/org/infinispan/config/parsing/XmlConfigurationParserImpl.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/parsing/XmlConfigurationParserImpl.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/core/src/main/java/org/infinispan/config/parsing/XmlConfigurationParserImpl.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -1,488 +0,0 @@
-package org.infinispan.config.parsing;
-
-import org.infinispan.config.CacheLoaderManagerConfig;
-import org.infinispan.config.Configuration;
-import org.infinispan.config.ConfigurationException;
-import org.infinispan.config.CustomInterceptorConfig;
-import org.infinispan.config.DuplicateCacheNameException;
-import org.infinispan.config.GlobalConfiguration;
-import org.infinispan.config.parsing.element.CustomInterceptorsElementParser;
-import org.infinispan.config.parsing.element.LoadersElementParser;
-import org.infinispan.eviction.EvictionStrategy;
-import org.infinispan.transaction.lookup.GenericTransactionManagerLookup;
-import org.infinispan.util.FileLookup;
-import org.infinispan.util.concurrent.IsolationLevel;
-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.Properties;
-import java.util.Set;
-
-/**
- * The default XML configuration parser
- *
- * @author Manik Surtani
- * @since 4.0
- */
-public class XmlConfigurationParserImpl extends XmlParserBase implements XmlConfigurationParser {
-
-   // this parser will need to be initialized.
-   boolean initialized = false;
-
-   // the root element, representing the <infinispan /> tag
-   Element rootElement;
-
-   GlobalConfiguration gc;
-   Map<String, Configuration> namedCaches;
-
-   /**
-    * 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();
-      if (gc == null) {
-         Element defaultElement = getSingleElementInCoreNS("default", rootElement);
-         // there may not be a <default /> element!
-         if (defaultElement == null) {
-            return new Configuration();
-         } else {
-            defaultElement.normalize();
-            return parseConfiguration(defaultElement);
-         }
-      } else {
-         return gc.getDefaultConfiguration();
-      }
-   }
-
-   public Map<String, Configuration> parseNamedConfigurations() throws ConfigurationException {
-      assertInitialized();
-      // there may not be any namedCache elements!
-      if (namedCaches == null) {
-         Set<Element> elements = getAllElementsInCoreNS("namedCache", rootElement);
-         if (elements.isEmpty()) return Collections.emptyMap();
-         namedCaches = new HashMap<String, Configuration>(elements.size(), 1.0f);
-         for (Element e : elements) {
-            String configurationName = getAttributeValue(e, "name");
-            if (namedCaches.containsKey(configurationName)) {
-               namedCaches = null;
-               throw new DuplicateCacheNameException("Named cache " + configurationName + " is declared more than once!");
-            }
-            try {
-               namedCaches.put(configurationName, parseConfiguration(e));
-            } catch (ConfigurationException ce) {
-               throw new ConfigurationException("Problems configuring named cache '" + configurationName + "'", ce);
-            }
-         }
-      }
-
-      return namedCaches;
-   }
-
-   public GlobalConfiguration parseGlobalConfiguration() {
-      assertInitialized();
-      if (gc == null) {
-         Element globalElement = getSingleElementInCoreNS("global", rootElement);
-         Configuration defaultConfig = parseDefaultConfiguration();
-         gc = new GlobalConfiguration();
-         gc.setDefaultConfiguration(defaultConfig);
-         // there may not be a <global /> element in the config!!
-         if (globalElement != null) {
-            globalElement.normalize();
-            configureAsyncListenerExecutor(getSingleElementInCoreNS("asyncListenerExecutor", globalElement), gc);
-            configureAsyncTransportExecutor(getSingleElementInCoreNS("asyncTransportExecutor", globalElement), gc);
-            configureEvictionScheduledExecutor(getSingleElementInCoreNS("evictionScheduledExecutor", globalElement), gc);
-            configureReplicationQueueScheduledExecutor(getSingleElementInCoreNS("replicationQueueScheduledExecutor", globalElement), gc);
-            configureTransport(getSingleElementInCoreNS("transport", globalElement), gc);
-            configureShutdown(getSingleElementInCoreNS("shutdown", globalElement), gc);
-            configureSerialization(getSingleElementInCoreNS("serialization", globalElement), gc);
-            configureGlobalJmxStatistics(getSingleElementInCoreNS("globalJmxStatistics", globalElement), gc);
-            configureGlobalJmxStatistics(getSingleElementInCoreNS("globalJmxStatistics", globalElement), gc);
-         }
-      }
-
-      return gc;
-   }
-
-   private Configuration parseConfiguration(Element e) {
-      Configuration c = new Configuration();
-      configureLocking(getSingleElementInCoreNS("locking", e), c);
-      configureTransaction(getSingleElementInCoreNS("transaction", e), c);
-      configureCacheJmxStatistics(getSingleElementInCoreNS("jmxStatistics", e), c);
-      configureLazyDeserialization(getSingleElementInCoreNS("lazyDeserialization", e), c);
-      configureInvocationBatching(getSingleElementInCoreNS("invocationBatching", e), c);
-      configureClustering(getSingleElementInCoreNS("clustering", e), c);
-      configureEviction(getSingleElementInCoreNS("eviction", e), c);
-      configureExpiration(getSingleElementInCoreNS("expiration", e), c);
-      configureCacheLoaders(getSingleElementInCoreNS("loaders", e), c);
-      configureCustomInterceptors(getSingleElementInCoreNS("customInterceptors", e), c);
-      configureUnsafe(getSingleElementInCoreNS("unsafe", e), c);
-      configureDeadlockDetection(getSingleElementInCoreNS("deadlockDetection", e), c);
-      return c;
-   }
-
-   void configureDeadlockDetection(Element element, Configuration c) {
-      if (element == null) return; //might me missing
-      String enabled = getAttributeValue(element, "enabled");
-      if (existsAttribute(enabled))
-         c.setEnableDeadlockDetection(getBoolean(enabled));
-      String spinDuration = getAttributeValue(element, "spinDuration");
-      if (existsAttribute(spinDuration))
-         c.setDeadlockDetectionSpinDuration(getLong(spinDuration));
-   }
-
-   private void assertInitialized() {
-      if (!initialized)
-         throw new ConfigurationException("Parser not initialized.  Please invoke initialize() first, or use a constructor that initializes the parser.");
-   }
-
-   void configureClustering(Element e, Configuration config) {
-      if (e == null) return; //we might not have this configured
-
-      Configuration.CacheMode cacheMode;
-      String mode = getAttributeValue(e, "mode").toUpperCase();
-      if (mode.startsWith("R"))
-         cacheMode = Configuration.CacheMode.REPL_SYNC;
-      else if (mode.startsWith("I"))
-         cacheMode = Configuration.CacheMode.INVALIDATION_SYNC;
-      else
-         cacheMode = Configuration.CacheMode.DIST_SYNC; // the default
-
-      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(cacheMode);
-         configureSyncMode(syncEl, config);
-      } else {
-         cacheMode = cacheMode.toAsync(); // get the async version of this mode
-         config.setCacheMode(cacheMode);
-         configureAsyncMode(asyncEl, config);
-      }
-
-      if (cacheMode.isDistributed()) {
-         // L1 cache
-         Element l1 = getSingleElementInCoreNS("l1", e);
-         String tmp = getAttributeValue(l1, "enabled");
-         if (existsAttribute(tmp)) config.setL1CacheEnabled(getBoolean(tmp));
-         tmp = getAttributeValue(l1, "lifespan");
-         if (existsAttribute(tmp)) config.setL1Lifespan(getLong(tmp));
-         tmp = getAttributeValue(l1, "onRehash");
-         if (existsAttribute(tmp)) config.setL1OnRehash(getBoolean(tmp));
-
-         // consistent hash algo
-         Element hash = getSingleElementInCoreNS("hash", e);
-         tmp = getAttributeValue(hash, "class");
-         if (existsAttribute(tmp)) config.setConsistentHashClass(tmp);
-         tmp = getAttributeValue(hash, "numOwners");
-         if (existsAttribute(tmp)) config.setNumOwners(getInt(tmp));
-         tmp = getAttributeValue(hash, "rehashWait");
-         if (existsAttribute(tmp)) config.setRehashWaitTime(getLong(tmp));
-         tmp = getAttributeValue(hash, "rehashRpcTimeout");
-         if (existsAttribute(tmp)) config.setRehashRpcTimeout(getLong(tmp));
-      } else if (getSingleElementInCoreNS("l1", e) != null || getSingleElementInCoreNS("hash", e) != null) {
-         throw new ConfigurationException("l1 and hash elements cannot be used with cache modes 'REPLICATION' and 'INVALIDATION'!");
-      }
-      configureStateRetrieval(getSingleElementInCoreNS("stateRetrieval", 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));
-      else
-         config.setFetchInMemoryState(true); // set this to true since the element was provided   
-      String stateRetrievalTimeout = getAttributeValue(element, "timeout");
-      if (existsAttribute(stateRetrievalTimeout)) config.setStateRetrievalTimeout(getLong(stateRetrievalTimeout));
-
-   }
-
-   void configureTransaction(Element element, Configuration config) {
-      if (element != null) {
-         String tmp = getAttributeValue(element, "transactionManagerLookupClass");
-         if (existsAttribute(tmp)) {
-            config.setTransactionManagerLookupClass(tmp);
-         } else {
-            // use defaults since the transaction element is still present!
-            config.setTransactionManagerLookupClass(GenericTransactionManagerLookup.class.getName());
-         }
-         String useEagerLocking = getAttributeValue(element, "useEagerLocking");
-         if (existsAttribute(useEagerLocking)) config.setUseEagerLocking(getBoolean(useEagerLocking));
-         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 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 configureInvocationBatching(Element element, Configuration config) {
-      if (element != null) {
-         String enabled = getAttributeValue(element, "enabled");
-         if (existsAttribute(enabled)) {
-            config.setInvocationBatchingEnabled(getBoolean(enabled));
-         } else {
-            // enable this anyway since the XML element is present
-            config.setInvocationBatchingEnabled(true);
-         }
-
-      }
-   }
-
-   void configureCacheLoaders(Element element, Configuration config) {
-      if (element == null) return; //null cache loaders are allowed
-      LoadersElementParser clElementParser = new LoadersElementParser();
-      CacheLoaderManagerConfig cacheLoaderConfig = clElementParser.parseLoadersElement(element);
-      config.setCacheLoaderManagerConfig(cacheLoaderConfig);
-   }
-
-   void configureExpiration(Element expirationElement, Configuration config) {
-      if (expirationElement != null) {
-         String tmp = getAttributeValue(expirationElement, "lifespan");
-         if (existsAttribute(tmp)) config.setExpirationLifespan(getLong(tmp));
-         tmp = getAttributeValue(expirationElement, "maxIdle");
-         if (existsAttribute(tmp)) config.setExpirationMaxIdle(getLong(tmp));
-      }
-   }
-
-   void configureEviction(Element evictionElement, Configuration config) {
-      if (evictionElement != null) {
-         String tmp = getAttributeValue(evictionElement, "strategy");
-         if (existsAttribute(tmp)) config.setEvictionStrategy(EvictionStrategy.valueOf(tmp.trim().toUpperCase()));
-         tmp = getAttributeValue(evictionElement, "maxEntries");
-         if (existsAttribute(tmp)) config.setEvictionMaxEntries(getInt(tmp));
-         tmp = getAttributeValue(evictionElement, "wakeUpInterval");
-         if (existsAttribute(tmp)) config.setEvictionWakeUpInterval(getLong(tmp));
-      }
-   }
-
-   void configureCacheJmxStatistics(Element element, Configuration config) {
-      if (element != null) {
-         String enabled = getAttributeValue(element, "enabled");
-         if (existsAttribute(enabled)) {
-            config.setExposeJmxStatistics(getBoolean(enabled));
-         }
-      }
-   }
-
-   void configureLazyDeserialization(Element element, Configuration config) {
-      if (element != null) {
-         String enabled = getAttributeValue(element, "enabled");
-         if (existsAttribute(enabled)) {
-            config.setUseLazyDeserialization(getBoolean(enabled));
-         }
-      }
-   }
-
-   void configureUnsafe(Element element, Configuration configuration) {
-      if (element != null) {
-         String tmp = getAttributeValue(element, "unreliableReturnValues");
-         if (existsAttribute(tmp)) configuration.setUnsafeUnreliableReturnValues(getBoolean(tmp));
-      }
-   }
-
-   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 tmp = getAttributeValue(element, "useReplQueue");
-      if (existsAttribute(tmp)) config.setUseReplQueue(getBoolean(tmp));
-      tmp = getAttributeValue(element, "replQueueInterval");
-      if (existsAttribute(tmp)) config.setReplQueueInterval(getLong(tmp));
-      tmp = getAttributeValue(element, "replQueueMaxElements");
-      if (existsAttribute(tmp)) config.setReplQueueMaxElements(getInt(tmp));
-      tmp = getAttributeValue(element, "asyncMarshalling");
-      if (existsAttribute(tmp)) config.setUseAsyncMarshalling(getBoolean(tmp));
-   }
-
-   void configureLocking(Element element, Configuration config) {
-      String isolationLevel = getAttributeValue(element, "isolationLevel");
-      if (existsAttribute(isolationLevel)) config.setIsolationLevel(IsolationLevel.valueOf(isolationLevel));
-      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 useLockStriping = getAttributeValue(element, "useLockStriping");
-      if (existsAttribute(useLockStriping)) config.setUseLockStriping(getBoolean(useLockStriping));
-      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 e, GlobalConfiguration gc) {
-      // if the element does NOT exist then don't use a transport class at all!
-      if (e != null) {
-         String tmp = getAttributeValue(e, "transportClass");
-         if (existsAttribute(tmp)) {
-            gc.setTransportClass(tmp);
-         } else {
-            // the class is not specified; use the default
-            gc.setTransportClass(GlobalConfiguration.getClusteredDefault().getTransportClass());
-         }
-
-         tmp = getAttributeValue(e, "clusterName");
-         if (existsAttribute(tmp)) gc.setClusterName(tmp);
-
-         tmp = getAttributeValue(e, "distributedSyncTimeout");
-         if (existsAttribute(tmp)) gc.setDistributedSyncTimeout(getLong(tmp));
-
-         Properties p = XmlConfigHelper.extractProperties(e);
-         if (p != null) gc.setTransportProperties(p);
-      }
-   }
-
-   void configureSerialization(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);
-      }
-   }
-
-   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 configureAsyncTransportExecutor(Element e, GlobalConfiguration gc) {
-      if (e != null) {
-         String tmp = getAttributeValue(e, "factory");
-         if (existsAttribute(tmp)) gc.setAsyncTransportExecutorFactoryClass(tmp);
-         Properties p = XmlConfigHelper.extractProperties(e);
-         if (p != null) gc.setAsyncTransportExecutorProperties(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);
-      }
-   }
-
-   public void configureGlobalJmxStatistics(Element e, GlobalConfiguration c) {
-      if (e != null) {
-         String enabled = getAttributeValue(e, "enabled");
-         if (existsAttribute(enabled)) c.setExposeGlobalJmxStatistics(getBoolean(enabled));
-         String jmxDomain = getAttributeValue(e, "jmxDomain");
-         if (existsAttribute(jmxDomain)) c.setJmxDomain(jmxDomain);
-         String mBeanServerLookup = getAttributeValue(e, "mBeanServerLookup");
-         if (existsAttribute(mBeanServerLookup)) c.setMBeanServerLookup(mBeanServerLookup);
-         String allowDuplicateDomains = getAttributeValue(e, "allowDuplicateDomains");
-         if (existsAttribute(allowDuplicateDomains)) c.setAllowDuplicateDomains(getBoolean(allowDuplicateDomains));
-      }
-   }
-
-   private Element getSingleElement(String elementName) {
-      return getSingleElementInCoreNS(elementName, rootElement);
-   }
-
-   /**
-    * Tests whether the element passed in is a valid config element.
-    *
-    * @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 "infinispan" element.
-      NodeList elements = element.getElementsByTagName("infinispan");
-      return elements != null && elements.getLength() > 0;
-   }
-}

Deleted: trunk/core/src/main/java/org/infinispan/config/parsing/XmlParserBase.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/parsing/XmlParserBase.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/core/src/main/java/org/infinispan/config/parsing/XmlParserBase.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -1,121 +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.infinispan.config.parsing;
-
-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.
- *
- * @author Mircea.Markus at jboss.com
- * @since 4.0
- */
-public abstract class XmlParserBase {
-
-   /**
-    * @see Integer#parseInt(String)
-    */
-   protected int getInt(String intStr) {
-      return Integer.parseInt(intStr);
-   }
-
-   /**
-    * @see Long#parseLong(String)
-    */
-   protected long getLong(String longStr) {
-      return Long.parseLong(longStr);
-   }
-
-   /**
-    * @see Boolean#valueOf(String)
-    */
-   protected boolean getBoolean(String str) {
-      return str == null ? false : Boolean.valueOf(str);
-   }
-
-   /**
-    * @return true if the given value is not empty.
-    */
-   protected boolean existsAttribute(String attrValue) {
-      return attrValue != null && attrValue.length() > 0;
-   }
-
-   /**
-    * Convenient method for retrieving a single element with the give name.
-    */
-   protected Element getSingleElement(String namespace, String elementName, Element parent) {
-      NodeList nodeList = parent.getElementsByTagNameNS(namespace, elementName);
-      if (nodeList.getLength() == 0) {
-         // Try outside the core NS
-         nodeList = parent.getElementsByTagName(elementName);
-         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++) {
-         Node n = nodeList.item(i);
-         if (n instanceof Element) elements.add((Element) n);
-      }
-      return elements;
-   }
-
-   /**
-    * 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.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.HORIZON_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/>
-    * {@link org.jboss.util.StringPropertyReplacer#replaceProperties(String)}
-    */
-   protected String getAttributeValue(Element element, String attrName) {
-      if (element == null || attrName == null) return null;
-      String value = element.getAttribute(attrName);
-      return value == null ? null : StringPropertyReplacer.replaceProperties(value);
-   }
-}

Deleted: trunk/core/src/test/java/org/infinispan/config/parsing/ConfigurationParserTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/config/parsing/ConfigurationParserTest.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/core/src/test/java/org/infinispan/config/parsing/ConfigurationParserTest.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -1,387 +0,0 @@
-package org.infinispan.config.parsing;
-
-import org.infinispan.config.CacheLoaderManagerConfig;
-import org.infinispan.config.Configuration;
-import org.infinispan.config.ConfigurationException;
-import org.infinispan.distribution.DefaultConsistentHash;
-import org.infinispan.eviction.EvictionStrategy;
-import org.infinispan.loaders.CacheStoreConfig;
-import org.infinispan.loaders.decorators.SingletonStoreConfig;
-import org.infinispan.loaders.file.FileCacheStore;
-import org.infinispan.loaders.file.FileCacheStoreConfig;
-import org.infinispan.transaction.lookup.GenericTransactionManagerLookup;
-import org.infinispan.util.concurrent.IsolationLevel;
-import org.testng.annotations.Test;
-import org.w3c.dom.Element;
-
- at Test(groups = "unit", testName = "config.parsing.ConfigurationParserTest")
-public class ConfigurationParserTest {
-
-   public void testLocking() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<locking\n" +
-            "            isolationLevel=\"REPEATABLE_READ\"\n" +
-            "            lockAcquisitionTimeout=\"200000\"\n" +
-            "            writeSkewCheck=\"true\"\n" +
-            "            concurrencyLevel=\"5\"/>";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      Configuration c = new Configuration();
-      parser.configureLocking(e, c);
-
-      assert c.getIsolationLevel() == IsolationLevel.REPEATABLE_READ;
-      assert c.getLockAcquisitionTimeout() == 200000;
-      assert c.isWriteSkewCheck();
-      assert c.getConcurrencyLevel() == 5;
-   }
-
-   public void testTransactions() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<transaction\n" +
-            "            transactionManagerLookupClass=\"org.blah.Blah\"\n" +
-            "            syncRollbackPhase=\"true\"\n" +
-            "            useEagerLocking=\"true\"\n" +
-            "            syncCommitPhase=\"true\"/>";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      Configuration c = new Configuration();
-      parser.configureTransaction(e, c);
-
-      assert c.getTransactionManagerLookupClass().equals("org.blah.Blah");
-      assert c.isSyncCommitPhase();
-      assert c.isSyncRollbackPhase();
-      assert c.isUseEagerLocking();
-   }
-
-   public void testTransactionsDefaults() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<transaction />";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      Configuration c = new Configuration();
-      parser.configureTransaction(e, c);
-
-      assert c.getTransactionManagerLookupClass().equals(GenericTransactionManagerLookup.class.getName());
-      assert !c.isSyncCommitPhase();
-      assert !c.isSyncRollbackPhase();
-   }
-
-   public void testCacheJmxStatistics() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<jmxStatistics enabled=\"true\"/>";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      Configuration c = new Configuration();
-      parser.configureCacheJmxStatistics(e, c);
-
-      assert c.isExposeJmxStatistics();
-   }
-
-   public void testLazyDeserialization() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<lazyDeserialization enabled=\"true\"/>";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      Configuration c = new Configuration();
-      parser.configureLazyDeserialization(e, c);
-
-      assert c.isUseAsyncMarshalling();
-   }
-
-   public void testJmxStatisticsDefaults() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<jmxStatistics />";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      Configuration c = new Configuration();
-      parser.configureCacheJmxStatistics(e, c);
-
-      assert !c.isExposeJmxStatistics();
-   }
-
-   public void testInvocationBatching() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<invocationBatching enabled=\"true\"/>";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      Configuration c = new Configuration();
-      parser.configureInvocationBatching(e, c);
-
-      assert c.isInvocationBatchingEnabled();
-   }
-
-   public void testDeadlockDetection() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<deadlockDetection enabled=\"true\" spinDuration=\"123\"/>";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      Configuration c = new Configuration();
-      parser.configureDeadlockDetection(e, c);
-
-      assert c.isEnableDeadlockDetection();
-      assert c.getDeadlockDetectionSpinDuration() == 123;
-   }
-
-   public void testInvocationBatchingDefaults() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<invocationBatching />";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      Configuration c = new Configuration();
-      parser.configureInvocationBatching(e, c);
-
-      assert c.isInvocationBatchingEnabled();
-   }
-
-   public void testClustering() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<clustering mode=\"invalidation\">\n" +
-            "         <stateRetrieval timeout=\"20000\" fetchInMemoryState=\"false\"/>\n" +
-            "         <async useReplQueue=\"true\" replQueueInterval=\"10000\" replQueueMaxElements=\"500\" asyncMarshalling=\"false\"/>\n" +
-            "      </clustering>";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      Configuration c = new Configuration();
-      parser.configureClustering(e, c);
-
-      assert c.getCacheMode() == Configuration.CacheMode.INVALIDATION_ASYNC;
-      assert c.getStateRetrievalTimeout() == 20000;
-      assert !c.isFetchInMemoryState();
-      assert c.isUseReplQueue();
-      assert c.getReplQueueInterval() == 10000;
-      assert c.getReplQueueMaxElements() == 500;
-      assert c.isUseAsyncMarshalling() == false;
-   }
-
-   public void testClusteringDefaults() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<clustering />";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      Configuration c = new Configuration();
-      parser.configureClustering(e, c);
-
-      assert c.getCacheMode() == Configuration.CacheMode.DIST_SYNC;
-      assert !c.isFetchInMemoryState();
-      assert !c.isUseReplQueue();
-      assert c.isL1CacheEnabled();
-   }
-
-   public void testCacheLoaders() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml =
-            "      <loaders passivation=\"true\" shared=\"true\" preload=\"true\">\n" +
-                  "         <loader class=\"org.infinispan.loaders.file.FileCacheStore\" fetchPersistentState=\"true\"\n" +
-                  "                 ignoreModifications=\"true\" purgeOnStartup=\"true\">\n" +
-                  "            <properties>\n" +
-                  "               <property name=\"location\" value=\"blahblah\"/>\n" +
-                  "            </properties>\n" +
-                  "            <singletonStore enabled=\"true\" pushStateWhenCoordinator=\"true\" pushStateTimeout=\"20000\"/>\n" +
-                  "            <async enabled=\"true\" threadPoolSize=\"10\" mapLockTimeout=\"10000\"/>\n" +
-                  "         </loader>\n" +
-                  "      </loaders>      ";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      Configuration c = new Configuration();
-      parser.configureCacheLoaders(e, c);
-
-      CacheLoaderManagerConfig clc = c.getCacheLoaderManagerConfig();
-      assert clc != null;
-      assert clc.isFetchPersistentState();
-      assert clc.isPassivation();
-      assert clc.isShared();
-      assert clc.isPreload();
-
-      CacheStoreConfig iclc = (CacheStoreConfig) clc.getFirstCacheLoaderConfig();
-      assert iclc.getCacheLoaderClassName().equals(FileCacheStore.class.getName());
-      assert iclc.getAsyncStoreConfig().isEnabled();
-      assert iclc.getAsyncStoreConfig().getMapLockTimeout() == 10000;
-      assert iclc.getAsyncStoreConfig().getThreadPoolSize() == 10;
-      assert iclc.isFetchPersistentState();
-      assert iclc.isIgnoreModifications();
-      assert iclc.isPurgeOnStartup();
-
-      assert clc.getCacheLoaderConfigs().size() == 1;
-      FileCacheStoreConfig csConf = (FileCacheStoreConfig) clc.getFirstCacheLoaderConfig();
-      assert csConf.getLocation().equals("blahblah");
-
-      SingletonStoreConfig ssc = iclc.getSingletonStoreConfig();
-      assert ssc.isSingletonStoreEnabled();
-      assert ssc.isPushStateWhenCoordinator();
-      assert ssc.getPushStateTimeout() == 20000;
-   }
-
-   public void testCacheLoadersDefaults() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<loaders>\n" +
-            "         <loader class=\"org.infinispan.loaders.file.FileCacheStore\">\n" +
-            "            <properties />\n" +
-            "         </loader>\n" +
-            "      </loaders>";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      Configuration c = new Configuration();
-      parser.configureCacheLoaders(e, c);
-
-      CacheLoaderManagerConfig clc = c.getCacheLoaderManagerConfig();
-      assert clc != null;
-      assert !clc.isFetchPersistentState();
-      assert !clc.isPassivation();
-      assert !clc.isShared();
-      assert !clc.isPreload();
-
-      CacheStoreConfig iclc = (CacheStoreConfig) clc.getFirstCacheLoaderConfig();
-      assert iclc.getCacheLoaderClassName().equals("org.infinispan.loaders.file.FileCacheStore");
-      assert !iclc.getAsyncStoreConfig().isEnabled();
-      assert !iclc.isFetchPersistentState();
-      assert !iclc.isIgnoreModifications();
-      assert !iclc.isPurgeOnStartup();
-
-      SingletonStoreConfig ssc = iclc.getSingletonStoreConfig();
-      assert !ssc.isSingletonStoreEnabled();
-   }
-
-   public void testDefaultEvictionAndExpiration() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<eviction />";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      Configuration c = new Configuration();
-
-      parser.configureEviction(e, c);
-      parser.configureExpiration(null, c);
-
-      assert c.getEvictionMaxEntries() == -1;
-      assert c.getEvictionStrategy() == EvictionStrategy.NONE;
-      assert c.getEvictionWakeUpInterval() == 5000;
-      assert c.getExpirationLifespan() == -1;
-      assert c.getExpirationMaxIdle() == -1;
-   }
-
-   public void testEvictionAndExpiration() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String evictionXml = "<eviction strategy=\"LRU\" " +
-            "wakeUpInterval=\"750\" maxEntries=\"7000\" />";
-      String expirationXml = "<expiration lifespan=\"2000\" maxIdle=\"500\"/>";
-
-      Element evictionElement = XmlConfigHelper.stringToElement(evictionXml);
-      Element expirationElement = XmlConfigHelper.stringToElement(expirationXml);
-
-      Configuration c = new Configuration();
-
-      parser.configureEviction(evictionElement, c);
-      parser.configureExpiration(expirationElement, c);
-
-      assert c.getEvictionStrategy() == EvictionStrategy.LRU;
-      assert c.getEvictionMaxEntries() == 7000;
-      assert c.getEvictionWakeUpInterval() == 750;
-      assert c.getExpirationLifespan() == 2000;
-      assert c.getExpirationMaxIdle() == 500;
-   }
-
-   public void testClusteringDist() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<clustering mode=\"d\">\n" +
-            "         <async />" +
-            "         <l1 enabled=\"false\"/>\n" +
-            "         <hash class=\"org.blah.Blah\" numOwners=\"900\" rehashWait=\"-1\" />" +
-            "      </clustering>";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      Configuration c = new Configuration();
-      parser.configureClustering(e, c);
-
-      assert c.getCacheMode() == Configuration.CacheMode.DIST_ASYNC;
-      assert !c.isFetchInMemoryState();
-      assert !c.isL1CacheEnabled();
-      assert c.getConsistentHashClass().equals("org.blah.Blah");
-      assert c.getNumOwners() == 900;
-      assert c.getRehashWaitTime() == -1;
-   }
-
-   public void testClusteringDistDefaults() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<clustering mode=\"d\" />";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      Configuration c = new Configuration();
-      parser.configureClustering(e, c);
-
-      assert c.getCacheMode() == Configuration.CacheMode.DIST_SYNC;
-      assert !c.isFetchInMemoryState();
-      assert c.isL1CacheEnabled();
-      assert c.getConsistentHashClass().equals(DefaultConsistentHash.class.getName());
-      assert c.getNumOwners() == 2;
-      assert c.getRehashWaitTime() == 60000;
-      assert c.getL1Lifespan() == 600000;
-      assert c.isL1OnRehash();
-   }
-
-   public void testInvalidClusteringCombinations() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<clustering mode=\"d\"><sync/><async/></clustering>";
-      try {
-         parser.configureClustering(XmlConfigHelper.stringToElement(xml), new Configuration());
-         assert false : "Should fail";
-      } catch (ConfigurationException ce) {
-         // expected
-      }
-
-      xml = "<clustering mode=\"d\"><stateRetrieval /></clustering>";
-      Configuration c = new Configuration();
-      parser.configureClustering(XmlConfigHelper.stringToElement(xml), c);
-      try {
-         c.assertValid();
-         assert false : "Should fail";
-      } catch (ConfigurationException expected) {
-      }
-
-      xml = "<clustering mode=\"d\"><stateRetrieval fetchInMemoryState=\"true\"/></clustering>";
-      c = new Configuration();
-      parser.configureClustering(XmlConfigHelper.stringToElement(xml), c);
-      try {
-         c.assertValid();
-         assert false : "Should fail";
-      } catch (ConfigurationException expected) {
-      }
-
-      xml = "<clustering mode=\"d\"><stateRetrieval fetchInMemoryState=\"false\"/></clustering>";
-      parser.configureClustering(XmlConfigHelper.stringToElement(xml), new Configuration());
-
-      xml = "<clustering mode=\"r\"><l1 /></clustering>";
-
-      try {
-         parser.configureClustering(XmlConfigHelper.stringToElement(xml), new Configuration());
-         assert false : "Should fail";
-      } catch (ConfigurationException ce) {
-         // expected
-      }
-
-      xml = "<clustering mode=\"i\"><l1 /></clustering>";
-
-      try {
-         parser.configureClustering(XmlConfigHelper.stringToElement(xml), new Configuration());
-         assert false : "Should fail";
-      } catch (ConfigurationException ce) {
-         // expected
-      }
-
-      xml = "<clustering mode=\"r\"><hash /></clustering>";
-
-      try {
-         parser.configureClustering(XmlConfigHelper.stringToElement(xml), new Configuration());
-         assert false : "Should fail";
-      } catch (ConfigurationException ce) {
-         // expected
-      }
-
-      xml = "<clustering mode=\"i\"><hash /></clustering>";
-
-      try {
-         parser.configureClustering(XmlConfigHelper.stringToElement(xml), new Configuration());
-         assert false : "Should fail";
-      } catch (ConfigurationException ce) {
-         // expected
-      }
-   }
-}

Deleted: trunk/core/src/test/java/org/infinispan/config/parsing/GlobalConfigurationParserTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/config/parsing/GlobalConfigurationParserTest.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/core/src/test/java/org/infinispan/config/parsing/GlobalConfigurationParserTest.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -1,209 +0,0 @@
-package org.infinispan.config.parsing;
-
-import org.infinispan.config.GlobalConfiguration;
-import org.infinispan.executors.DefaultExecutorFactory;
-import org.infinispan.executors.DefaultScheduledExecutorFactory;
-import org.infinispan.marshall.VersionAwareMarshaller;
-import org.infinispan.marshall.jboss.JBossMarshaller;
-import org.infinispan.remoting.transport.jgroups.JGroupsTransport;
-import org.testng.annotations.Test;
-import org.w3c.dom.Element;
-
-
- at Test(groups = "unit", testName = "config.parsing.GlobalConfigurationParserTest")
-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=\"value\"/></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 testGlobalJmxStatistics() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<globalJmxStatistics enabled=\"true\" jmxDomain=\"horizons\" mBeanServerLookup=\"org.infinispan.jmx.PerThreadMBeanServerLookup\" allowDuplicateDomains=\"true\"/>";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      GlobalConfiguration c = new GlobalConfiguration();
-      parser.configureGlobalJmxStatistics(e, c);
-
-      assert c.isExposeGlobalJmxStatistics();
-      assert c.getJmxDomain().equals("horizons");
-      assert c.getMBeanServerLookup().equals("org.infinispan.jmx.PerThreadMBeanServerLookup");
-      assert c.isAllowDuplicateDomains();
-   }
-
-   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.infinispan.marshall.jboss.JBossMarshaller\" version=\"9.2\" />";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      GlobalConfiguration gc = new GlobalConfiguration();
-      parser.configureSerialization(e, gc);
-
-      assert gc.getMarshallerClass().equals(JBossMarshaller.class.getName());
-      assert gc.getMarshallVersionString().equals("9.2");
-   }
-
-   public void testMarshallingDefaults() throws Exception {
-      XmlConfigurationParserImpl parser = new XmlConfigurationParserImpl();
-      String xml = "<serialization />";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      GlobalConfiguration gc = new GlobalConfiguration();
-      parser.configureSerialization(e, gc);
-
-      assert gc.getMarshallerClass().equals(VersionAwareMarshaller.class.getName());
-      assert gc.getMarshallVersionString().equals("4.0");
-   }
-
-   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 = "<asyncTransportExecutor factory=\"com.mycompany.Factory\">\n" +
-            "         <property name=\"maxThreads\" value=\"5\" />" +
-            "      </asyncTransportExecutor>";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      GlobalConfiguration gc = new GlobalConfiguration();
-      parser.configureAsyncTransportExecutor(e, gc);
-
-      assert gc.getAsyncTransportExecutorFactoryClass().equals("com.mycompany.Factory");
-      assert gc.getAsyncTransportExecutorProperties().size() == 1;
-      assert gc.getAsyncTransportExecutorProperties().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 = "<asyncTransportExecutor />";
-      Element e = XmlConfigHelper.stringToElement(xml);
-
-      GlobalConfiguration gc = new GlobalConfiguration();
-      parser.configureAsyncTransportExecutor(e, gc);
-
-      assert gc.getAsyncTransportExecutorFactoryClass().equals(DefaultExecutorFactory.class.getName());
-      assert gc.getAsyncTransportExecutorProperties().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: trunk/core/src/test/java/org/infinispan/config/parsing/Jbc2InfinispanTransformerTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/config/parsing/Jbc2InfinispanTransformerTest.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/core/src/test/java/org/infinispan/config/parsing/Jbc2InfinispanTransformerTest.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -3,6 +3,7 @@
 import org.infinispan.config.CacheLoaderManagerConfig;
 import org.infinispan.config.Configuration;
 import org.infinispan.config.GlobalConfiguration;
+import org.infinispan.config.InfinispanConfiguration;
 import org.infinispan.eviction.EvictionStrategy;
 import org.infinispan.loaders.CacheStoreConfig;
 import org.infinispan.loaders.decorators.AsyncStoreConfig;
@@ -40,8 +41,7 @@
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          convertor.parse(fileName, baos, XSLT_FILE);
 
-         XmlConfigurationParser newParser = new XmlConfigurationParserImpl();
-         newParser.initialize(new ByteArrayInputStream(baos.toByteArray()));
+         XmlConfigurationParser newParser = InfinispanConfiguration.newInfinispanConfiguration(new ByteArrayInputStream(baos.toByteArray()));
          GlobalConfiguration globalConfig = newParser.parseGlobalConfiguration();
          Map<String, Configuration> map = newParser.parseNamedConfigurations();
          Configuration defaultConfig = globalConfig.getDefaultConfiguration();

Deleted: trunk/tools/src/main/java/org/infinispan/tools/schema/SchemaGenerator.java
===================================================================
--- trunk/tools/src/main/java/org/infinispan/tools/schema/SchemaGenerator.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/tools/src/main/java/org/infinispan/tools/schema/SchemaGenerator.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -1,118 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.infinispan.tools.schema;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.util.List;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.infinispan.Version;
-import org.infinispan.config.AbstractConfigurationBean;
-import org.infinispan.config.parsing.TreeNode;
-import org.infinispan.util.ClassFinder;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-
-/**
- * Generates XML Schema for Infinispan configuration
- *
- * @author Vladimir Blagojevic
- * @since 4.0
- */
-public class SchemaGenerator {
-   private final List<Class<?>> beans;
-   private final File fileToWrite;
-   
-   protected SchemaGenerator(File fileToWrite, String searchPath) throws Exception {
-      this.fileToWrite = fileToWrite;
-      List<Class<?>> infinispanClasses = null;
-      String pathUsed = ClassFinder.PATH;
-      if (searchPath == null || searchPath.length() == 0) {
-         infinispanClasses = ClassFinder.infinispanClasses();
-      } else {
-         pathUsed = searchPath;
-         infinispanClasses = ClassFinder.infinispanClasses(searchPath);
-      }
-      if (infinispanClasses == null || infinispanClasses.isEmpty())
-         throw new IllegalArgumentException("Could not find infinispan classes on your classpath "
-                  + pathUsed);
-
-      beans = ClassFinder.isAssignableFrom(infinispanClasses, AbstractConfigurationBean.class);
-      if (beans.isEmpty())
-         throw new IllegalStateException("Could not find AbstractConfigurationBean(s) on your classpath " 
-                  + pathUsed);
-   }
-   
-   public static void main(String[] args) throws Exception {
-      String outputDir = "./";
-
-      for (int i = 0; i < args.length; i++) {
-         String arg = args[i];
-         if ("-o".equals(arg)) {
-            outputDir = args[++i];
-            continue;
-         } else {
-            System.out.println("SchemaGenerator -o <path to newly created xsd schema file>");
-            return;
-         }
-      }
-
-      File f = new File(outputDir, "infinispan-config-" +Version.getMajorVersion() + ".xsd");
-      SchemaGenerator sg = new SchemaGenerator(f,null);
-      sg.generateSchema();
-   }
-
-   private void generateSchema() throws Exception{      
-      FileWriter fw = new FileWriter(fileToWrite, false);
-      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-      DocumentBuilder builder = factory.newDocumentBuilder();
-      DOMImplementation impl = builder.getDOMImplementation();
-      Document xmldoc = impl.createDocument("http://www.w3.org/2001/XMLSchema", "xs:schema",null);
-      xmldoc.getDocumentElement().setAttribute("targetNamespace", "urn:infinispan:config:" + Version.getMajorVersion());
-      xmldoc.getDocumentElement().setAttribute("xmlns:tns","urn:infinispan:config:" + Version.getMajorVersion());
-      xmldoc.getDocumentElement().setAttribute("elementFormDefault", "qualified");                 
-
-      ConfigurationTreeWalker tw = new SchemaGeneratorTreeWalker(xmldoc,beans);
-      TreeNode root = tw.constructTreeFromBeans(beans);         
-      tw.preOrderTraverse(root);
-      tw.postTraverseCleanup();
-            
-      DOMSource domSource = new DOMSource(xmldoc);
-      StreamResult streamResult = new StreamResult(fw);
-      TransformerFactory tf = TransformerFactory.newInstance();
-      Transformer serializer = tf.newTransformer();
-      serializer.setOutputProperty(OutputKeys.METHOD, "xml");
-      serializer.setOutputProperty(OutputKeys.INDENT, "yes");
-      serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
-      serializer.transform(domSource, streamResult);                 
-      fw.flush();
-      fw.close();      
-   }
-}

Deleted: trunk/tools/src/main/java/org/infinispan/tools/schema/SchemaGeneratorTreeWalker.java
===================================================================
--- trunk/tools/src/main/java/org/infinispan/tools/schema/SchemaGeneratorTreeWalker.java	2009-08-11 14:33:03 UTC (rev 651)
+++ trunk/tools/src/main/java/org/infinispan/tools/schema/SchemaGeneratorTreeWalker.java	2009-08-12 06:51:26 UTC (rev 652)
@@ -1,280 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.infinispan.tools.schema;
-
-import java.lang.reflect.Method;
-import java.util.List;
-import org.infinispan.config.ConfigurationAttribute;
-import org.infinispan.config.ConfigurationElement;
-import org.infinispan.config.ConfigurationException;
-import org.infinispan.config.ConfigurationProperty;
-import org.infinispan.config.ConfigurationElement.Cardinality;
-import org.infinispan.config.parsing.ConfigurationElementWriter;
-import org.infinispan.config.parsing.TreeNode;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * TreeWalker that generates each node of the XML schema
- *
- * @author Vladimir Blagojevic
- * @see SchemaGenerator
- * @since 4.0
- */
-public class SchemaGeneratorTreeWalker extends ConfigurationTreeWalker{
-   
-   Document xmldoc;
-   private List<Class<?>> beans;
-
-   public SchemaGeneratorTreeWalker(Document xmldoc, List<Class<?>> beans) {
-      super();
-      this.xmldoc = xmldoc;
-      this.beans = beans;
-   }
-   
-   public void visitNode(TreeNode treeNode) {
-      Class<?> bean = findBean(beans, treeNode.getName(), treeNode.getParent().getName());
-      if (bean == null) {
-         log.warn("Did not find bean for node " + treeNode+ ". Should happen only for infinispan node");
-         writeInfinispanType();
-         return;
-      }
-           
-      ConfigurationElement ce = findConfigurationElementForBean(bean, treeNode.getName(), treeNode.getParent().getName());
-      if(ce == null){
-         log.warn("Did not find ConfigurationElement for " + treeNode+ ". Verify annotations on all AbstractConfigurationBeans");
-         return;
-      }
-      
-      ConfigurationElementWriter writer = null;
-      boolean hasCustomWriter = !ce.customWriter().equals(ConfigurationElementWriter.class);
-      if(hasCustomWriter){
-         try {
-         writer = ce.customWriter().newInstance();
-         } catch (Exception e1) {
-            throw new ConfigurationException("Could not instantiate custom writer ", e1);
-         }      
-      }
-      log.debug("Visiting " + treeNode.getName() + ((hasCustomWriter)?" will use " + writer:""));     
-      if (hasCustomWriter) {         
-         try {
-            writer.process(treeNode, xmldoc);
-         } catch (Exception e1) {
-            throw new ConfigurationException("Exception while using custom writer ", e1);
-         }
-      } else {      
-         Element complexType = xmldoc.createElement("xs:complexType");
-         complexType.setAttribute("name", treeNode.getName() + "TypeIn" + treeNode.getParent().getName());
-         createProperty(treeNode, complexType);
-         if(treeNode.hasChildren()) {
-            boolean sequence = false;
-            for(TreeNode child:treeNode.getChildren()){
-               ConfigurationElement cce = findConfigurationElement(beans,child.getName(),treeNode.getName());
-               if(cce.cardinalityInParent().equals(Cardinality.UNBOUNDED)){
-                  sequence = true;
-                  break;
-               }
-            }
-            Element allOrSequence = null;
-            if(sequence){
-               allOrSequence = xmldoc.createElement("xs:sequence");
-            } else {
-               allOrSequence = xmldoc.createElement("xs:all");
-            }
-            complexType.appendChild(allOrSequence);
-            
-            for (TreeNode child : treeNode.getChildren()) {
-               ConfigurationElement cce = findConfigurationElement(beans,child.getName(),treeNode.getName());
-               Element childElement = xmldoc.createElement("xs:element");
-               childElement.setAttribute("name", child.getName());
-               childElement.setAttribute("type", "tns:" + child.getName() + "TypeIn" + child.getParent().getName());
-               childElement.setAttribute("minOccurs", "0");
-               if(cce.cardinalityInParent().equals(Cardinality.UNBOUNDED)){
-                  childElement.setAttribute("maxOccurs", "unbounded");     
-               } else {
-                  childElement.setAttribute("maxOccurs", "1");            
-               }      
-               //add documentation for this child
-               if (cce.description().length() > 0) {
-                  addDocumentation(cce.description(), childElement);
-               }
-               allOrSequence.appendChild(childElement);
-            }
-            createAttribute(treeNode, complexType);            
-         } else { 
-            createAttribute(treeNode, complexType);         
-         }         
-         postProcess(treeNode,complexType);
-         xmldoc.getDocumentElement().appendChild(complexType);
-      }
-   }
-   
-   protected void postProcess(TreeNode treeNode, Element complexType) {
-      
-      //dealing with default/namedCache intricacies
-      if(treeNode.getName().equals("default")){
-         Element element = xmldoc.createElement("xs:attribute");
-         element.setAttribute("name", "name");
-         element.setAttribute("type", "xs:string");
-         complexType.appendChild(element);
-      }
-   }
-
-   @Override
-   public void postTraverseCleanup() {
-      //include special property type not visited by TreeWalker
-      Element property = xmldoc.createElement("xs:complexType");       
-      property.setAttribute("name", "propertyType");
-      Element att = xmldoc.createElement("xs:attribute");       
-      att.setAttribute("name", "name");
-      att.setAttribute("type", "xs:string");
-      property.appendChild(att);
-      att = xmldoc.createElement("xs:attribute");       
-      att.setAttribute("name", "value");
-      att.setAttribute("type", "xs:string");
-      property.appendChild(att);
-      
-      xmldoc.getDocumentElement().appendChild(property);            
-   }
-
-   private void createAttribute(TreeNode treeNode, Element complexType) {
-      Class <?> bean = findBean(beans, treeNode.getName(), treeNode.getParent().getName());
-      if(bean == null){
-         log.warn("Did not find bean for node " + treeNode + ". Verify annotations on all AbstractConfigurationBeans");
-         return;
-      }   
-      
-      for (Method m : bean.getMethods()) {                  
-         ConfigurationAttribute a = m.getAnnotation(ConfigurationAttribute.class);
-         boolean childElement = a != null && a.containingElement().equals(treeNode.getName());           
-         if (childElement) {
-            String type = "";
-            if (isSetterMethod(m)) {
-               type = m.getParameterTypes()[0].getSimpleName();
-               type = type.toLowerCase();
-            }                            
-            Element att = xmldoc.createElement("xs:attribute");
-            att.setAttribute("name", a.name());
-            boolean hasRestriction = a.allowedValues().length >0;
-            if(!hasRestriction){
-               att.setAttribute("type", "xs:" + type);
-            }
-            else {
-               Element simpleType = xmldoc.createElement("xs:simpleType");
-               att.appendChild(simpleType);
-               Element restriction = xmldoc.createElement("xs:restriction");
-               restriction.setAttribute("base", "xs:" + type);
-               simpleType.appendChild(restriction);
-               String [] values = a.allowedValues();
-               for (String constraint : values) {
-                  Element restrictionValue = xmldoc.createElement("xs:enumeration");                     
-                  restrictionValue.setAttribute("value", constraint.trim());
-                  restriction.appendChild(restrictionValue);                     
-               }                  
-            }
-            //add documentation
-            if (a.description().length() > 0) {
-               addDocumentation(a.description(), att);
-            }
-            complexType.appendChild(att);
-         }         
-      }
-   }
-
-   private void addDocumentation(String doco, Element e) {
-      Element annotationElement = xmldoc.createElement("xs:annotation");
-      e.appendChild(annotationElement);
-      Element documentationElement = xmldoc.createElement("xs:documentation");
-      documentationElement.setTextContent(doco);
-      annotationElement.appendChild(documentationElement);
-   }
-   
-   private void createProperty(TreeNode treeNode, Element complexType) {
-      if (treeNode.getParent().getParent() == null)
-         return;
-      
-      Class<?> bean = findBean(beans, treeNode.getName(), treeNode.getParent().getName());
-      if (bean == null) {
-         log.warn("Did not find bean for node " + treeNode+ ". Try parent, maybe property is there...");
-         bean = findBean(beans, treeNode.getParent().getName(), treeNode.getParent().getParent().getName());
-         if(bean == null)
-            return;
-      }    
-      
-      String createdForParentElement = null;
-      for (Method m : bean.getMethods()) {         
-         for (ConfigurationProperty c : propertiesElementsOnMethod(m)) {
-            boolean property = treeNode.getName().equals(c.parentElement());
-            if (property && !c.parentElement().equals(createdForParentElement)) {
-               createdForParentElement = c.parentElement();
-               Element prop = xmldoc.createElement("xs:sequence");
-               Element e = xmldoc.createElement("xs:element");
-               prop.appendChild(e);
-               e.setAttribute("name", "property");
-               e.setAttribute("maxOccurs", "unbounded");
-               e.setAttribute("minOccurs", "0");
-               e.setAttribute("type", "tns:propertyType");
-               complexType.appendChild(prop);
-            }
-         }         
-      }
-   }  
-   
-   private boolean isSetterMethod(Method m) {
-      return m.getName().startsWith("set") && m.getParameterTypes().length == 1;
-   }
-   
-   private void writeInfinispanType() {
-      Element xsElement = xmldoc.createElement("xs:element");
-      xsElement.setAttribute("name", "infinispan");
-      xsElement.setAttribute("type", "tns:infinispanTypeIn");
-      xmldoc.getDocumentElement().appendChild(xsElement);
-
-      Element complexType = xmldoc.createElement("xs:complexType");
-      complexType.setAttribute("name", "infinispanTypeIn");
-      Element seq = xmldoc.createElement("xs:sequence");
-      complexType.appendChild(seq);
-
-      Element e = xmldoc.createElement("xs:element");
-      e.setAttribute("name", "global");
-      e.setAttribute("type", "tns:globalTypeIninfinispan");
-      e.setAttribute("minOccurs", "0");
-      e.setAttribute("maxOccurs", "1");
-      seq.appendChild(e);
-
-      e = xmldoc.createElement("xs:element");
-      e.setAttribute("name", "default");
-      e.setAttribute("type", "tns:defaultTypeIninfinispan");
-      e.setAttribute("minOccurs", "0");
-      e.setAttribute("maxOccurs", "1");
-      seq.appendChild(e);
-
-      e = xmldoc.createElement("xs:element");
-      e.setAttribute("name", "namedCache");
-      e.setAttribute("type", "tns:defaultTypeIninfinispan");
-      e.setAttribute("minOccurs", "0");
-      e.setAttribute("maxOccurs", "unbounded");
-      seq.appendChild(e);
-
-      xmldoc.getDocumentElement().appendChild(complexType);
-   }
-}
\ No newline at end of file



More information about the infinispan-commits mailing list