[hornetq-commits] JBoss hornetq SVN: r8861 - in trunk: src/main/org/hornetq/jms/server/config/impl and 3 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Feb 3 21:12:56 EST 2010


Author: clebert.suconic at jboss.com
Date: 2010-02-03 21:12:55 -0500 (Wed, 03 Feb 2010)
New Revision: 8861

Added:
   trunk/src/main/org/hornetq/jms/server/impl/JMSServerConfigParserImpl.java
   trunk/tests/src/org/hornetq/tests/integration/jms/server/config/JMSServerConfigParserTest.java
Removed:
   trunk/tests/src/org/hornetq/tests/util/junit/
Modified:
   trunk/build-hornetq.xml
   trunk/build-maven.xml
   trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java
   trunk/src/main/org/hornetq/jms/server/impl/JMSServerDeployer.java
Log:
 Refactoring parser of xml jms configuration for a better integration with the Application Server 5 and 6 and adding install script on build-maven.xml for upload on local repository for development and tests purposes on the AS integration

Modified: trunk/build-hornetq.xml
===================================================================
--- trunk/build-hornetq.xml	2010-01-31 11:49:12 UTC (rev 8860)
+++ trunk/build-hornetq.xml	2010-02-04 02:12:55 UTC (rev 8861)
@@ -637,7 +637,7 @@
    <!-- ======================================================================================== -->
 
    <target name="jar"
-           depends="jar-core, jar-core-client, jar-jms, jar-jms-client, jar-transports, jar-jboss-integration, jar-jboss-service, jar-bootstrap, jar-logging, jar-ra, jar-mc, jar-jnp-client">
+           depends="jar-core, jar-core-client, jar-jms, jar-jms-client, jar-transports, jar-jboss-integration, jar-jboss-service, jar-bootstrap, jar-logging, jar-ra, jar-mc, jar-jnp-client, jar-resources">
    </target>
 	
    <target name="jar-jnp-client" depends="init">
@@ -792,7 +792,7 @@
    </target>
 
    <property name="build.examples.dir" value="${build.dir}/examples"/>
-   <target name="jar-resources" depends="clean,init">
+   <target name="jar-resources" depends="init">
       <jar jarfile="${build.jars.dir}/${resources.jar.name}">
          <fileset dir=".">
            <include name="examples/**"/>

Modified: trunk/build-maven.xml
===================================================================
--- trunk/build-maven.xml	2010-01-31 11:49:12 UTC (rev 8860)
+++ trunk/build-maven.xml	2010-02-04 02:12:55 UTC (rev 8861)
@@ -13,7 +13,7 @@
   -->
 
 <project default="upload" name="HornetQ">
-   <property name="hornetq.version" value="2.0.0.CR3"/>
+   <property name="hornetq.version" value="2.0.0.snapshot"/>
    <property name="build.dir" value="build"/>
    <property name="jars.dir" value="${build.dir}/jars"/>
 
@@ -88,6 +88,60 @@
    </target>
 
 
+   <target name="install">
+      <antcall target="upload-local-target">
+          <param name="artifact.id" value="hornetq-resources"/>
+      </antcall>
+
+      <antcall target="upload-local-target">
+          <param name="artifact.id" value="hornetq-jms"/>
+      </antcall>
+
+      <antcall target="upload-local-target">
+          <param name="artifact.id" value="hornetq-jms-client"/>
+      </antcall>
+
+      <antcall target="upload-local-target">
+          <param name="artifact.id" value="hornetq-core"/>
+      </antcall>
+
+      <antcall target="upload-local-target">
+          <param name="artifact.id" value="hornetq-jboss-as-integration"/>
+      </antcall>
+
+      <antcall target="upload-local-target">
+          <param name="artifact.id" value="hornetq-bootstrap"/>
+      </antcall>
+
+      <antcall target="upload-local-target">
+          <param name="artifact.id" value="hornetq-core-client"/>
+      </antcall>
+
+      <antcall target="upload-local-target">
+          <param name="artifact.id" value="hornetq-logging"/>
+      </antcall>
+
+      <antcall target="upload-local-target">
+          <param name="artifact.id" value="hornetq-ra"/>
+      </antcall>
+
+      <antcall target="upload-local-target">
+          <param name="artifact.id" value="hornetq-transports"/>
+      </antcall>
+
+   </target>
+
+   <target name="upload-local-target">
+       <exec executable="mvn">
+        <arg value="install:install-file"/>
+        <arg value="-DgroupId=org.hornetq"/>
+        <arg value="-DartifactId=${artifact.id}"/>
+        <arg value="-Dversion=${hornetq.version}"/>
+        <arg value="-Dpackaging=jar"/>
+        <arg value="-Dfile=./build/jars/${artifact.id}.jar"/>
+       </exec>
+   </target>
+
    <target name="upload">
       <exec executable="mvn">
          <arg value="-s settings.xml"/>
@@ -172,4 +226,4 @@
       <checksum file="${dest.dir}/${jarName}/maven-metadata.xml" algorithm="sha1"/>
    </target>
 
-</project>
\ No newline at end of file
+</project>

Modified: trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java	2010-01-31 11:49:12 UTC (rev 8860)
+++ trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java	2010-02-04 02:12:55 UTC (rev 8861)
@@ -19,7 +19,6 @@
 import org.hornetq.api.core.Pair;
 import org.hornetq.api.core.TransportConfiguration;
 import org.hornetq.api.core.client.HornetQClient;
