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

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Feb 24 08:34:09 EST 2009


Author: manik.surtani at jboss.com
Date: 2009-02-24 08:34:08 -0500 (Tue, 24 Feb 2009)
New Revision: 7769

Added:
   core/trunk/src/main/java/org/jboss/cache/config/parsing/element/JGroupsStackParser.java
   core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd
   core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd
   core/trunk/src/test/java/org/jboss/cache/config/parsing/ParseFileWith30SchemaTest.java
   core/trunk/src/test/resources/configs/incorrect-3_0-config-file.xml
   core/trunk/src/test/resources/configs/simple-3_0-config-file.xml
Removed:
   core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java
Modified:
   core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/element/CustomInterceptorsElementParser.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
   core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java
   core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
   core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElementParserTest.java
   core/trunk/src/test/java/org/jboss/cache/config/parsing/JGroupsStackParserTest.java
   core/trunk/src/test/java/org/jboss/cache/profiling/AbstractProfileTest.java
Log:
Configuration compatibility with JBC 3.0

Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/Configuration.java	2009-02-24 12:56:11 UTC (rev 7768)
+++ core/trunk/src/main/java/org/jboss/cache/config/Configuration.java	2009-02-24 13:34:08 UTC (rev 7769)
@@ -23,7 +23,7 @@
 
 import org.jboss.cache.Version;
 import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.config.parsing.JGroupsStackParser;
+import org.jboss.cache.config.parsing.element.JGroupsStackParser;
 import org.jboss.cache.factories.annotations.NonVolatile;
 import org.jboss.cache.factories.annotations.Start;
 import org.jboss.cache.lock.IsolationLevel;

