[jboss-cvs] JBoss Messaging SVN: r3290 - in branches/Branch_MC_Integration_New: docs/examples/distributed-topic and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Nov 6 11:01:31 EST 2007


Author: ataylor
Date: 2007-11-06 11:01:31 -0500 (Tue, 06 Nov 2007)
New Revision: 3290

Added:
   branches/Branch_MC_Integration_New/src/etc/server/default/deploy/jbm-connection-factories.xml
   branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryDeployer.java
Modified:
   branches/Branch_MC_Integration_New/build-messaging.xml
   branches/Branch_MC_Integration_New/docs/examples/distributed-topic/build.xml
   branches/Branch_MC_Integration_New/docs/examples/ejb3mdb/build.xml
   branches/Branch_MC_Integration_New/docs/examples/queue-failover/build.xml
   branches/Branch_MC_Integration_New/src/etc/server/default/deploy/jbm-beans.xml
   branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/ServerPeer.java
   branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java
Log:
initial microcontainer integration, added connection factory deployer

Modified: branches/Branch_MC_Integration_New/build-messaging.xml
===================================================================
--- branches/Branch_MC_Integration_New/build-messaging.xml	2007-11-06 12:03:15 UTC (rev 3289)
+++ branches/Branch_MC_Integration_New/build-messaging.xml	2007-11-06 16:01:31 UTC (rev 3290)
@@ -371,6 +371,7 @@
       <copy todir="${build.sar}/META-INF" file="${source.etc}/server/default/deploy/jbm-beans.xml"/>
       <copy todir="${build.sar}" file="${source.etc}/server/default/deploy/jbm-destinations.xml"/>
       <copy todir="${build.sar}" file="${source.etc}/server/default/deploy/jbm-configuration.xml"/>
+      <copy todir="${build.sar}" file="${source.etc}/server/default/deploy/jbm-connection-factories.xml"/>
    </target>
 
    <target name="artifacts" depends="jar, sar, client-jar"/>

Modified: branches/Branch_MC_Integration_New/docs/examples/distributed-topic/build.xml
===================================================================
--- branches/Branch_MC_Integration_New/docs/examples/distributed-topic/build.xml	2007-11-06 12:03:15 UTC (rev 3289)
+++ branches/Branch_MC_Integration_New/docs/examples/distributed-topic/build.xml	2007-11-06 16:01:31 UTC (rev 3290)
@@ -23,7 +23,7 @@
    <property name="example.topic.name" value="testDistributedTopic"/>
 
    <path id="common.compilation.classpath">
-      <fileset file="${jboss.home}/client/jboss-j2ee.jar"/>
+      <fileset file="${jboss.home}/client/jboss-javaee.jar"/>
       <fileset file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
    </path>
 
@@ -40,9 +40,10 @@
       <fileset file="${jboss.home}/server/${jboss.configuration0}/lib/jboss-remoting.jar"/>
       <fileset file="${jboss.home}/client/jbossall-client.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration0}/lib/log4j.jar"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration0}/lib/javassist.jar"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration0}/deploy/jboss-aop-jdk50.deployer/jboss-aop-jdk50.jar"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration0}/deploy/jboss-aop-jdk50.deployer/trove.jar"/>
+      <fileset file="${jboss.home}/lib/javassist.jar"/>
+      <fileset file="${jboss.home}/lib/jboss-aop-jdk50.jar"/>
+      <fileset file="${jboss.home}/lib/trove.jar"/>
+      <fileset file="${jboss.home}/lib/jboss-container.jar"/>
    </path>
 
    <target name="identify">
@@ -51,6 +52,7 @@
       <echo message="###########################################################################"/>
       <echo message="The topic:      ${example.topic.name}"/>
       <echo message="The client jar: ${messaging.client.jar.path}/${messaging.client.jar.name}"/>
+      <echo message="JBOSS_HOME is: ${jboss.home}"/>
    </target>
 
    <target name="sanity-check" depends="identify">

