[infinispan-commits] Infinispan SVN: r668 - in trunk/core: src/main/java/org/infinispan/util and 1 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Thu Aug 13 09:18:41 EDT 2009


Author: vblagojevic at jboss.com
Date: 2009-08-13 09:18:41 -0400 (Thu, 13 Aug 2009)
New Revision: 668

Added:
   trunk/core/src/main/java/org/infinispan/util/JaxbSchemaGenerator.java
Removed:
   trunk/core/src/main/resources/schema/infinispan-config-4.0.xsd
Modified:
   trunk/core/pom.xml
Log:
[ISPN-96] - Generate configuration XSD schema and parse configuration XML files 

Modified: trunk/core/pom.xml
===================================================================
--- trunk/core/pom.xml	2009-08-13 11:02:01 UTC (rev 667)
+++ trunk/core/pom.xml	2009-08-13 13:18:41 UTC (rev 668)
@@ -83,4 +83,50 @@
          <scope>test</scope>
       </dependency>
    </dependencies>
+   <build>
+    <plugins>
+      <!-- 
+      Generates XML schema for Infinispan configuration files
+      Run with mvn exec:java
+      For more details see:
+      http://mojo.codehaus.org/exec-maven-plugin/usage.html -->
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>exec-maven-plugin</artifactId>
+        <version>1.1</version>
+        <executions>
+          <execution>
+          	<phase>process-classes</phase>      
+          	<goals>
+            	<goal>java</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <mainClass>org.infinispan.util.JaxbSchemaGenerator</mainClass>
+        </configuration>
+      </plugin>
+      <plugin>
+           <artifactId>maven-antrun-plugin</artifactId>
+           <executions>
+             <execution>
+               <phase>process-classes</phase>
+               <goals>
+                 <goal>run</goal>
+               </goals>
+               <configuration>
+                 <tasks>                    	
+  					<copy todir="${basedir}/src/main/resources/schema" overwrite="true">
+    					<fileset dir="${basedir}" includes="*.xsd"/>
+  					</copy>  	
+  					<delete>
+    					<fileset dir="${basedir}" includes="*.xsd"/>
+					</delete>  						  					  						
+                 </tasks>
+               </configuration>
+             </execution>
+           </executions>
+         </plugin>      
+    </plugins>
+  </build>
 </project>

Added: trunk/core/src/main/java/org/infinispan/util/JaxbSchemaGenerator.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/util/JaxbSchemaGenerator.java	                        (rev 0)
+++ trunk/core/src/main/java/org/infinispan/util/JaxbSchemaGenerator.java	2009-08-13 13:18:41 UTC (rev 668)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.util;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.SchemaOutputResolver;
+import javax.xml.transform.Result;
+import javax.xml.transform.stream.StreamResult;
+
+import org.infinispan.Version;
+import org.infinispan.config.InfinispanConfiguration;
+
+/**
+ * Generates XML schema using JAXB annotations from our configuration class hierarchy.
+ * 
+ * @author Vladimir Blagojevic
+ * @since 4.0
+ */
+public class JaxbSchemaGenerator {
+
+   public static void main(String[] args) throws Exception {
+      final File baseDir = new File(".");
+      class InfinispanSchemaOutputResolver extends SchemaOutputResolver {
+          public Result createOutput( String namespaceUri, String suggestedFileName ) throws IOException {
+              return new StreamResult(new File(baseDir,"infinispan-config-" +Version.getMajorVersion()+ ".xsd"));
+          }
+      }
+      JAXBContext context = JAXBContext.newInstance(InfinispanConfiguration.class);
+      context.generateSchema(new InfinispanSchemaOutputResolver()); 
+   }
+}

