[jboss-cvs] JBoss Messaging SVN: r6536 - in trunk: src/main/org/jboss/messaging/jms/server/management and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 23 08:01:18 EDT 2009


Author: jmesnil
Date: 2009-04-23 08:01:17 -0400 (Thu, 23 Apr 2009)
New Revision: 6536

Added:
   trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementHelperTest.java
Modified:
   trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java
   trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
   trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
   trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java
   trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
Log:
* modified JMS Server Control class to allow multiple JNDI bindings when creating a connection factory
* in ManagementHelper, allow String[] as parameter (stored in a String property with the format L[$str1||$str2 )?\194?\160

Modified: trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java	2009-04-23 11:22:22 UTC (rev 6535)
+++ trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java	2009-04-23 12:01:17 UTC (rev 6536)
@@ -138,6 +138,12 @@
                {
                   value = null;
                }
+               if (value.toString().startsWith("L["))
+               {
+                  String str = value.toString().substring(2);
+                  String[] strings = str.split("\\|\\|");
+                  value = strings;
+               }
                params.add(index, value);
             }
             catch (NumberFormatException e)
@@ -252,6 +258,16 @@
       {
          message.putStringProperty(key, new SimpleString((String)typedProperty));
       }
+      else if (typedProperty instanceof String[])
+      {
+         String str = "L[";
+         String[] strings = (String[])typedProperty;
+         for (String string : strings)
+         {
+            str += string + "||";
+         }
+         message.putStringProperty(key, new SimpleString(str));         
+      }
       // serialize as a SimpleString
       else
       {
@@ -268,7 +284,9 @@
             (o instanceof Long) ||
             (o instanceof Float) ||
             (o instanceof Double) ||
-            (o instanceof String) || (o instanceof SimpleString)))
+            (o instanceof String) || 
+            (o instanceof String[]) || 
+            (o instanceof SimpleString)))
       {
          throw new IllegalStateException("Can not store object as a message property: " + o);
       }

Modified: trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java	2009-04-23 11:22:22 UTC (rev 6535)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java	2009-04-23 12:01:17 UTC (rev 6536)
@@ -66,7 +66,7 @@
    boolean destroyTopic(@Parameter(name = "name", desc = "Name of the topic to destroy")
    String name) throws Exception;
 
-   void createConnectionFactory(String name, String connectorFactoryClassName, String jndiBinding) throws Exception;
+   void createConnectionFactory(String name, String connectorFactoryClassName, String[] jndiBindings) throws Exception;
 
    void createConnectionFactory(String name,
                                 String connectorFactoryClassName,
@@ -74,7 +74,7 @@
                                 boolean blockOnNonPersistentSend,
                                 boolean blockOnPersistentSend,
                                 boolean preAcknowledge,
-                                String jndiBinding) throws Exception;
+                                String[] jndiBindings) throws Exception;
 
    void createSimpleConnectionFactory(String name,
                                       String connectorFactoryClassName,

Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java	2009-04-23 11:22:22 UTC (rev 6535)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java	2009-04-23 12:01:17 UTC (rev 6536)
@@ -23,6 +23,7 @@
 package org.jboss.messaging.jms.server.management.impl;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -143,17 +144,14 @@
    
    public void createConnectionFactory(String name,
                                              String connectorFactoryClassName,
-                                             String jndiBinding) throws Exception
+                                             String[] jndiBindings) throws Exception
    {
-      List<String> bindings = new ArrayList<String>();
-      bindings.add(jndiBinding);
-
       List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
       connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(new TransportConfiguration(connectorFactoryClassName), null));
 
       boolean created = server.createConnectionFactory(name,
                                                        connectorConfigs,
-                                                       bindings);
+                                                       Arrays.asList(jndiBindings));
       if (created)
       {
          sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
@@ -166,11 +164,8 @@
                                              boolean blockOnNonPersistentSend,
                                              boolean blockOnPersistentSend,
                                              boolean preAcknowledge,
-                                             String jndiBinding) throws Exception
+                                             String[] jndiBindings) throws Exception
    {
-      List<String> bindings = new ArrayList<String>();
-      bindings.add(jndiBinding);
-
       List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
       connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(new TransportConfiguration(connectorFactoryClassName), null));
 
