[jbosscache-commits] JBoss Cache SVN: r6621 - in core/trunk/src: main/resources/schema and 3 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Aug 26 18:46:35 EDT 2008


Author: mircea.markus
Date: 2008-08-26 18:46:35 -0400 (Tue, 26 Aug 2008)
New Revision: 6621

Added:
   core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java
   core/trunk/src/main/resources/schema/jbosscache-registry-3.0.xsd
   core/trunk/src/test/resources/jbc3-registry-configs.xml
Modified:
   core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.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/resources/schema/jbosscache-config-3.0.xsd
   core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
   core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java
   core/trunk/src/test/java/org/jboss/cache/manager/CacheManagerTest.java
Log:
xml improvements

Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java	2008-08-26 11:07:03 UTC (rev 6620)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java	2008-08-26 22:46:35 UTC (rev 6621)
@@ -22,10 +22,6 @@
 
 package org.jboss.cache.config.parsing;
 
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.config.Configuration;
@@ -35,6 +31,10 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * Parser able to parse a series of cache configurations stored in an
  * XML document with the following structure:
@@ -89,8 +89,8 @@
    public Map<String, Configuration> parseConfigs(InputStream stream) throws CloneNotSupportedException
    {
       // loop through all elements in XML.
-      Element root = XmlConfigHelper.getDocumentRoot(stream);
-      NodeList list = root.getElementsByTagName(CONFIG_ROOT);
+      Element root = getDocumentRoot(stream);
+      NodeList list = root.getElementsByTagNameNS(RootElementBuilder.JBOSSCACHE_REPO_NS, CONFIG_ROOT);
       if (list == null || list.getLength() == 0)
          throw new ConfigurationException("Can't find " + CONFIG_ROOT + " tag");
 
@@ -118,4 +118,10 @@
 
       return result;
    }
+
+   private Element getDocumentRoot(InputStream stream)
+   {
+      RootElementBuilder rootElementBuilder = new RootElementBuilder();
+      return rootElementBuilder.readRoot(stream);
+   }
 }
\ No newline at end of file