-import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
 import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
 
 /**
@@ -138,7 +137,6 @@
 
    public ConnectionFactoryConfigurationImpl(final String name,
                                              final List<Pair<TransportConfiguration, TransportConfiguration>> transportConfigs,
-                                             final TransportConfiguration backupConfig,
                                              final String... bindings)
    {
       this(name, bindings);

Added: trunk/src/main/org/hornetq/jms/server/impl/JMSServerConfigParserImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/impl/JMSServerConfigParserImpl.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/jms/server/impl/JMSServerConfigParserImpl.java	2010-02-04 02:12:55 UTC (rev 8861)
@@ -0,0 +1,535 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.server.impl;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hornetq.api.core.HornetQException;
+import org.hornetq.api.core.Pair;
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.api.core.client.HornetQClient;
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.config.impl.Validators;
+import org.hornetq.core.logging.Logger;
+import org.hornetq.core.server.cluster.DiscoveryGroupConfiguration;
+import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
+import org.hornetq.jms.server.config.JMSConfiguration;
+import org.hornetq.jms.server.config.QueueConfiguration;
+import org.hornetq.jms.server.config.TopicConfiguration;
+import org.hornetq.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
+import org.hornetq.jms.server.config.impl.JMSConfigurationImpl;
+import org.hornetq.jms.server.config.impl.QueueConfigurationImpl;
+import org.hornetq.jms.server.config.impl.TopicConfigurationImpl;
+import org.hornetq.utils.XMLConfigurationUtil;
+import org.hornetq.utils.XMLUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * It parses JMS Configuration Files
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class JMSServerConfigParserImpl
+{
+   private static final Logger log = Logger.getLogger(JMSServerConfigParserImpl.class);
+
+   // Constants -----------------------------------------------------
+
+   protected static final String NAME_ATTR = "name";
+
+   // Attributes ----------------------------------------------------
+
+   private final Configuration configuration;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public JMSServerConfigParserImpl(final Configuration configuration)
+   {
+      this.configuration = configuration;
+   }
+
+   // Public --------------------------------------------------------
+
+   /**
+    * Parse the JMS Configuration XML as a JMSConfiguration object
+    */
+   public JMSConfiguration parseConfiguration(final InputStream stream) throws Exception
+   {
+      Reader reader = new InputStreamReader(stream);
+      String xml = org.hornetq.utils.XMLUtil.readerToString(reader);
+      xml = XMLUtil.replaceSystemProps(xml);
+      return parseConfiguration(XMLUtil.stringToElement(xml));
+   }
+
+   /**
+    * Parse the JMS Configuration XML as a JMSConfiguration object
+    */
+   public JMSConfiguration parseConfiguration(final Node rootnode) throws Exception
+   {
+
+      ArrayList<QueueConfiguration> queues = new ArrayList<QueueConfiguration>();
+      ArrayList<TopicConfiguration> topics = new ArrayList<TopicConfiguration>();
+      ArrayList<ConnectionFactoryConfiguration> cfs = new ArrayList<ConnectionFactoryConfiguration>();
+
+      Element e = (Element)rootnode;
+
+      org.hornetq.utils.XMLUtil.validate(rootnode, "schema/hornetq-jms.xsd");
+
+      String elements[] = new String[] { JMSServerDeployer.QUEUE_NODE_NAME,
+                                        JMSServerDeployer.TOPIC_NODE_NAME,
+                                        JMSServerDeployer.CONNECTION_FACTORY_NODE_NAME };
+      for (String element : elements)
+      {
+         NodeList children = e.getElementsByTagName(element);
+         for (int i = 0; i < children.getLength(); i++)
+         {
+            Node node = children.item(i);
+            Node keyNode = node.getAttributes().getNamedItem(JMSServerConfigParserImpl.NAME_ATTR);
+            if (keyNode == null)
+            {
+               JMSServerConfigParserImpl.log.error("key attribute missing for configuration " + node);
+               continue;
+            }
+
+            if (node.getNodeName().equals(JMSServerDeployer.CONNECTION_FACTORY_NODE_NAME))
+            {
+               cfs.add(parseConnectionFactoryConfiguration(node));
+            }
+            else if (node.getNodeName().equals(JMSServerDeployer.TOPIC_NODE_NAME))
+            {
+               topics.add(parseTopicConfiguration(node));
+            }
+            else if (node.getNodeName().equals(JMSServerDeployer.QUEUE_NODE_NAME))
+            {
+               queues.add(parseQueueConfiguration(node));
+            }
+         }
+      }
+
+      JMSConfiguration value = newConfig(queues, topics, cfs);
+
+      return value;
+   }
+
+   /**
+    * Parse the topic node as a TopicConfiguration object
+    * @param node
+    * @return
+    * @throws Exception
+    */
+   public TopicConfiguration parseTopicConfiguration(final Node node) throws Exception
+   {
+      String topicName = node.getAttributes().getNamedItem(JMSServerConfigParserImpl.NAME_ATTR).getNodeValue();
+      NodeList children = node.getChildNodes();
+      ArrayList<String> jndiNames = new ArrayList<String>();
+      for (int i = 0; i < children.getLength(); i++)
+      {
+         Node child = children.item(i);
+
+         if (JMSServerDeployer.ENTRY_NODE_NAME.equals(children.item(i).getNodeName()))
+         {
+            String jndiElement = child.getAttributes().getNamedItem("name").getNodeValue();
+            jndiNames.add(jndiElement);
+         }
+      }
+
+      String[] strBindings = jndiNames.toArray(new String[jndiNames.size()]);
+
+      return newTopic(topicName, strBindings);
+
+   }
+
+   /**
+    * Parse the Queue Configuration node as a QueueConfiguration object
+    * @param node
+    * @return
+    * @throws Exception
+    */
+   public QueueConfiguration parseQueueConfiguration(final Node node) throws Exception
+   {
+      Element e = (Element)node;
+      NamedNodeMap atts = node.getAttributes();
+      String queueName = atts.getNamedItem(JMSServerConfigParserImpl.NAME_ATTR).getNodeValue();
+      String selectorString = null;
+      boolean durable = XMLConfigurationUtil.getBoolean(e, "durable", JMSServerDeployer.DEFAULT_QUEUE_DURABILITY);
+      NodeList children = node.getChildNodes();
+      ArrayList<String> jndiNames = new ArrayList<String>();
+      for (int i = 0; i < children.getLength(); i++)
+      {
+         Node child = children.item(i);
+
+         if (JMSServerDeployer.ENTRY_NODE_NAME.equals(children.item(i).getNodeName()))
+         {
+            String jndiName = child.getAttributes().getNamedItem("name").getNodeValue();
+            jndiNames.add(jndiName);
+         }
+         else if (JMSServerDeployer.QUEUE_SELECTOR_NODE_NAME.equals(children.item(i).getNodeName()))
+         {
+            Node selectorNode = children.item(i);
+            Node attNode = selectorNode.getAttributes().getNamedItem("string");
+            selectorString = attNode.getNodeValue();
+         }
+      }
+
+      String jndiArray[] = jndiNames.toArray(new String[jndiNames.size()]);
+      return newQueue(queueName, selectorString, durable, jndiArray);
+   }
+
+   /**
+    * Parse the Connection Configuration node as a ConnectionFactoryConfiguration object
+    * @param node
+    * @return
+    * @throws Exception
+    */
+   public ConnectionFactoryConfiguration parseConnectionFactoryConfiguration(final Node node) throws Exception
+   {
+      if (!node.getNodeName().equals(JMSServerDeployer.CONNECTION_FACTORY_NODE_NAME))
+      {
+         // sanity check, this shouldn't ever happen
+         throw new HornetQException(HornetQException.INTERNAL_ERROR, "Invalid node " + node.getNodeName() +
+                                                                     " at parseConnectionFactory");
+      }
+      Element e = (Element)node;
+
+      String name = node.getAttributes().getNamedItem(JMSServerConfigParserImpl.NAME_ATTR).getNodeValue();
+
+      long clientFailureCheckPeriod = XMLConfigurationUtil.getLong(e,
+                                                                   "client-failure-check-period",
+                                                                   HornetQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
+                                                                   Validators.MINUS_ONE_OR_GT_ZERO);
+      long connectionTTL = XMLConfigurationUtil.getLong(e,
+                                                        "connection-ttl",
+                                                        HornetQClient.DEFAULT_CONNECTION_TTL,
+                                                        Validators.MINUS_ONE_OR_GE_ZERO);
+      long callTimeout = XMLConfigurationUtil.getLong(e,
+                                                      "call-timeout",
+                                                      HornetQClient.DEFAULT_CALL_TIMEOUT,
+                                                      Validators.GE_ZERO);
+      String clientID = XMLConfigurationUtil.getString(e, "client-id", null, Validators.NO_CHECK);
+      int dupsOKBatchSize = XMLConfigurationUtil.getInteger(e,
+                                                            "dups-ok-batch-size",
+                                                            HornetQClient.DEFAULT_ACK_BATCH_SIZE,
+                                                            Validators.GT_ZERO);
+      int transactionBatchSize = XMLConfigurationUtil.getInteger(e,
+                                                                 "transaction-batch-size",
+                                                                 HornetQClient.DEFAULT_ACK_BATCH_SIZE,
+                                                                 Validators.GT_ZERO);
+      int consumerWindowSize = XMLConfigurationUtil.getInteger(e,
+                                                               "consumer-window-size",
+                                                               HornetQClient.DEFAULT_CONSUMER_WINDOW_SIZE,
+                                                               Validators.MINUS_ONE_OR_GE_ZERO);
+      int producerWindowSize = XMLConfigurationUtil.getInteger(e,
+                                                               "producer-window-size",
+                                                               HornetQClient.DEFAULT_PRODUCER_WINDOW_SIZE,
+                                                               Validators.MINUS_ONE_OR_GT_ZERO);
+      int consumerMaxRate = XMLConfigurationUtil.getInteger(e,
+                                                            "consumer-max-rate",
+                                                            HornetQClient.DEFAULT_CONSUMER_MAX_RATE,
+                                                            Validators.MINUS_ONE_OR_GT_ZERO);
+      int confirmationWindowSize = XMLConfigurationUtil.getInteger(e,
+                                                                   "confirmation-window-size",
+                                                                   HornetQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE,
+                                                                   Validators.MINUS_ONE_OR_GT_ZERO);
+      int producerMaxRate = XMLConfigurationUtil.getInteger(e,
+                                                            "producer-max-rate",
+                                                            HornetQClient.DEFAULT_PRODUCER_MAX_RATE,
+                                                            Validators.MINUS_ONE_OR_GT_ZERO);
+      boolean cacheLargeMessagesClient = XMLConfigurationUtil.getBoolean(e,
+                                                                         "cache-large-message-client",
+                                                                         HornetQClient.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT);
+      int minLargeMessageSize = XMLConfigurationUtil.getInteger(e,
+                                                                "min-large-message-size",
+                                                                HornetQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
+                                                                Validators.GT_ZERO);
+      boolean blockOnAcknowledge = XMLConfigurationUtil.getBoolean(e,
+                                                                   "block-on-acknowledge",
+                                                                   HornetQClient.DEFAULT_BLOCK_ON_ACKNOWLEDGE);
+      boolean blockOnNonDurableSend = XMLConfigurationUtil.getBoolean(e,
+                                                                      "block-on-non-durable-send",
+                                                                      HornetQClient.DEFAULT_BLOCK_ON_NON_DURABLE_SEND);
+      boolean blockOnDurableSend = XMLConfigurationUtil.getBoolean(e,
+                                                                   "block-on-durable-send",
+                                                                   HornetQClient.DEFAULT_BLOCK_ON_DURABLE_SEND);
+      boolean autoGroup = XMLConfigurationUtil.getBoolean(e, "auto-group", HornetQClient.DEFAULT_AUTO_GROUP);
+      boolean preAcknowledge = XMLConfigurationUtil.getBoolean(e,
+                                                               "pre-acknowledge",
+                                                               HornetQClient.DEFAULT_PRE_ACKNOWLEDGE);
+      long retryInterval = XMLConfigurationUtil.getLong(e,
+                                                        "retry-interval",
+                                                        HornetQClient.DEFAULT_RETRY_INTERVAL,
+                                                        Validators.GT_ZERO);
+      double retryIntervalMultiplier = XMLConfigurationUtil.getDouble(e,
+                                                                      "retry-interval-multiplier",
+                                                                      HornetQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
+                                                                      Validators.GT_ZERO);
+      long maxRetryInterval = XMLConfigurationUtil.getLong(e,
+                                                           "max-retry-interval",
+                                                           HornetQClient.DEFAULT_MAX_RETRY_INTERVAL,
+                                                           Validators.GT_ZERO);
+      int reconnectAttempts = XMLConfigurationUtil.getInteger(e,
+                                                              "reconnect-attempts",
+                                                              HornetQClient.DEFAULT_RECONNECT_ATTEMPTS,
+                                                              Validators.MINUS_ONE_OR_GE_ZERO);
+      boolean failoverOnServerShutdown = XMLConfigurationUtil.getBoolean(e,
+                                                                         "failover-on-server-shutdown",
+                                                                         HornetQClient.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN);
+      boolean useGlobalPools = XMLConfigurationUtil.getBoolean(e,
+                                                               "use-global-pools",
+                                                               HornetQClient.DEFAULT_USE_GLOBAL_POOLS);
+      int scheduledThreadPoolMaxSize = XMLConfigurationUtil.getInteger(e,
+                                                                       "scheduled-thread-pool-max-size",
+                                                                       HornetQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
+                                                                       Validators.MINUS_ONE_OR_GT_ZERO);
+      int threadPoolMaxSize = XMLConfigurationUtil.getInteger(e,
+                                                              "thread-pool-max-size",
+                                                              HornetQClient.DEFAULT_THREAD_POOL_MAX_SIZE,
+                                                              Validators.MINUS_ONE_OR_GT_ZERO);
+      String connectionLoadBalancingPolicyClassName = XMLConfigurationUtil.getString(e,
+                                                                                     "connection-load-balancing-policy-class-name",
+                                                                                     HornetQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+                                                                                     Validators.NOT_NULL_OR_EMPTY);
+      long discoveryInitialWaitTimeout = XMLConfigurationUtil.getLong(e,
+                                                                      "discovery-initial-wait-timeout",
+                                                                      HornetQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT,
+                                                                      Validators.GT_ZERO);
+      String groupid = XMLConfigurationUtil.getString(e, "group-id", null, Validators.NO_CHECK);
+      List<String> jndiBindings = new ArrayList<String>();
+      List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
+      DiscoveryGroupConfiguration discoveryGroupConfiguration = null;
+
+      NodeList children = node.getChildNodes();
+
+      for (int j = 0; j < children.getLength(); j++)
+      {
+         Node child = children.item(j);
+
+         if (JMSServerDeployer.ENTRIES_NODE_NAME.equals(child.getNodeName()))
+         {
+            NodeList entries = child.getChildNodes();
+            for (int i = 0; i < entries.getLength(); i++)
+            {
+               Node entry = entries.item(i);
+               if (JMSServerDeployer.ENTRY_NODE_NAME.equals(entry.getNodeName()))
+               {
+                  String jndiName = entry.getAttributes().getNamedItem("name").getNodeValue();
+
+                  jndiBindings.add(jndiName);
+               }
+            }
+         }
+         else if (JMSServerDeployer.CONNECTORS_NODE_NAME.equals(child.getNodeName()))
+         {
+            NodeList entries = child.getChildNodes();
+            for (int i = 0; i < entries.getLength(); i++)
+            {
+               Node entry = entries.item(i);
+               if (JMSServerDeployer.CONNECTOR_REF_ELEMENT.equals(entry.getNodeName()))
+               {
+                  String connectorName = entry.getAttributes().getNamedItem("connector-name").getNodeValue();
+                  TransportConfiguration connector = configuration.getConnectorConfigurations().get(connectorName);
+
+                  if (connector == null)
+                  {
+                     JMSServerConfigParserImpl.log.warn("There is no connector with name '" + connectorName +
+                                                        "' deployed.");
+                     throw new HornetQException(HornetQException.ILLEGAL_STATE,
+                                                "There is no connector with name '" + connectorName + "' deployed.");
+                  }
+
+                  TransportConfiguration backupConnector = null;
+                  Node backupNode = entry.getAttributes().getNamedItem("backup-connector-name");
+                  if (backupNode != null)
+                  {
+                     String backupConnectorName = backupNode.getNodeValue();
+                     backupConnector = configuration.getConnectorConfigurations().get(backupConnectorName);
+
+                     if (backupConnector == null)
+                     {
+                        JMSServerConfigParserImpl.log.warn("There is no backup connector with name '" + backupConnectorName +
+                                                           "' deployed.");
+                        throw new HornetQException(HornetQException.ILLEGAL_STATE,
+                                                   "There is no backup connector with name '" + backupConnectorName +
+                                                            "' deployed.");
+                     }
+                  }
+
+                  connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(connector,
+                                                                                                backupConnector));
+               }
+            }
+         }
+         else if (JMSServerDeployer.DISCOVERY_GROUP_ELEMENT.equals(child.getNodeName()))
+         {
+            String discoveryGroupName = child.getAttributes().getNamedItem("discovery-group-name").getNodeValue();
+
+            discoveryGroupConfiguration = configuration.getDiscoveryGroupConfigurations().get(discoveryGroupName);
+
+            if (discoveryGroupConfiguration == null)
+            {
+               JMSServerConfigParserImpl.log.warn("There is no discovery group with name '" + discoveryGroupName +
+                                                  "' deployed.");
+
+               throw new HornetQException(HornetQException.ILLEGAL_STATE,
+                                          "There is no discovery group with name '" + discoveryGroupName +
+                                                   "' deployed.");
+            }
+         }
+      }
+
+      ConnectionFactoryConfiguration cfConfig;
+
+      String[] strbindings = jndiBindings.toArray(new String[jndiBindings.size()]);
+
+      if (discoveryGroupConfiguration != null)
+      {
+         cfConfig = newCF(name, discoveryInitialWaitTimeout, discoveryGroupConfiguration, strbindings);
+      }
+      else
+      {
+         cfConfig = newCF(name, connectorConfigs, strbindings);
+      }
+      
+      cfConfig.setInitialWaitTimeout(discoveryInitialWaitTimeout);
+      cfConfig.setClientID(clientID);
+      cfConfig.setClientFailureCheckPeriod(clientFailureCheckPeriod);
+      cfConfig.setConnectionTTL(connectionTTL);
+      cfConfig.setCallTimeout(callTimeout);
+      cfConfig.setCacheLargeMessagesClient(cacheLargeMessagesClient);
+      cfConfig.setMinLargeMessageSize(minLargeMessageSize);
+      cfConfig.setConsumerWindowSize(consumerWindowSize);
+      cfConfig.setConsumerMaxRate(consumerMaxRate);
+      cfConfig.setConfirmationWindowSize(confirmationWindowSize);
+      cfConfig.setProducerWindowSize(producerWindowSize);
+      cfConfig.setProducerMaxRate(producerMaxRate);
+      cfConfig.setBlockOnAcknowledge(blockOnAcknowledge);
+      cfConfig.setBlockOnDurableSend(blockOnDurableSend);
+      cfConfig.setBlockOnNonDurableSend(blockOnNonDurableSend);
+      cfConfig.setAutoGroup(autoGroup);
+      cfConfig.setPreAcknowledge(preAcknowledge);
+      cfConfig.setLoadBalancingPolicyClassName(connectionLoadBalancingPolicyClassName);
+      cfConfig.setTransactionBatchSize(transactionBatchSize);
+      cfConfig.setDupsOKBatchSize(dupsOKBatchSize);
+      cfConfig.setUseGlobalPools(useGlobalPools);
+      cfConfig.setScheduledThreadPoolMaxSize(scheduledThreadPoolMaxSize);
+      cfConfig.setThreadPoolMaxSize(threadPoolMaxSize);
+      cfConfig.setRetryInterval(retryInterval);
+      cfConfig.setRetryIntervalMultiplier(retryIntervalMultiplier);
+      cfConfig.setMaxRetryInterval(maxRetryInterval);
+      cfConfig.setReconnectAttempts(reconnectAttempts);
+      cfConfig.setFailoverOnServerShutdown(failoverOnServerShutdown);
+      cfConfig.setGroupID(groupid);
+      return cfConfig;
+   }
+
+   /**
+    * hook for integration layers 
+    * @param name
+    * @param connectorConfigs
+    * @param strbindings
+    * @return
+    */
+   protected ConnectionFactoryConfiguration newCF(final String name,
+                                                  final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+                                                  final String[] strbindings)
+   {
+      ConnectionFactoryConfigurationImpl cfConfig;
+      cfConfig = new ConnectionFactoryConfigurationImpl(name, connectorConfigs, strbindings);
+      return cfConfig;
+   }
+
+   /**
+    * hook for integration layers 
+    * @param name
+    * @param discoveryInitialWaitTimeout
+    * @param discoveryGroupConfiguration
+    * @param strbindings
+    * @return
+    */
+   protected ConnectionFactoryConfigurationImpl newCF(final String name,
+                                                      final long discoveryInitialWaitTimeout,
+                                                      final DiscoveryGroupConfiguration discoveryGroupConfiguration,
+                                                      final String[] strbindings)
+   {
+      ConnectionFactoryConfigurationImpl cfConfig;
+      cfConfig = new ConnectionFactoryConfigurationImpl(name,
+                                                        discoveryGroupConfiguration.getGroupAddress(),
+                                                        discoveryGroupConfiguration.getGroupPort(),
+                                                        strbindings);
+      cfConfig.setDiscoveryRefreshTimeout(discoveryGroupConfiguration.getRefreshTimeout());
+      cfConfig.setInitialWaitTimeout(discoveryInitialWaitTimeout);
+      return cfConfig;
+   }
+
+   /**
+    * hook for integration layers 
+    * @param topicName
+    * @param strBindings
+    * @return
+    */
+   protected TopicConfiguration newTopic(final String topicName, final String[] strBindings)
+   {
+      return new TopicConfigurationImpl(topicName, strBindings);
+   }
+
+   /**
+    * hook for integration layers 
+    * @param queueName
+    * @param selectorString
+    * @param durable
+    * @param jndiArray
+    * @return
+    */
+   protected QueueConfiguration newQueue(final String queueName,
+                                         final String selectorString,
+                                         final boolean durable,
+                                         final String[] jndiArray)
+   {
+      return new QueueConfigurationImpl(queueName, selectorString, durable, jndiArray);
+   }
+
+   /**
+    * hook for integration layers 
+    * @param queues
+    * @param topics
+    * @param cfs
+    * @return
+    */
+   protected JMSConfiguration newConfig(final ArrayList<QueueConfiguration> queues,
+                                        final ArrayList<TopicConfiguration> topics,
+                                        final ArrayList<ConnectionFactoryConfiguration> cfs)
+   {
+      JMSConfiguration value = new JMSConfigurationImpl(cfs, queues, topics);
+      return value;
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Modified: trunk/src/main/org/hornetq/jms/server/impl/JMSServerDeployer.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/impl/JMSServerDeployer.java	2010-01-31 11:49:12 UTC (rev 8860)
+++ trunk/src/main/org/hornetq/jms/server/impl/JMSServerDeployer.java	2010-02-04 02:12:55 UTC (rev 8861)
@@ -14,23 +14,16 @@
 package org.hornetq.jms.server.impl;
 
 import java.util.ArrayList;
-import java.util.List;
 
-import org.hornetq.api.core.Pair;
-import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.HornetQClient;
 import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.Validators;
 import org.hornetq.core.deployers.DeploymentManager;
 import org.hornetq.core.deployers.impl.XmlDeployer;
 import org.hornetq.core.logging.Logger;
-import org.hornetq.core.server.cluster.DiscoveryGroupConfiguration;
 import org.hornetq.jms.server.JMSServerManager;
-import org.hornetq.utils.XMLConfigurationUtil;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
+import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
+import org.hornetq.jms.server.config.QueueConfiguration;
+import org.hornetq.jms.server.config.TopicConfiguration;
 import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 
 /**
  * @author <a href="ataylor at redhat.com">Andy Taylor</a>
@@ -42,28 +35,30 @@
    private static final Logger log = Logger.getLogger(JMSServerDeployer.class);
 
    private final Configuration configuration;
+   
+   private final JMSServerConfigParserImpl parser;
 
    private final JMSServerManager jmsServerControl;
 
-   private static final String CONNECTOR_REF_ELEMENT = "connector-ref";
+   protected static final String CONNECTOR_REF_ELEMENT = "connector-ref";
 
-   private static final String DISCOVERY_GROUP_ELEMENT = "discovery-group-ref";
+   protected static final String DISCOVERY_GROUP_ELEMENT = "discovery-group-ref";
 
-   private static final String ENTRIES_NODE_NAME = "entries";
+   protected static final String ENTRIES_NODE_NAME = "entries";
 
-   private static final String ENTRY_NODE_NAME = "entry";
+   protected static final String ENTRY_NODE_NAME = "entry";
 
-   private static final String CONNECTORS_NODE_NAME = "connectors";
+   protected static final String CONNECTORS_NODE_NAME = "connectors";
 
-   private static final String CONNECTION_FACTORY_NODE_NAME = "connection-factory";
+   protected static final String CONNECTION_FACTORY_NODE_NAME = "connection-factory";
 
-   private static final String QUEUE_NODE_NAME = "queue";
+   protected static final String QUEUE_NODE_NAME = "queue";
 
-   private static final String QUEUE_SELECTOR_NODE_NAME = "selector";
+   protected static final String QUEUE_SELECTOR_NODE_NAME = "selector";
 
-   private static final String TOPIC_NODE_NAME = "topic";
+   protected static final String TOPIC_NODE_NAME = "topic";
 
-   private static final boolean DEFAULT_QUEUE_DURABILITY = true;
+   protected static final boolean DEFAULT_QUEUE_DURABILITY = true;
 
    public JMSServerDeployer(final JMSServerManager jmsServerManager,
                             final DeploymentManager deploymentManager,
@@ -74,6 +69,8 @@
       jmsServerControl = jmsServerManager;
 
       configuration = config;
+      
+      parser = new JMSServerConfigParserImpl(configuration);
    }
 
    /**
@@ -117,305 +114,15 @@
    {
       if (node.getNodeName().equals(JMSServerDeployer.CONNECTION_FACTORY_NODE_NAME))
       {
-         Element e = (Element)node;
-
-         long clientFailureCheckPeriod = XMLConfigurationUtil.getLong(e,
-                                                                      "client-failure-check-period",
-                                                                      HornetQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
-                                                                      Validators.MINUS_ONE_OR_GT_ZERO);
-         long connectionTTL = XMLConfigurationUtil.getLong(e,
-                                                           "connection-ttl",
-                                                           HornetQClient.DEFAULT_CONNECTION_TTL,
-                                                           Validators.MINUS_ONE_OR_GE_ZERO);
-         long callTimeout = XMLConfigurationUtil.getLong(e,
-                                                         "call-timeout",
-                                                         HornetQClient.DEFAULT_CALL_TIMEOUT,
-                                                         Validators.GE_ZERO);
-         String clientID = XMLConfigurationUtil.getString(e, "client-id", null, Validators.NO_CHECK);
-         int dupsOKBatchSize = XMLConfigurationUtil.getInteger(e,
-                                                               "dups-ok-batch-size",
-                                                               HornetQClient.DEFAULT_ACK_BATCH_SIZE,
-                                                               Validators.GT_ZERO);
-         int transactionBatchSize = XMLConfigurationUtil.getInteger(e,
-                                                                    "transaction-batch-size",
-                                                                    HornetQClient.DEFAULT_ACK_BATCH_SIZE,
-                                                                    Validators.GT_ZERO);
-         int consumerWindowSize = XMLConfigurationUtil.getInteger(e,
-                                                                  "consumer-window-size",
-                                                                  HornetQClient.DEFAULT_CONSUMER_WINDOW_SIZE,
-                                                                  Validators.MINUS_ONE_OR_GE_ZERO);
-         int producerWindowSize = XMLConfigurationUtil.getInteger(e,
-                                                                  "producer-window-size",
-                                                                  HornetQClient.DEFAULT_PRODUCER_WINDOW_SIZE,
-                                                                  Validators.MINUS_ONE_OR_GT_ZERO);
-         int consumerMaxRate = XMLConfigurationUtil.getInteger(e,
-                                                               "consumer-max-rate",
-                                                               HornetQClient.DEFAULT_CONSUMER_MAX_RATE,
-                                                               Validators.MINUS_ONE_OR_GT_ZERO);
-         int confirmationWindowSize = XMLConfigurationUtil.getInteger(e,
-                                                                      "confirmation-window-size",
-                                                                      HornetQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE,
-                                                                      Validators.MINUS_ONE_OR_GT_ZERO);
-         int producerMaxRate = XMLConfigurationUtil.getInteger(e,
-                                                               "producer-max-rate",
-                                                               HornetQClient.DEFAULT_PRODUCER_MAX_RATE,
-                                                               Validators.MINUS_ONE_OR_GT_ZERO);
-         boolean cacheLargeMessagesClient = XMLConfigurationUtil.getBoolean(e,
-                                                                            "cache-large-message-client",
-                                                                            HornetQClient.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT);
-         int minLargeMessageSize = XMLConfigurationUtil.getInteger(e,
-                                                                   "min-large-message-size",
-                                                                   HornetQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
-                                                                   Validators.GT_ZERO);
-         boolean blockOnAcknowledge = XMLConfigurationUtil.getBoolean(e,
-                                                                      "block-on-acknowledge",
-                                                                      HornetQClient.DEFAULT_BLOCK_ON_ACKNOWLEDGE);
-         boolean blockOnNonDurableSend = XMLConfigurationUtil.getBoolean(e,
-                                                                            "block-on-non-durable-send",
-                                                                            HornetQClient.DEFAULT_BLOCK_ON_NON_DURABLE_SEND);
-         boolean blockOnDurableSend = XMLConfigurationUtil.getBoolean(e,
-                                                                         "block-on-durable-send",
-                                                                         HornetQClient.DEFAULT_BLOCK_ON_DURABLE_SEND);
-         boolean autoGroup = XMLConfigurationUtil.getBoolean(e,
-                                                             "auto-group",
-                                                             HornetQClient.DEFAULT_AUTO_GROUP);
-         boolean preAcknowledge = XMLConfigurationUtil.getBoolean(e,
-                                                                  "pre-acknowledge",
-                                                                  HornetQClient.DEFAULT_PRE_ACKNOWLEDGE);
-         long retryInterval = XMLConfigurationUtil.getLong(e,
-                                                           "retry-interval",
-                                                           HornetQClient.DEFAULT_RETRY_INTERVAL,
-                                                           Validators.GT_ZERO);
-         double retryIntervalMultiplier = XMLConfigurationUtil.getDouble(e,
-                                                                         "retry-interval-multiplier",
-                                                                         HornetQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
-                                                                         Validators.GT_ZERO);
-         long maxRetryInterval = XMLConfigurationUtil.getLong(e,
-                                                              "max-retry-interval",
-                                                              HornetQClient.DEFAULT_MAX_RETRY_INTERVAL,
-                                                              Validators.GT_ZERO);
-         int reconnectAttempts = XMLConfigurationUtil.getInteger(e,
-                                                                 "reconnect-attempts",
-                                                                 HornetQClient.DEFAULT_RECONNECT_ATTEMPTS,
-                                                                 Validators.MINUS_ONE_OR_GE_ZERO);
-         boolean failoverOnServerShutdown = XMLConfigurationUtil.getBoolean(e,
-                                                                            "failover-on-server-shutdown",
-                                                                            HornetQClient.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN);
-         boolean useGlobalPools = XMLConfigurationUtil.getBoolean(e,
-                                                                  "use-global-pools",
-                                                                  HornetQClient.DEFAULT_USE_GLOBAL_POOLS);
-         int scheduledThreadPoolMaxSize = XMLConfigurationUtil.getInteger(e,
-                                                                          "scheduled-thread-pool-max-size",
-                                                                          HornetQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
-                                                                          Validators.MINUS_ONE_OR_GT_ZERO);
-         int threadPoolMaxSize = XMLConfigurationUtil.getInteger(e,
-                                                                 "thread-pool-max-size",
-                                                                 HornetQClient.DEFAULT_THREAD_POOL_MAX_SIZE,
-                                                                 Validators.MINUS_ONE_OR_GT_ZERO);
-         String connectionLoadBalancingPolicyClassName = XMLConfigurationUtil.getString(e,
-                                                                                        "connection-load-balancing-policy-class-name",
-                                                                                        HornetQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
-                                                                                        Validators.NOT_NULL_OR_EMPTY);
-         long discoveryInitialWaitTimeout = XMLConfigurationUtil.getLong(e,
-                                                                         "discovery-initial-wait-timeout",
-                                                                         HornetQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT,
-                                                                         Validators.GT_ZERO);
-         String groupid = XMLConfigurationUtil.getString(e, "group-id", null, Validators.NO_CHECK);
-         List<String> jndiBindings = new ArrayList<String>();
-         List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
-         DiscoveryGroupConfiguration discoveryGroupConfiguration = null;
-
-         NodeList children = node.getChildNodes();
-
-         for (int j = 0; j < children.getLength(); j++)
-         {
-            Node child = children.item(j);
-
-            if (JMSServerDeployer.ENTRIES_NODE_NAME.equals(child.getNodeName()))
-            {
-               NodeList entries = child.getChildNodes();
-               for (int i = 0; i < entries.getLength(); i++)
-               {
-                  Node entry = entries.item(i);
-                  if (JMSServerDeployer.ENTRY_NODE_NAME.equals(entry.getNodeName()))
-                  {
-                     String jndiName = entry.getAttributes().getNamedItem("name").getNodeValue();
-
-                     jndiBindings.add(jndiName);
-                  }
-               }
-            }
-            else if (JMSServerDeployer.CONNECTORS_NODE_NAME.equals(child.getNodeName()))
-            {
-               NodeList entries = child.getChildNodes();
-               for (int i = 0; i < entries.getLength(); i++)
-               {
-                  Node entry = entries.item(i);
-                  if (JMSServerDeployer.CONNECTOR_REF_ELEMENT.equals(entry.getNodeName()))
-                  {
-                     String connectorName = entry.getAttributes().getNamedItem("connector-name").getNodeValue();
-                     TransportConfiguration connector = configuration.getConnectorConfigurations().get(connectorName);
-
-                     if (connector == null)
-                     {
-                        JMSServerDeployer.log.warn("There is no connector with name '" + connectorName + "' deployed.");
-                        return;
-                     }
-
-                     TransportConfiguration backupConnector = null;
-                     Node backupNode = entry.getAttributes().getNamedItem("backup-connector-name");
-                     if (backupNode != null)
-                     {
-                        String backupConnectorName = backupNode.getNodeValue();
-                        backupConnector = configuration.getConnectorConfigurations().get(backupConnectorName);
-
-                        if (backupConnector == null)
-                        {
-                           JMSServerDeployer.log.warn("There is no backup connector with name '" + connectorName +
-                                                      "' deployed.");
-                           return;
-                        }
-                     }
-
-                     connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(connector,
-                                                                                                   backupConnector));
-                  }
-               }
-            }
-            else if (JMSServerDeployer.DISCOVERY_GROUP_ELEMENT.equals(child.getNodeName()))
-            {
-               String discoveryGroupName = child.getAttributes().getNamedItem("discovery-group-name").getNodeValue();
-
-               discoveryGroupConfiguration = configuration.getDiscoveryGroupConfigurations().get(discoveryGroupName);
-
-               if (discoveryGroupConfiguration == null)
-               {
-                  JMSServerDeployer.log.warn("There is no discovery group with name '" + discoveryGroupName +
-                                             "' deployed.");
-
-                  return;
-               }
-            }
-         }
-
-         String name = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
-
-         if (discoveryGroupConfiguration != null)
-         {
-            jmsServerControl.createConnectionFactory(name,
-                                                     discoveryGroupConfiguration.getGroupAddress(),
-                                                     discoveryGroupConfiguration.getGroupPort(),
-                                                     clientID,
-                                                     discoveryGroupConfiguration.getRefreshTimeout(),
-                                                     clientFailureCheckPeriod,
-                                                     connectionTTL,
-                                                     callTimeout,
-                                                     cacheLargeMessagesClient,
-                                                     minLargeMessageSize,
-                                                     consumerWindowSize,
-                                                     consumerMaxRate,
-                                                     confirmationWindowSize,
-                                                     producerWindowSize,
-                                                     producerMaxRate,
-                                                     blockOnAcknowledge,
-                                                     blockOnDurableSend,
-                                                     blockOnNonDurableSend,
-                                                     autoGroup,
-                                                     preAcknowledge,
-                                                     connectionLoadBalancingPolicyClassName,
-                                                     transactionBatchSize,
-                                                     dupsOKBatchSize,
-                                                     discoveryInitialWaitTimeout,
-                                                     useGlobalPools,
-                                                     scheduledThreadPoolMaxSize,
-                                                     threadPoolMaxSize,
-                                                     retryInterval,
-                                                     retryIntervalMultiplier,
-                                                     maxRetryInterval,
-                                                     reconnectAttempts,
-                                                     failoverOnServerShutdown,
-                                                     groupid,
-                                                     jndiBindings);
-         }
-         else
-         {
-            jmsServerControl.createConnectionFactory(name,
-                                                     connectorConfigs,
-                                                     clientID,
-                                                     clientFailureCheckPeriod,
-                                                     connectionTTL,
-                                                     callTimeout,
-                                                     cacheLargeMessagesClient,
-                                                     minLargeMessageSize,
-                                                     consumerWindowSize,
-                                                     consumerMaxRate,
-                                                     confirmationWindowSize,
-                                                     producerWindowSize,
-                                                     producerMaxRate,
-                                                     blockOnAcknowledge,
-                                                     blockOnDurableSend,
-                                                     blockOnNonDurableSend,
-                                                     autoGroup,
-                                                     preAcknowledge,
-                                                     connectionLoadBalancingPolicyClassName,
-                                                     transactionBatchSize,
-                                                     dupsOKBatchSize,
-                                                     useGlobalPools,
-                                                     scheduledThreadPoolMaxSize,
-                                                     threadPoolMaxSize,
-                                                     retryInterval,
-                                                     retryIntervalMultiplier,
-                                                     maxRetryInterval,
-                                                     reconnectAttempts,
-                                                     failoverOnServerShutdown,
-                                                     groupid,
-                                                     jndiBindings);
-         }
+         deployConnectionFactory(node);
       }
       else if (node.getNodeName().equals(JMSServerDeployer.QUEUE_NODE_NAME))
       {
-         Element e = (Element)node;
-         NamedNodeMap atts = node.getAttributes();
-         String queueName = atts.getNamedItem(getKeyAttribute()).getNodeValue();
-         String selectorString = null;
-         boolean durable = XMLConfigurationUtil.getBoolean(e, "durable", JMSServerDeployer.DEFAULT_QUEUE_DURABILITY);
-         NodeList children = node.getChildNodes();
-         ArrayList<String> jndiNames = new ArrayList<String>();
-         for (int i = 0; i < children.getLength(); i++)
-         {
-            Node child = children.item(i);
-
-            if (JMSServerDeployer.ENTRY_NODE_NAME.equals(children.item(i).getNodeName()))
-            {
-               String jndiName = child.getAttributes().getNamedItem("name").getNodeValue();
-               jndiNames.add(jndiName);
-            }
-            else if (JMSServerDeployer.QUEUE_SELECTOR_NODE_NAME.equals(children.item(i).getNodeName()))
-            {
-               Node selectorNode = children.item(i);
-               Node attNode = selectorNode.getAttributes().getNamedItem("string");
-               selectorString = attNode.getNodeValue();
-            }
-         }
-         for (String jndiName : jndiNames)
-         {
-            jmsServerControl.createQueue(queueName, jndiName, selectorString, durable);
-         }
+         deployQueue(node);
       }
       else if (node.getNodeName().equals(JMSServerDeployer.TOPIC_NODE_NAME))
       {
-         String topicName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
-         NodeList children = node.getChildNodes();
-         for (int i = 0; i < children.getLength(); i++)
-         {
-            Node child = children.item(i);
-
-            if (JMSServerDeployer.ENTRY_NODE_NAME.equals(children.item(i).getNodeName()))
-            {
-               String jndiName = child.getAttributes().getNamedItem("name").getNodeValue();
-               jmsServerControl.createTopic(topicName, jndiName);
-            }
-         }
+         deployTopic(node);
       }
    }
 
@@ -451,4 +158,121 @@
       return new String[] { "hornetq-jms.xml" };
    }
 
+   
+   
+   
+   /**
+    * @param node
+    * @throws Exception
+    */
+   private void deployTopic(final Node node) throws Exception
+   {
+      TopicConfiguration topicConfig = parser.parseTopicConfiguration(node);
+      for (String jndi : topicConfig.getBindings())
+      {
+         jmsServerControl.createTopic(topicConfig.getName(), jndi);
+      }
+   }
+
+   /**
+    * @param node
+    * @throws Exception
+    */
+   private void deployQueue(final Node node) throws Exception
+   {
+      QueueConfiguration queueconfig = parser.parseQueueConfiguration(node);
+      for (String jndiName : queueconfig.getBindings())
+      {
+         jmsServerControl.createQueue(queueconfig.getName(), jndiName, queueconfig.getSelector(), queueconfig.isDurable());
+      }
+   }
+
+   /**
+    * @param node
+    * @throws Exception
+    */
+   private void deployConnectionFactory(final Node node) throws Exception
+   {
+      ConnectionFactoryConfiguration cfConfig = parser.parseConnectionFactoryConfiguration(node);
+
+      ArrayList<String> listBindings = new ArrayList<String>();
+      for (String str: cfConfig.getBindings())
+      {
+         listBindings.add(str);
+      }
+      
+      if (cfConfig.getDiscoveryAddress() != null)
+      {
+         jmsServerControl.createConnectionFactory(cfConfig.getName(),
+                                                  cfConfig.getDiscoveryAddress(),
+                                                  cfConfig.getDiscoveryPort(),
+                                                  cfConfig.getClientID(),
+                                                  cfConfig.getDiscoveryRefreshTimeout(),
+                                                  cfConfig.getClientFailureCheckPeriod(),
+                                                  cfConfig.getConnectionTTL(),
+                                                  cfConfig.getCallTimeout(),
+                                                  cfConfig.isCacheLargeMessagesClient(),
+                                                  cfConfig.getMinLargeMessageSize(),
+                                                  cfConfig.getConsumerWindowSize(),
+                                                  cfConfig.getConsumerMaxRate(),
+                                                  cfConfig.getConfirmationWindowSize(),
+                                                  cfConfig.getProducerWindowSize(),
+                                                  cfConfig.getProducerMaxRate(),
+                                                  cfConfig.isBlockOnAcknowledge(),
+                                                  cfConfig.isBlockOnDurableSend(),
+                                                  cfConfig.isBlockOnNonDurableSend(),
+                                                  cfConfig.isAutoGroup(),
+                                                  cfConfig.isPreAcknowledge(),
+                                                  cfConfig.getLoadBalancingPolicyClassName(),
+                                                  cfConfig.getTransactionBatchSize(),
+                                                  cfConfig.getDupsOKBatchSize(),
+                                                  cfConfig.getInitialWaitTimeout(),
+                                                  cfConfig.isUseGlobalPools(),
+                                                  cfConfig.getScheduledThreadPoolMaxSize(),
+                                                  cfConfig.getThreadPoolMaxSize(),
+                                                  cfConfig.getRetryInterval(),
+                                                  cfConfig.getRetryIntervalMultiplier(),
+                                                  cfConfig.getMaxRetryInterval(),
+                                                  cfConfig.getReconnectAttempts(),
+                                                  cfConfig.isFailoverOnServerShutdown(),
+                                                  cfConfig.getGroupID(),
+                                                  listBindings);
+      }
+      else
+      {
+         jmsServerControl.createConnectionFactory(cfConfig.getName(),
+                                                  cfConfig.getConnectorConfigs(),
+                                                  cfConfig.getClientID(),
+                                                  cfConfig.getClientFailureCheckPeriod(),
+                                                  cfConfig.getConnectionTTL(),
+                                                  cfConfig.getCallTimeout(),
+                                                  cfConfig.isCacheLargeMessagesClient(),
+                                                  cfConfig.getMinLargeMessageSize(),
+                                                  cfConfig.getConsumerWindowSize(),
+                                                  cfConfig.getConsumerMaxRate(),
+                                                  cfConfig.getConfirmationWindowSize(),
+                                                  cfConfig.getProducerWindowSize(),
+                                                  cfConfig.getProducerMaxRate(),
+                                                  cfConfig.isBlockOnAcknowledge(),
+                                                  cfConfig.isBlockOnDurableSend(),
+                                                  cfConfig.isBlockOnNonDurableSend(),
+                                                  cfConfig.isAutoGroup(),
+                                                  cfConfig.isPreAcknowledge(),
+                                                  cfConfig.getLoadBalancingPolicyClassName(),
+                                                  cfConfig.getTransactionBatchSize(),
+                                                  cfConfig.getDupsOKBatchSize(),
+                                                  cfConfig.isUseGlobalPools(),
+                                                  cfConfig.getScheduledThreadPoolMaxSize(),
+                                                  cfConfig.getThreadPoolMaxSize(),
+                                                  cfConfig.getRetryInterval(),
+                                                  cfConfig.getRetryIntervalMultiplier(),
+                                                  cfConfig.getMaxRetryInterval(),
+                                                  cfConfig.getReconnectAttempts(),
+                                                  cfConfig.isFailoverOnServerShutdown(),
+                                                  cfConfig.getGroupID(),
+                                                  listBindings);
+      }
+   }
+
+   
 }

