[jbosscache-commits] JBoss Cache SVN: r6201 - in core/trunk/src: main/java/org/jboss/cache/config/parsing and 4 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Mon Jul 7 19:13:35 EDT 2008
Author: mircea.markus
Date: 2008-07-07 19:13:35 -0400 (Mon, 07 Jul 2008)
New Revision: 6201
Added:
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlSchemaTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/config/CustomInterceptorConfig.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
core/trunk/src/main/resources/all-elements-file-3.x.xml
core/trunk/src/main/resources/config-samples/buddy-replication.xml
core/trunk/src/main/resources/jbosscache-config.xsd
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
core/trunk/src/test/resources/configs/buddy-replication-cache.xml
core/trunk/src/test/resources/configs/clonable-config.xml
core/trunk/src/test/resources/configs/local-lru-eviction.xml
core/trunk/src/test/resources/configs/local-passivation.xml
core/trunk/src/test/resources/configs/local-tx.xml
core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml
core/trunk/src/test/resources/configs/mux.xml
core/trunk/src/test/resources/configs/parser-test.xml
core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml
core/trunk/src/test/resources/configs/replSync.xml
Log:
more elaborated xml schema + unit tests
Modified: core/trunk/src/main/java/org/jboss/cache/config/CustomInterceptorConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/CustomInterceptorConfig.java 2008-07-07 21:27:37 UTC (rev 6200)
+++ core/trunk/src/main/java/org/jboss/cache/config/CustomInterceptorConfig.java 2008-07-07 23:13:35 UTC (rev 6201)
@@ -9,6 +9,7 @@
/**
* Holds information about the custom interceptors defined in the configuration file.
+ * todo : As a tip on your CustomInterceptorConfig, you should consider extending ConfigurationComponent which gives you a lot of the basic stuff you need.
*
* @author Mircea.Markus at jboss.com
* @since 3.0
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-07-07 21:27:37 UTC (rev 6200)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-07-07 23:13:35 UTC (rev 6201)
@@ -10,6 +10,9 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -32,8 +35,25 @@
private Configuration config = new Configuration();
private Element root;
+ private ErrorHandler errorHandler;
+ private boolean isValidating = true;
+ public XmlConfigurationParser(ErrorHandler errorHandler)
+ {
+ this.errorHandler = errorHandler;
+ }
+ public XmlConfigurationParser(boolean validating, ErrorHandler errorHandler)
+ {
+ isValidating = validating;
+ this.errorHandler = errorHandler;
+ }
+
+ public XmlConfigurationParser()
+ {
+ this(new LoggingErrorHandler());
+ }
+
/**
* Parses an XML file and returns a new configuration. This method attempts to look for the file name passed in on
* the classpath. If not found, it will search for the file on the file system instead, treating the name as an
@@ -304,13 +324,42 @@
try
{
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+ if (isValidating)
+ {
+ docBuilderFactory.setValidating(true);
+ docBuilderFactory.setNamespaceAware(true);
+ docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
+ }
DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
+ parser.setErrorHandler(errorHandler);
Document doc = parser.parse(config);
root = doc.getDocumentElement();
root.normalize();
} catch (Exception e)
{
- throw new ConfigurationException("Could not parseStream the ");
+ log.error(e);
+ throw new ConfigurationException("Could not parseStream the config file");
}
}
+
+ /**
+ * Default schema validation error handler, that only logs validation exceptions.
+ */
+ private static class LoggingErrorHandler implements ErrorHandler
+ {
+ public void warning(SAXParseException exception) throws SAXException
+ {
+ log.warn("Configuration warning: " + exception.getMessage());
+ }
+
+ public void error(SAXParseException exception) throws SAXException
+ {
+ log.warn("Configuration error: " + exception.getMessage());
+ }
+
+ public void fatalError(SAXParseException exception) throws SAXException
+ {
+ log.warn("Configuration fatal error : " + exception.getMessage());
+ }
+ }
}
Modified: core/trunk/src/main/resources/all-elements-file-3.x.xml
===================================================================
--- core/trunk/src/main/resources/all-elements-file-3.x.xml 2008-07-07 21:27:37 UTC (rev 6200)
+++ core/trunk/src/main/resources/all-elements-file-3.x.xml 2008-07-07 23:13:35 UTC (rev 6201)
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="file:///C:/projects/cache/branches/za_trunk/src/main/resources/jbosscache-config.xsd">
<locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="true" lockAcquisitionTimeout="10234"
nodeLockingScheme="mvcc" allowWriteSkew="true" concurrencyLevel="21"/>
@@ -15,6 +16,7 @@
<!-- either replication or invalidation tags will be present, not both -->
<replication>
<sync replTimeout="15421"/>
+ <async useReplQueue="false" replQueueInterval="12" replQueueMaxElements="12345"/>
<buddy enabled="true" poolName="myBuddyPoolReplicationGroup" communicationTimeout="2000">
<dataGravitation auto="true" removeOnFind="true" searchBackupTrees="true"/>
<locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator">
@@ -28,8 +30,6 @@
<!-- either replication or invalidation tags will be present, not both -->
<invalidation>
- <!-- either sync or async will be present, not both -->
- <async useReplQueue="false" replQueueInterval="12" replQueueMaxElements="12345"/>
<sync replTimeout="15421"/>
</invalidation>
@@ -64,6 +64,7 @@
<root>
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">1000</attribute>
+ <attribute name="timeToLive">1000</attribute>
</root>
<region name="/org/jboss/data">
<attribute name="timeToLive">1002</attribute>
Modified: core/trunk/src/main/resources/config-samples/buddy-replication.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/buddy-replication.xml 2008-07-07 21:27:37 UTC (rev 6200)
+++ core/trunk/src/main/resources/config-samples/buddy-replication.xml 2008-07-07 23:13:35 UTC (rev 6201)
@@ -3,7 +3,9 @@
<!-- todo mmarkus add comments to sample config files (after DTD is written) -->
<!-- todo mmarkus include the DTD file in all configs -->
-<jbosscache>
+<jbosscache xmlns="http://www.jboss.org/jbosscache" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.jboss.org/jbosscache ../jbosscache-config.xsd">
+
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="10000" nodeLockingScheme="mvcc"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<startup stateRetrievalTimeout="20000"/>
Modified: core/trunk/src/main/resources/jbosscache-config.xsd
===================================================================
--- core/trunk/src/main/resources/jbosscache-config.xsd 2008-07-07 21:27:37 UTC (rev 6200)
+++ core/trunk/src/main/resources/jbosscache-config.xsd 2008-07-07 23:13:35 UTC (rev 6201)
@@ -1,362 +1,245 @@
<?xml version="1.0" encoding="UTF-8"?>
-<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:element name="jbosscache" type="jbosscacheType"/>
- <xs:complexType name="FRAG2Type">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="frag_size"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="dataGravitationType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="auto"/>
- <xs:attribute type="xs:string" name="removeOnFind"/>
- <xs:attribute type="xs:string" name="searchBackupTrees"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="pbcast.STREAMING_STATE_TRANSFERType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="use_reading_thread"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="positionType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="first" use="optional"/>
- <xs:attribute type="xs:string" name="last" use="optional"/>
- <xs:attribute type="xs:string" name="index" use="optional"/>
- <xs:attribute type="xs:string" name="before" use="optional"/>
- <xs:attribute type="xs:string" name="after" use="optional"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="rootType">
- <xs:sequence>
- <xs:element type="attributeType" name="attribute" maxOccurs="unbounded" minOccurs="0"/>
- </xs:sequence>
- </xs:complexType>
- <xs:complexType name="evictionType">
- <xs:sequence>
- <xs:element type="defaultsType" name="defaults"/>
- <xs:element type="rootType" name="root"/>
- <xs:element type="regionType" name="region" maxOccurs="unbounded" minOccurs="0"/>
- </xs:sequence>
- <xs:attribute type="xs:string" name="wakeUpInterval"/>
- </xs:complexType>
- <xs:complexType name="lockingType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="isolationLevel"/>
- <xs:attribute type="xs:string" name="lockParentForChildInsertRemove"/>
- <xs:attribute type="xs:string" name="lockAcquisitionTimeout"/>
- <xs:attribute type="xs:string" name="nodeLockingScheme"/>
- <xs:attribute type="xs:string" name="allowWriteSkew"/>
- <xs:attribute type="xs:string" name="concurrencyLevel"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="jmxStatisticsType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="enabled"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="defaultsType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="policyClass"/>
- <xs:attribute type="xs:string" name="eventQueueSize"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="transactionType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="transactionManagerLookupClass"/>
- <xs:attribute type="xs:string" name="syncRollbackPhase"/>
- <xs:attribute type="xs:string" name="syncCommitPhase"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="pbcast.FLUSHType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="timeout"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="pbcast.STABLEType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="stability_delay"/>
- <xs:attribute type="xs:string" name="desired_avg_gossip"/>
- <xs:attribute type="xs:string" name="max_bytes"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="transportType">
- <xs:sequence>
- <xs:element type="jgroupsConfigType" name="jgroupsConfig"/>
- </xs:sequence>
- <xs:attribute type="xs:string" name="clusterName"/>
- <xs:attribute type="xs:string" name="multiplexerStack"/>
- </xs:complexType>
- <xs:complexType name="regionType">
- <xs:sequence>
- <xs:element type="attributeType" name="attribute" maxOccurs="unbounded" minOccurs="0"/>
- </xs:sequence>
- <xs:attribute type="xs:string" name="name" use="optional"/>
- <xs:attribute type="xs:string" name="policyClass" use="optional"/>
- <xs:attribute type="xs:string" name="eventQueueSize" use="optional"/>
- </xs:complexType>
- <xs:complexType name="jgroupsConfigType">
- <xs:sequence>
- <xs:element type="PINGType" name="PING"/>
- <xs:element type="MERGE2Type" name="MERGE2"/>
- <xs:element type="xs:string" name="FD_SOCK"/>
- <xs:element type="FDType" name="FD"/>
- <xs:element type="VERIFY_SUSPECTType" name="VERIFY_SUSPECT"/>
- <xs:element type="pbcast.NAKACKType" name="pbcast.NAKACK"/>
- <xs:element type="UNICASTType" name="UNICAST"/>
- <xs:element type="pbcast.STABLEType" name="pbcast.STABLE"/>
- <xs:element type="pbcast.GMSType" name="pbcast.GMS"/>
- <xs:element type="FRAG2Type" name="FRAG2"/>
- <xs:element type="pbcast.STREAMING_STATE_TRANSFERType" name="pbcast.STREAMING_STATE_TRANSFER"/>
- <xs:element type="pbcast.FLUSHType" name="pbcast.FLUSH"/>
- </xs:sequence>
- </xs:complexType>
- <xs:complexType name="shutdownType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="hookBehavior"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="asyncType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="useReplQueue"/>
- <xs:attribute type="xs:string" name="replQueueInterval"/>
- <xs:attribute type="xs:string" name="replQueueMaxElements"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="serializationType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="objectInputStreamPoolSize"/>
- <xs:attribute type="xs:string" name="objectOutputStreamPoolSize"/>
- <xs:attribute type="xs:string" name="version"/>
- <xs:attribute type="xs:string" name="marshallerClass"/>
- <xs:attribute type="xs:string" name="useLazyDeserialization"/>
- <xs:attribute type="xs:string" name="useRegionBasedMarshalling"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="customInterceptorsType">
- <xs:sequence>
- <xs:element type="interceptorType" name="interceptor" maxOccurs="unbounded" minOccurs="0"/>
- </xs:sequence>
- </xs:complexType>
- <xs:complexType name="startupType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="fetchInMemoryState"/>
- <xs:attribute type="xs:string" name="stateRetrievalTimeout"/>
- <xs:attribute type="xs:string" name="inactiveOnStartup"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="pbcast.GMSType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="print_local_addr"/>
- <xs:attribute type="xs:string" name="join_timeout"/>
- <xs:attribute type="xs:string" name="shun"/>
- <xs:attribute type="xs:string" name="view_bundling"/>
- <xs:attribute type="xs:string" name="view_ack_collection_timeout"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="UNICASTType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="timeout"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="jbosscacheType">
- <xs:sequence>
- <xs:element type="lockingType" name="locking"/>
- <xs:element type="transactionType" name="transaction"/>
- <xs:element type="serializationType" name="serialization">
- <xs:annotation>
- <xs:documentation>serialization related configuration, used for replication and cache loading</xs:documentation>
- </xs:annotation>
- </xs:element>
- <xs:element type="replicationType" name="replication">
- <xs:annotation>
- <xs:documentation>either replication or invalidation tags will be present, not both</xs:documentation>
- </xs:annotation>
- </xs:element>
- <xs:element type="invalidationType" name="invalidation">
- <xs:annotation>
- <xs:documentation>either replication or invalidation tags will be present, not both</xs:documentation>
- </xs:annotation>
- </xs:element>
- <xs:element type="startupType" name="startup"/>
- <xs:element type="shutdownType" name="shutdown"/>
- <xs:element type="jmxStatisticsType" name="jmxStatistics"/>
- <xs:element type="transportType" name="transport"/>
- <xs:element type="evictionType" name="eviction"/>
- <xs:element type="loadersType" name="loaders"/>
- <xs:element type="customInterceptorsType" name="customInterceptors">
- <xs:annotation>
- <xs:documentation>this is new behavior added within 3.x only. it support configuring custom interceptors through configurations</xs:documentation>
- </xs:annotation>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- <xs:complexType name="attributeType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="name" use="optional"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="PINGType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="timeout"/>
- <xs:attribute type="xs:string" name="num_initial_members"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="nodeType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="fqn" use="optional"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="invalidationType">
- <xs:sequence>
- <xs:element type="asyncType" name="async">
- <xs:annotation>
- <xs:documentation>either sync or async will be present, not both</xs:documentation>
- </xs:annotation>
- </xs:element>
- <xs:element type="syncType" name="sync"/>
- </xs:sequence>
- </xs:complexType>
- <xs:complexType name="loaderType">
- <xs:sequence>
- <xs:element type="xs:string" name="properties"/>
- <xs:element type="singletonStoreType" name="singletonStore"/>
- </xs:sequence>
- <xs:attribute type="xs:string" name="class"/>
- <xs:attribute type="xs:string" name="async"/>
- <xs:attribute type="xs:string" name="fetchPersistentState"/>
- <xs:attribute type="xs:string" name="ignoreModifications"/>
- <xs:attribute type="xs:string" name="purgeOnStartup"/>
- </xs:complexType>
- <xs:complexType name="replicationType">
- <xs:sequence>
- <xs:element type="syncType" name="sync"/>
- <xs:element type="buddyType" name="buddy"/>
- </xs:sequence>
- </xs:complexType>
- <xs:complexType name="interceptorType">
- <xs:sequence>
- <xs:element type="xs:string" name="properties" minOccurs="0"/>
- <xs:element type="positionType" name="position"/>
- </xs:sequence>
- <xs:attribute type="xs:string" name="class" use="optional"/>
- </xs:complexType>
- <xs:complexType name="buddyType">
- <xs:sequence>
- <xs:element type="dataGravitationType" name="dataGravitation"/>
- <xs:element type="locatorType" name="locator"/>
- </xs:sequence>
- <xs:attribute type="xs:string" name="enabled"/>
- <xs:attribute type="xs:string" name="poolName"/>
- <xs:attribute type="xs:string" name="communicationTimeout"/>
- </xs:complexType>
- <xs:complexType name="locatorType">
- <xs:sequence>
- <xs:element type="xs:string" name="properties"/>
- </xs:sequence>
- <xs:attribute type="xs:string" name="class"/>
- </xs:complexType>
- <xs:complexType name="pbcast.NAKACKType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="use_mcast_xmit"/>
- <xs:attribute type="xs:string" name="gc_lag"/>
- <xs:attribute type="xs:string" name="retransmit_timeout"/>
- <xs:attribute type="xs:string" name="discard_delivered_msgs"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="preloadType">
- <xs:sequence>
- <xs:element type="nodeType" name="node" maxOccurs="unbounded" minOccurs="0"/>
- </xs:sequence>
- </xs:complexType>
- <xs:complexType name="MERGE2Type">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="max_interval"/>
- <xs:attribute type="xs:string" name="min_interval"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="VERIFY_SUSPECTType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="timeout"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="syncType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="replTimeout" use="optional"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="FDType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute type="xs:string" name="timeout"/>
- <xs:attribute type="xs:string" name="max_tries"/>
- <xs:attribute type="xs:string" name="shun"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="singletonStoreType">
- <xs:sequence>
- <xs:element type="xs:string" name="properties"/>
- </xs:sequence>
- <xs:attribute type="xs:string" name="enabled"/>
- <xs:attribute type="xs:string" name="class"/>
- </xs:complexType>
- <xs:complexType name="loadersType">
- <xs:sequence>
- <xs:element type="preloadType" name="preload"/>
- <xs:element type="loaderType" name="loader">
- <xs:annotation>
- <xs:documentation>we can now have multiple cache loaders, which get chained</xs:documentation>
- </xs:annotation>
- </xs:element>
- </xs:sequence>
- <xs:attribute type="xs:string" name="passivation"/>
- <xs:attribute type="xs:string" name="shared"/>
- </xs:complexType>
-</xs:schema>
\ No newline at end of file
+<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="jbosscache">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="locking" type="lockingType" minOccurs="0"/>
+ <xs:element name="transaction" type="transactionType" minOccurs="0"/>
+ <xs:element name="startup" type="startupType" minOccurs="0"/>
+ <xs:element name="shutdown" type="shutdownType" minOccurs="0"/>
+ <xs:element name="serialization" type="serializationType" minOccurs="0"/>
+ <xs:element name="replication" type="replicationType" minOccurs="0"/>
+ <xs:element name="invalidation" type="invalidationType" minOccurs="0"/>
+ <xs:element name="jmxStatistics" type="jmxStatisticsType" minOccurs="0"/>
+ <xs:element name="transport" type="transportType" minOccurs="0"/>
+ <xs:element name="eviction" type="evictionType" minOccurs="0"/>
+ <xs:element name="loaders" type="loadersType" minOccurs="0"/>
+ <xs:element name="customInterceptors" type="customInterceptorsType" minOccurs="0"/>
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:complexType name="lockingType">
+ <xs:attribute name="isolationLevel">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="SERIALIZABLE"/>
+ <xs:enumeration value="REPEATABLE_READ"/>
+ <xs:enumeration value="READ_COMMITTED"/>
+ <xs:enumeration value="READ_UNCOMMITTED"/>
+ <xs:enumeration value="NONE"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="lockParentForChildInsertRemove" type="booleanType"/>
+ <xs:attribute name="lockAcquisitionTimeout" type="xs:positiveInteger"/>
+ <xs:attribute name="nodeLockingScheme">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="mvcc"/>
+ <xs:enumeration value="optimistic"/>
+ <xs:enumeration value="pessimistic"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="allowWriteSkew" type="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="booleanType"/>
+ <xs:attribute name="syncCommitPhase" type="booleanType"/>
+ </xs:complexType>
+
+ <xs:complexType name="startupType">
+ <xs:attribute name="fetchInMemoryState" type="booleanType"/>
+ <xs:attribute name="inactiveOnStartup" type="booleanType"/>
+ <xs:attribute name="stateRetrievalTimeout" type="xs:positiveInteger"/>
+ </xs:complexType>
+
+ <xs:complexType name="shutdownType">
+ <xs:attribute name="hookBehavior">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="DEFAULT"/>
+ <xs:enumeration value="REGISTER"/>
+ <xs:enumeration value="DONT_REGISTER"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:complexType>
+
+ <xs:complexType name="serializationType">
+ <xs:attribute name="objectInputStreamPoolSize" type="xs:positiveInteger"/>
+ <xs:attribute name="objectOutputStreamPoolSize" type="xs:positiveInteger"/>
+ <xs:attribute name="version" type="xs:string"/>
+ <xs:attribute name="marshallerClass" type="xs:string"/>
+ <xs:attribute name="useLazyDeserialization" type="booleanType"/>
+ <xs:attribute name="useRegionBasedMarshalling" type="booleanType"/>
+ </xs:complexType>
+
+ <xs:simpleType name="booleanType">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="true"/>
+ <xs:enumeration value="false"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:complexType name="replicationType">
+ <xs:sequence>
+ <xs:choice>
+ <xs:element name="sync" type="syncType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="async" type="asyncType" minOccurs="0" maxOccurs="1"/>
+ </xs:choice>
+ <xs:element name="buddy" minOccurs="0">
+ <xs:complexType>
+ <xs:all minOccurs="0">
+ <xs:element name="dataGravitation">
+ <xs:complexType>
+ <xs:attribute name="auto" type="booleanType"/>
+ <xs:attribute name="removeOnFind" type="booleanType"/>
+ <xs:attribute name="searchBackupTrees" type="booleanType"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="locator">
+ <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="booleanType"/>
+ <xs:attribute name="poolName" type="xs:string"/>
+ <xs:attribute name="communicationTimeout" type="xs:integer"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="invalidationType">
+ <xs:choice>
+ <xs:element name="sync" type="syncType"/>
+ <xs:element name="async" type="asyncType"/>
+ </xs:choice>
+ </xs:complexType>
+
+ <xs:complexType name="jmxStatisticsType">
+ <xs:attribute name="enabled" type="booleanType"/>
+ </xs:complexType>
+
+ <xs:complexType name="transportType">
+ <xs:sequence>
+ <xs:element name="jgroupsConfig" type="xs:anyType" minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ <xs:attribute name="clusterName" type="xs:string"/>
+ <xs:attribute name="multiplexerStack" type="xs:string"/>
+ </xs:complexType>
+
+ <xs:complexType name="syncType">
+ <xs:attribute name="replTimeout" type="xs:positiveInteger"/>
+ </xs:complexType>
+
+
+ <xs:complexType name="asyncType">
+ <xs:attribute name="useReplQueue" type="booleanType"/>
+ <xs:attribute name="replQueueInterval" type="xs:positiveInteger"/>
+ <xs:attribute name="replQueueMaxElements" type="xs:positiveInteger"/>
+ </xs:complexType>
+
+ <xs:complexType name="evictionType">
+ <xs:sequence>
+ <xs:element name="defaults" minOccurs="0">
+ <xs:complexType>
+ <xs:attribute name="policyClass" type="xs:string"/>
+ <xs:attribute name="eventQueueSize" type="xs:positiveInteger"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="root" type="evictionRegionType" minOccurs="0"/>
+ <xs:element name="region" minOccurs="0" maxOccurs="unbounded" type="evictionRegionType"/>
+ </xs:sequence>
+ <xs:attribute name="wakeUpInterval" type="xs:positiveInteger"/>
+ </xs:complexType>
+
+ <xs:complexType name="evictionRegionType">
+ <xs:sequence>
+ <xs:element name="attribute" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="name" type="xs:string"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string"/>
+ <xs:attribute name="policyClass" type="xs:string"/>
+ <xs:attribute name="eventQueueSize" type="xs:positiveInteger"/>
+ </xs:complexType>
+
+ <xs:complexType name="loadersType">
+ <xs:sequence>
+ <xs:element name="preload" 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">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="properties" type="xs:string"/>
+ </xs:all>
+ <xs:attribute name="enabled" type="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="booleanType"/>
+ <xs:attribute name="fetchPersistentState" type="booleanType"/>
+ <xs:attribute name="ignoreModifications" type="booleanType"/>
+ <xs:attribute name="purgeOnStartup" type="booleanType"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="passivation" type="booleanType"/>
+ <xs:attribute name="shared" type="booleanType"/>
+ </xs:complexType>
+
+ <xs:complexType name="customInterceptorsType">
+ <xs:sequence>
+ <xs:element name="interceptor" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="properties" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="position" minOccurs="0" maxOccurs="1">
+ <xs:complexType>
+ <xs:attribute name="first" type="booleanType"/>
+ <xs:attribute name="last" type="booleanType"/>
+ <xs:attribute name="index" type="xs:positiveInteger"/>
+ <xs:attribute name="before" type="xs:string"/>
+ <xs:attribute name="after" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:all>
+ <xs:attribute name="class" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </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-07-07 21:27:37 UTC (rev 6200)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-07-07 23:13:35 UTC (rev 6201)
@@ -207,7 +207,6 @@
public void testCustomInterceptors()
{
List<CustomInterceptorConfig> interceptorConfigs = config.getCustomInterceptors();
- if (interceptorConfigs.isEmpty()) return; //todo drop this once you drop the old configuration
assert interceptorConfigs.size() == 5;
assert interceptorConfigs.get(0).getInterceptorClass().equals("com.myCompany.MyInterceptor1");
assert interceptorConfigs.get(1).getInterceptorClass().equals("com.myCompany.MyInterceptor2");
Added: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlSchemaTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlSchemaTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlSchemaTest.java 2008-07-07 23:13:35 UTC (rev 6201)
@@ -0,0 +1,83 @@
+package org.jboss.cache.config.parsing;
+
+import org.testng.annotations.Test;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Class that tests how schema works.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 3.0
+ */
+ at Test (groups = "unit")
+public class XmlSchemaTest
+{
+ public static final String BASE_DIR_FOR_CONFIG = "./configs";
+
+ private String[] testFiles =
+ {
+ "buddy-replication-cache.xml",
+ "clonable-config.xml",
+ "local-lru-eviction.xml",
+ "local-passivation.xml",
+ "local-tx.xml",
+ "mixedPolicy-eviction.xml",
+ "mux.xml",
+ "parser-test.xml",
+ "policyPerRegion-eviction.xml",
+ "replSync.xml",
+ "string-property-replaced.xml"
+ };
+
+ /**
+ * Simple test to prove that validation works.
+ */
+ public void testSimpleFile()
+ {
+ EceptionCountingErrorHanlder handler = new EceptionCountingErrorHanlder();
+ XmlConfigurationParser parser = new XmlConfigurationParser(handler);
+ for (String file : testFiles)
+ {
+ System.out.println("file = " + file);
+ parser.parseFile(BASE_DIR_FOR_CONFIG + File.separator + file);
+ assert handler.noErrors() : "error during parsing";
+ }
+ }
+
+ private static class EceptionCountingErrorHanlder implements ErrorHandler
+ {
+ List<SAXParseException> exceptionList = new ArrayList<SAXParseException>();
+
+ public void warning(SAXParseException exception) throws SAXException
+ {
+ handleDefault(exception);
+ }
+
+ public void error(SAXParseException exception) throws SAXException
+ {
+ handleDefault(exception);
+ }
+
+ public void fatalError(SAXParseException exception) throws SAXException
+ {
+ handleDefault(exception);
+ }
+
+ private void handleDefault(SAXParseException exception)
+ {
+ System.out.println("Error :" + exception.getMessage());
+ exceptionList.add(exception);
+ }
+
+ boolean noErrors()
+ {
+ return exceptionList.isEmpty();
+ }
+ }
+}
Modified: core/trunk/src/test/resources/configs/buddy-replication-cache.xml
===================================================================
--- core/trunk/src/test/resources/configs/buddy-replication-cache.xml 2008-07-07 21:27:37 UTC (rev 6200)
+++ core/trunk/src/test/resources/configs/buddy-replication-cache.xml 2008-07-07 23:13:35 UTC (rev 6201)
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="file:///C:/projects/cache/branches/za_trunk/src/main/resources/jbosscache-config.xsd">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="10000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<startup stateRetrievalTimeout="20000"/>
Modified: core/trunk/src/test/resources/configs/clonable-config.xml
===================================================================
--- core/trunk/src/test/resources/configs/clonable-config.xml 2008-07-07 21:27:37 UTC (rev 6200)
+++ core/trunk/src/test/resources/configs/clonable-config.xml 2008-07-07 23:13:35 UTC (rev 6201)
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="file:///C:/projects/cache/branches/za_trunk/src/main/resources/jbosscache-config.xsd">
<locking isolationLevel="SERIALIZABLE" lockAcquisitionTimeout="1" nodeLockingScheme="optimistic"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<startup fetchInMemoryState="false" stateRetrievalTimeout="3"/>
Modified: core/trunk/src/test/resources/configs/local-lru-eviction.xml
===================================================================
--- core/trunk/src/test/resources/configs/local-lru-eviction.xml 2008-07-07 21:27:37 UTC (rev 6200)
+++ core/trunk/src/test/resources/configs/local-lru-eviction.xml 2008-07-07 23:13:35 UTC (rev 6201)
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="file:///C:/projects/cache/branches/za_trunk/src/main/resources/jbosscache-config.xsd">
+
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<startup stateRetrievalTimeout="20000"/>
Modified: core/trunk/src/test/resources/configs/local-passivation.xml
===================================================================
--- core/trunk/src/test/resources/configs/local-passivation.xml 2008-07-07 21:27:37 UTC (rev 6200)
+++ core/trunk/src/test/resources/configs/local-passivation.xml 2008-07-07 23:13:35 UTC (rev 6201)
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="file:///C:/projects/cache/branches/za_trunk/src/main/resources/jbosscache-config.xsd">
+
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<startup stateRetrievalTimeout="20000"/>
Modified: core/trunk/src/test/resources/configs/local-tx.xml
===================================================================
--- core/trunk/src/test/resources/configs/local-tx.xml 2008-07-07 21:27:37 UTC (rev 6200)
+++ core/trunk/src/test/resources/configs/local-tx.xml 2008-07-07 23:13:35 UTC (rev 6201)
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="file:///C:/projects/cache/branches/za_trunk/src/main/resources/jbosscache-config.xsd">
+
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<serialization useRegionBasedMarshalling="false"/>
Modified: core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml
===================================================================
--- core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml 2008-07-07 21:27:37 UTC (rev 6200)
+++ core/trunk/src/test/resources/configs/mixedPolicy-eviction.xml 2008-07-07 23:13:35 UTC (rev 6201)
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="file:///C:/projects/cache/branches/za_trunk/src/main/resources/jbosscache-config.xsd">
+
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<startup stateRetrievalTimeout="20000"/>
Modified: core/trunk/src/test/resources/configs/mux.xml
===================================================================
--- core/trunk/src/test/resources/configs/mux.xml 2008-07-07 21:27:37 UTC (rev 6200)
+++ core/trunk/src/test/resources/configs/mux.xml 2008-07-07 23:13:35 UTC (rev 6201)
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="file:///C:/projects/cache/branches/za_trunk/src/main/resources/jbosscache-config.xsd">
+
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="10000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<startup stateRetrievalTimeout="20000"/>
Modified: core/trunk/src/test/resources/configs/parser-test.xml
===================================================================
--- core/trunk/src/test/resources/configs/parser-test.xml 2008-07-07 21:27:37 UTC (rev 6200)
+++ core/trunk/src/test/resources/configs/parser-test.xml 2008-07-07 23:13:35 UTC (rev 6201)
@@ -2,8 +2,10 @@
<!-- file used for functional test of the xml parser -->
-<jbosscache>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="file:///C:/projects/cache/branches/za_trunk/src/main/resources/jbosscache-config.xsd">
+
<locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="true" lockAcquisitionTimeout="10234"
nodeLockingScheme="mvcc" allowWriteSkew="true" concurrencyLevel="21"/>
Modified: core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml
===================================================================
--- core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml 2008-07-07 21:27:37 UTC (rev 6200)
+++ core/trunk/src/test/resources/configs/policyPerRegion-eviction.xml 2008-07-07 23:13:35 UTC (rev 6201)
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="file:///C:/projects/cache/branches/za_trunk/src/main/resources/jbosscache-config.xsd">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<startup stateRetrievalTimeout="20000"/>
@@ -32,6 +33,7 @@
<pbcast.FLUSH timeout="0"/>
</jgroupsConfig>
</transport>
+
<eviction wakeUpInterval="5000">
<root policyClass="org.jboss.cache.eviction.LRUPolicy">
<attribute name="maxNodes">5000</attribute>
Modified: core/trunk/src/test/resources/configs/replSync.xml
===================================================================
--- core/trunk/src/test/resources/configs/replSync.xml 2008-07-07 21:27:37 UTC (rev 6200)
+++ core/trunk/src/test/resources/configs/replSync.xml 2008-07-07 23:13:35 UTC (rev 6201)
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="file:///C:/projects/cache/branches/za_trunk/src/main/resources/jbosscache-config.xsd">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="10000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<serialization useRegionBasedMarshalling="true"/>
@@ -32,6 +33,7 @@
<pbcast.FLUSH timeout="0"/>
</jgroupsConfig>
</transport>
+
<replication>
<sync replTimeout="15000"/>
</replication>
More information about the jbosscache-commits
mailing list