Modified: branches/Branch_MC_Integration_New/docs/examples/ejb3mdb/build.xml
===================================================================
--- branches/Branch_MC_Integration_New/docs/examples/ejb3mdb/build.xml	2007-11-06 12:03:15 UTC (rev 3289)
+++ branches/Branch_MC_Integration_New/docs/examples/ejb3mdb/build.xml	2007-11-06 16:01:31 UTC (rev 3290)
@@ -21,7 +21,7 @@
    <property name="example.queue.name" value="testQueue"/>
 
    <path id="common.compilation.classpath">
-      <fileset file="${jboss.home}/client/jboss-j2ee.jar"/>
+      <fileset file="${jboss.home}/client/jboss-javaee.jar"/>
       <fileset file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
       <fileset file="${jboss.home}/client/jboss-ejb3x.jar"/>
    </path>
@@ -39,9 +39,10 @@
       <fileset file="${jboss.home}/server/${jboss.configuration}/lib/jboss-remoting.jar"/>
       <fileset file="${jboss.home}/client/jbossall-client.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration}/lib/log4j.jar"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration}/lib/javassist.jar"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration}/deploy/jboss-aop-jdk50.deployer/jboss-aop-jdk50.jar"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration}/deploy/jboss-aop-jdk50.deployer/trove.jar"/>
+      <fileset file="${jboss.home}/lib/javassist.jar"/>
+      <fileset file="${jboss.home}/lib/jboss-aop-jdk50.jar"/>
+      <fileset file="${jboss.home}/lib/trove.jar"/>
+      <fileset file="${jboss.home}/lib/jboss-container.jar"/>
    </path>
 
    <target name="identify">
@@ -50,13 +51,14 @@
       <echo message="###########################################################################"/>
       <echo message="The queue:      ${example.queue.name}"/>
       <echo message="The client jar: ${messaging.client.jar.path}/${messaging.client.jar.name}"/>
+      <echo message="JBOSS_HOME is: ${jboss.home}"/>
    </target>
 
    <target name="sanity-check" depends="identify">
       <available property="client.jar.present" file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
       <fail message="Could not find client jar ${messaging.client.jar.path}/${messaging.client.jar.name}"
             unless="client.jar.present"/>
-      <available property="ejb3.support.installed" file="${jboss.home}/server/${jboss.configuration}/deploy/ejb3.deployer"/>
+      <available property="ejb3.support.installed" file="${jboss.home}/server/${jboss.configuration}/deployers/ejb3.deployer"/>
       <fail message="EJB3 does not seem to be installed in ${jboss.home}/server/${jboss.configuration}! Install it and try again."
             unless="ejb3.support.installed"/>
    </target>

Modified: branches/Branch_MC_Integration_New/docs/examples/queue-failover/build.xml
===================================================================
--- branches/Branch_MC_Integration_New/docs/examples/queue-failover/build.xml	2007-11-06 12:03:15 UTC (rev 3289)
+++ branches/Branch_MC_Integration_New/docs/examples/queue-failover/build.xml	2007-11-06 16:01:31 UTC (rev 3290)
@@ -21,7 +21,7 @@
    <property name="example.queue.name" value="testDistributedQueue"/>
 
    <path id="common.compilation.classpath">
-      <fileset file="${jboss.home}/client/jboss-j2ee.jar"/>
+      <fileset file="${jboss.home}/client/jboss-javaee.jar"/>
       <fileset file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
    </path>
 
@@ -38,9 +38,10 @@
       <fileset file="${jboss.home}/server/${jboss.configuration0}/lib/jboss-remoting.jar"/>
       <fileset file="${jboss.home}/client/jbossall-client.jar"/>
       <fileset file="${jboss.home}/server/${jboss.configuration0}/lib/log4j.jar"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration0}/lib/javassist.jar"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration0}/deploy/jboss-aop-jdk50.deployer/jboss-aop-jdk50.jar"/>