@@ -180,7 +175,7 @@
                                                        blockOnNonPersistentSend,
                                                        blockOnPersistentSend,
                                                        preAcknowledge,
-                                                       bindings);
+                                                       Arrays.asList(jndiBindings));
       if (created)
       {
          sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);

Modified: trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java	2009-04-23 11:22:22 UTC (rev 6535)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java	2009-04-23 12:01:17 UTC (rev 6536)
@@ -70,9 +70,9 @@
 
    public void createConnectionFactory(final String name,
                                        final String connectorFactoryClassName,
-                                       final String jndiBinding) throws Exception
+                                       final String[] jndiBindings) throws Exception
    {
-      replicationAwareInvoke("createConnectionFactory", name, connectorFactoryClassName, jndiBinding);
+      replicationAwareInvoke("createConnectionFactory", name, connectorFactoryClassName, jndiBindings);
    }
 
    public void createConnectionFactory(final String name,
@@ -81,7 +81,7 @@
                                        final boolean blockOnNonPersistentSend,
                                        final boolean blockOnPersistentSend,
                                        final boolean preAcknowledge,
-                                       final String jndiBinding) throws Exception
+                                       final String[] jndiBindings) throws Exception
    {
       replicationAwareInvoke("createConnectionFactory",
                              name,
@@ -90,7 +90,7 @@
                              blockOnNonPersistentSend,
                              blockOnPersistentSend,
                              preAcknowledge,
-                             jndiBinding);
+                             jndiBindings);
    }
 
    public void createSimpleConnectionFactory(final String name,

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlTest.java	2009-04-23 11:22:22 UTC (rev 6535)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlTest.java	2009-04-23 12:01:17 UTC (rev 6536)
@@ -163,33 +163,42 @@
 
    public void testCreateConnectionFactory() throws Exception
    {
-      String cfJNDIBinding = randomString();
+      String[] cfJNDIBindings = new String[] { randomString(), randomString(), randomString() };
       String cfName = randomString();
 
-      checkNoBinding(context, cfJNDIBinding);
+      for (String cfJNDIBinding : cfJNDIBindings)
+      {
+         checkNoBinding(context, cfJNDIBinding);
+      }
       checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
 
       JMSServerControlMBean control = createManagementControl();
-      control.createConnectionFactory(cfName, InVMConnectorFactory.class.getName(), cfJNDIBinding);
+      control.createConnectionFactory(cfName, InVMConnectorFactory.class.getName(), cfJNDIBindings);
 
-      Object o = checkBinding(context, cfJNDIBinding);
-      assertTrue(o instanceof ConnectionFactory);
-      ConnectionFactory cf = (ConnectionFactory)o;
-      Connection connection = cf.createConnection();
-      connection.close();
+      for (String cfJNDIBinding : cfJNDIBindings)
+      {
+         Object o = checkBinding(context, cfJNDIBinding);
+         assertTrue(o instanceof ConnectionFactory);
+         ConnectionFactory cf = (ConnectionFactory)o;
+         Connection connection = cf.createConnection();
+         connection.close();
+      }
       checkResource(ObjectNames.getConnectionFactoryObjectName(cfName));
    }
 
    public void testCreateConnectionFactory_2() throws Exception
    {
-      String cfJNDIBinding = randomString();
+      String[] cfJNDIBindings = new String[] { randomString(), randomString(), randomString() };
       String cfName = randomString();
       boolean preAcknowledge = randomBoolean();
       boolean blockOnAcknowledge = randomBoolean();
       boolean blockOnNonPersistentSend = randomBoolean();
       boolean blockOnPersistentSend = randomBoolean();
 
-      checkNoBinding(context, cfJNDIBinding);
+      for (String cfJNDIBinding : cfJNDIBindings)
+      {
+         checkNoBinding(context, cfJNDIBinding);         
+      }
       checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
 
       JMSServerControlMBean control = createManagementControl();
@@ -199,13 +208,16 @@
                                       blockOnNonPersistentSend,
                                       blockOnPersistentSend,
                                       preAcknowledge,
-                                      cfJNDIBinding);
+                                      cfJNDIBindings);
 
