[jboss-cvs] JBoss Messaging SVN: r1944 - in trunk: src/etc/xmdesc and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 10 09:38:45 EST 2007


Author: ovidiu.feodorov at jboss.com
Date: 2007-01-10 09:38:36 -0500 (Wed, 10 Jan 2007)
New Revision: 1944

Added:
   trunk/src/main/org/jboss/jms/client/plugin/
   trunk/src/main/org/jboss/jms/client/plugin/LoadBalancingPolicy.java
   trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingPolicy.java
Modified:
   trunk/src/etc/server/default/deploy/connection-factories-service.xml
   trunk/src/etc/xmdesc/ConnectionFactory-xmbean.xml
   trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java
   trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
   trunk/src/main/org/jboss/jms/server/ConnectionFactoryManager.java
   trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java
   trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/LoadBalancingTest.java
   trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
Log:
Made load balancing policy pluggable.
http://jira.jboss.org/jira/browse/JBMESSAGING-675


Modified: trunk/src/etc/server/default/deploy/connection-factories-service.xml
===================================================================
--- trunk/src/etc/server/default/deploy/connection-factories-service.xml	2007-01-10 12:56:46 UTC (rev 1943)
+++ trunk/src/etc/server/default/deploy/connection-factories-service.xml	2007-01-10 14:38:36 UTC (rev 1944)
@@ -25,6 +25,7 @@
       </attribute>
       
       <attribute name="Clustered">true</attribute>
+      <attribute name="LoadBalancingPolicy">org.jboss.jms.client.plugin.RoundRobinLoadBalancingPolicy</attribute>
    </mbean>
 
 </server>
\ No newline at end of file

Modified: trunk/src/etc/xmdesc/ConnectionFactory-xmbean.xml
===================================================================
--- trunk/src/etc/xmdesc/ConnectionFactory-xmbean.xml	2007-01-10 12:56:46 UTC (rev 1943)
+++ trunk/src/etc/xmdesc/ConnectionFactory-xmbean.xml	2007-01-10 14:38:36 UTC (rev 1944)
@@ -86,8 +86,14 @@
       <description>Is this a clustered connection factory?</description>
       <name>Clustered</name>
       <type>boolean</type>
-   </attribute>    
+   </attribute>
 
+   <attribute access="read-write" getMethod="getLoadBalancingPolicy" setMethod="setLoadBalancingPolicy">
+      <description>The pluggable load balancing policy that is used to decide the next cluster node to create a clustered connection to</description>
+      <name>LoadBalancingPolicy</name>
+      <type>org.jboss.jms.client.plugin.LoadBalancingPolicy</type>
+   </attribute>
+
    <!-- Managed operations -->
 
    <operation>

Modified: trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java	2007-01-10 12:56:46 UTC (rev 1943)
+++ trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java	2007-01-10 14:38:36 UTC (rev 1944)
@@ -15,10 +15,12 @@
 import org.jboss.jms.client.delegate.DelegateSupport;
 import org.jboss.jms.client.state.ConnectionState;
 import org.jboss.jms.client.FailoverCommandCenter;
+import org.jboss.jms.client.plugin.LoadBalancingPolicy;
 import org.jboss.jms.server.endpoint.CreateConnectionResult;
 
 import javax.jms.JMSException;
 import java.util.Map;