Deleted: core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java	2009-02-24 12:56:11 UTC (rev 7768)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java	2009-02-24 13:34:08 UTC (rev 7769)
@@ -1,107 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.config.parsing;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.NodeList;
-
-/**
- * The purpose of this class is to parse the jgroups configuration from the config file into an compact string
- * that can be passed as a config to the channel.
- *
- * @author Mircea.Markus at jboss.com
- * @since 3.0
- */
-public class JGroupsStackParser
-{
-   /**
-    * Parses the cluster config which is used to start a JGroups channel
-    *
-    * @param config an old-style JGroups protocol config String
-    */
-   public String parseClusterConfigXml(Element config)
-   {
-      StringBuilder buffer = new StringBuilder();
-      NodeList stack = config.getChildNodes();
-      int length = stack.getLength();
-
-      for (int s = 0; s < length; s++)
-      {
-         org.w3c.dom.Node node = stack.item(s);
-         if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
-         {
-            continue;
-         }
-
-         // Ignore Namespace until JGroups defines one
-         Element tag = (Element) node;
-         String protocol = tag.getLocalName();
-         if (protocol == null)
-         {
-            protocol = tag.getNodeName(); // try a non-namespace aware version
-         }
-         buffer.append(protocol);
-         processAttributes(buffer, tag);
-         buffer.append(':');
-      }
-      if (buffer.length() > 0)
-      {
-         //Remove the trailing ':'
-         buffer.setLength(buffer.length() - 1);
-      }
-      return buffer.toString();
-   }
-
-   private void processAttributes(StringBuilder buffer, Element tag)
-   {
-      NamedNodeMap attrs = tag.getAttributes();
-      int attrLength = attrs.getLength();
-      if (attrLength > 0)
-      {
-         buffer.append('(');
-      }
-      for (int a = 0; a < attrLength; a++)
-      {
-         Attr attr = (Attr) attrs.item(a);
-         processSingleAttribute(buffer, attr);
-         if (a < attrLength - 1)
-         {
-            buffer.append(';');
-         }
-      }
-      if (attrLength > 0)
-      {
-         buffer.append(')');
-      }
-   }
-
-   private void processSingleAttribute(StringBuilder buffer, Attr attr)
-   {
-      String name = attr.getName();
-      String value = attr.getValue();
-      buffer.append(name);
-      buffer.append('=');
-      buffer.append(value);
-   }
-}

Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java	2009-02-24 12:56:11 UTC (rev 7768)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java	2009-02-24 13:34:08 UTC (rev 7769)
@@ -36,7 +36,7 @@
 import java.io.InputStream;
 
 /**
- * Parses an xml files and validates xml elements form {@link RootElementBuilder#JBOSSCACHE_CORE_NS} namespace
+ * Parses an xml files and validates xml elements form {@link RootElementBuilder#JBOSSCACHE_CORE_NS_31} namespace
  * according to the configured schema.
  *
  * @author Mircea.Markus at jboss.com
@@ -47,14 +47,18 @@
 
    private static final JBossEntityResolver resolver = new JBossEntityResolver();
 
-   public static final String JBOSSCACHE_CORE_NS = "urn:jboss:jbosscache-core:config:3.1";
-   public static final String JBOSSCACHE_REPO_NS = "urn:jboss:jbosscache-core:cache-repo:3.1";
+   public static final String JBOSSCACHE_CORE_NS_31 = "urn:jboss:jbosscache-core:config:3.1";
+   public static final String JBOSSCACHE_REPO_NS_31 = "urn:jboss:jbosscache-core:cache-repo:3.1";
+   public static final String JBOSSCACHE_CORE_NS_30 = "urn:jboss:jbosscache-core:config:3.0";
+   public static final String JBOSSCACHE_REPO_NS_30 = "urn:jboss:jbosscache-core:cache-repo:3.0";
 
    static
    {
       // Globally register this namespace
-      JBossEntityResolver.registerEntity(JBOSSCACHE_CORE_NS, "jbosscache-config-3.1.xsd");
-      JBossEntityResolver.registerEntity(JBOSSCACHE_REPO_NS, "jbosscache-registry-3.1.xsd");
+      JBossEntityResolver.registerEntity(JBOSSCACHE_CORE_NS_31, "jbosscache-config-3.1.xsd");
+      JBossEntityResolver.registerEntity(JBOSSCACHE_REPO_NS_31, "jbosscache-registry-3.1.xsd");
+      JBossEntityResolver.registerEntity(JBOSSCACHE_CORE_NS_30, "jbosscache-config-3.0.xsd");
+      JBossEntityResolver.registerEntity(JBOSSCACHE_REPO_NS_30, "jbosscache-registry-3.0.xsd");
    }
 
    private static final Log log = LogFactory.getLog(RootElementBuilder.class);
@@ -83,7 +87,7 @@
    {
       this(new FailureErrorHandler(), validating);
    }
-
+ 
    public Element readRoot(InputStream config)
    {
       try
@@ -94,8 +98,8 @@
          {
             docBuilderFactory.setValidating(true);
             docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
-            String[] value = {JBOSSCACHE_CORE_NS, JBOSSCACHE_REPO_NS};
-            docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", value);
+            docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource",
+                  new String[]{JBOSSCACHE_CORE_NS_30, JBOSSCACHE_CORE_NS_31, JBOSSCACHE_REPO_NS_30, JBOSSCACHE_REPO_NS_31});
          }
          DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
          parser.setEntityResolver(resolver);
@@ -107,8 +111,7 @@
       }
       catch (Exception e)
       {
-         log.error(e);
-         throw new ConfigurationException("Could not parse the config file");
+         throw new ConfigurationException("Could not parse the config file", e);
       }
    }
 

Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java	2009-02-24 12:56:11 UTC (rev 7768)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java	2009-02-24 13:34:08 UTC (rev 7769)
@@ -391,7 +391,7 @@
     */
    public static Element stringToElementInCoreNS(String xml) throws Exception
    {
-      xml = "<wrapper xmlns='" + RootElementBuilder.JBOSSCACHE_CORE_NS + "'>" + xml + "</wrapper>";
+      xml = "<wrapper xmlns='" + RootElementBuilder.JBOSSCACHE_CORE_NS_31 + "'>" + xml + "</wrapper>";
       ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("utf8"));
       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
       factory.setNamespaceAware(true);

Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java	2009-02-24 12:56:11 UTC (rev 7768)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java	2009-02-24 13:34:08 UTC (rev 7769)
@@ -31,6 +31,7 @@
 import org.jboss.cache.config.parsing.element.CustomInterceptorsElementParser;
 import org.jboss.cache.config.parsing.element.EvictionElementParser;
 import org.jboss.cache.config.parsing.element.LoadersElementParser;
+import org.jboss.cache.config.parsing.element.JGroupsStackParser;
 import org.jboss.cache.lock.IsolationLevel;
 import org.jboss.cache.util.FileLookup;
 import org.w3c.dom.Element;
@@ -142,10 +143,17 @@
 
    private Configuration processElements(boolean ignoreRoot)
    {
+      coreNamespace = root.getNamespaceURI();
+      if (coreNamespace == null) coreNamespace = RootElementBuilder.JBOSSCACHE_CORE_NS_31; // use the default
+      
       if (!ignoreRoot &&
-            (!"jbosscache".equals(root.getLocalName()) || !RootElementBuilder.JBOSSCACHE_CORE_NS.equals(root.getNamespaceURI())))
+            (!"jbosscache".equals(root.getLocalName()) ||
+             (!RootElementBuilder.JBOSSCACHE_CORE_NS_31.equals(coreNamespace) &&
+             !RootElementBuilder.JBOSSCACHE_CORE_NS_30.equals(coreNamespace))
+         ))
       {
-            throw new ConfigurationException("Expected root element {" + RootElementBuilder.JBOSSCACHE_CORE_NS + "}" + "jbosscache");
+            throw new ConfigurationException("Expected root element <jbosscache />" + (isValidating() ? " in either {" +
+                  RootElementBuilder.JBOSSCACHE_CORE_NS_30 + "} or {" + RootElementBuilder.JBOSSCACHE_CORE_NS_31 + "} namespaces" : ""));
       }
 
       try
