[jboss-cvs] JBoss Messaging SVN: r6454 - in trunk: src/main/org/jboss/messaging/core/deployers/impl and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 16 10:42:12 EDT 2009


Author: jmesnil
Date: 2009-04-16 10:42:11 -0400 (Thu, 16 Apr 2009)
New Revision: 6454

Modified:
   trunk/examples/jms/bridge/server0/jbm-configuration.xml
   trunk/src/main/org/jboss/messaging/core/deployers/impl/QueueDeployer.java
   trunk/src/schemas/jbm-configuration.xsd
   trunk/src/schemas/jbm-queues.xsd
   trunk/tests/config/ConfigurationTest-full-config.xml
   trunk/tests/src/org/jboss/messaging/tests/unit/core/config/impl/QueueDeployerTest.java
Log:
JBMESSAGING-1596: make XML Schemas simpler to read by unordering elements

* updated queue XSD definition so that it is consistent with other elements (characteristics defined with elements inside of attributes)

Modified: trunk/examples/jms/bridge/server0/jbm-configuration.xml
===================================================================
--- trunk/examples/jms/bridge/server0/jbm-configuration.xml	2009-04-16 14:21:52 UTC (rev 6453)
+++ trunk/examples/jms/bridge/server0/jbm-configuration.xml	2009-04-16 14:42:11 UTC (rev 6454)
@@ -29,9 +29,11 @@
       
 	   <!-- We need to create a core queue for the JMS queue explicitly because the bridge will be deployed
       before the JMS queue is deployed, so the first time, it otherwise won't find the queue --> 
-      <queues>     
-      	<queue name="jms.queue.sausage-factory" address="jms.queue.sausage-factory"/>
-      </queues>
+      <queues>   
+         <queue name="jms.queue.sausage-factory">
+            <address>jms.queue.sausage-factory</address>
+         </queue>
+	  </queues>
 
       <!-- We set-up a bridge that forwards from a queue on this node to an address on another node.
       We specify a filter with the bridge, and a transformer too. The filter and transformer are optional -->

Modified: trunk/src/main/org/jboss/messaging/core/deployers/impl/QueueDeployer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/deployers/impl/QueueDeployer.java	2009-04-16 14:21:52 UTC (rev 6453)
+++ trunk/src/main/org/jboss/messaging/core/deployers/impl/QueueDeployer.java	2009-04-16 14:42:11 UTC (rev 6454)
@@ -26,6 +26,7 @@
 import org.jboss.messaging.core.config.cluster.QueueConfiguration;
 import org.jboss.messaging.core.deployers.DeploymentManager;
 import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 import java.util.List;
 
@@ -98,28 +99,30 @@
    private QueueConfiguration parseQueueConfiguration(final Node node)
    {
       String name = node.getAttributes().getNamedItem("name").getNodeValue();
-
-      String address = node.getAttributes().getNamedItem("address").getNodeValue();
-
+      String address = null;
       String filterString = null;
+      boolean durable = false;
+      
+      NodeList children = node.getChildNodes();
 
-      Node filterNode = node.getAttributes().getNamedItem("filter");
-      if (filterNode != null)
+      for (int j = 0; j < children.getLength(); j++)
       {
-         String filterValue = filterNode.getNodeValue();
-         if (!"".equals(filterValue.trim()))
+         Node child = children.item(j);
+
+         if (child.getNodeName().equals("address"))
          {
-            filterString = filterValue;
+            address = child.getTextContent().trim();
          }
+         else if (child.getNodeName().equals("filter"))
+         {
+            filterString = child.getAttributes().getNamedItem("string").getNodeValue();
+         }
+         else if (child.getNodeName().equals("durable"))
+         {
+            durable = Boolean.parseBoolean(child.getTextContent().trim());
+         }
       }
 
-      boolean durable = false;
-      Node durableNode = node.getAttributes().getNamedItem("durable");
-      if (durableNode != null)
-      {
-         durable = Boolean.parseBoolean(durableNode.getNodeValue());
-      }
-
       return new QueueConfiguration(address, name, filterString, durable);
    }
 

Modified: trunk/src/schemas/jbm-configuration.xsd
===================================================================
--- trunk/src/schemas/jbm-configuration.xsd	2009-04-16 14:21:52 UTC (rev 6453)
+++ trunk/src/schemas/jbm-configuration.xsd	2009-04-16 14:42:11 UTC (rev 6454)
@@ -360,7 +360,7 @@
 
 	<xsd:complexType name="bridgeType">	   
 		<xsd:sequence>
-			<xsd:element name="queue-name" type="xsd:string"
+			<xsd:element name="queue-name" type="xsd:IDREF"
 				maxOccurs="1" minOccurs="1">
 			</xsd:element>
 			<xsd:element name="forwarding-address" type="xsd:string"
@@ -476,10 +476,6 @@
 		</xsd:attribute>
 	</xsd:complexType>
 