Deleted: trunk/core/src/main/resources/schema/infinispan-config-4.0.xsd
===================================================================
--- trunk/core/src/main/resources/schema/infinispan-config-4.0.xsd	2009-08-13 11:02:01 UTC (rev 667)
+++ trunk/core/src/main/resources/schema/infinispan-config-4.0.xsd	2009-08-13 13:18:41 UTC (rev 668)
@@ -1,410 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" targetNamespace="urn:infinispan:config:4.0" xmlns:tns="urn:infinispan:config:4.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
-
-  <xs:element name="infinispan" type="tns:infinispanConfiguration"/>
-
-  <xs:complexType name="infinispanConfiguration">
-    <xs:sequence>
-      <xs:element name="global" type="tns:globalConfiguration" minOccurs="0"/>
-      <xs:element name="default" type="tns:configuration" minOccurs="0"/>
-      <xs:element name="namedCache" type="tns:configuration" minOccurs="0" maxOccurs="unbounded"/>
-    </xs:sequence>
-  </xs:complexType>
-
-  <xs:complexType name="globalConfiguration">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractConfigurationBean">
-        <xs:all>
-          <xs:element name="asyncListenerExecutor" type="tns:factoryClassWithPropertiesType" minOccurs="0"/>
-          <xs:element name="asyncTransportExecutor" type="tns:factoryClassWithPropertiesType" minOccurs="0"/>
-          <xs:element name="evictionScheduledExecutor" type="tns:factoryClassWithPropertiesType" minOccurs="0"/>
-          <xs:element name="replicationQueueScheduledExecutor" type="tns:factoryClassWithPropertiesType" minOccurs="0"/>
-          <xs:element name="globalJmxStatistics" type="tns:globalJmxStatisticsType" minOccurs="0"/>
-          <xs:element name="transport" type="tns:transportType" minOccurs="0"/>
-          <xs:element name="serialization" type="tns:serializationType" minOccurs="0"/>
-          <xs:element name="shutdown" type="tns:shutdownType" minOccurs="0"/>
-        </xs:all>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="abstractConfigurationBean" abstract="true">
-    <xs:sequence/>
-  </xs:complexType>
-
-  <xs:complexType name="factoryClassWithPropertiesType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractConfigurationBeanWithGCR">
-        <xs:sequence>
-          <xs:element name="properties" type="tns:propertiesType" minOccurs="0"/>
-        </xs:sequence>
-        <xs:attribute name="factory" type="xs:string"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="abstractConfigurationBeanWithGCR">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractConfigurationBean">
-        <xs:sequence/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="propertiesType">
-    <xs:sequence>
-      <xs:element name="property" type="tns:property" minOccurs="0" maxOccurs="unbounded"/>
-    </xs:sequence>
-  </xs:complexType>
-
-  <xs:complexType name="property">
-    <xs:sequence/>
-    <xs:attribute name="name" type="xs:string"/>
-    <xs:attribute name="value" type="xs:string"/>
-  </xs:complexType>
-
-  <xs:complexType name="globalJmxStatisticsType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractConfigurationBeanWithGCR">
-        <xs:sequence/>
-        <xs:attribute name="allowDuplicateDomains" type="xs:boolean"/>
-        <xs:attribute name="enabled" type="xs:boolean"/>
-        <xs:attribute name="jmxDomain" type="xs:string"/>
-        <xs:attribute name="mBeanServerLookup" type="xs:string"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="transportType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractConfigurationBeanWithGCR">
-        <xs:sequence>
-          <xs:element name="properties" type="tns:propertiesType" minOccurs="0"/>
-        </xs:sequence>
-        <xs:attribute name="clusterName" type="xs:string"/>
-        <xs:attribute name="distributedSyncTimeout" type="xs:long"/>
-        <xs:attribute name="transportClass" type="xs:string"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="serializationType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractConfigurationBeanWithGCR">
-        <xs:sequence/>
-        <xs:attribute name="marshallerClass" type="xs:string"/>
-        <xs:attribute name="version" type="xs:string"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="shutdownType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractConfigurationBeanWithGCR">
-        <xs:sequence/>
-        <xs:attribute name="hookBehavior" type="tns:shutdownHookBehavior"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="configuration">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:all>
-          <xs:element name="locking" type="tns:lockingType" minOccurs="0"/>
-          <xs:element name="loaders" type="tns:cacheLoaderManagerConfig" minOccurs="0"/>
-          <xs:element name="transaction" type="tns:transactionType" minOccurs="0"/>
-          <xs:element name="customInterceptors" type="tns:customInterceptorsType" minOccurs="0"/>
-          <xs:element name="eviction" type="tns:evictionType" minOccurs="0"/>
-          <xs:element name="expiration" type="tns:expirationType" minOccurs="0"/>
-          <xs:element name="unsafe" type="tns:unsafeType" minOccurs="0"/>
-          <xs:element name="clustering" type="tns:clusteringType" minOccurs="0"/>
-          <xs:element name="jmxStatistics" type="tns:booleanAttributeType" minOccurs="0"/>
-          <xs:element name="lazyDeserialization" type="tns:booleanAttributeType" minOccurs="0"/>
-          <xs:element name="invocationBatching" type="tns:booleanAttributeType" minOccurs="0"/>
-          <xs:element name="deadlockDetection" type="tns:deadlockDetectionType" minOccurs="0"/>
-        </xs:all>
-        <xs:attribute name="name" type="xs:string"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="abstractNamedCacheConfigurationBean" abstract="true">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractConfigurationBean">
-        <xs:sequence/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="lockingType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence/>
-        <xs:attribute name="concurrencyLevel" type="xs:int"/>
-        <xs:attribute name="isolationLevel" type="tns:isolationLevel"/>
-        <xs:attribute name="lockAcquisitionTimeout" type="xs:long"/>
-        <xs:attribute name="useLockStriping" type="xs:boolean"/>
-        <xs:attribute name="writeSkewCheck" type="xs:boolean"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="cacheLoaderManagerConfig">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence>
-          <xs:element name="loader" type="tns:abstractCacheStoreConfig" minOccurs="0" maxOccurs="unbounded"/>
-        </xs:sequence>
-        <xs:attribute name="passivation" type="xs:boolean"/>
-        <xs:attribute name="preload" type="xs:boolean"/>
-        <xs:attribute name="shared" type="xs:boolean"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="abstractCacheStoreConfig">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractCacheLoaderConfig">
-        <xs:sequence>
-          <xs:element name="singletonStore" type="tns:singletonStoreConfig" minOccurs="0"/>
-          <xs:element name="async" type="tns:asyncStoreConfig" minOccurs="0"/>
-        </xs:sequence>
-        <xs:attribute name="ignoreModifications" type="xs:boolean"/>
-        <xs:attribute name="fetchPersistentState" type="xs:boolean"/>
-        <xs:attribute name="purgeOnStartup" type="xs:boolean"/>
-        <xs:attribute name="purgeSynchronously" type="xs:boolean"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="abstractCacheLoaderConfig">
-    <xs:complexContent>
-      <xs:extension base="tns:pluggableConfigurationComponent">
-        <xs:sequence/>
-        <xs:attribute name="class" type="xs:string"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="pluggableConfigurationComponent" abstract="true">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence>
-          <xs:element name="properties" type="tns:propertiesType" minOccurs="0"/>
-        </xs:sequence>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="singletonStoreConfig">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence/>
-        <xs:attribute name="enabled" type="xs:boolean"/>
-        <xs:attribute name="pushStateWhenCoordinator" type="xs:boolean"/>
-        <xs:attribute name="pushStateTimeout" type="xs:long"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="asyncStoreConfig">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence/>
-        <xs:attribute name="enabled" type="xs:boolean"/>
-        <xs:attribute name="threadPoolSize" type="xs:int"/>
-        <xs:attribute name="mapLockTimeout" type="xs:long"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="transactionType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence/>
-        <xs:attribute name="syncCommitPhase" type="xs:boolean"/>
-        <xs:attribute name="syncRollbackPhase" type="xs:boolean"/>
-        <xs:attribute name="transactionManagerLookupClass" type="xs:string"/>
-        <xs:attribute name="useEagerLocking" type="xs:boolean"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="customInterceptorsType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence>
-          <xs:element name="interceptor" type="tns:interceptor" minOccurs="0" maxOccurs="unbounded"/>
-        </xs:sequence>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="interceptor">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence>
-          <xs:element name="properties" type="tns:propertiesType" minOccurs="0"/>
-        </xs:sequence>
-        <xs:attribute name="index" type="xs:int"/>
-        <xs:attribute name="after" type="xs:string"/>
-        <xs:attribute name="before" type="xs:string"/>
-        <xs:attribute name="position" type="tns:position"/>
-        <xs:attribute name="class" type="xs:string"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="evictionType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence/>
-        <xs:attribute name="maxEntries" type="xs:int"/>
-        <xs:attribute name="strategy" type="tns:evictionStrategy"/>
-        <xs:attribute name="wakeUpInterval" type="xs:long"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="expirationType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence/>
-        <xs:attribute name="lifespan" type="xs:long"/>
-        <xs:attribute name="maxIdle" type="xs:long"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="unsafeType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence/>
-        <xs:attribute name="unreliableReturnValues" type="xs:boolean"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="clusteringType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:all>
-          <xs:element name="sync" type="tns:syncType" minOccurs="0"/>
-          <xs:element name="stateRetrieval" type="tns:stateRetrievalType" minOccurs="0"/>
-          <xs:element name="l1" type="tns:l1Type" minOccurs="0"/>
-          <xs:element name="async" type="tns:asyncType" minOccurs="0"/>
-          <xs:element name="hash" type="tns:hashType" minOccurs="0"/>
-        </xs:all>
-        <xs:attribute name="mode" type="xs:string"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="syncType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence/>
-        <xs:attribute name="replTimeout" type="xs:long"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="stateRetrievalType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence/>
-        <xs:attribute name="fetchInMemoryState" type="xs:boolean"/>
-        <xs:attribute name="timeout" type="xs:long"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="l1Type">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence/>
-        <xs:attribute name="enabled" type="xs:boolean"/>
-        <xs:attribute name="lifespan" type="xs:long"/>
-        <xs:attribute name="onRehash" type="xs:boolean"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="asyncType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence/>
-        <xs:attribute name="asyncMarshalling" type="xs:boolean"/>
-        <xs:attribute name="replQueueInterval" type="xs:long"/>
-        <xs:attribute name="replQueueMaxElements" type="xs:int"/>
-        <xs:attribute name="useReplQueue" type="xs:boolean"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="hashType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence/>
-        <xs:attribute name="class" type="xs:string"/>
-        <xs:attribute name="numOwners" type="xs:int"/>
-        <xs:attribute name="rehashRpcTimeout" type="xs:long"/>
-        <xs:attribute name="rehashWait" type="xs:long"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="booleanAttributeType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence/>
-        <xs:attribute name="enabled" type="xs:boolean"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:complexType name="deadlockDetectionType">
-    <xs:complexContent>
-      <xs:extension base="tns:abstractNamedCacheConfigurationBean">
-        <xs:sequence/>
-        <xs:attribute name="enabled" type="xs:boolean"/>
-        <xs:attribute name="spinDuration" type="xs:long"/>
-      </xs:extension>
-    </xs:complexContent>
-  </xs:complexType>
-
-  <xs:simpleType name="shutdownHookBehavior">
-    <xs:restriction base="xs:string">
-      <xs:enumeration value="DEFAULT"/>
-      <xs:enumeration value="REGISTER"/>
-      <xs:enumeration value="DONT_REGISTER"/>
-    </xs:restriction>
-  </xs:simpleType>
-
-  <xs:simpleType name="isolationLevel">
-    <xs:restriction base="xs:string">
-      <xs:enumeration value="NONE"/>
-      <xs:enumeration value="SERIALIZABLE"/>
-      <xs:enumeration value="REPEATABLE_READ"/>
-      <xs:enumeration value="READ_COMMITTED"/>
-      <xs:enumeration value="READ_UNCOMMITTED"/>
-    </xs:restriction>
-  </xs:simpleType>
-
-  <xs:simpleType name="position">
-    <xs:restriction base="xs:string">
-      <xs:enumeration value="FIRST"/>
-      <xs:enumeration value="LAST"/>
-    </xs:restriction>
-  </xs:simpleType>
-
-  <xs:simpleType name="evictionStrategy">
-    <xs:restriction base="xs:string">
-      <xs:enumeration value="NONE"/>
-      <xs:enumeration value="FIFO"/>
-      <xs:enumeration value="LRU"/>
-    </xs:restriction>
-  </xs:simpleType>
-</xs:schema>
-



More information about the infinispan-commits mailing list