-      <fileset file="${jboss.home}/server/${jboss.configuration0}/deploy/jboss-aop-jdk50.deployer/trove.jar"/>
+      <fileset file="${jboss.home}/lib/javassist.jar"/>
+      <fileset file="${jboss.home}/lib/jboss-aop-jdk50.jar"/>
+      <fileset file="${jboss.home}/lib/trove.jar"/>
+      <fileset file="${jboss.home}/lib/jboss-container.jar"/>
    </path>
 
    <target name="identify">
@@ -49,6 +50,7 @@
       <echo message="###########################################################################"/>
       <echo message="The queue:      ${example.queue.name}"/>
       <echo message="The client jar: ${messaging.client.jar.path}/${messaging.client.jar.name}"/>
+      <echo message="JBOSS_HOME is: ${jboss.home}"/>
    </target>
 
    <target name="sanity-check" depends="identify">

Modified: branches/Branch_MC_Integration_New/src/etc/server/default/deploy/jbm-beans.xml
===================================================================
--- branches/Branch_MC_Integration_New/src/etc/server/default/deploy/jbm-beans.xml	2007-11-06 12:03:15 UTC (rev 3289)
+++ branches/Branch_MC_Integration_New/src/etc/server/default/deploy/jbm-beans.xml	2007-11-06 16:01:31 UTC (rev 3290)
@@ -24,6 +24,9 @@
       <property name="jmsUserManager">
          <inject bean="JMSUserManager"/>
       </property>
+      <property name="connector">
+         <inject bean="Remoting"/>
+      </property>
    </bean>
 
   
@@ -104,74 +107,6 @@
 
    </bean>
 
-
-
-   <bean class="org.jboss.jms.server.connectionfactory.ConnectionFactory"
-         name="ConnectionFactory">
-      <property name="name">ConnectionFactory</property>
-      <property name="serverPeer">
-         <inject bean="ServerPeer"/>
-      </property>
-      <property name="connector">
-         <inject bean="Remoting"/>
-      </property>
-      <property name="JNDIBindings">
-         <list elementClass="java.lang.String">
-            <value>/ConnectionFactory</value>
-            <value>/XAConnectionFactory</value>
-            <value>java:/ConnectionFactory</value>
-            <value>java:/XAConnectionFactory</value>
-         </list>
-      </property>
-   </bean>
-
-   <bean class="org.jboss.jms.server.connectionfactory.ConnectionFactory"
-         name="ClusteredConnectionFactory">
-      <property name="name">ClusteredConnectionFactory</property>
-      <property name="connector">
-         <inject bean="Remoting"/>
-      </property>
-      <property name="serverPeer">
-         <inject bean="ServerPeer"/>
-      </property>
-      <property name="JNDIBindings">
-         <list elementClass="java.lang.String">
-            <value>/ClusteredConnectionFactory</value>
-            <value>/ClusteredXAConnectionFactory</value>
-            <value>java:/ClusteredConnectionFactory</value>
-            <value>java:/ClusteredXAConnectionFactory</value>
-         </list>
-      </property>
-      <property name="supportsFailover">true</property>
-      <property name="supportsLoadBalancing">true</property>
-   </bean>
-
-   <bean name="jboss.messaging.connectionfactory:service=ClusterPullConnectionFactory"
-         class="org.jboss.jms.server.connectionfactory.ConnectionFactory">
-      <property name="name">jboss.messaging.connectionfactory:service=ClusterPullConnectionFactory</property>
-      <property name="connector">
-         <inject bean="Remoting"/>
-      </property>
-      <property name="serverPeer">
-         <inject bean="ServerPeer"/>
-      </property>
-      <property name="supportsFailover">false</property>
-      <property name="supportsLoadBalancing">false</property>
-   </bean>
-
-   <!--cant use the LTDS as its dependant on the jboss-jca service running does this matter-->
-   <!--<bean name="DataSource" class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
-        <property name="jndiName">MessagingDS</property>
-       <property name="driverClass">com.mysql.jdbc.Driver</property>
-       <property name="connectionURL">jdbc:mysql://localhost:3306/messaging</property>
-       <property name="userName">andy</property>
-        <property name="transactionManager"><inject bean="ServiceLocator" property="transactionManager"/> </property>
-   </bean>-->
-   <!--<bean name="DataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
-       <property name="url">jdbc:mysql://localhost:3306/messaging</property>
-       <property name="user">andy</property>
-   </bean>-->
-
    <bean name="Remoting" class="org.jboss.jms.server.microcontainer.factory.Connector">
       <constructor>
          <parameter>