-	<xsd:complexType name="filterType">
-		<xsd:attribute name="string" type="xsd:string" use="required"></xsd:attribute>
-	</xsd:complexType>
-
 	<xsd:simpleType name="portRange">
 		<xsd:restriction base="xsd:int">
 		      <xsd:minExclusive value="1024"></xsd:minExclusive>

Modified: trunk/src/schemas/jbm-queues.xsd
===================================================================
--- trunk/src/schemas/jbm-queues.xsd	2009-04-16 14:21:52 UTC (rev 6453)
+++ trunk/src/schemas/jbm-queues.xsd	2009-04-16 14:42:11 UTC (rev 6454)
@@ -86,13 +86,23 @@
    <xsd:element name="queue" type="queueType"></xsd:element>
    
     <xsd:complexType name="queueType">
-        <xsd:attribute name="name" type="xsd:string" use="required"></xsd:attribute>
-        <xsd:attribute name="address" type="xsd:string"
-            use="required">
-        </xsd:attribute>
-        <xsd:attribute name="filter" type="xsd:string" use="optional"></xsd:attribute>
-        <xsd:attribute name="durable" type="xsd:boolean"
-            use="optional">
-        </xsd:attribute>
+        <xsd:all>
+            <xsd:element name="address" type="xsd:string"
+                maxOccurs="1" minOccurs="1">
+            </xsd:element>
+            <xsd:element name="filter" type="filterType"
+                maxOccurs="1" minOccurs="0">
+            </xsd:element>
+            <xsd:element name="durable" type="xsd:boolean"
+                maxOccurs="1" minOccurs="0">
+            </xsd:element>
+        </xsd:all>
+        <xsd:attribute name="name" type="xsd:ID" use="required"></xsd:attribute>
     </xsd:complexType>
+    
+    <xsd:complexType name="filterType">
+        <xsd:attribute name="string" type="xsd:string" use="required"></xsd:attribute>
+    </xsd:complexType>
+
+    
 </xsd:schema>

Modified: trunk/tests/config/ConfigurationTest-full-config.xml
===================================================================
--- trunk/tests/config/ConfigurationTest-full-config.xml	2009-04-16 14:21:52 UTC (rev 6453)
+++ trunk/tests/config/ConfigurationTest-full-config.xml	2009-04-16 14:42:11 UTC (rev 6454)
@@ -119,8 +119,16 @@
          </divert>
       </diverts>
       <queues>
-         <queue name="foo" address="bar" filter="color = 'red'" durable="false" />
-         <queue name="foo2" address="bar2" filter="color = 'red'" durable="false" />
+         <queue name="foo">
+            <address>bar</address>
+            <filter string="color='red'" />
+            <durable>false</durable>
+         </queue>
+         <queue name="foo2">
+            <address>bar2</address>
+            <filter string="color='red'" />
+            <durable>false</durable>
+         </queue>
       </queues>
       <bridges>
          <bridge name="bridge">
@@ -181,7 +189,9 @@
    </configuration>
    
    <settings>
-      <queue name="foo3" address="bar" />
+      <queue name="foo3">
+        <address>bar</address>
+      </queue>
    </settings>
 
 </deployment>
\ No newline at end of file

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/config/impl/QueueDeployerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/config/impl/QueueDeployerTest.java	2009-04-16 14:21:52 UTC (rev 6453)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/config/impl/QueueDeployerTest.java	2009-04-16 14:42:11 UTC (rev 6454)
@@ -56,7 +56,11 @@
       QueueDeployer deployer = new QueueDeployer(new FileDeploymentManager(500), configuration);
 
       String xml = "<settings xmlns='urn:jboss:messaging'>"
-                 + "<queue name='foo' address='bar' filter='speed > 88' durable='false' />"
+                 + "   <queue name='foo'>"
+                 + "      <address>bar</address>"
+                 + "      <filter string='speed > 88' />"
+                 + "      <durable>false</durable>" 
+                 + "   </queue>"
                  + "</settings>";
       
       Element rootNode = org.jboss.messaging.utils.XMLUtil.stringToElement(xml);
@@ -85,11 +89,19 @@
                  + "<acceptor><factory-class>FooAcceptor</factory-class></acceptor>"
                  + "</acceptors>"
                  + "<queues>"
-                 + "<queue name='foo' address='bar' filter='speed > 88' durable='false' />"
+                 + "   <queue name='foo'>"
+                 + "      <address>bar</address>"
+                 + "      <filter string='speed > 88' />"
+                 + "      <durable>false</durable>" 
+                 + "   </queue>"
                  + "</queues>"
                  + "</configuration>"
                  + "<settings>"
-                 + "<queue name='foo2' address='bar2' filter='speed > 88' durable='true' />"
+                 + "   <queue name='foo2'>"
+                 + "      <address>bar2</address>"
+                 + "      <filter string='speed > 88' />"
+                 + "      <durable>true</durable>" 
+                 + "   </queue>"
                  + "</settings>"
                  + "</deployment>";
       




More information about the jboss-cvs-commits mailing list