Added: trunk/tests/src/org/hornetq/tests/integration/jms/server/config/JMSServerConfigParserTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/server/config/JMSServerConfigParserTest.java	                        (rev 0)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/server/config/JMSServerConfigParserTest.java	2010-02-04 02:12:55 UTC (rev 8861)
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.jms.server.config;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.core.config.Configuration;
+import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
+import org.hornetq.jms.server.config.JMSConfiguration;
+import org.hornetq.jms.server.config.QueueConfiguration;
+import org.hornetq.jms.server.config.TopicConfiguration;
+import org.hornetq.jms.server.impl.JMSServerConfigParserImpl;
+import org.hornetq.tests.util.ServiceTestBase;
+
+/**
+ * A JMSServerConfigParserTest
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class JMSServerConfigParserTest extends ServiceTestBase
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+   
+   
+   public void testParsing() throws Exception
+   {
+      Configuration config = createDefaultConfig();
+      
+      // anything so the parsing will work
+      config.getConnectorConfigurations().put("netty", new TransportConfiguration());
+      
+      JMSServerConfigParserImpl parser = new JMSServerConfigParserImpl(config);
+      
+      String conf = "hornetq-jms-for-JMSServerDeployerTest.xml";
+      URL confURL = Thread.currentThread().getContextClassLoader().getResource(conf);
+      
+      InputStream stream = confURL.openStream();
+      
+      JMSConfiguration jmsconfig = parser.parseConfiguration(stream);
+      stream.close();
+
+      ConnectionFactoryConfiguration cfConfig = jmsconfig.getConnectionFactoryConfigurations().get(0);
+      
+      assertEquals(1234, cfConfig.getClientFailureCheckPeriod());
+      assertEquals(5678, cfConfig.getCallTimeout());
+      assertEquals(12345, cfConfig.getConsumerWindowSize());
+      assertEquals(6789, cfConfig.getConsumerMaxRate());
+      assertEquals(123456, cfConfig.getConfirmationWindowSize());
+      assertEquals(7712652, cfConfig.getProducerWindowSize());
+      assertEquals(789, cfConfig.getProducerMaxRate());
+      assertEquals(12, cfConfig.getMinLargeMessageSize());
+      assertEquals("TestClientID", cfConfig.getClientID());
+      assertEquals(3456, cfConfig.getDupsOKBatchSize());
+      assertEquals(4567, cfConfig.getTransactionBatchSize());
+      assertEquals(true, cfConfig.isBlockOnAcknowledge());
+      assertEquals(false, cfConfig.isBlockOnNonDurableSend());
+      assertEquals(true, cfConfig.isBlockOnDurableSend());
+      assertEquals(false, cfConfig.isAutoGroup());
+      assertEquals(true, cfConfig.isPreAcknowledge());
+      assertEquals(2345, cfConfig.getConnectionTTL());
+      assertEquals(678, cfConfig.getInitialWaitTimeout());
+      assertEquals(false, cfConfig.isFailoverOnServerShutdown());
+      assertEquals("FooClass", cfConfig.getLoadBalancingPolicyClassName());
+      assertEquals(34, cfConfig.getReconnectAttempts());
+      assertEquals(5, cfConfig.getRetryInterval());
+      assertEquals(6.0, cfConfig.getRetryIntervalMultiplier());
+      assertEquals(300, cfConfig.getMaxRetryInterval());
+      assertEquals(true, cfConfig.isCacheLargeMessagesClient());
+      
+      
+      assertEquals(1, jmsconfig.getQueueConfigurations().size());
+
+      QueueConfiguration queueConfig = jmsconfig.getQueueConfigurations().get(0);
+      assertEquals("fullConfigurationQueue", queueConfig.getName());
+      assertEquals(2, queueConfig.getBindings().length);
+      assertEquals("/fullConfigurationQueue", queueConfig.getBindings()[0]);
+      assertEquals("/queue/fullConfigurationQueue", queueConfig.getBindings()[1]);
+      
+
+      assertEquals(1, jmsconfig.getTopicConfigurations().size());
+      TopicConfiguration topicConfig = jmsconfig.getTopicConfigurations().get(0);
+      assertEquals("fullConfigurationTopic", topicConfig.getName());
+      assertEquals(2, topicConfig.getBindings().length);
+      assertEquals("/fullConfigurationTopic", topicConfig.getBindings()[0]);
+      assertEquals("/topic/fullConfigurationTopic", topicConfig.getBindings()[1]);
+      
+      
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}



More information about the hornetq-commits mailing list