Added: branches/Branch_MC_Integration_New/src/etc/server/default/deploy/jbm-connection-factories.xml
===================================================================
--- branches/Branch_MC_Integration_New/src/etc/server/default/deploy/jbm-connection-factories.xml	                        (rev 0)
+++ branches/Branch_MC_Integration_New/src/etc/server/default/deploy/jbm-connection-factories.xml	2007-11-06 16:01:31 UTC (rev 3290)
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+     Messaging Connection Factories configuration.
+
+     $Id: connection-factories-service.xml 3201 2007-10-19 10:39:50Z timfox $
+ -->
+
+<factories>
+
+   <!-- The default connection factory does not support automatic failover or load balancing-
+        this is so we can maintain compatiblity with applications written for JBoss MQ which use this
+        connection factory.
+   -->
+   <factory name="ConnectionFactory">
+      <jndi-bindings>
+            <binding>/ConnectionFactory</binding>
+            <binding>/XAConnectionFactory</binding>
+            <binding>java:/ConnectionFactory</binding>
+            <binding>java:/XAConnectionFactory</binding>
+      </jndi-bindings>
+   </factory>
+
+   <factory name="ClusteredConnectionFactory">
+      <jndi-bindings>
+            <binding>/ClusteredConnectionFactory</binding>
+            <binding>/ClusteredXAConnectionFactory</binding>
+            <binding>java:/ClusteredConnectionFactory</binding>
+            <binding>java:/ClusteredXAConnectionFactory</binding>
+                     </jndi-bindings>
+      <supports-failover>true</supports-failover>
+      <supports-load-balancing>true</supports-load-balancing>
+   </factory>
+
+   <factory name="jboss.messaging.connectionfactory:service=ClusterPullConnectionFactory">
+      <supports-failover>true</supports-failover>
+      <supports-load-balancing>true</supports-load-balancing>
+   </factory>
+   <!-- An example connection factory with all attributes shown  -->
+
+   <factory name="jboss.messaging.connectionfactory:service=MyExampleConnectionFactory">
+      <!-- You can specify the default Client ID to use for connections created using this factory -->
+      <client-id>MyClientID</client-id>
+      <!-- PrefetchSize determines the approximate maximum number of messages the client consumer will buffer locally -->
+      <prefetch-size>150</prefetch-size>
+      <!-- Paging params to be used for temporary queues -->
+      <default-temp-queue-full-size>200000</default-temp-queue-full-size>
+      <default-temp-queue-page-size>2000</default-temp-queue-page-size>
+      <default-temp-queue-down-cache-size>2000</default-temp-queue-down-cache-size>
+      <!-- The batch size to use when using the DUPS_OK_ACKNOWLEDGE acknowledgement mode -->
+      <dups-ok-batch-size>5000</dups-ok-batch-size>
+      <!-- Does this connection factory support automatic failover? -->
+      <supports-failover>false</supports-failover>
+      <!-- Does this connection factory support automatic client side load balancing? -->
+      <supports-load-balancing>false</supports-load-balancing>
+      <!-- The class name of the factory used to create the load balancing policy to use on the client side -->
+      <load-balancing-factory>org.jboss.jms.client.plugin.RoundRobinLoadBalancingFactory</load-balancing-factory>
+      <!-- Whether we should be strict TCK compliant, i.e. how we deal with foreign messages, defaults to false-->
+      <strict-tck>true</strict-tck>
+      <!-- Disable JBoss Remoting Connector sanity checks - There is rarely a good reason to set this to true -->
+      <disable-remoting-checks>false</disable-remoting-checks>
+      <!-- The connection factory will be bound in the following places in JNDI -->
+      <jndi-bindings>
+            <binding>/acme/MyExampleConnectionFactory</binding>
+            <binding>/acme/MyExampleConnectionFactoryDupe</binding>
+            <binding>java:/xyz/CF1</binding>
+            <binding>java:/connectionfactories/acme/connection_factory</binding>
+      </jndi-bindings>
+   </factory>
+   
+</factories>
\ No newline at end of file