@@ -249,7 +257,7 @@
    private void configureCustomInterceptors(Element element)
    {
       if (element == null) return; //this element might be missing
-      CustomInterceptorsElementParser parser = new CustomInterceptorsElementParser();
+      CustomInterceptorsElementParser parser = new CustomInterceptorsElementParser(coreNamespace);
       List<CustomInterceptorConfig> interceptorConfigList = parser.parseCustomInterceptors(element);
       config.setCustomInterceptors(interceptorConfigList);
    }
@@ -274,7 +282,7 @@
    private void configureBuddyReplication(Element element)
    {
       if (element == null) return;//buddy config might not exist, expect that
-      BuddyElementParser buddyElementParser = new BuddyElementParser();
+      BuddyElementParser buddyElementParser = new BuddyElementParser(coreNamespace);
       BuddyReplicationConfig brConfig = buddyElementParser.parseBuddyElement(element);
       config.setBuddyReplicationConfig(brConfig);
    }
@@ -282,7 +290,7 @@
    private void configureCacheLoaders(Element element)
    {
       if (element == null) return; //null cache loaders are allowed
-      LoadersElementParser clElementParser = new LoadersElementParser();
+      LoadersElementParser clElementParser = new LoadersElementParser(coreNamespace);
       CacheLoaderConfig cacheLoaderConfig = clElementParser.parseLoadersElement(element);
       config.setCacheLoaderConfig(cacheLoaderConfig);
    }
