[jboss-cvs] JBoss Messaging SVN: r1945 - in trunk: src/main/org/jboss/messaging/core/plugin/postoffice/cluster and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 10 11:59:18 EST 2007


Author: ovidiu.feodorov at jboss.com
Date: 2007-01-10 11:59:08 -0500 (Wed, 10 Jan 2007)
New Revision: 1945

Added:
   trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceAttributeOverrides.java
Modified:
   trunk/src/main/org/jboss/messaging/core/plugin/ClusteredPostOfficeService.java
   trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java
   trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultMessagePullPolicy.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTest.java
   trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
   trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java
   trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java
   trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java
Log:
Infrastructure required by http://jira.jboss.org/jira/browse/JBMESSAGING-688.


Modified: trunk/src/main/org/jboss/messaging/core/plugin/ClusteredPostOfficeService.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/ClusteredPostOfficeService.java	2007-01-10 14:38:36 UTC (rev 1944)
+++ trunk/src/main/org/jboss/messaging/core/plugin/ClusteredPostOfficeService.java	2007-01-10 16:59:08 UTC (rev 1945)
@@ -322,8 +322,8 @@
 
          Class clazz = Class.forName(messagePullPolicy);
          MessagePullPolicy pullPolicy = (MessagePullPolicy)clazz.newInstance();
+
          clazz = Class.forName(clusterRouterFactory);