Modified: branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/ServerPeer.java
===================================================================
--- branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/ServerPeer.java	2007-11-06 12:03:15 UTC (rev 3289)
+++ branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/ServerPeer.java	2007-11-06 16:01:31 UTC (rev 3290)
@@ -24,6 +24,7 @@
 import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
 import org.jboss.aop.AspectXmlLoader;
 import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+import org.jboss.jms.server.connectionfactory.ConnectionFactoryDeployer;
 import org.jboss.jms.server.connectionfactory.ConnectionFactoryJNDIMapper;
 import org.jboss.jms.server.connectionmanager.SimpleConnectionManager;
 import org.jboss.jms.server.connectormanager.SimpleConnectorManager;
@@ -51,6 +52,7 @@
 import org.jboss.messaging.util.ExceptionUtil;
 import org.jboss.messaging.util.Version;
 import org.jboss.remoting.marshal.MarshalFactory;
+import org.jboss.remoting.transport.Connector;
 import org.jboss.util.JBossStringBuilder;
 
 import javax.transaction.xa.Xid;
@@ -133,7 +135,11 @@
 
    private DestinationDeployer destinationDeployer;
 
+   private ConnectionFactoryDeployer connectionFactoryDeployer;
 
+   private Connector connector;
+
+
    // Constructors ---------------------------------------------------------------------------------
    public ServerPeer() throws Exception
    {
@@ -186,6 +192,7 @@
          memoryManager = new SimpleMemoryManager();
          messageStore = new SimpleMessageStore();
          destinationDeployer = new DestinationDeployer(this);
+         connectionFactoryDeployer = new ConnectionFactoryDeployer(this, connector);
          txRepository =
                  new TransactionRepository(persistenceManager, messageStore, transactionIDManager);
          messageCounterManager = new MessageCounterManager(Configuration.getMessageCounterSamplePeriod());
@@ -231,6 +238,7 @@
          securityStore.start();
          txRepository.start();
          clusterConnectionManager.start();
+         connectionFactoryDeployer.start();
          destinationDeployer.start();
 
          // Note we do not start the message counter manager by default. This must be done
@@ -296,7 +304,10 @@
          JMSServerInvocationHandler.setClosed(true);
 
          // Stop the wired components
-
+         destinationDeployer.stop();
+         destinationDeployer = null;
+         connectionFactoryDeployer.stop();
+         connectionFactoryDeployer = null;
          messageIDManager.stop();
          messageIDManager = null;
          channelIDManager.stop();
@@ -988,4 +999,14 @@
       return ((ManagedQueue) getDestinationManager().getDestination(queueName, true)).listAllMessages(null);
    }
 
+
+   public Connector getConnector()
+   {
+      return connector;
+   }
+
+   public void setConnector(Connector connector)
+   {
+      this.connector = connector;
+   }
 }

Modified: branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java
===================================================================
--- branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java	2007-11-06 12:03:15 UTC (rev 3289)
+++ branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java	2007-11-06 16:01:31 UTC (rev 3290)
@@ -225,7 +225,7 @@
       } 
    }
    