+import java.util.Arrays;
 
 /**
  * This aspect is part of a clustered ConnectionFactory aspect stack.
@@ -53,15 +55,10 @@
    // This is a PER_INSTANCE aspect, so it has a 1-to-1 relationship with its delegate
    private ClientClusteredConnectionFactoryDelegate clusteredDelegate;
 
-   // The index of the next non-clustered delegate to be used. Only access it from a synchronized
-   // block. Currently hardcoded round-robin, the algorithm must be made pluggable.
-   private int next;
-
    // Constructors ---------------------------------------------------------------------------------
 
    public ClusteringAspect()
    {
-      next = 0;
    }
 
    // Public ---------------------------------------------------------------------------------------
@@ -74,9 +71,17 @@
       if (clusteredDelegate == null)
       {
          clusteredDelegate = (ClientClusteredConnectionFactoryDelegate)invocation.getTargetObject();
+
+         // TODO JBMESSAGING-674 - for the time being we assume that the cluster view is static, so 
+         //      we only initialize the load balancing policy here. This is obviously not true,
+         //      we'll need to review this when working on
+         //      http://jira.jboss.org/jira/browse/JBMESSAGING-674
+
+         clusteredDelegate.getLoadBalancingPolicy().
+            updateView(Arrays.asList(clusteredDelegate.getDelegates()));
       }
 
-      // the method handles both the case of a first connection creation attempt and a re-try during
+      // the method handles both the case of a first connection creation attempt and a retry during
       // a client-side failover. The difference is given by the failedNodeID (-1 for first attempt)
 
       MethodInvocation mi = (MethodInvocation)invocation;
@@ -92,7 +97,6 @@
 
       while (attemptCount < MAX_RECONNECT_HOP_COUNT)
       {
-
          int failedNodeIDToServer = -1;
 
          if (delegate == null)
@@ -104,7 +108,8 @@
             }
             else
             {
-               delegate = getNextRoundRobinDelegate();
+               LoadBalancingPolicy loadBalancingPolicy = clusteredDelegate.getLoadBalancingPolicy();
+               delegate = (ClientConnectionFactoryDelegate)loadBalancingPolicy.getNext();
             }
          }
 
@@ -198,29 +203,6 @@
 
    // Private --------------------------------------------------------------------------------------
 
-
-   /**
-    * TODO This is currently hardcoded as round robin. The policy should be pluggable.
-    */
-   private synchronized ClientConnectionFactoryDelegate getNextRoundRobinDelegate()
-   {
-      ClientConnectionFactoryDelegate[] delegates = clusteredDelegate.getDelegates();
-
-      if (next >= delegates.length)
-      {
-         next = 0;
-      }
-
-      ClientConnectionFactoryDelegate delegate = delegates[next++];
-
-         if (next >= delegates.length)
-         {
-            next = 0;
-         }
-
-      return delegate;
-   }
-
    private synchronized ClientConnectionFactoryDelegate getFailoverDelegateForNode(Integer nodeID)
    {
       ClientConnectionFactoryDelegate[] delegates = clusteredDelegate.getDelegates();

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java	2007-01-10 12:56:46 UTC (rev 1943)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java	2007-01-10 14:38:36 UTC (rev 1944)
@@ -26,6 +26,7 @@
 
 import org.jboss.jms.server.endpoint.CreateConnectionResult;
 import org.jboss.jms.delegate.ConnectionFactoryDelegate;
+import org.jboss.jms.client.plugin.LoadBalancingPolicy;
 import org.jboss.messaging.core.plugin.IDBlock;
 import org.jboss.logging.Logger;
 
@@ -65,13 +66,17 @@
    // Map <Integer(nodeID)->Integer(failoverNodeID)>
    private Map failoverMap;
 
+   private LoadBalancingPolicy loadBalancingPolicy;
+
    // Constructors ---------------------------------------------------------------------------------
 
    public ClientClusteredConnectionFactoryDelegate(ClientConnectionFactoryDelegate[] delegates,
-                                                   Map failoverMap)
+                                                   Map failoverMap,
+                                                   LoadBalancingPolicy loadBalancingPolicy)
    {
       this.delegates = delegates;
       this.failoverMap = failoverMap;
+      this.loadBalancingPolicy = loadBalancingPolicy;
    }
 
    // ConnectionFactoryDelegate implementation -----------------------------------------------------
@@ -139,6 +144,11 @@
       this.failoverMap = failoverMap;
    }
 