@@ -290,7 +298,7 @@
    private void configureEviction(Element element)
    {
       if (element == null) return; //no eviction might be configured
-      EvictionElementParser evictionElementParser = new EvictionElementParser();
+      EvictionElementParser evictionElementParser = new EvictionElementParser(coreNamespace);
       config.setEvictionConfig(evictionElementParser.parseEvictionElement(element));
    }
 

Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java	2009-02-24 12:56:11 UTC (rev 7768)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java	2009-02-24 13:34:08 UTC (rev 7769)
@@ -34,6 +34,7 @@
  */
 public abstract class XmlParserBase
 {
+   protected String coreNamespace;
    /**
     * @see Integer#parseInt(String)
     */
@@ -84,7 +85,7 @@
     */
    protected Element getSingleElementInCoreNS(String elementName, Element parent)
    {
-      return getSingleElement(RootElementBuilder.JBOSSCACHE_CORE_NS, elementName, parent);
+      return getSingleElement(coreNamespace, elementName, parent);
    }
 
    /**

Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java	2009-02-24 12:56:11 UTC (rev 7768)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java	2009-02-24 13:34:08 UTC (rev 7769)
@@ -25,6 +25,7 @@
 import org.jboss.cache.config.BuddyReplicationConfig;
 import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jboss.cache.config.parsing.XmlParserBase;
+import org.jboss.cache.config.parsing.RootElementBuilder;
 import org.w3c.dom.Element;
 
 import java.util.Properties;
@@ -41,6 +42,16 @@
  */
 public class BuddyElementParser extends XmlParserBase
 {
+   public BuddyElementParser()
+   {
+      this(RootElementBuilder.JBOSSCACHE_CORE_NS_31);
+   }
+
+   public BuddyElementParser(String coreNamespace)
+   {
+      this.coreNamespace = coreNamespace;
+   }
+
    public BuddyReplicationConfig parseBuddyElement(Element element)
    {
       assertNotLegacyElement(element);

Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/CustomInterceptorsElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/CustomInterceptorsElementParser.java	2009-02-24 12:56:11 UTC (rev 7768)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/CustomInterceptorsElementParser.java	2009-02-24 13:34:08 UTC (rev 7769)
@@ -25,6 +25,7 @@
 import org.jboss.cache.config.CustomInterceptorConfig;
 import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jboss.cache.config.parsing.XmlParserBase;
+import org.jboss.cache.config.parsing.RootElementBuilder;
 import org.jboss.cache.interceptors.base.CommandInterceptor;
 import org.jboss.cache.util.Util;
 import org.w3c.dom.Element;
@@ -46,6 +47,16 @@
  */
 public class CustomInterceptorsElementParser extends XmlParserBase
 {
+   public CustomInterceptorsElementParser()
+   {
+      this(RootElementBuilder.JBOSSCACHE_CORE_NS_31);
+   }
+
+   public CustomInterceptorsElementParser(String coreNamespace)
+   {
+      this.coreNamespace = coreNamespace;
+   }
+
    /**
     * Iterates within the given element looking for custom interceptors.
     *

Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java	2009-02-24 12:56:11 UTC (rev 7768)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java	2009-02-24 13:34:08 UTC (rev 7769)
@@ -28,6 +28,7 @@
 import org.jboss.cache.config.MissingPolicyException;
 import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jboss.cache.config.parsing.XmlParserBase;
+import org.jboss.cache.config.parsing.RootElementBuilder;
 import org.jboss.cache.eviction.EvictionAlgorithm;
 import org.jboss.cache.util.Util;
 import org.w3c.dom.Element;
@@ -49,6 +50,16 @@
  */
 public class EvictionElementParser extends XmlParserBase
 {
+   public EvictionElementParser()
+   {
+      this(RootElementBuilder.JBOSSCACHE_CORE_NS_31);
+   }
+
+   public EvictionElementParser(String coreNamespace)
+   {
+      this.coreNamespace = coreNamespace;
+   }
+
    public EvictionConfig parseEvictionElement(Element evictionElement)
    {
       assertNotLegacyElement(evictionElement);

Copied: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/JGroupsStackParser.java (from rev 7766, core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/JGroupsStackParser.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/JGroupsStackParser.java	2009-02-24 13:34:08 UTC (rev 7769)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.cache.config.parsing.element;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.NodeList;
+
+/**
+ * The purpose of this class is to parse the jgroups configuration from the config file into an compact string
+ * that can be passed as a config to the channel.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 3.0
+ */
+public class JGroupsStackParser
+{
+   /**
+    * Parses the cluster config which is used to start a JGroups channel
+    *
+    * @param config an old-style JGroups protocol config String
+    */
+   public String parseClusterConfigXml(Element config)
+   {
+      StringBuilder buffer = new StringBuilder();
+      NodeList stack = config.getChildNodes();
+      int length = stack.getLength();
+
+      for (int s = 0; s < length; s++)
+      {
+         org.w3c.dom.Node node = stack.item(s);
+         if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
+         {
+            continue;
+         }
+
+         // Ignore Namespace until JGroups defines one
+         Element tag = (Element) node;
+         String protocol = tag.getLocalName();
+         if (protocol == null)
+         {
+            protocol = tag.getNodeName(); // try a non-namespace aware version
+         }
+         buffer.append(protocol);
+         processAttributes(buffer, tag);
+         buffer.append(':');
+      }
+      if (buffer.length() > 0)
+      {
+         //Remove the trailing ':'
+         buffer.setLength(buffer.length() - 1);
+      }
+      return buffer.toString();
+   }
+
+   private void processAttributes(StringBuilder buffer, Element tag)
+   {
+      NamedNodeMap attrs = tag.getAttributes();
+      int attrLength = attrs.getLength();
+      if (attrLength > 0)
+      {
+         buffer.append('(');
+      }
+      for (int a = 0; a < attrLength; a++)
+      {
+         Attr attr = (Attr) attrs.item(a);
+         processSingleAttribute(buffer, attr);
+         if (a < attrLength - 1)
+         {
+            buffer.append(';');
+         }
+      }
+      if (attrLength > 0)
+      {
+         buffer.append(')');
+      }
+   }
+
+   private void processSingleAttribute(StringBuilder buffer, Attr attr)
+   {
+      String name = attr.getName();
+      String value = attr.getValue();
+      buffer.append(name);
+      buffer.append('=');
+      buffer.append(value);
+   }
+}


Property changes on: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/JGroupsStackParser.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java	2009-02-24 12:56:11 UTC (rev 7768)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java	2009-02-24 13:34:08 UTC (rev 7769)
@@ -25,6 +25,7 @@
 import org.jboss.cache.config.ConfigurationException;
 import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jboss.cache.config.parsing.XmlParserBase;
+import org.jboss.cache.config.parsing.RootElementBuilder;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 
@@ -42,6 +43,16 @@
  */
 public class LoadersElementParser extends XmlParserBase
 {
+   public LoadersElementParser()
+   {
+      this(RootElementBuilder.JBOSSCACHE_CORE_NS_31);
+   }
+
+   public LoadersElementParser(String coreNamespace)
+   {
+      this.coreNamespace = coreNamespace;
+   }
+
    public CacheLoaderConfig parseLoadersElement(Element element)
    {
       assertNotLegacyElement(element);

Modified: core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java	2009-02-24 12:56:11 UTC (rev 7768)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java	2009-02-24 13:34:08 UTC (rev 7769)
@@ -36,8 +36,9 @@
 import org.jboss.cache.config.EvictionConfig;
 import org.jboss.cache.config.LegacyConfigurationException;
 import org.jboss.cache.config.RuntimeConfig;
-import org.jboss.cache.config.parsing.JGroupsStackParser;
+import org.jboss.cache.config.parsing.element.JGroupsStackParser;
 import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
+import org.jboss.cache.config.parsing.RootElementBuilder;
 import org.jboss.cache.config.parsing.element.BuddyElementParser;
 import org.jboss.cache.config.parsing.element.EvictionElementParser;
 import org.jboss.cache.config.parsing.element.LoadersElementParser;

Added: core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd
===================================================================
--- core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd	                        (rev 0)
+++ core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd	2009-02-24 13:34:08 UTC (rev 7769)
@@ -0,0 +1,261 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
+           xmlns:tns="urn:jboss:jbosscache-core:config:3.0" targetNamespace="urn:jboss:jbosscache-core:config:3.0"
+           xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
+
+   <xs:element name="jbosscache" type="tns:cacheConfigurationType"/>
+
+   <xs:complexType name="cacheConfigurationType">
+      <xs:all>
+         <xs:element name="locking" type="tns:lockingType" minOccurs="0" maxOccurs="1"/>
+         <xs:element name="transaction" type="tns:transactionType" minOccurs="0" maxOccurs="1"/>
+         <xs:element name="startup" type="tns:startupType" minOccurs="0" maxOccurs="1"/>
+         <xs:element name="shutdown" type="tns:shutdownType" minOccurs="0" maxOccurs="1"/>
+         <xs:element name="serialization" type="tns:serializationType" minOccurs="0" maxOccurs="1"/>
+         <xs:element name="jmxStatistics" type="tns:jmxStatisticsType" minOccurs="0" maxOccurs="1"/>
+         <xs:element name="listeners" type="tns:listenersType" minOccurs="0" maxOccurs="1"/>
+         <xs:element name="invocationBatching" type="tns:invocationBatchingType" minOccurs="0" maxOccurs="1"/>
+         <xs:element name="eviction" type="tns:evictionType" minOccurs="0" maxOccurs="1"/>
+         <xs:element name="loaders" type="tns:loadersType" minOccurs="0" maxOccurs="1"/>
+         <xs:element name="customInterceptors" type="tns:customInterceptorsType" minOccurs="0" maxOccurs="1"/>
+         <xs:element name="clustering" type="tns:clusteringType" minOccurs="0" maxOccurs="1"/>
+      </xs:all>
+   </xs:complexType>
+
+   <xs:complexType name="clusteringType">
+      <xs:all>         
+         <xs:element name="sync" type="tns:syncType" minOccurs="0" maxOccurs="1"/>
+         <xs:element name="async" type="tns:asyncType" minOccurs="0" maxOccurs="1"/>
+         <xs:element name="stateRetrieval" type="tns:stateRetrievalType" minOccurs="0" maxOccurs="1"/>
+         <xs:element name="buddy" minOccurs="0" maxOccurs="1">
+            <xs:complexType>
+               <xs:all minOccurs="0">
+                  <xs:element name="dataGravitation" maxOccurs="1">
+                     <xs:complexType>
+                        <xs:attribute name="auto" type="tns:booleanType"/>
+                        <xs:attribute name="removeOnFind" type="tns:booleanType"/>
+                        <xs:attribute name="searchBackupTrees" type="tns:booleanType"/>
+                     </xs:complexType>
+                  </xs:element>
+                  <xs:element name="locator" maxOccurs="1">
+                     <xs:complexType>
+                        <xs:all>
+                           <xs:element name="properties" type="xs:string" maxOccurs="1"/>
+                        </xs:all>
+                        <xs:attribute name="class" type="xs:string"/>
+                     </xs:complexType>
+                  </xs:element>
+               </xs:all>
+               <xs:attribute name="enabled" type="tns:booleanType"/>
+               <xs:attribute name="poolName" type="xs:string"/>
+               <xs:attribute name="communicationTimeout" type="xs:integer"/>
+            </xs:complexType>
+         </xs:element>
+         <xs:element name="jgroupsConfig" type="tns:jgroupsConfigType" minOccurs="0" maxOccurs="1"/>
+      </xs:all>
+      <xs:attribute name="mode">
+         <xs:simpleType>
+            <xs:restriction base="xs:string">
+               <xs:pattern
+                     value="[Rr][Ee][Pp][Ll][Ii][Cc][Aa][Tt][Ii][Oo][Nn]|[Ii][Nn][Vv][Aa][Ll][Ii][Dd][Aa][Tt][Ii][Oo][Nn]|[Rr]|[Ii]|\$\{.*\}"/>
+            </xs:restriction>
+         </xs:simpleType>
+      </xs:attribute>
+      <xs:attribute name="clusterName" type="xs:string" />
+
+
+   </xs:complexType>
+   
+   <xs:complexType name="lockingType">
+      <xs:attribute name="isolationLevel">
+         <xs:simpleType>
+            <xs:restriction base="xs:string">
+               <xs:pattern
+                     value="[Ss][Ee][Rr][Ii][Aa][Ll][Ii][Zz][Aa][Bb][Ll][Ee]|[Rr][Ee][Pp][Ee][Aa][Tt][Aa][Bb][Ll][Ee]_[Rr][Ee][Aa][Dd]|[Rr][Ee][Aa][Dd]_[Cc][Oo][Mm][Mm][Ii][Tt][Tt][Ee][Dd]|[Nn][Oo][Nn][Ee]|\$\{.*\}"/>
+            </xs:restriction>
+         </xs:simpleType>
+      </xs:attribute>
+      <xs:attribute name="lockParentForChildInsertRemove" type="tns:booleanType"/>
+      <xs:attribute name="lockAcquisitionTimeout" type="tns:positiveInteger"/>
+      <xs:attribute name="nodeLockingScheme">
+         <xs:simpleType>
+            <xs:restriction base="xs:string">
+               <xs:pattern
+                     value="[Mm][Vv][Cc][Cc]|[Oo][Pp][Tt][Ii][Mm][Ii][Ss][Tt][Ii][Cc]|[Pp][Ee][Ss][Ss][Ii][Mm][Ii][Ss][Tt][Ii][Cc]|\$\{.*\}"/>
+            </xs:restriction>
+         </xs:simpleType>
+      </xs:attribute>
+      <xs:attribute name="writeSkewCheck" type="tns:booleanType"/>
+      <xs:attribute name="concurrencyLevel" type="xs:integer"/>
+   </xs:complexType>
+
+   <xs:complexType name="transactionType">
+      <xs:attribute name="transactionManagerLookupClass" type="xs:string"/>
+      <xs:attribute name="syncRollbackPhase" type="tns:booleanType"/>
+      <xs:attribute name="syncCommitPhase" type="tns:booleanType"/>
+   </xs:complexType>
+
+   <xs:complexType name="startupType">
+      <xs:attribute name="regionsInactiveOnStartup" type="tns:booleanType"/>
+   </xs:complexType>
+
+   <xs:complexType name="stateRetrievalType">
+      <xs:attribute name="fetchInMemoryState" type="tns:booleanType"/>
+      <xs:attribute name="timeout" type="tns:positiveInteger"/>
+   </xs:complexType>
+
+   <xs:complexType name="shutdownType">
+      <xs:attribute name="hookBehavior">
+         <xs:simpleType>
+            <xs:restriction base="xs:string">
+               <xs:pattern
+                     value="[Dd][Ee][Ff][Aa][Uu][Ll][Tt]|[Rr][Ee][Gg][Ii][Ss][Tt][Ee][Rr]|[Dd][Oo][Nn][Tt]_[Rr][Ee][Gg][Ii][Ss][Tt][Ee][Rr]|\$\{.*\}"/>
+            </xs:restriction>
+         </xs:simpleType>
+      </xs:attribute>
+   </xs:complexType>
+
+   <xs:complexType name="serializationType">
+      <xs:attribute name="objectInputStreamPoolSize" type="tns:positiveInteger"/>
+      <xs:attribute name="objectOutputStreamPoolSize" type="tns:positiveInteger"/>
+      <xs:attribute name="version" type="xs:string"/>
+      <xs:attribute name="marshallerClass" type="xs:string"/>
+      <xs:attribute name="useLazyDeserialization" type="tns:booleanType"/>
+      <xs:attribute name="useRegionBasedMarshalling" type="tns:booleanType"/>
+   </xs:complexType>
+
+   <xs:simpleType name="booleanType">
+      <xs:restriction base="xs:string">
+         <xs:pattern value="\$\{.*\}|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]"/>
+      </xs:restriction>
+   </xs:simpleType>
+
+   <xs:simpleType name="positiveInteger">
+      <xs:restriction base="xs:string">
+         <xs:pattern value="\$\{.*\}|\+?[0-9]*"/>
+      </xs:restriction>
+   </xs:simpleType>
+
+   <xs:complexType name="jmxStatisticsType">
+      <xs:attribute name="enabled" type="tns:booleanType"/>
+   </xs:complexType>
+
+   <xs:complexType name="listenersType">
+      <xs:attribute name="asyncPoolSize" type="tns:positiveInteger"/>
+      <xs:attribute name="asyncQueueSize" type="tns:positiveInteger"/>
+   </xs:complexType>
+
+   <xs:complexType name="invocationBatchingType">
+      <xs:attribute name="enabled" type="tns:booleanType"/>
+   </xs:complexType>
+
+   <xs:complexType name="jgroupsConfigType">
+      <xs:sequence>
+         <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+      </xs:sequence>
+      <xs:attribute name="configFile" type="xs:string"/>
+      <xs:attribute name="multiplexerStack" type="xs:string"/>
+   </xs:complexType>
+
+   <xs:complexType name="syncType">
+      <xs:attribute name="replTimeout" type="tns:positiveInteger"/>
+   </xs:complexType>
+
+   <xs:complexType name="asyncType">
+      <xs:attribute name="useReplQueue" type="tns:booleanType"/>
+      <xs:attribute name="replQueueInterval" type="tns:positiveInteger"/>
+      <xs:attribute name="replQueueMaxElements" type="tns:positiveInteger"/>
+      <xs:attribute name="serializationExecutorPoolSize" type="tns:positiveInteger"/>
+      <xs:attribute name="serializationExecutorQueueSize" type="tns:positiveInteger"/>
+   </xs:complexType>
+
+   <xs:complexType name="evictionType">
+      <xs:sequence>
+         <xs:element name="default" type="tns:evictionRegionType" minOccurs="0" maxOccurs="1"/>
+         <xs:element name="region" minOccurs="0" maxOccurs="unbounded" type="tns:evictionRegionType"/>
+      </xs:sequence>
+      <xs:attribute name="wakeUpInterval" type="tns:positiveInteger" use="required"/>
+   </xs:complexType>
+
+   <xs:complexType name="evictionRegionType">
+      <xs:sequence>
+         <xs:element name="property" minOccurs="0" maxOccurs="unbounded" type="tns:propertyType"/>
+      </xs:sequence>
+      <xs:attribute name="name" type="xs:string"/>
+      <xs:attribute name="algorithmClass" type="xs:string"/>
+      <xs:attribute name="actionPolicyClass" type="xs:string"/>
+      <xs:attribute name="eventQueueSize" type="tns:positiveInteger"/>
+   </xs:complexType>
+
+   <xs:complexType name="loadersType">
+      <xs:sequence>
+         <xs:element name="preload" minOccurs="0" maxOccurs="1">
+            <xs:complexType>
+               <xs:sequence>
+                  <xs:element name="node" maxOccurs="unbounded">
+                     <xs:complexType>
+                        <xs:attribute name="fqn" type="xs:string"/>
+                     </xs:complexType>
+                  </xs:element>
+               </xs:sequence>
+            </xs:complexType>
+         </xs:element>
+         <xs:element name="loader" maxOccurs="unbounded">
+            <xs:complexType>
+               <xs:all>
+                  <xs:element name="properties"/>
+                  <xs:element name="singletonStore" minOccurs="0" maxOccurs="1">
+                     <xs:complexType>
+                        <xs:all>
+                           <xs:element name="properties" type="xs:string" minOccurs="0" maxOccurs="1"/>
+                        </xs:all>
+                        <xs:attribute name="enabled" type="tns:booleanType"/>
+                        <xs:attribute name="class" type="xs:string"/>
+                     </xs:complexType>
+                  </xs:element>
+               </xs:all>
+               <xs:attribute name="class" type="xs:string"/>
+               <xs:attribute name="async" type="tns:booleanType"/>
+               <xs:attribute name="fetchPersistentState" type="tns:booleanType"/>
+               <xs:attribute name="ignoreModifications" type="tns:booleanType"/>
+               <xs:attribute name="purgeOnStartup" type="tns:booleanType"/>
+            </xs:complexType>
+         </xs:element>
+      </xs:sequence>
+      <xs:attribute name="passivation" type="tns:booleanType"/>
+      <xs:attribute name="shared" type="tns:booleanType"/>
+   </xs:complexType>
+
+   <xs:complexType name="customInterceptorsType">
+      <xs:sequence>
+         <xs:element name="interceptor" maxOccurs="unbounded">
+            <xs:complexType>
+               <xs:sequence>
+                  <xs:element name="property" maxOccurs="unbounded" type="tns:propertyType" minOccurs="0"/>
+               </xs:sequence>
+               <xs:attribute name="class" type="xs:string"/>
+               <xs:attribute name="position">
+                  <xs:simpleType>
+                     <xs:restriction base="xs:string">
+                        <xs:pattern value="[Ff][Ii][Rr][Ss][Tt]|[Ll][Aa][Ss][Tt]"/>
+                     </xs:restriction>
+                  </xs:simpleType>
+               </xs:attribute>
+               <xs:attribute name="before" type="xs:string"/>
+               <xs:attribute name="after" type="xs:string"/>
+               <xs:attribute name="index" type="tns:positiveInteger"/>
+            </xs:complexType>
+         </xs:element>
+      </xs:sequence>
+   </xs:complexType>
+
+   <xs:complexType name="propertyType">
+      <xs:simpleContent>
+         <xs:extension base="xs:string">
+            <xs:attribute name="name" type="xs:string"/>
+            <xs:attribute name="value" type="xs:string"/>
+         </xs:extension>
+      </xs:simpleContent>
+   </xs:complexType>
+</xs:schema>
+

Added: core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd
===================================================================
--- core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd	                        (rev 0)
+++ core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd	2009-02-24 13:34:08 UTC (rev 7769)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
+           xmlns:tns="urn:jboss:jbosscache-core:config:3.0"
+           xmlns:repo="urn:jboss:jbosscache-core:cache-repo:3.0"
+           targetNamespace="urn:jboss:jbosscache-core:cache-repo:3.0"
+           xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
+   <xs:import schemaLocation="jbosscache-config-3.0.xsd" namespace="urn:jboss:jbosscache-core:config:3.0"/>
+
+   <xs:element name="cache-configs">
+      <xs:complexType>
+         <xs:sequence>
+            <xs:element name="cache-config" type="repo:cacheConfig" minOccurs="1" maxOccurs="unbounded"/>
+         </xs:sequence>
+      </xs:complexType>
+   </xs:element>
+
+   <xs:complexType name="cacheConfig">                                                                                                                                                      
+      <xs:complexContent>
+         <xs:extension base="tns:cacheConfigurationType" xml:space="default">
+            <xs:attribute name="name" type="xs:string"/>
+         </xs:extension>
+      </xs:complexContent>
+   </xs:complexType>
+</xs:schema>

Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElementParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElementParserTest.java	2009-02-24 12:56:11 UTC (rev 7768)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/CacheLoadersElementParserTest.java	2009-02-24 13:34:08 UTC (rev 7769)
@@ -109,7 +109,7 @@
 
    }
 
-   public void testSingletonStoreDisaled() throws Exception
+   public void testSingletonStoreDisabled() throws Exception
    {
       String xml =
             "   <loaders passivation=\"true\" shared=\"true\">\n" +

Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/JGroupsStackParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/JGroupsStackParserTest.java	2009-02-24 12:56:11 UTC (rev 7768)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/JGroupsStackParserTest.java	2009-02-24 13:34:08 UTC (rev 7769)
@@ -2,9 +2,10 @@
 
 import org.testng.annotations.Test;
 import org.w3c.dom.Element;
+import org.jboss.cache.config.parsing.element.JGroupsStackParser;
 
 /**
- * Tester class for {@link org.jboss.cache.config.parsing.JGroupsStackParser}
+ * Tester class for {@link org.jboss.cache.config.parsing.element.JGroupsStackParser}
  *
  * @author Mircea.Markus at jboss.com
  * @since 3.0

Added: core/trunk/src/test/java/org/jboss/cache/config/parsing/ParseFileWith30SchemaTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/ParseFileWith30SchemaTest.java	                        (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/ParseFileWith30SchemaTest.java	2009-02-24 13:34:08 UTC (rev 7769)
@@ -0,0 +1,28 @@
+package org.jboss.cache.config.parsing;
+
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.ConfigurationException;
+import org.testng.annotations.Test;
+
+ at Test(groups = "unit", testName = "config.parsing.ParseFileWith30SchemaTest")
+public class ParseFileWith30SchemaTest
+{
+   public void testFileWithDeclared30Schema()
+   {
+      String fileToTest = "configs/simple-3_0-config-file.xml";
+      XmlConfigurationParser parser = new XmlConfigurationParser();
+      assert parser.isValidating();
+      Configuration c = parser.parseFile(fileToTest);
+      assert c.getLockAcquisitionTimeout() == 500;
+   }
+
+   @Test (expectedExceptions = ConfigurationException.class)
+   public void testFileWithDeclared30SchemaWith31Elements()
+   {
+      String fileToTest = "configs/incorrect-3_0-config-file.xml";
+      XmlConfigurationParser parser = new XmlConfigurationParser();
+      assert parser.isValidating();
+      Configuration c = parser.parseFile(fileToTest);
+      assert false : "Should throw exception!";
+   }
+}

Modified: core/trunk/src/test/java/org/jboss/cache/profiling/AbstractProfileTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/AbstractProfileTest.java	2009-02-24 12:56:11 UTC (rev 7768)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/AbstractProfileTest.java	2009-02-24 13:34:08 UTC (rev 7769)
@@ -3,7 +3,7 @@
 import org.jboss.cache.Cache;
 import org.jboss.cache.UnitTestCacheFactory;
 import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.parsing.JGroupsStackParser;
+import org.jboss.cache.config.parsing.element.JGroupsStackParser;
 import org.jboss.cache.config.parsing.XmlConfigHelper;
 import org.jboss.cache.factories.UnitTestConfigurationFactory;
 import org.jboss.cache.util.TestingUtil;

Added: core/trunk/src/test/resources/configs/incorrect-3_0-config-file.xml
===================================================================
--- core/trunk/src/test/resources/configs/incorrect-3_0-config-file.xml	                        (rev 0)
+++ core/trunk/src/test/resources/configs/incorrect-3_0-config-file.xml	2009-02-24 13:34:08 UTC (rev 7769)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbosscache  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xmlns="urn:jboss:jbosscache-core:config:3.0">
+   <locking lockAcquisitionTimeout="500"/>
+   <clustering>
+       <stateRetrieval fetchInMemoryState="true" nonBlocking="true" />
+   </clustering>
+</jbosscache>

Added: core/trunk/src/test/resources/configs/simple-3_0-config-file.xml
===================================================================
--- core/trunk/src/test/resources/configs/simple-3_0-config-file.xml	                        (rev 0)
+++ core/trunk/src/test/resources/configs/simple-3_0-config-file.xml	2009-02-24 13:34:08 UTC (rev 7769)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbosscache  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xmlns="urn:jboss:jbosscache-core:config:3.0">
+   <locking lockAcquisitionTimeout="500"/>
+</jbosscache>




More information about the jbosscache-commits mailing list