-   public synchronized void stopService() throws Exception
+   public synchronized void stop() throws Exception
    {
       try
       {

Added: branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryDeployer.java
===================================================================
--- branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryDeployer.java	                        (rev 0)
+++ branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryDeployer.java	2007-11-06 16:01:31 UTC (rev 3290)
@@ -0,0 +1,170 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005, JBoss Inc., and individual contributors as indicated
+   * by the @authors tag. See the copyright.txt in the distribution for a
+   * full listing of individual contributors.
+   *
+   * This is free software; you can redistribute it and/or modify it
+   * under the terms of the GNU Lesser General Public License as
+   * published by the Free Software Foundation; either version 2.1 of
+   * the License, or (at your option) any later version.
+   *
+   * This software is distributed in the hope that it will be useful,
+   * but WITHOUT ANY WARRANTY; without even the implied warranty of
+   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   * Lesser General Public License for more details.
+   *
+   * You should have received a copy of the GNU Lesser General Public
+   * License along with this software; if not, write to the Free
+   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+   */
+package org.jboss.jms.server.connectionfactory;
+
+import org.jboss.jms.server.ServerPeer;
+import org.jboss.messaging.util.XMLUtil;
+import org.jboss.remoting.transport.Connector;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class ConnectionFactoryDeployer
+{
+   private static final String JBM_FACTORIES_XML = "jbm-connection-factories.xml";
+   private static final String FACTORY_ELEMENT = "factory";
+   private static final String NAME_ATTR = "name";
+   private static final String CLIENTID_ELEMENT = "client-id";
+   private static final String PREFETECH_SIZE_ELEMENT = "prefetch-size";
+   private static final String DEF_TEMP_Q_FULL_SIZE = "default-temp-queue-full-size";
+   private static final String DEF_TEMP_Q_PAGE_SIZE_SIZE = "default-temp-queue-page-size";
+   private static final String DEF_TEMP_Q_DOWN_CACHE_SIZE = "default-temp-queue-down-cache-size";
+   private static final String DUPS_OK_BATCH_SIZE = "dups-ok-batch-size";
+   private static final String SUPPORTS_FAILOVER = "supports-failover";
+   private static final String SUPPORTS_LOAD_BALANCING = "supports-load-balancing";
+   private static final String LOAD_BALANCING_FACTORY = "load-balancing-factory";
+   private static final String STRICT_TCK = "strict-tck";
+   private static final String DISABLE_REMOTING_CHECKS = "disable-remoting-checks";
+   private static final String JNDI_BINDINGS = "jndi-bindings";
+   private static final String BIDING = "binding";
+
+   private List<ConnectionFactory> connectionFactories = new ArrayList<ConnectionFactory>();
+   private ServerPeer serverPeer;
+   private Connector connector;
+
+
+   public ConnectionFactoryDeployer(ServerPeer serverPeer, Connector connector)
+   {
+      this.serverPeer = serverPeer;
+      this.connector = connector;
+   }
+
+   /**
+    * lifecycle method that will deploy and undeploy connection factories
+    */
+   public void start() throws Exception
+   {
+      //find the config file
+      URL url = getClass().getClassLoader().getResource(JBM_FACTORIES_XML);
+      Element e = XMLUtil.urlToElement(url);
+      //lets get all the factories and create them
+      NodeList children = e.getElementsByTagName(FACTORY_ELEMENT);
+      for (int i = 0; i < children.getLength(); i++)
+      {
+         String clientId = null;
+         String name = children.item(i).getAttributes().getNamedItem(NAME_ATTR).getNodeValue();
+         ConnectionFactory connectionFactory = new ConnectionFactory(clientId);
+         connectionFactory.setName(name);
+         connectionFactories.add(connectionFactory);
+         NodeList attributes = children.item(i).getChildNodes();
+         for (int j = 0; j < attributes.getLength(); j++)
+         {
+            if (CLIENTID_ELEMENT.equalsIgnoreCase(attributes.item(j).getNodeName()))
+            {
+               clientId = attributes.item(j).getTextContent();
+            }
+
+            if (PREFETECH_SIZE_ELEMENT.equalsIgnoreCase(attributes.item(j).getNodeName()))
+            {
+               connectionFactory.setPrefetchSize(Integer.parseInt(attributes.item(j).getTextContent().trim()));
+            }
+            if (DEF_TEMP_Q_FULL_SIZE.equalsIgnoreCase(attributes.item(j).getNodeName()))
+            {
+               connectionFactory.setDefaultTempQueueFullSize(Integer.parseInt(attributes.item(j).getTextContent().trim()));
+            }
+            if (DEF_TEMP_Q_PAGE_SIZE_SIZE.equalsIgnoreCase(attributes.item(j).getNodeName()))
+            {
+               connectionFactory.setDefaultTempQueuePageSize(Integer.parseInt(attributes.item(j).getTextContent().trim()));
+            }
+            if (DEF_TEMP_Q_DOWN_CACHE_SIZE.equalsIgnoreCase(attributes.item(j).getNodeName()))
+            {
+               connectionFactory.setDefaultTempQueueDownCacheSize(Integer.parseInt(attributes.item(j).getTextContent().trim()));
+            }
+            if (DUPS_OK_BATCH_SIZE.equalsIgnoreCase(attributes.item(j).getNodeName()))
+            {
+               connectionFactory.setDupsOKBatchSize(Integer.parseInt(attributes.item(j).getTextContent().trim()));
+            }
+            if (SUPPORTS_FAILOVER.equalsIgnoreCase(attributes.item(j).getNodeName()))
+            {
+               connectionFactory.setSupportsFailover(Boolean.parseBoolean(attributes.item(j).getTextContent().trim()));
+            }
+            if (SUPPORTS_LOAD_BALANCING.equalsIgnoreCase(attributes.item(j).getNodeName()))
+            {
+               connectionFactory.setSupportsLoadBalancing(Boolean.parseBoolean(attributes.item(j).getTextContent().trim()));
+            }
+            if (LOAD_BALANCING_FACTORY.equalsIgnoreCase(attributes.item(j).getNodeName()))
+            {
+               connectionFactory.setLoadBalancingFactory(attributes.item(j).getTextContent().trim());
+            }
+            if (STRICT_TCK.equalsIgnoreCase(attributes.item(j).getNodeName()))
+            {
+               connectionFactory.setStrictTck(Boolean.parseBoolean(attributes.item(j).getTextContent().trim()));
+            }
+            if (DISABLE_REMOTING_CHECKS.equalsIgnoreCase(attributes.item(j).getNodeName()))
+            {
+               connectionFactory.setDisableRemotingChecks(Boolean.parseBoolean(attributes.item(j).getTextContent().trim()));
+            }
+            if (JNDI_BINDINGS.equalsIgnoreCase(attributes.item(j).getNodeName()))
+            {
+               connectionFactory.setJNDIBindings(getBindings(attributes.item(j).getChildNodes()));
+            }
+
+         }
+         connectionFactory.setServerPeer(serverPeer);
+         connectionFactory.setConnector(connector);
+         connectionFactory.start();
+      }
+   }
+
+   private List<String> getBindings(NodeList childNodes)
+   {
+      List<String> bindings = new ArrayList<String>();
+      for (int i = 0; i < childNodes.getLength(); i++)
+      {
+         if (BIDING.equalsIgnoreCase(childNodes.item(i).getNodeName()))
+         {
+            bindings.add(childNodes.item(i).getTextContent().trim());
+         }
+      }
+      return bindings;
+   }
+
+   /**
+    * lifecycle method to stop factories
+    *
+    * @throws Exception
+    */
+   public void stop() throws Exception
+   {
+      for (ConnectionFactory connectionFactory : connectionFactories)
+      {
+         connectionFactory.stop();
+      }
+   }
+
+}




More information about the jboss-cvs-commits mailing list