-
          ClusterRouterFactory rf = (ClusterRouterFactory)clazz.newInstance();
 
          ConditionFactory cf = new JMSConditionFactory();

Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java	2007-01-10 14:38:36 UTC (rev 1944)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultClusteredPostOffice.java	2007-01-10 16:59:08 UTC (rev 1945)
@@ -807,30 +807,28 @@
       {
          if (nodeId == this.currentNodeId)
          {
-            //Sanity check
-            throw new IllegalStateException("Received stats from node with id that matches this nodes id. You may have started two or more nodes with the same node id!");
+            // Sanity check
+            throw new IllegalStateException("Received stats from node with ID that matches this " +
+               "node's ID. You may have started two or more nodes with the same node ID!");
          }
 
          Map nameMap = (Map)nameMaps.get(new Integer(nodeId));
 
          if (nameMap == null)
          {
-            //This is ok, the node might have left
+            // This is ok, the node might have left
             if (trace) { log.trace(this + " cannot find node in name map, i guess the node might have left?"); }
          }
          else
          {
-            Iterator iter = statsList.iterator();
-
-            while (iter.hasNext())
+            for(Iterator i = statsList.iterator(); i.hasNext(); )
             {
-               QueueStats st = (QueueStats)iter.next();
-
+               QueueStats st = (QueueStats)i.next();
                Binding bb = (Binding)nameMap.get(st.getQueueName());
 
                if (bb == null)
                {
-                  //I guess this is possible if the queue was unbound
+                  // I guess this is possible if the queue was unbound
                   if (trace) { log.trace(this + " cannot find binding for queue " + st.getQueueName() + " it could have been unbound"); }
                }
                else
@@ -843,14 +841,16 @@
 
                   ClusterRouter router = (ClusterRouter)routerMap.get(st.getQueueName());
 
-                  //Maybe the local queue now wants to pull message(s) from the remote queue given that the
-                  //stats for the remote queue have changed
+                  // Maybe the local queue now wants to pull message(s) from the remote queue given
+                  // that the stats for the remote queue have changed
                   LocalClusteredQueue localQueue = (LocalClusteredQueue)router.getLocalQueue();
 
-                  if (localQueue!=null)
+                  if (localQueue != null)
                   {
-                     //TODO - the call to getQueues is too slow since it creates a new list and adds the local queue!!!
-                     RemoteQueueStub toQueue = (RemoteQueueStub)messagePullPolicy.chooseQueue(router.getQueues());
+                     //TODO - the call to getQueues is too slow since it creates a new list and adds
+                     //       the local queue!!!
+                     RemoteQueueStub toQueue =
+                        (RemoteQueueStub)messagePullPolicy.chooseQueue(router.getQueues());
 
                      if (trace) { log.trace(this.currentNodeId + " recalculated pull queue for queue " + st.getQueueName() + " to be " + toQueue); }
 
@@ -858,8 +858,8 @@
 
                      if (toQueue != null && localQueue.getRefCount() == 0)
                      {
-                        //We now trigger delivery - this may cause a pull event
-                        //We only do this if there are no refs in the local queue
+                        // We now trigger delivery - this may cause a pull event
+                        // We only do this if there are no refs in the local queue
 
                         localQueue.deliver(false);
 

Modified: trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultMessagePullPolicy.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultMessagePullPolicy.java	2007-01-10 14:38:36 UTC (rev 1944)
+++ trunk/src/main/org/jboss/messaging/core/plugin/postoffice/cluster/DefaultMessagePullPolicy.java	2007-01-10 16:59:08 UTC (rev 1945)
@@ -24,8 +24,6 @@
 import java.util.Iterator;
 import java.util.List;
 
-import org.jboss.logging.Logger;
-
 /**
  * A DefaultMessagePullPolicy
  * 
@@ -39,8 +37,6 @@
  */
 public class DefaultMessagePullPolicy implements MessagePullPolicy
 {
-   private static final Logger log = Logger.getLogger(DefaultMessagePullPolicy.class);
-   
    public ClusteredQueue chooseQueue(List queues)
    {
       Iterator iter = queues.iterator();

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTest.java	2007-01-10 14:38:36 UTC (rev 1944)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTest.java	2007-01-10 16:59:08 UTC (rev 1945)
@@ -6,7 +6,9 @@
  */
 package org.jboss.test.messaging.jms.clustering;
 
-import org.jboss.test.messaging.jms.clustering.base.ClusteringTestBase;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
 import org.jboss.jms.client.state.ConnectionState;
 import org.jboss.jms.client.delegate.DelegateSupport;
 import org.jboss.jms.client.JBossConnection;
@@ -17,14 +19,24 @@
 import javax.jms.DeliveryMode;
 import javax.jms.MessageConsumer;
 import javax.jms.TextMessage;
+import javax.jms.ConnectionFactory;
+import javax.jms.Queue;
+import javax.naming.InitialContext;
+import javax.management.ObjectName;
+import java.util.Map;
+import java.util.HashMap;
 
 /**
+ * Extending MessagingTestCase and not ClusteringTestBase because I want to start the messaging
+ * servers (the clustered post offices in this case) configured in a particular way (a specific
+ * message redistribution policy).
+ *
  * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
  * @version <tt>$Revision$</tt>
  *
  * $Id$
  */
-public class DistributedQueueTest extends ClusteringTestBase
+public class DistributedQueueTest extends MessagingTestCase
 {
    // Constants -----------------------------------------------------
 
@@ -41,69 +53,98 @@
 
    // Public --------------------------------------------------------
 
-   public void testNoop()
+   public void testMessageRedistributionAmongNodes() throws Exception
    {
-   }
+      // start servers with redistribution policies that actually do something
+      ServiceAttributeOverrides attrOverrides = new ServiceAttributeOverrides();
 
+      attrOverrides.
+         put(new ObjectName("jboss.messaging:service=PostOffice"), "MessagePullPolicy",
+             "org.jboss.messaging.core.plugin.postoffice.cluster.DefaultMessagePullPolicy");
 
-   // If you're wondering why this test is commented out,
-   // see http://jira.jboss.com/jira/browse/JBMESSAGING-688
+      ServerManagement.start(0, "all", attrOverrides, true);
+      ServerManagement.start(1, "all", attrOverrides, false);
 
-//   public void testForwardingMessageAmongNodes() throws Exception
-//   {
-//      Connection conn = null;
-//
-//      try
-//      {
-//         conn = cf.createConnection();
-//
-//         // send a message
-//
-//         Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-//         MessageProducer p = s.createProducer(queue[0]);
-//         p.setDeliveryMode(DeliveryMode.PERSISTENT);
-//         p.send(s.createTextMessage("blip"));
-//
-//         conn.close();
-//
-//         // create a connection to a different node
-//
-//         conn = cf.createConnection();
-//
-//         // make sure we're connecting to node 1
-//
-//         int nodeID = ((ConnectionState)((DelegateSupport)((JBossConnection)conn).
-//            getDelegate()).getState()).getServerID();
-//
-//         assertEquals(1, nodeID);
-//
-//         s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-//         MessageConsumer c = s.createConsumer(queue[1]);
-//         conn.start();
-//
-//         // we must receive the message
-//
-//         TextMessage tm = (TextMessage)c.receive(1000);
-//         assertEquals("blip", tm.getText());
-//
-//      }
-//      finally
-//      {
-//         if (conn != null)
-//         {
-//            conn.close();
-//         }
-//      }
-//   }
+      ServerManagement.deployClusteredQueue("testDistributedQueue", 0);
+      ServerManagement.deployClusteredQueue("testDistributedQueue", 1);
 
+      InitialContext ic0 = null;
+      InitialContext ic1 = null;
+      Connection conn = null;
+
+      try
+      {
+         ic0 = new InitialContext(ServerManagement.getJNDIEnvironment(0));
+         ic1 = new InitialContext(ServerManagement.getJNDIEnvironment(1));
+
+         ConnectionFactory cf = (ConnectionFactory)ic0.lookup("/ConnectionFactory");
+         Queue queue0 = (Queue)ic0.lookup("/queue/testDistributedQueue");
+         Queue queue1 = (Queue)ic1.lookup("/queue/testDistributedQueue");
+
+         conn = cf.createConnection();
+
+         // send a message
+
+         Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         MessageProducer p = s.createProducer(queue0);
+         p.setDeliveryMode(DeliveryMode.PERSISTENT);
+         p.send(s.createTextMessage("blip"));
+
+         conn.close();
+
+         // create a connection to a different node
+
+         conn = cf.createConnection();
+
+         // make sure we're connecting to node 1
+
+         int nodeID = ((ConnectionState)((DelegateSupport)((JBossConnection)conn).
+            getDelegate()).getState()).getServerID();
+
+         assertEquals(1, nodeID);
+
+         s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         MessageConsumer c = s.createConsumer(queue1);
+         conn.start();
+
+         // we must receive the message
+
+         TextMessage tm = (TextMessage)c.receive(1000);
+         assertNotNull(tm);
+         assertEquals("blip", tm.getText());
+
+      }
+      finally
+      {
+         if (conn != null)
+         {
+            conn.close();
+         }
+
+         if (ic0 != null)
+         {
+            ic0.close();
+         }
+
+         if (ic1 != null)
+         {
+            ic1.close();
+         }
+
+         ServerManagement.undeployQueue("testDistributedQueue", 0);
+         ServerManagement.undeployQueue("testDistributedQueue", 1);
+
+         ServerManagement.stop(1);
+         ServerManagement.stop(0);
+      }
+   }
+
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------
 
    protected void setUp() throws Exception
    {
-      nodeCount = 2;
-
       super.setUp();
 
       log.debug("setup done");

Modified: trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java	2007-01-10 14:38:36 UTC (rev 1944)
+++ trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java	2007-01-10 16:59:08 UTC (rev 1945)
@@ -45,6 +45,7 @@
 import org.jboss.test.messaging.tools.jmx.rmi.RMITestServer;
 import org.jboss.test.messaging.tools.jmx.rmi.Server;
 import org.jboss.test.messaging.tools.jmx.rmi.NotificationListenerID;
+import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
 import org.jboss.test.messaging.tools.jndi.InVMInitialContextFactory;
 import org.jboss.test.messaging.tools.jndi.RemoteInitialContextFactory;
 
@@ -163,7 +164,7 @@
    /**
     * Will clear the database at startup.
     */
-   public static synchronized void start(String config) throws Exception
+   public static void start(String config) throws Exception
    {
       start(0, config, true);
    }
@@ -171,18 +172,23 @@
    /**
     * Will clear the database at startup.
     */
-   public static synchronized void start(int i, String config) throws Exception
+   public static void start(int i, String config) throws Exception
    {
       start(i, config, true);
    }
 
+   public static void start(int i, String config, boolean clearDatabase) throws Exception
+   {
+      start(i, config, null, clearDatabase);
+   }
 
    /**
     * When this method correctly completes, the server (local or remote) is started and fully
     * operational (the service container and the server peer are created and started)
     */
-   public static synchronized void start(int i, String config, boolean clearDatabase)
-      throws Exception
+   public static synchronized void start(int i, String config,
+                                         ServiceAttributeOverrides attrOverrides,
+                                         boolean clearDatabase) throws Exception
    {
       Server s = create(i);
 
@@ -190,7 +196,7 @@
 
       log.info("starting server " + i);
 
-      s.start(config, clearDatabase);
+      s.start(config, attrOverrides, clearDatabase);
 
       log.info("server " + i + " started");
    }
@@ -673,9 +679,22 @@
                                       String defaultQueueJNDIContext,
                                       String defaultTopicJNDIContext) throws Exception
    {
+      startServerPeer(serverPeerID, defaultQueueJNDIContext, defaultTopicJNDIContext, null);
+   }
+
+   /**
+    * @param serverPeerID - if null, the jboss-service.xml value will be used.
+    * @param defaultQueueJNDIContext - if null, the jboss-service.xml value will be used.
+    * @param defaultTopicJNDIContext - if null, the jboss-service.xml value will be used.
+    */
+   public static void startServerPeer(int serverPeerID,
+                                      String defaultQueueJNDIContext,
+                                      String defaultTopicJNDIContext,
+                                      ServiceAttributeOverrides attrOverrids) throws Exception
+   {
       insureStarted();
-      servers[0].getServer().
-         startServerPeer(serverPeerID, defaultQueueJNDIContext, defaultTopicJNDIContext, false);
+      servers[0].getServer().startServerPeer(serverPeerID, defaultQueueJNDIContext,
+                                             defaultTopicJNDIContext, attrOverrids, false);
    }
 
    public static void stopServerPeer() throws Exception

Added: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceAttributeOverrides.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceAttributeOverrides.java	2007-01-10 14:38:36 UTC (rev 1944)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceAttributeOverrides.java	2007-01-10 16:59:08 UTC (rev 1945)
@@ -0,0 +1,76 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.messaging.tools.jmx;
+
+import javax.management.ObjectName;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ * $Id$
+ */
+public class ServiceAttributeOverrides implements Serializable
+{
+   // Constants ------------------------------------------------------------------------------------
+
+   private static final long serialVersionUID = 2347829429579213573L;
+
+   // Static ---------------------------------------------------------------------------------------
+
+   // Attributes -----------------------------------------------------------------------------------
+
+   // Map<ObjectName - Map<attrName<String>-attrValue<Object>>
+   private Map map;
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   public ServiceAttributeOverrides()
+   {
+      map = new HashMap();
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+   /**
+    * @return a Map<attributeName<String>-attributeValue<Object>>. Can be empty, but never null.
+    */
+   public Map get(ObjectName on)
+   {
+      Map attrs = (Map)map.get(on);
+
+      if (attrs == null)
+      {
+         attrs = Collections.EMPTY_MAP;
+      }
+      return attrs;
+   }
+
+   public void put(ObjectName on, String attrName, Object attrValue)
+   {
+      Map attrs = (Map)map.get(on);
+
+      if (attrs == null)
+      {
+         attrs = new HashMap();
+         map.put(on, attrs);
+      }
+
+      attrs.put(attrName, attrValue);
+   }
+
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
+   // Private --------------------------------------------------------------------------------------
+
+   // Inner classes --------------------------------------------------------------------------------
+}


Property changes on: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceAttributeOverrides.java
___________________________________________________________________
Name: svn:keywords
   + Id LastChangedDate Author Revision

Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java	2007-01-10 14:38:36 UTC (rev 1944)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java	2007-01-10 16:59:08 UTC (rev 1945)
@@ -26,6 +26,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.Map;
 import javax.jms.Destination;
 import javax.jms.Queue;
 import javax.jms.Topic;
@@ -45,6 +46,7 @@
 import org.jboss.test.messaging.tools.jmx.MockJBossSecurityManager;
 import org.jboss.test.messaging.tools.jmx.RemotingJMXWrapper;
 import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
 import org.jboss.test.messaging.tools.jndi.Constants;
 import org.jboss.aop.AspectXmlLoader;
 import org.w3c.dom.Element;
@@ -114,8 +116,16 @@
       return serverIndex;
    }
 
-   public synchronized void start(String containerConfig, boolean clearDatabase) throws Exception
+   public void start(String containerConfig,
+                     boolean clearDatabase) throws Exception
    {
+      start(containerConfig, null, clearDatabase);
+   }
+
+   public synchronized void start(String containerConfig,
+                                  ServiceAttributeOverrides attrOverrides,
+                                  boolean clearDatabase) throws Exception
+   {
       if (isStarted())
       {
          return;
@@ -140,7 +150,7 @@
             return;
          }
 
-         startServerPeer(serverIndex, null, null, sc.isClustered());
+         startServerPeer(serverIndex, null, null, attrOverrides, sc.isClustered());
 
          log.info("Server " + serverIndex + " started");
       }
@@ -280,6 +290,7 @@
    public void startServerPeer(int serverPeerID,
                                String defaultQueueJNDIContext,
                                String defaultTopicJNDIContext,
+                               ServiceAttributeOverrides attrOverrides,
                                boolean clustered) throws Exception
    {
       try
@@ -316,32 +327,41 @@
 
          log.info(" Persistence config file .. " + persistenceConfigFile);
 
-         URL persistenceConfigFileURL = getClass().getClassLoader().getResource(persistenceConfigFile);
+         URL persistenceConfigFileURL =
+            getClass().getClassLoader().getResource(persistenceConfigFile);
+
          if (persistenceConfigFileURL == null)
          {
             throw new Exception("Cannot find " + persistenceConfigFile + " in the classpath");
          }
 
          String connFactoryConfigFile = "server/default/deploy/connection-factories-service.xml";
-         URL connFactoryConfigFileURL = getClass().getClassLoader().getResource(connFactoryConfigFile);
+         URL connFactoryConfigFileURL =
+            getClass().getClassLoader().getResource(connFactoryConfigFile);
+
          if (connFactoryConfigFileURL == null)
          {
             throw new Exception("Cannot find " + connFactoryConfigFile + " in the classpath");
          }
 
-         ServiceDeploymentDescriptor mdd = new ServiceDeploymentDescriptor(mainConfigFileURL);
-         ServiceDeploymentDescriptor pdd = new ServiceDeploymentDescriptor(persistenceConfigFileURL);
-         ServiceDeploymentDescriptor cfdd = new ServiceDeploymentDescriptor(connFactoryConfigFileURL);
+         ServiceDeploymentDescriptor mdd =
+            new ServiceDeploymentDescriptor(mainConfigFileURL);
+         ServiceDeploymentDescriptor pdd =
+            new ServiceDeploymentDescriptor(persistenceConfigFileURL);
+         ServiceDeploymentDescriptor cfdd =
+            new ServiceDeploymentDescriptor(connFactoryConfigFileURL);
 
          MBeanConfigurationElement persistenceManagerConfig =
             (MBeanConfigurationElement)pdd.query("service", "PersistenceManager").iterator().next();
          persistenceManagerObjectName = sc.registerAndConfigureService(persistenceManagerConfig);
+         overrideAttributes(persistenceManagerObjectName, attrOverrides);
          sc.invoke(persistenceManagerObjectName, "create", new Object[0], new String[0]);
          sc.invoke(persistenceManagerObjectName, "start", new Object[0], new String[0]);
 
          MBeanConfigurationElement jmsUserManagerConfig =
             (MBeanConfigurationElement)pdd.query("service", "JMSUserManager").iterator().next();
          jmsUserManagerObjectName = sc.registerAndConfigureService(jmsUserManagerConfig);
+         overrideAttributes(jmsUserManagerObjectName, attrOverrides);
          sc.invoke(jmsUserManagerObjectName, "create", new Object[0], new String[0]);
          sc.invoke(jmsUserManagerObjectName, "start", new Object[0], new String[0]);
 
@@ -363,6 +383,8 @@
 
          serverPeerObjectName = sc.registerAndConfigureService(serverPeerConfig);
 
+         overrideAttributes(serverPeerObjectName, attrOverrides);
+
          // overwrite the config file security domain
          sc.setAttribute(serverPeerObjectName, "SecurityDomain",
                          MockJBossSecurityManager.TEST_SECURITY_DOMAIN);
@@ -374,7 +396,9 @@
 
          MBeanConfigurationElement postOfficeConfig =
             (MBeanConfigurationElement)pdd.query("service", "PostOffice").iterator().next();
+
          postOfficeObjectName = sc.registerAndConfigureService(postOfficeConfig);
+         overrideAttributes(postOfficeObjectName, attrOverrides);
          sc.invoke(postOfficeObjectName, "create", new Object[0], new String[0]);
          sc.invoke(postOfficeObjectName, "start", new Object[0], new String[0]);
 
@@ -386,6 +410,7 @@
          {
             MBeanConfigurationElement connFactoryElement = (MBeanConfigurationElement)i.next();
             ObjectName on = sc.registerAndConfigureService(connFactoryElement);
+            overrideAttributes(on, attrOverrides);
             // dependencies have been automatically injected already
             sc.invoke(on, "create", new Object[0], new String[0]);
             sc.invoke(on, "start", new Object[0], new String[0]);
@@ -869,6 +894,26 @@
 
    // Private -------------------------------------------------------
 
+   private void overrideAttributes(ObjectName on, ServiceAttributeOverrides attrOverrides)
+      throws Exception
+   {
+      if (attrOverrides == null)
+      {
+         return;
+      }
+
+      Map sao = attrOverrides.get(on);
+
+      for(Iterator i = sao.entrySet().iterator(); i.hasNext();)
+      {
+         Map.Entry entry = (Map.Entry)i.next();
+         String attrName = (String)entry.getKey();
+         Object attrValue = entry.getValue();
+         sc.setAttribute(on, attrName, attrValue.toString());
+
+      }
+   }
+
    // Inner classes -------------------------------------------------
 
 }

Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java	2007-01-10 14:38:36 UTC (rev 1944)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java	2007-01-10 16:59:08 UTC (rev 1945)
@@ -38,6 +38,7 @@
 import org.jboss.messaging.core.plugin.contract.MessageStore;
 import org.jboss.messaging.core.plugin.contract.PersistenceManager;
 import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
 
 /**
  * An RMI wrapper to access the ServiceContainer from a different address space.
@@ -141,9 +142,15 @@
 
    public void start(String containerConfig, boolean clearDatabase) throws Exception
    {
-      server.start(containerConfig, clearDatabase);
+      start(containerConfig, null, clearDatabase);
    }
 
+   public void start(String containerConfig, ServiceAttributeOverrides attrOverrides,
+                     boolean clearDatabase) throws Exception
+   {
+      server.start(containerConfig, attrOverrides, clearDatabase);
+   }
+
    public boolean stop() throws Exception
    {
       boolean result = server.stop();
@@ -157,7 +164,6 @@
       new Thread(new VMKiller(), "VM Killer").start();
    }
 
-
    public void ping() throws Exception
    {
       //noop - nothing to be done
@@ -248,10 +254,20 @@
    public void startServerPeer(int serverPeerID, String defaultQueueJNDIContext,
                                String defaultTopicJNDIContext, boolean clustered) throws Exception
    {
-      server.
-         startServerPeer(serverPeerID, defaultQueueJNDIContext, defaultTopicJNDIContext, clustered);
+      startServerPeer(serverPeerID, defaultQueueJNDIContext,
+                      defaultTopicJNDIContext, null, clustered);
    }
 
+
+   public void startServerPeer(int serverPeerID, String defaultQueueJNDIContext,
+                               String defaultTopicJNDIContext,
+                               ServiceAttributeOverrides attrOverrides, boolean clustered)
+      throws Exception
+   {
+      server.startServerPeer(serverPeerID, defaultQueueJNDIContext,
+                             defaultTopicJNDIContext, attrOverrides, clustered);
+   }
+
    public void stopServerPeer() throws Exception
    {
       server.stopServerPeer();
@@ -378,7 +394,7 @@
                                        int defaultTempQueueDownCacheSize) throws Exception
    {
       server.deployConnectionFactory(objectName, jndiBindings, prefetchSize,
-               defaultTempQueueFullSize, defaultTempQueuePageSize, defaultTempQueueDownCacheSize);
+                                     defaultTempQueueFullSize, defaultTempQueuePageSize, defaultTempQueueDownCacheSize);
    }
 
    public void undeployConnectionFactory(ObjectName objectName) throws Exception

Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java	2007-01-10 14:38:36 UTC (rev 1944)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java	2007-01-10 16:59:08 UTC (rev 1945)
@@ -34,6 +34,7 @@
 import org.jboss.messaging.core.plugin.contract.MessageStore;
 import org.jboss.messaging.core.plugin.contract.PersistenceManager;
 import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
 
 /**
  * The remote interface exposed by TestServer.
@@ -50,6 +51,14 @@
    void start(String containerConfig, boolean clearDatabase) throws Exception;
 
    /**
+    * @param attrOverrides - service attribute overrides that will take precedence over values
+    *        read from configuration files.
+    */
+   void start(String containerConfig,
+              ServiceAttributeOverrides attrOverrides,
+              boolean clearDatabase) throws Exception;
+
+   /**
     * @return true if the server was stopped indeed, or false if the server was stopped already
     *         when the method was invoked.
     */
@@ -110,8 +119,11 @@
    void startServerPeer(int serverPeerID,
                         String defaultQueueJNDIContext,
                         String defaultTopicJNDIContext,
+                        ServiceAttributeOverrides attrOverrides,
                         boolean clustered) throws Exception;
+
    void stopServerPeer() throws Exception;
+
    boolean isServerPeerStarted() throws Exception;
 
    ObjectName getServerPeerObjectName() throws Exception;
@@ -198,11 +210,11 @@
    boolean destroyDestination(boolean isQueue, String name) throws Exception;
 
    void deployConnectionFactory(String objectName,
-            String[] jndiBindings,
-            int prefetchSize,
-            int defaultTempQueueFullSize,
-            int defaultTempQueuePageSize,
-            int defaultTempQueueDownCacheSize) throws Exception;
+                                String[] jndiBindings,
+                                int prefetchSize,
+                                int defaultTempQueueFullSize,
+                                int defaultTempQueuePageSize,
+                                int defaultTempQueueDownCacheSize) throws Exception;
 
    void deployConnectionFactory(String objectName,
                                 String[] jndiBindings,




More information about the jboss-cvs-commits mailing list