Added: core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java	                        (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java	2008-08-26 22:46:35 UTC (rev 6621)
@@ -0,0 +1,141 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.Document;
+import org.w3c.dom.Element;
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import java.io.InputStream;
+
+/**
+ * Parses an xml files and validates xml elements form {@link RootElementBuilder#JBOSSCACHE_CORE_NS} namespace
+ * according to the configured schema.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 3.0
+ */
+public class RootElementBuilder
+{
+
+   private static final JBossEntityResolver resolver = new JBossEntityResolver();
+
+   public static final String JBOSSCACHE_CORE_NS = "urn:jboss:jbosscache-core:config:3.0";
+   public static final String JBOSSCACHE_REPO_NS = "urn:jboss:jbosscache-core:cache-repo:3.0";
+
+   static
+   {
+      // Globally register this namespace
+      JBossEntityResolver.registerEntity(JBOSSCACHE_CORE_NS, "jbosscache-config-3.0.xsd");
+      JBossEntityResolver.registerEntity(JBOSSCACHE_REPO_NS, "jbosscache-registry-3.0.xsd");
+   }
+
+   private static final Log log = LogFactory.getLog(RootElementBuilder.class);
+   private ErrorHandler errorHandler;
+   private boolean isValidating;
+   public static final String VALIDATING_SYSTEM_PROPERTY = "jbosscache.config.validate";
+
+   public RootElementBuilder(ErrorHandler errorHandler)
+   {
+      this.errorHandler = errorHandler;
+      isValidating = System.getProperty(VALIDATING_SYSTEM_PROPERTY) == null || Boolean.getBoolean(VALIDATING_SYSTEM_PROPERTY);
+   }
+
+   public RootElementBuilder(ErrorHandler errorHandler, boolean validating)
+   {
+      this.errorHandler = errorHandler;
+      isValidating = validating;
+   }
+
+   public RootElementBuilder()
+   {
+      this(new FailureErrorHandler());
+   }
+
+   public Element readRoot(InputStream config)
+   {
+      try
+      {
+         DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+         docBuilderFactory.setNamespaceAware(true);
+         if (isValidating)
+         {
+            docBuilderFactory.setValidating(true);
+            docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
+            String[] value = {JBOSSCACHE_CORE_NS, JBOSSCACHE_REPO_NS};
+            docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", value);
+         }
+         DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
+         parser.setEntityResolver(resolver);
+         parser.setErrorHandler(errorHandler);
+         Document doc = parser.parse(config);
+         Element root = doc.getDocumentElement();
+         root.normalize();
+         return root;
+      }
+      catch (Exception e)
+      {
+         log.error(e);
+         throw new ConfigurationException("Could not parse the config file");
+      }
+   }
+
+   /**
+    * Default schema validation error handler, that throws an exception on validation errors.
+    */
+   private static class FailureErrorHandler implements ErrorHandler
+   {
+      public void warning(SAXParseException exception) throws SAXException
+      {
+         logAndThrowException(exception);
+      }
+
+      public void error(SAXParseException exception) throws SAXException
+      {
+         logAndThrowException(exception);
+      }
+
+      public void fatalError(SAXParseException exception) throws SAXException
+      {
+         logAndThrowException(exception);
+      }
+
+      private void logAndThrowException(SAXParseException exception)
+      {
+         log.error("Configuration warning: " + exception.getMessage());
+         throw new ConfigurationException("Incorrect configuration file. Use '-Djbosscache.config.validate=false' to disable validation.", exception);
+      }
+   }
+
+   public boolean isValidating()
+   {
+      return isValidating;
+   }
+}

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	2008-08-26 11:07:03 UTC (rev 6620)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java	2008-08-26 22:46:35 UTC (rev 6621)
@@ -366,7 +366,7 @@
     */
    public static Element stringToElementInCoreNS(String xml) throws Exception
    {
-      xml = "<wrapper xmlns='" + XmlParserBase.JBOSSCACHE_CORE_NS + "'>" + xml + "</wrapper>";
+      xml = "<wrapper xmlns='" + RootElementBuilder.JBOSSCACHE_CORE_NS + "'>" + 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	2008-08-26 11:07:03 UTC (rev 6620)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java	2008-08-26 22:46:35 UTC (rev 6621)
@@ -23,27 +23,18 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.CustomInterceptorConfig;
-import org.jboss.cache.config.OldFileFormatException;
+import org.jboss.cache.config.*;
 import org.jboss.cache.config.parsing.element.BuddyElementParser;
 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.lock.IsolationLevel;
 import org.jboss.cache.util.FileLookup;
-import org.jboss.util.xml.JBossEntityResolver;
-import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.ErrorHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
 import java.io.InputStream;
 import java.util.List;
 
@@ -60,38 +51,26 @@
  *
  * @author Mircea.Markus at jboss.com
  * @since 3.0
+ * @see org.jboss.cache.config.parsing.RootElementBuilder
  */
 public class XmlConfigurationParser extends XmlParserBase
 {
 
    private static final Log log = LogFactory.getLog(XmlConfigurationParser.class);
-   private static final JBossEntityResolver resolver = new JBossEntityResolver();
+   private RootElementBuilder rootElementBuilder;
 
-
-   public static final String VALIDATING_SYSTEM_PROPERTY = "jbosscache.config.validate";
-
-   static
-   {
-      // Globally register this namespace
-      JBossEntityResolver.registerEntity(JBOSSCACHE_CORE_NS, "jbosscache-config-3.0.xsd");
-   }
-
    /**
     * the resulting configuration.
     */
    private Configuration config = new Configuration();
    private Element root;
-   private ErrorHandler errorHandler;
-   private boolean isValidating;
-
    /**
     * If validation is on (default) one can specify an error handler for handling validation errors.
     * The default error handler just logs parsing errors received.
     */
    public XmlConfigurationParser(ErrorHandler errorHandler)
    {
-      this.errorHandler = errorHandler;
-      isValidating = System.getProperty(VALIDATING_SYSTEM_PROPERTY) == null || Boolean.getBoolean(VALIDATING_SYSTEM_PROPERTY);
+      rootElementBuilder = new RootElementBuilder(errorHandler);
    }
 
    /**
@@ -101,8 +80,7 @@
     */
    public XmlConfigurationParser(boolean validating, ErrorHandler errorHandler)
    {
-      isValidating = validating;
-      this.errorHandler = errorHandler;
+      rootElementBuilder = new RootElementBuilder(errorHandler, validating);
    }
 
    /**
@@ -110,7 +88,7 @@
     */
    public XmlConfigurationParser()
    {
-      this(new LoggingErrorHandler());
+      rootElementBuilder = new RootElementBuilder();
    }
 
    /**
@@ -153,8 +131,6 @@
       return processElements(false);
    }
 
-   // FIXME: CacheConfigsXmlParser should be using a valid schema!
-   @Deprecated
    public Configuration parseElementIgnoringRoot(Element root)
    {
       this.root = root;
@@ -164,7 +140,7 @@
 
    public boolean isValidating()
    {
-      return isValidating;
+      return rootElementBuilder.isValidating();
    }
 
    private Configuration processElements(boolean ignoreRoot)
@@ -176,8 +152,8 @@
             throw new OldFileFormatException();
          }
 
-         if (!"jbosscache".equals(root.getLocalName()) || !JBOSSCACHE_CORE_NS.equals(root.getNamespaceURI()))
-            throw new ConfigurationException("Expected root element {" + JBOSSCACHE_CORE_NS + "}" + "jbosscache");
+         if (!"jbosscache".equals(root.getLocalName()) || !RootElementBuilder.JBOSSCACHE_CORE_NS.equals(root.getNamespaceURI()))
+            throw new ConfigurationException("Expected root element {" + RootElementBuilder.JBOSSCACHE_CORE_NS + "}" + "jbosscache");
       }
 
       try
@@ -415,49 +391,33 @@
 
    private void readRoot(InputStream config)
    {
-      try
-      {
-         DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
-         docBuilderFactory.setNamespaceAware(true);
-         if (isValidating)
-         {
-            docBuilderFactory.setValidating(true);
-            docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
-            docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", JBOSSCACHE_CORE_NS);
-         }
-
-         DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
-         parser.setEntityResolver(resolver);
-         parser.setErrorHandler(errorHandler);
-         Document doc = parser.parse(config);
-         root = doc.getDocumentElement();
-         root.normalize();
-      }
-      catch (Exception e)
-      {
-         log.error(e);
-         throw new ConfigurationException("Could not parse the config file");
-      }
+      root = rootElementBuilder.readRoot(config);
    }
 
    /**
-    * Default schema validation error handler, that only logs validation exceptions.
+    * Default schema validation error handler, that throws an exception on validation errors.
     */
-   private static class LoggingErrorHandler implements ErrorHandler
+   private static class FailureErrorHandler implements ErrorHandler
    {
       public void warning(SAXParseException exception) throws SAXException
       {
-         log.warn("Configuration warning: " + exception.getMessage());
+         logAndThrowException(exception);
       }
 
       public void error(SAXParseException exception) throws SAXException
       {
-         log.warn("Configuration error: " + exception.getMessage());
+         logAndThrowException(exception);
       }
 
       public void fatalError(SAXParseException exception) throws SAXException
       {
-         log.warn("Configuration fatal error : " + exception.getMessage());
+         logAndThrowException(exception);
       }
+
+      private void logAndThrowException(SAXParseException exception)
+      {
+         log.error("Configuration warning: " + exception.getMessage());
+         throw new ConfigurationException("Incorrect configuration file. Use '-Djbosscache.config.validate=false' to disable validation.", exception);
+      }
    }
 }

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	2008-08-26 11:07:03 UTC (rev 6620)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java	2008-08-26 22:46:35 UTC (rev 6621)
@@ -33,7 +33,6 @@
  */
 public abstract class XmlParserBase
 {
-   public static final String JBOSSCACHE_CORE_NS = "urn:jboss:jbosscache-core:config:3.0";
 
    /**
     * @see Integer#parseInt(String)
@@ -85,7 +84,7 @@
     */
    protected Element getSingleElementInCoreNS(String elementName, Element parent)
    {
-      return getSingleElement(JBOSSCACHE_CORE_NS, elementName, parent);
+      return getSingleElement(RootElementBuilder.JBOSSCACHE_CORE_NS, elementName, parent);
    }
 
    /**

Modified: core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd
===================================================================
--- core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd	2008-08-26 11:07:03 UTC (rev 6620)
+++ core/trunk/src/main/resources/schema/jbosscache-config-3.0.xsd	2008-08-26 22:46:35 UTC (rev 6621)
@@ -2,33 +2,33 @@
 <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">
-      <xs:complexType>
-         <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="stateRetrieval" type="tns:stateRetrievalType" 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="replication" type="tns:replicationType" minOccurs="0" maxOccurs="1"/>
-            <xs:element name="invalidation" type="tns:invalidationType" 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="transport" type="tns:transportType" 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:all>
-      </xs:complexType>
-   </xs:element>
+   <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="stateRetrieval" type="tns:stateRetrievalType" 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="replication" type="tns:replicationType" minOccurs="0" maxOccurs="1"/>
+         <xs:element name="invalidation" type="tns:invalidationType" 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="transport" type="tns:transportType" 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:all>
+   </xs:complexType>
+
    <xs:complexType name="lockingType">
       <xs:attribute name="isolationLevel">
          <xs:simpleType>
             <xs:restriction base="xs:string">
-               <xs:pattern value="SERIALIZABLE|REPEATABLE_READ|READ_COMMITTED|NONE|\$\{.*\}"/>
+               <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>
@@ -64,7 +64,7 @@
       <xs:attribute name="hookBehavior">
          <xs:simpleType>
             <xs:restriction base="xs:string">
-               <xs:pattern value="DEFAULT|REGISTER|DONT_REGISTER|\$\{.*\}"/>
+               <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>
@@ -81,7 +81,7 @@
 
    <xs:simpleType name="booleanType">
       <xs:restriction base="xs:string">
-         <xs:pattern value="\$\{.*\}|true|false"/>
+         <xs:pattern value="\$\{.*\}|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]"/>
       </xs:restriction>
    </xs:simpleType>
 
@@ -230,8 +230,7 @@
                <xs:attribute name="position">
                   <xs:simpleType>
                      <xs:restriction base="xs:string">
-                        <xs:enumeration value="first"/>
-                        <xs:enumeration value="last"/>
+                        <xs:pattern value="[Ff][Ii][Rr][Ss][Tt]|[Ll][Aa][Ss][Tt]"/>
                      </xs:restriction>
                   </xs:simpleType>
                </xs:attribute>

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	2008-08-26 22:46:35 UTC (rev 6621)
@@ -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/XmlConfigurationParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java	2008-08-26 11:07:03 UTC (rev 6620)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java	2008-08-26 22:46:35 UTC (rev 6621)
@@ -38,6 +38,7 @@
 
    public void testParseOldConfigFile()
    {
+      System.setProperty("jbosscache.config.validate","false");
       XmlConfigurationParser parser = new XmlConfigurationParser();
       try
       {
@@ -48,6 +49,9 @@
       {
          //expectd
       }
+      finally {
+         System.setProperty("jbosscache.config.validate","true");
+      }
    }
 
    public void testTransactionManagerLookupClass()

Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java	2008-08-26 11:07:03 UTC (rev 6620)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java	2008-08-26 22:46:35 UTC (rev 6621)
@@ -61,11 +61,11 @@
       XmlConfigurationParser parser = new XmlConfigurationParser();
       assert parser.isValidating() : "by default we have a validating parser";
 
-      System.setProperty(XmlConfigurationParser.VALIDATING_SYSTEM_PROPERTY, "false");
+      System.setProperty(RootElementBuilder.VALIDATING_SYSTEM_PROPERTY, "false");
       parser = new XmlConfigurationParser();
       assert !parser.isValidating();
 
-      System.setProperty(XmlConfigurationParser.VALIDATING_SYSTEM_PROPERTY, "true");
+      System.setProperty(RootElementBuilder.VALIDATING_SYSTEM_PROPERTY, "true");
       parser = new XmlConfigurationParser();
       assert parser.isValidating();
    }

Modified: core/trunk/src/test/java/org/jboss/cache/manager/CacheManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/manager/CacheManagerTest.java	2008-08-26 11:07:03 UTC (rev 6620)
+++ core/trunk/src/test/java/org/jboss/cache/manager/CacheManagerTest.java	2008-08-26 22:46:35 UTC (rev 6621)
@@ -32,7 +32,7 @@
    /**
     * A file that includes every configuration element I could think of
     */
-   public static final String DEFAULT_CONFIGURATION_FILE = "jbc2-registry-configs.xml";
+   public static final String DEFAULT_CONFIGURATION_FILE = "jbc3-registry-configs.xml";
 
    private Set<Cache<Object, Object>> caches = new HashSet<Cache<Object, Object>>();
 

Added: core/trunk/src/test/resources/jbc3-registry-configs.xml
===================================================================
--- core/trunk/src/test/resources/jbc3-registry-configs.xml	                        (rev 0)
+++ core/trunk/src/test/resources/jbc3-registry-configs.xml	2008-08-26 22:46:35 UTC (rev 6621)
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<registry:cache-configs xmlns="urn:jboss:jbosscache-core:config:3.0" xmlns:registry="urn:jboss:jbosscache-core:cache-repo:3.0">
+
+    <!--
+     Various JBoss Cache configurations, suitable for different caching
+     uses (e.g. entities vs. queries).
+
+     In all cases, TransactionManager configuration not required.
+     Hibernate will plug in its own transaction manager integration.
+    -->
+
+
+    <!-- A config appropriate for entity/collection caching. -->
+    <registry:cache-config name="optimistic-entity">
+       <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
+       <transaction syncCommitPhase="true" syncRollbackPhase="true"
+                    transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+       <serialization useRegionBasedMarshalling="true"/>
+       <startup regionsInactiveOnStartup="true"/>
+       <stateRetrieval fetchInMemoryState="false" timeout="20000"/>
+       <transport clusterName="optimistic-entity" multiplexerStack="udp-sync"/>
+       <invalidation>
+          <sync replTimeout="20000"/>
+       </invalidation>
+       <eviction wakeUpInterval="5000">
+          <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+             <attribute name="maxNodes">5000</attribute>
+             <attribute name="timeToLive">1000</attribute>
+          </default>
+          <region name="/TS">
+             <attribute name="maxNodes">0</attribute>
+             <attribute name="timeToLive">0</attribute>
+          </region>
+       </eviction>
+    </registry:cache-config>
+
+    <!-- A config appropriate for entity/collection caching that
+         uses pessimistic locking -->
+    <registry:cache-config name="pessimistic-entity">
+       <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="pessimistic"/>
+       <serialization useRegionBasedMarshalling="true"/>
+       <startup regionsInactiveOnStartup="true"/>
+       <stateRetrieval fetchInMemoryState="false" timeout="20000"/>
+       <transport clusterName="pessimistic-entity" multiplexerStack="udp-sync"/>
+       <invalidation>
+          <sync replTimeout="20000"/>
+       </invalidation>
+       <eviction wakeUpInterval="5000">
+          <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+             <attribute name="maxNodes">5000</attribute>
+             <attribute name="timeToLive">1000</attribute>
+          </default>
+          <region name="/TS">
+             <attribute name="maxNodes">0</attribute>
+             <attribute name="timeToLive">0</attribute>
+          </region>
+       </eviction>
+    </registry:cache-config>
+
+    <!-- A config appropriate for query caching. Does not replicate
+         queries. DO NOT STORE TIMESTAMPS IN THIS CACHE.
+    -->
+    <registry:cache-config name="local-query">
+       <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
+       <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+       <eviction wakeUpInterval="5000">
+          <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+             <attribute name="maxNodes">5000</attribute>
+             <attribute name="timeToLive">1000</attribute>
+          </default>
+          <region name="/TS">
+             <attribute name="maxNodes">0</attribute>
+             <attribute name="timeToLive">0</attribute>
+          </region>
+       </eviction>
+    </registry:cache-config>
+
+    <!-- A query cache that replicates queries. Replication is asynchronous.
+          DO NOT STORE TIMESTAMPS IN THIS CACHE.
+    -->
+    <registry:cache-config name="replicated-query">
+       <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
+       <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+       <serialization useRegionBasedMarshalling="false"/>
+       <startup regionsInactiveOnStartup="false"/>
+       <stateRetrieval fetchInMemoryState="false" timeout="20000"/>
+       <transport clusterName="replicated-query" multiplexerStack="udp"/>
+       <replication>
+          <async/>
+       </replication>
+       <eviction wakeUpInterval="5000">
+          <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+             <attribute name="maxNodes">5000</attribute>
+             <attribute name="timeToLive">1000</attribute>
+          </default>
+          <region name="/TS" >
+             <attribute name="maxNodes">0</attribute>
+             <attribute name="timeToLive">0</attribute>
+          </region>
+       </eviction>
+    </registry:cache-config>
+
+    <!-- Optimized for timestamp caching. A clustered timestamp cache
+         is required if query caching is used, even if the query cache
+         itself is configured with CacheMode=LOCAL.
+    -->
+    <registry:cache-config name="timestamps-cache">
+       <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="pessimistic"/>
+       <serialization useRegionBasedMarshalling="true"/>
+       <startup regionsInactiveOnStartup="true"/>
+       <stateRetrieval fetchInMemoryState="true" timeout="20000"/>
+       <transport clusterName="timestamps-cache" multiplexerStack="udp"/>
+       <replication>
+          <async/>
+       </replication>
+       <eviction wakeUpInterval="5000">
+          <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+             <attribute name="maxNodes">5000</attribute>
+             <attribute name="timeToLive">1000</attribute>
+          </default>
+          <region name="/TS">
+             <attribute name="maxNodes">0</attribute>
+             <attribute name="timeToLive">0</attribute>
+          </region>
+       </eviction>
+    </registry:cache-config>
+
+    <!-- A config appropriate for a cache that's shared for
+         entity, collection, query and timestamp caching. Not an advised
+         configuration, since it requires cache mode REPL_SYNC, which is the
+         least efficient mode. Also requires a full state transfer at startup,
+         which can be expensive. Uses optimistic locking. -->
+    <registry:cache-config name="optimistic-shared">
+       <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
+       <transaction syncCommitPhase="true" syncRollbackPhase="true"
+                    transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+       <serialization useRegionBasedMarshalling="true"/>
+       <startup regionsInactiveOnStartup="true"/>
+       <stateRetrieval fetchInMemoryState="true" timeout="20000"/>
+       <transport clusterName="optimistic-shared" multiplexerStack="udp"/>
+       <replication>
+          <sync replTimeout="20000"/>
+       </replication>
+       <eviction wakeUpInterval="5000">
+          <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+             <attribute name="maxNodes">5000</attribute>
+             <attribute name="timeToLive">1000</attribute>
+          </default>
+          <region name="/TS">
+             <attribute name="maxNodes">0</attribute>
+             <attribute name="timeToLive">0</attribute>
+          </region>
+       </eviction>
+    </registry:cache-config>
+
+
+
+    <!-- A config appropriate for a cache that's shared for
+         entity, collection, query and timestamp caching. Not an advised
+         configuration, since it requires cache mode REPL_SYNC, which is the
+         least efficient mode. Also requires a full state transfer at startup,
+         which can be expensive. Uses pessmistic locking.
+    -->
+    <registry:cache-config name="pessimistic-shared">
+
+       <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="pessimistic"/>
+       <serialization useRegionBasedMarshalling="true"/>
+       <startup regionsInactiveOnStartup="true"/>
+       <stateRetrieval fetchInMemoryState="true" timeout="20000"/>
+       <transport clusterName="pessimistic-shared" multiplexerStack="udp"/>
+       <replication>
+          <sync replTimeout="20000"/>
+       </replication>
+       <eviction wakeUpInterval="5000">
+          <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+             <attribute name="maxNodes">5000</attribute>
+             <attribute name="timeToLive">1000</attribute>
+          </default>
+          <region name="/TS">
+             <attribute name="maxNodes">0</attribute>
+             <attribute name="timeToLive">0</attribute>
+          </region>
+       </eviction>
+    </registry:cache-config>
+</registry:cache-configs>




More information about the jbosscache-commits mailing list