-      Object o = checkBinding(context, cfJNDIBinding);
-      assertTrue(o instanceof ConnectionFactory);
-      ConnectionFactory cf = (ConnectionFactory)o;
-      Connection connection = cf.createConnection();
-      connection.close();
+      for (String cfJNDIBinding : cfJNDIBindings)
+      {
+         Object o = checkBinding(context, cfJNDIBinding);
+         assertTrue(o instanceof ConnectionFactory);
+         ConnectionFactory cf = (ConnectionFactory)o;
+         Connection connection = cf.createConnection();
+         connection.close();
+      }
 
       checkResource(ObjectNames.getConnectionFactoryObjectName(cfName));
       ConnectionFactoryControlMBean cfControl = ManagementControlHelper.createConnectionFactoryControl(cfName,
@@ -315,7 +327,7 @@
       checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
 
       JMSServerControlMBean control = createManagementControl();
-      control.createConnectionFactory(cfName, InVMConnectorFactory.class.getName(), cfJNDIBinding);
+      control.createConnectionFactory(cfName, InVMConnectorFactory.class.getName(), new String[] {cfJNDIBinding});
 
       Object o = checkBinding(context, cfJNDIBinding);
       assertTrue(o instanceof ConnectionFactory);

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java	2009-04-23 11:22:22 UTC (rev 6535)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java	2009-04-23 12:01:17 UTC (rev 6536)
@@ -31,7 +31,6 @@
 import javax.jms.Session;
 
 import org.jboss.messaging.core.config.TransportConfiguration;
-import org.jboss.messaging.core.config.impl.ConfigurationImpl;
 import org.jboss.messaging.core.management.ResourceNames;
 import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
 import org.jboss.messaging.jms.JBossQueue;
@@ -104,9 +103,9 @@
 
          public void createConnectionFactory(final String name,
                                              final String connectorFactoryClassName,
-                                             final String jndiBinding) throws Exception
+                                             final String[] jndiBindings) throws Exception
          {
-            proxy.invokeOperation("createConnectionFactory", name, connectorFactoryClassName, jndiBinding);
+            proxy.invokeOperation("createConnectionFactory", name, connectorFactoryClassName, jndiBindings);
          }
 
          public void createConnectionFactory(final String name,
@@ -115,7 +114,7 @@
                                              final boolean blockOnNonPersistentSend,
                                              final boolean blockOnPersistentSend,
                                              final boolean preAcknowledge,
-                                             final String jndiBinding) throws Exception
+                                             final String[] jndiBindings) throws Exception
          {
             proxy.invokeOperation("createConnectionFactory",
                                  name,
@@ -124,7 +123,7 @@
                                  blockOnNonPersistentSend,
                                  blockOnPersistentSend,
                                  preAcknowledge,
-                                 jndiBinding);
+                                 jndiBindings);
          }
 
          public void createSimpleConnectionFactory(final String name,

Added: trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementHelperTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementHelperTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementHelperTest.java	2009-04-23 12:01:17 UTC (rev 6536)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * 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.messaging.tests.integration.management;
+
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.client.impl.ClientMessageImpl;
+import org.jboss.messaging.core.client.management.impl.ManagementHelper;
+import org.jboss.messaging.core.message.Message;
+
+/**
+ * A ManagementHelperTest
+ *
+ * @author jmesnil
+ *
+ *
+ */
+public class ManagementHelperTest extends TestCase
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testArrayOfStringParameter() throws Exception
+   {
+      String resource = randomString();
+      String operationName = randomString();      
+      String param = randomString();
+      String[] params = new String[] { randomString(), randomString(), randomString() };
+      Message msg = new ClientMessageImpl();
+      ManagementHelper.putOperationInvocation(msg, resource, operationName, param, params);
+      
+      List<Object> parameters = ManagementHelper.retrieveOperationParameters(msg);
+      assertEquals(2, parameters.size());
+      assertEquals(param, parameters.get(0));
+      Object parameter_2 = parameters.get(1);
+      assertTrue(parameter_2 instanceof String[]);
+      String[] retrievedParams = (String[])parameter_2;
+      for (int i = 0; i < retrievedParams.length; i++)
+      {
+         assertEquals(params[i], retrievedParams[i]);
+      }
+   }
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}




More information about the jboss-cvs-commits mailing list