+   public LoadBalancingPolicy getLoadBalancingPolicy()
+   {
+      return loadBalancingPolicy;
+   }
+
    public String toString()
    {
       StringBuffer sb = new StringBuffer("ClusteredConnectionFactoryDelegate[");

Added: trunk/src/main/org/jboss/jms/client/plugin/LoadBalancingPolicy.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/plugin/LoadBalancingPolicy.java	2007-01-10 12:56:46 UTC (rev 1943)
+++ trunk/src/main/org/jboss/jms/client/plugin/LoadBalancingPolicy.java	2007-01-10 14:38:36 UTC (rev 1944)
@@ -0,0 +1,33 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.jms.client.plugin;
+
+import org.jboss.jms.delegate.ConnectionFactoryDelegate;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * The interface that must be implemented by any load balancing policy plugin.
+ *
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ * $Id$
+ */
+public interface LoadBalancingPolicy extends Serializable
+{
+   static final long serialVersionUID = 328573973957394573L;
+
+   ConnectionFactoryDelegate getNext();
+
+   /**
+    * @param delegates - a List<ConnectionFactoryDelegate> representing the lastest cluster view
+    *        to chose delegates from
+    */
+   void updateView(List delegates);
+
+}


Property changes on: trunk/src/main/org/jboss/jms/client/plugin/LoadBalancingPolicy.java
___________________________________________________________________
Name: svn:keywords
   + "Id LastChangedDate Author Revision"

Added: trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingPolicy.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingPolicy.java	2007-01-10 12:56:46 UTC (rev 1943)
+++ trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingPolicy.java	2007-01-10 14:38:36 UTC (rev 1944)
@@ -0,0 +1,64 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.jms.client.plugin;
+
+import org.jboss.jms.delegate.ConnectionFactoryDelegate;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class RoundRobinLoadBalancingPolicy implements LoadBalancingPolicy
+{
+   // Constants ------------------------------------------------------------------------------------
+
+   // Static ---------------------------------------------------------------------------------------
+
+   // Attributes -----------------------------------------------------------------------------------
+
+   // The index of the next delegate to be used
+   private int next;
+
+   // List<ConnectionFactoryDelegate>
+   private List view;
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   // LoadBalancingPolicy implementation -----------------------------------------------------------
+
+   public synchronized ConnectionFactoryDelegate getNext()
+   {
+      if (next >= view.size())
+      {
+         next = 0;
+      }
+
+      return (ConnectionFactoryDelegate)view.get(next++);
+   }
+
+   public synchronized void updateView(List delegates)
+   {
+      view = new ArrayList(delegates);
+      next = 0;
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
+   // Private --------------------------------------------------------------------------------------
+
+   // Inner classes --------------------------------------------------------------------------------
+
+}


Property changes on: trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingPolicy.java
___________________________________________________________________
Name: svn:keywords
   + "Id LastChangedDate Author Revision"

Modified: trunk/src/main/org/jboss/jms/server/ConnectionFactoryManager.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/ConnectionFactoryManager.java	2007-01-10 12:56:46 UTC (rev 1943)
+++ trunk/src/main/org/jboss/jms/server/ConnectionFactoryManager.java	2007-01-10 14:38:36 UTC (rev 1944)
@@ -22,6 +22,7 @@
 package org.jboss.jms.server;
 
 import org.jboss.jms.server.connectionfactory.JNDIBindings;
+import org.jboss.jms.client.plugin.LoadBalancingPolicy;
 import org.jboss.messaging.core.plugin.contract.MessagingComponent;
 
 /**
@@ -43,7 +44,8 @@
                                  int defaultTempQueueFullSize,
                                  int defaultTempQueuePageSize,
                                  int defaultTempQueueDownCacheSize,
-                                 boolean clustered) throws Exception;
+                                 boolean clustered,
+                                 LoadBalancingPolicy loadBalancingPolicy) throws Exception;
 
    void unregisterConnectionFactory(String uniqueName, boolean clustered) throws Exception;
 }

Modified: trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java	2007-01-10 12:56:46 UTC (rev 1943)
+++ trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java	2007-01-10 14:38:36 UTC (rev 1944)
@@ -12,6 +12,8 @@
 import org.jboss.jms.server.ConnectorManager;
 import org.jboss.jms.server.ServerPeer;
 import org.jboss.jms.util.ExceptionUtil;
+import org.jboss.jms.client.plugin.LoadBalancingPolicy;
+import org.jboss.jms.client.plugin.RoundRobinLoadBalancingPolicy;
 import org.jboss.remoting.InvokerLocator;
 import org.jboss.system.ServiceMBeanSupport;
 import org.w3c.dom.Element;
@@ -37,6 +39,7 @@
    protected JNDIBindings jndiBindings;
    protected int prefetchSize = 150;
    protected boolean clustered;
+   protected LoadBalancingPolicy loadBalancingPolicy;
    
    protected int defaultTempQueueFullSize = 75000;
    protected int defaultTempQueuePageSize = 2000;
@@ -62,6 +65,9 @@
    public ConnectionFactory(String clientID)
    {
       this.clientID = clientID;
+
+      // by default, a clustered connection uses a round-robin load balancing policy
+      this.loadBalancingPolicy = new RoundRobinLoadBalancingPolicy();
    }
 
    // ServiceMBeanSupport overrides ---------------------------------
@@ -116,7 +122,8 @@
             registerConnectionFactory(getServiceName().toString(), clientID, jndiBindings,
                                       locatorURI, enablePing, prefetchSize,
                                       defaultTempQueueFullSize, defaultTempQueuePageSize,
-                                      defaultTempQueueDownCacheSize, clustered);
+                                      defaultTempQueueDownCacheSize, clustered,
+                                      loadBalancingPolicy);
       
          InvokerLocator locator = new InvokerLocator(locatorURI);
 
@@ -147,8 +154,8 @@
       {
          started = false;
          
-         connectionFactoryManager.unregisterConnectionFactory(getServiceName().toString(), clustered);
-         
+         connectionFactoryManager.
+            unregisterConnectionFactory(getServiceName().toString(), clustered);
          connectorManager.unregisterConnector(connectorObjectName.getCanonicalName());
          
          log.info(this + " undeployed");
@@ -269,6 +276,21 @@
       this.clustered = clustered;
    }
 
+   public LoadBalancingPolicy getLoadBalancingPolicy()
+   {
+      return loadBalancingPolicy;
+   }
+
+   public void setLoadBalancingPolicy(LoadBalancingPolicy loadBalancingPolicy)
+   {
+      if (started)
+      {
+         log.warn("Load balancing policy can only be changed when connection factory is stopped");
+         return;
+      }
+      this.loadBalancingPolicy = loadBalancingPolicy;
+   }
+
    // JMX managed operations ----------------------------------------
 
    // Public --------------------------------------------------------

Modified: trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java	2007-01-10 12:56:46 UTC (rev 1943)
+++ trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java	2007-01-10 14:38:36 UTC (rev 1944)
@@ -37,6 +37,7 @@
 import javax.naming.NamingException;
 
 import org.jboss.jms.client.JBossConnectionFactory;
+import org.jboss.jms.client.plugin.LoadBalancingPolicy;
 import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
 import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
 import org.jboss.jms.server.ConnectionFactoryManager;
@@ -101,6 +102,9 @@
 
    // ConnectionFactoryManager implementation -----------------------
 
+   /**
+    * @param loadBalancingPolicy - ignored for non-clustered connection factories.
+    */
    public synchronized void registerConnectionFactory(String uniqueName,
                                                       String clientID,
                                                       JNDIBindings jndiBindings,
@@ -110,7 +114,8 @@
                                                       int defaultTempQueueFullSize,
                                                       int defaultTempQueuePageSize,
                                                       int defaultTempQueueDownCacheSize,
-                                                      boolean clustered)
+                                                      boolean clustered,
+                                                      LoadBalancingPolicy loadBalancingPolicy)
       throws Exception
    {
       log.debug(this + " registering connection factory '" + uniqueName +
@@ -165,7 +170,7 @@
          // Create a clustered delegate
 
          Map localDelegates = replicator.get(CF_PREFIX + uniqueName);
-         delegate = createClusteredDelegate(localDelegates.values());
+         delegate = createClusteredDelegate(localDelegates.values(), loadBalancingPolicy);
 
          log.debug(this + " created clustered delegate " + delegate);
       }
@@ -297,8 +302,6 @@
             {
                Map.Entry entry = (Map.Entry)i.next();
                String uniqueName = (String)entry.getKey();
-               ServerConnectionFactoryEndpoint endpoint =
-                  (ServerConnectionFactoryEndpoint)entry.getValue();
 
                ClientClusteredConnectionFactoryDelegate del =
                   (ClientClusteredConnectionFactoryDelegate)delegates.get(uniqueName);
@@ -394,7 +397,8 @@
     * @param localDelegates - Collection<ClientConnectionFactoryDelegate>
     */
    private ClientClusteredConnectionFactoryDelegate
-      createClusteredDelegate(Collection localDelegates) throws Exception
+      createClusteredDelegate(Collection localDelegates, LoadBalancingPolicy loadBalancingPolicy)
+      throws Exception
    {
       log.trace(this + " creating a clustered ConnectionFactoryDelegate based on " + localDelegates);
 
@@ -419,7 +423,9 @@
          failoverMap = recalculateFailoverMap(nodeAddressMap.keySet());
       }
 
-      return new ClientClusteredConnectionFactoryDelegate(delegates, failoverMap);
+      return new ClientClusteredConnectionFactoryDelegate(delegates,
+                                                          failoverMap,
+                                                          loadBalancingPolicy);
    }
 
    private void rebindConnectionFactory(Context ic, JNDIBindings jndiBindings,

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/LoadBalancingTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/LoadBalancingTest.java	2007-01-10 12:56:46 UTC (rev 1943)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/LoadBalancingTest.java	2007-01-10 14:38:36 UTC (rev 1944)
@@ -9,8 +9,6 @@
 import org.jboss.test.messaging.tools.ServerManagement;
 import org.jboss.test.messaging.MessagingTestCase;
 import org.jboss.jms.client.JBossConnection;
-import org.jboss.jms.client.state.ConnectionState;
-import org.jboss.jms.client.delegate.DelegateSupport;
 
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
@@ -28,23 +26,25 @@
 public class LoadBalancingTest extends MessagingTestCase
 {
 
-   // Constants -----------------------------------------------------
+   // Constants ------------------------------------------------------------------------------------
 
-   // Static --------------------------------------------------------
+   // Static ---------------------------------------------------------------------------------------
 
-   // Attributes ----------------------------------------------------
+   // Attributes -----------------------------------------------------------------------------------
 
-   // Constructors --------------------------------------------------
+   // Constructors ---------------------------------------------------------------------------------
 
    public LoadBalancingTest(String name)
    {
       super(name);
    }
 
-   // Public --------------------------------------------------------
+   // Public ---------------------------------------------------------------------------------------
 
-   public void testLoadBalancingOneNode() throws Exception
+   public void testRoundRobinLoadBalancingOneNode() throws Exception
    {
+      // the round robin policy is default
+
       ServerManagement.start(0, "all", true);
 
       try
@@ -55,25 +55,16 @@
 
          Connection conn0 = cf.createConnection();
 
-         int serverID = ((ConnectionState)((DelegateSupport)((JBossConnection)conn0).getDelegate()).
-            getState()).getServerID();
+         assertEquals(0, ((JBossConnection)conn0).getServerID());
 
-         assertEquals(0, serverID);
-
          Connection conn1 = cf.createConnection();
 
-         serverID = ((ConnectionState)((DelegateSupport)((JBossConnection)conn1).getDelegate()).
-            getState()).getServerID();
+         assertEquals(0, ((JBossConnection)conn1).getServerID());
 
-         assertEquals(0, serverID);
-
          Connection conn2 = cf.createConnection();
 
-         serverID = ((ConnectionState)((DelegateSupport)((JBossConnection)conn2).getDelegate()).
-            getState()).getServerID();
+         assertEquals(0, ((JBossConnection)conn2).getServerID());
 
-         assertEquals(0, serverID);
-
          conn0.close();
          conn1.close();
          conn2.close();
@@ -86,7 +77,7 @@
       }
    }
 
-   public void testLoadBalancingTwoNodes() throws Exception
+   public void testRoundRobinLoadBalancingTwoNodes() throws Exception
    {
       // Make sure all servers are created and started; make sure that database is zapped ONLY for
       // the first server, the others rely on values they expect to find in shared tables; don't
@@ -95,6 +86,7 @@
       ServerManagement.start(0, "all", true);
       ServerManagement.start(1, "all", false);
 
+      // the round robin policy is default
 
       try
       {
@@ -104,40 +96,24 @@
 
          Connection conn0 = cf.createConnection();
 
-         int serverID = ((ConnectionState)((DelegateSupport)((JBossConnection)conn0).getDelegate()).
-            getState()).getServerID();
+         assertEquals(0, ((JBossConnection)conn0).getServerID());
 
-         assertEquals(0, serverID);
-
          Connection conn1 = cf.createConnection();
 
-         serverID = ((ConnectionState)((DelegateSupport)((JBossConnection)conn1).getDelegate()).
-            getState()).getServerID();
+         assertEquals(1, ((JBossConnection)conn1).getServerID());
 
-         assertEquals(1, serverID);
-
          Connection conn2 = cf.createConnection();
 
-         serverID = ((ConnectionState)((DelegateSupport)((JBossConnection)conn2).getDelegate()).
-            getState()).getServerID();
+         assertEquals(0, ((JBossConnection)conn2).getServerID());
 
-         assertEquals(0, serverID);
-
          Connection conn3 = cf.createConnection();
 
-         serverID = ((ConnectionState)((DelegateSupport)((JBossConnection)conn3).getDelegate()).
-            getState()).getServerID();
+         assertEquals(1, ((JBossConnection)conn3).getServerID());
 
-         assertEquals(1, serverID);
-
          Connection conn4 = cf.createConnection();
 
-         serverID = ((ConnectionState)((DelegateSupport)((JBossConnection)conn4).getDelegate()).
-            getState()).getServerID();
+         assertEquals(0, ((JBossConnection)conn4).getServerID());
 
-         assertEquals(0, serverID);
-
-
          conn0.close();
          conn1.close();
          conn2.close();
@@ -153,9 +129,9 @@
       }
    }
 
-   // Package protected ---------------------------------------------
+   // Package protected ----------------------------------------------------------------------------
 
-   // Protected -----------------------------------------------------
+   // Protected ------------------------------------------------------------------------------------
 
    protected void setUp() throws Exception
    {
@@ -168,8 +144,8 @@
       super.tearDown();
    }
 
-   // Private -------------------------------------------------------
+   // Private --------------------------------------------------------------------------------------
 
-   // Inner classes -------------------------------------------------
+   // Inner classes --------------------------------------------------------------------------------
 
 }

Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java	2007-01-10 12:56:46 UTC (rev 1943)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java	2007-01-10 14:38:36 UTC (rev 1944)
@@ -245,6 +245,12 @@
       {
          return XMLUtil.stringToElement(valueAsString);
       }
+      else if (type.startsWith("org.jboss."))
+      {
+         Class interfazza = ServiceContainer.class.getClassLoader().loadClass(type);
+         Class implementation = ServiceContainer.class.getClassLoader().loadClass(valueAsString);
+         return implementation.newInstance();
+      }
 
       throw new Exception("Don't know to handle type " + type);
 




More information about the jboss-cvs-commits mailing list