[jboss-cvs] JBoss Messaging SVN: r4781 - in trunk: src/bin and 29 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 7 08:16:18 EDT 2008


Author: jmesnil
Date: 2008-08-07 08:16:17 -0400 (Thu, 07 Aug 2008)
New Revision: 4781

Added:
   trunk/src/main/org/jboss/messaging/core/management/AddressControlMBean.java
   trunk/src/main/org/jboss/messaging/core/management/ManagementService.java
   trunk/src/main/org/jboss/messaging/core/management/MessageInfo.java
   trunk/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java
   trunk/src/main/org/jboss/messaging/core/management/Operation.java
   trunk/src/main/org/jboss/messaging/core/management/Parameter.java
   trunk/src/main/org/jboss/messaging/core/management/PropertiesInfo.java
   trunk/src/main/org/jboss/messaging/core/management/QueueControlMBean.java
   trunk/src/main/org/jboss/messaging/core/management/RoleInfo.java
   trunk/src/main/org/jboss/messaging/core/management/impl/AddressControl.java
   trunk/src/main/org/jboss/messaging/core/management/impl/MBeanInfoHelper.java
   trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java
   trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java
   trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java
   trunk/src/main/org/jboss/messaging/jms/server/management/
   trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java
   trunk/src/main/org/jboss/messaging/jms/server/management/DestinationControlMBean.java
   trunk/src/main/org/jboss/messaging/jms/server/management/JMSManagementService.java
   trunk/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java
   trunk/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java
   trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
   trunk/src/main/org/jboss/messaging/jms/server/management/SubscriberInfo.java
   trunk/src/main/org/jboss/messaging/jms/server/management/TopicControlMBean.java
   trunk/src/main/org/jboss/messaging/jms/server/management/impl/
   trunk/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java
   trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementServiceImpl.java
   trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java
   trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
   trunk/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/management/MessageInfoTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/management/RoleInfoTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/AddressControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/ManagementServiceImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/QueueControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/JMSMessageInfoTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/SubscriberInfoTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/ConnectionFactoryControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSManagementServiceImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSServerControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/TopicControlTest.java
Removed:
   trunk/src/main/org/jboss/messaging/jms/server/SubscriptionInfo.java
   trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java
   trunk/src/main/org/jboss/messaging/jms/server/management/DestinationControlMBean.java
   trunk/src/main/org/jboss/messaging/jms/server/management/JMSManagementService.java
   trunk/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java
   trunk/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java
   trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
   trunk/src/main/org/jboss/messaging/jms/server/management/SubscriberInfo.java
   trunk/src/main/org/jboss/messaging/jms/server/management/TopicControlMBean.java
   trunk/src/main/org/jboss/messaging/jms/server/management/impl/
   trunk/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java
   trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementServiceImpl.java
   trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java
   trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
   trunk/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/JMSMessageInfoTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/SubscriberInfoTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/ConnectionFactoryControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSServerControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/TopicControlTest.java
Modified:
   trunk/build-messaging.xml
   trunk/src/bin/run.sh
   trunk/src/config/jbm-beans.xml
   trunk/src/config/jbm-configuration.xml
   trunk/src/config/jbm-jndi.xml
   trunk/src/config/jbm-standalone-beans.xml
   trunk/src/config/queues.xml
   trunk/src/main/org/jboss/messaging/core/config/Configuration.java
   trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java
   trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java
   trunk/src/main/org/jboss/messaging/core/management/MessagingServerManagement.java
   trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerManagementImpl.java
   trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java
   trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
   trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
   trunk/src/main/org/jboss/messaging/core/server/MessageReference.java
   trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
   trunk/src/main/org/jboss/messaging/core/server/Queue.java
   trunk/src/main/org/jboss/messaging/core/server/impl/MessageReferenceImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
   trunk/src/main/org/jboss/messaging/jms/JBossQueue.java
   trunk/src/main/org/jboss/messaging/jms/JBossTopic.java
   trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
   trunk/src/main/org/jboss/messaging/jms/client/JBossMessage.java
   trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
   trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java
   trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
   trunk/tests/jms-tests/src/org/jboss/test/messaging/JBMServerTestCase.java
   trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java
   trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
   trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
   trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/Server.java
   trunk/tests/src/org/jboss/messaging/tests/performance/persistence/StorageManagerTimingTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerManagementImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessageReferenceImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessagingServerImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java
Log:
JBMESSAGING-1303: Revisit management interfaces

* merged branch Branch_JBMESSAGING-1303 into the trunk

Modified: trunk/build-messaging.xml
===================================================================
--- trunk/build-messaging.xml	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/build-messaging.xml	2008-08-07 12:16:17 UTC (rev 4781)
@@ -906,6 +906,7 @@
          <jvmarg value="-Xmx2048M"/>
          <jvmarg value="-XX:+AggressiveOpts"/>
          <jvmarg value="-XX:+UseFastAccessorMethods"/>
+      	 <jvmarg value="-Dcom.sun.management.jmxremote"/>
          <jvmarg value="-Dorg.jboss.logging.Logger.pluginClass=org.jboss.messaging.core.logging.JBMLoggerPlugin"/>
          <jvmarg value="-Djava.library.path=${native.bin.dir}"/>
          <jvmarg value="-Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory"/>

Modified: trunk/src/bin/run.sh
===================================================================
--- trunk/src/bin/run.sh	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/bin/run.sh	2008-08-07 12:16:17 UTC (rev 4781)
@@ -8,4 +8,4 @@
 echo ***********************************************************************************
 echo "java $JVM_ARGS -classpath $CLASSPATH org.jboss.jms.server.microcontainer.JBMBootstrapServer jbm-standalone-beans.xml"
 echo ***********************************************************************************
-java $JVM_ARGS -classpath $CLASSPATH org.jboss.messaging.microcontainer.JBMBootstrapServer jbm-standalone-beans.xml
\ No newline at end of file
+java $JVM_ARGS -classpath $CLASSPATH -Dcom.sun.management.jmxremote org.jboss.messaging.microcontainer.JBMBootstrapServer jbm-standalone-beans.xml
\ No newline at end of file

Modified: trunk/src/config/jbm-beans.xml
===================================================================
--- trunk/src/config/jbm-beans.xml	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/config/jbm-beans.xml	2008-08-07 12:16:17 UTC (rev 4781)
@@ -30,7 +30,6 @@
 
    <bean name="MessagingServerManagement"
          class="org.jboss.messaging.core.management.impl.MessagingServerManagementImpl">
-      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.messaging:service=MessagingServerManagement",exposedInterface=org.jboss.messaging.core.management.MessagingServerManagement.class)</annotation>
       <constructor factoryMethod="getServerManagement">
          <factory bean="MessagingServer"/>
       </constructor>
@@ -49,6 +48,9 @@
       <property name="securityManager">
          <inject bean="JBMSecurityManager"/>
       </property>      
+      <property name="managementService">
+         <inject bean="ManagementService"/>
+      </property>      
    </bean>
 
    <bean name="StorageManager" class="org.jboss.messaging.core.persistence.impl.journal.JournalStorageManager">
@@ -56,6 +58,9 @@
          <parameter>
             <inject bean="Configuration"/>
          </parameter>
+         <parameter>
+            <inject bean="ManagementService"/>
+         </parameter>
       </constructor>
    </bean>
 
@@ -68,11 +73,13 @@
    </bean>
 
    <bean name="JMSServerManager" class="org.jboss.messaging.jms.server.impl.JMSServerManagerImpl">
-      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.messaging:service=JMSServerManager",exposedInterface=org.jboss.messaging.jms.server.JMSServerManager.class)</annotation>
       <constructor>
          <parameter>
             <inject bean="MessagingServer" property="serverManagement"/>
          </parameter>
+         <parameter>
+            <inject bean="JMSManagementService"/>
+         </parameter>
       </constructor>
    </bean>
 
@@ -108,5 +115,32 @@
          </parameter>
       </constructor>
    </bean>
+   
+   <bean name="ManagementService" class="org.jboss.messaging.core.management.impl.ManagementServiceImpl">
+      <constructor>
+         <parameter>
+            <inject bean="MBeanServer"/>
+         </parameter>
+         <parameter>
+            <inject bean="Configuration" property="managementEnabled" />
+         </parameter>
+      </constructor>
+   </bean>
+   
+   <bean name="JMSManagementService" class="org.jboss.messaging.jms.server.management.impl.JMSManagementServiceImpl">
+      <constructor>
+         <parameter>
+            <inject bean="MBeanServer"/>
+         </parameter>
+         <parameter>
+            <inject bean="Configuration" property="managementEnabled" />
+         </parameter>
+      </constructor>
+   </bean>
+   
+   <bean name="MBeanServer" class="javax.management.MBeanServer">
+      <constructor factoryClass="java.lang.management.ManagementFactory"
+                   factoryMethod="getPlatformMBeanServer"/>
+   </bean> 
 
 </deployment>
\ No newline at end of file

Modified: trunk/src/config/jbm-configuration.xml
===================================================================
--- trunk/src/config/jbm-configuration.xml	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/config/jbm-configuration.xml	2008-08-07 12:16:17 UTC (rev 4781)
@@ -12,6 +12,8 @@
       
       <security-invalidation-interval>10000</security-invalidation-interval>
       
+      <management-enabled>true</management-enabled>
+
       <!-- Remoting configuration -->
 
       <!-- one of: TCP, INVM                                                                     -->

Modified: trunk/src/config/jbm-jndi.xml
===================================================================
--- trunk/src/config/jbm-jndi.xml	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/config/jbm-jndi.xml	2008-08-07 12:16:17 UTC (rev 4781)
@@ -102,7 +102,7 @@
       <entry name="/queue/QueueWithOwnRedeliveryDelay"/>
    </queue>
    <topic name="TopicWithOwnRedeliveryDelay">
-      <entry name="/queue/TopicWithOwnRedeliveryDelay"/>
+      <entry name="/topic/TopicWithOwnRedeliveryDelay"/>
    </topic>
    <queue name="testDistributedQueue">
       <entry name="/topic/testDistributedQueue"/>

Modified: trunk/src/config/jbm-standalone-beans.xml
===================================================================
--- trunk/src/config/jbm-standalone-beans.xml	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/config/jbm-standalone-beans.xml	2008-08-07 12:16:17 UTC (rev 4781)
@@ -48,7 +48,6 @@
 
    <bean name="MessagingServerManagement"
          class="org.jboss.messaging.core.management.impl.MessagingServerManagementImpl">
-      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.messaging:service=MessagingServerManagement",exposedInterface=org.jboss.messaging.core.management.MessagingServerManagement.class)</annotation>      
       <constructor factoryMethod="getServerManagement">
          <factory bean="MessagingServer"/>
       </constructor>
@@ -67,6 +66,9 @@
       </property>
       <property name="securityManager">
          <inject bean="JBMSecurityManager"/>
+      </property>
+      <property name="managementService">
+         <inject bean="ManagementService"/>
       </property>      
    </bean>
 
@@ -75,6 +77,9 @@
          <parameter>
             <inject bean="Configuration"/>
          </parameter>
+         <parameter>
+            <inject bean="ManagementService"/>
+         </parameter>         
       </constructor>
    </bean>
 
@@ -87,11 +92,13 @@
    </bean>
    
    <bean name="JMSServerManager" class="org.jboss.messaging.jms.server.impl.JMSServerManagerImpl">
-      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.messaging:service=JMSServerManager",exposedInterface=org.jboss.messaging.jms.server.JMSServerManager.class)</annotation>
       <constructor>
          <parameter>
             <inject bean="MessagingServer" property="serverManagement"/>
          </parameter>
+         <parameter>
+            <inject bean="JMSManagementService"/>
+         </parameter>
       </constructor>
    </bean>
 
@@ -128,4 +135,31 @@
       </constructor>
    </bean>
 
+   <bean name="ManagementService" class="org.jboss.messaging.core.management.impl.ManagementServiceImpl">
+      <constructor>
+         <parameter>
+            <inject bean="MBeanServer"/>
+         </parameter>
+         <parameter>
+            <inject bean="Configuration" property="managementEnabled" />
+         </parameter>
+      </constructor>
+   </bean>
+   
+   <bean name="JMSManagementService" class="org.jboss.messaging.jms.server.management.impl.JMSManagementServiceImpl">
+      <constructor>
+         <parameter>
+            <inject bean="MBeanServer"/>
+         </parameter>
+         <parameter>
+            <inject bean="Configuration" property="managementEnabled" />
+         </parameter>
+      </constructor>
+   </bean>
+   
+   <bean name="MBeanServer" class="javax.management.MBeanServer">
+      <constructor factoryClass="java.lang.management.ManagementFactory"
+                   factoryMethod="getPlatformMBeanServer"/>
+   </bean> 
+   
 </deployment>
\ No newline at end of file

Modified: trunk/src/config/queues.xml
===================================================================
--- trunk/src/config/queues.xml	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/config/queues.xml	2008-08-07 12:16:17 UTC (rev 4781)
@@ -64,12 +64,12 @@
    </security>
 
    <queue-settings match="queuejms.QueueWithOwnDLQAndExpiryQueue">
-      <dlq>PrivateDLQ</dlq>
+      <dlq>queuejms.PrivateDLQ</dlq>
       <expiry-queue>queuejms.PrivateExpiryQueue</expiry-queue>
    </queue-settings>
 
    <queue-settings match="topicjms.TopicWithOwnDLQAndExpiryQueue">
-      <dlq>PrivateDLQ</dlq>
+      <dlq>queuejms.PrivateDLQ</dlq>
       <expiry-queue>queuejms.PrivateExpiryQueue</expiry-queue>
    </queue-settings>
 
@@ -96,7 +96,7 @@
    <!--default for catch all-->
    <queue-settings match="*">
       <clustered>false</clustered>
-      <dlq>DLQ</dlq>
+      <dlq>queuejms.DLQ</dlq>
       <expiry-queue>queuejms.ExpiryQueue</expiry-queue>
       <redelivery-delay>0</redelivery-delay>
       <max-size-bytes>-1</max-size-bytes>

Modified: trunk/src/main/org/jboss/messaging/core/config/Configuration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/Configuration.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/core/config/Configuration.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -62,6 +62,10 @@
    
    void setRequireDestinations(boolean require);
 
+   boolean isManagementEnabled();
+
+   void setManagementEnabled(boolean enabled);
+
    // Remoting related attributes ----------------------------------------------------------
    
    List<String> getInterceptorClassNames();
@@ -157,4 +161,5 @@
    boolean isCreateJournalDir();
    
    void setCreateJournalDir(boolean create);
+
 }

Modified: trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -61,6 +61,8 @@
    
    public static final boolean DEFAULT_SECURITY_ENABLED = true;
    
+   public static final boolean DEFAULT_MANAGEMENT_ENABLED = true;
+   
    public static final boolean DEFAULT_SSL_ENABLED = false;
    
    public static final String DEFAULT_KEYSTORE_PATH = "messaging.keystore";
@@ -106,6 +108,7 @@
    
    protected boolean securityEnabled = DEFAULT_SECURITY_ENABLED;
 
+   protected boolean managementEnabled = DEFAULT_MANAGEMENT_ENABLED;
    
    // Journal related attributes
    
@@ -442,6 +445,16 @@
       this.securityEnabled = enabled;
    }
 
+	public boolean isManagementEnabled()
+	{
+	   return managementEnabled ;
+	}
+	
+	public void setManagementEnabled(boolean enabled)
+	{
+	   this.managementEnabled = enabled;
+	}
+	
    public ConnectionParams getConnectionParams()
    {
       return this.defaultConnectionParams;

Modified: trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -79,6 +79,8 @@
       
       securityEnabled = getBoolean(e, "security-enabled", securityEnabled);
       
+      managementEnabled = getBoolean(e, "management-enabled", managementEnabled);
+      
       securityInvalidationInterval = getLong(e, "security-invalidation-interval", securityInvalidationInterval);
             
       // Remoting config

Copied: trunk/src/main/org/jboss/messaging/core/management/AddressControlMBean.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/AddressControlMBean.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/AddressControlMBean.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/AddressControlMBean.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.core.management;
+
+import javax.management.openmbean.TabularData;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public interface AddressControlMBean
+{
+   // Attributes ----------------------------------------------------
+
+   String getAddress();
+
+   TabularData getRoles() throws Exception;
+   
+   RoleInfo[] getRoleInfos() throws Exception;
+
+   String[] getQueueNames() throws Exception;
+
+   // Operations ----------------------------------------------------
+
+   @Operation(desc = "Add a Role to this address")
+   void addRole(
+         @Parameter(name = "name", desc = "Name of the role to add") String name,
+         @Parameter(name = "create", desc = "Can the user create resource?") boolean create,
+         @Parameter(name = "read", desc = "Can the user read from this address?") boolean read,
+         @Parameter(name = "write", desc = "Can the user write from this address?") boolean write)
+         throws Exception;
+
+   @Operation(desc = "Remove a Role from this address")
+   void removeRole(
+         @Parameter(name = "name", desc = "Name of the role to remove") String name)
+         throws Exception;
+}

Copied: trunk/src/main/org/jboss/messaging/core/management/ManagementService.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/ManagementService.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/ManagementService.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/ManagementService.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.core.management;
+
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.settings.HierarchicalRepository;
+import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public interface ManagementService
+{
+   void setPostOffice(PostOffice postOffice);
+
+   void setQueueSettingsRepository(
+         HierarchicalRepository<QueueSettings> queueSettingsRepository);
+
+   void registerServer(MessagingServerManagement server)
+         throws Exception;
+
+   void unregisterServer() throws Exception;
+
+   void registerAddress(SimpleString address) throws Exception;
+
+   void unregisterAddress(SimpleString address) throws Exception;
+
+   void registerQueue(Queue queue, SimpleString address, StorageManager storageManager)
+         throws Exception;
+
+   void unregisterQueue(SimpleString name, SimpleString address)
+         throws Exception;
+}

Copied: trunk/src/main/org/jboss/messaging/core/management/MessageInfo.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/MessageInfo.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/MessageInfo.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/MessageInfo.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,202 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.core.management;
+
+import static javax.management.openmbean.SimpleType.BOOLEAN;
+import static javax.management.openmbean.SimpleType.BYTE;
+import static javax.management.openmbean.SimpleType.INTEGER;
+import static javax.management.openmbean.SimpleType.LONG;
+import static javax.management.openmbean.SimpleType.STRING;
+
+import java.util.Map;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class MessageInfo
+{
+   // Constants -----------------------------------------------------
+
+   public static final CompositeType TYPE;
+   private static final String MESSAGE_TYPE_NAME = "MessageInfo";
+   private static final String MESSAGE_TABULAR_TYPE_NAME = "MessageTabularInfo";
+   private static final String[] ITEM_NAMES = new String[] { "id",
+         "destination", "durable", "timestamp", "type", "size", "priority",
+         "expired", "expiration", "properties" };
+   private static final String[] ITEM_DESCRIPTIONS = new String[] {
+         "Message ID", "destination of the message", "Is the message durable?",
+         "Timestamp of the message", "Type of the message",
+         "Size of the encoded messag", "Priority of the message",
+         "Is the message expired?", "Expiration of the message",
+         "Properties of the message" };
+   private static final OpenType[] TYPES;
+   private static final TabularType TABULAR_TYPE;
+
+   static
+   {
+      try
+      {
+         TYPES = new OpenType[] { LONG, STRING, BOOLEAN, LONG, BYTE, INTEGER,
+               BYTE, BOOLEAN, LONG, PropertiesInfo.TABULAR_TYPE };
+         TYPE = new CompositeType(MESSAGE_TYPE_NAME,
+               "Information for a Message", ITEM_NAMES, ITEM_DESCRIPTIONS,
+               TYPES);
+         TABULAR_TYPE = new TabularType(MESSAGE_TABULAR_TYPE_NAME,
+               "Information for tabular MessageInfo", TYPE,
+               new String[] { "id" });
+      } catch (OpenDataException e)
+      {
+         e.printStackTrace();
+         throw new IllegalStateException(e);
+      }
+   }
+
+   // Attributes ----------------------------------------------------
+
+   private final long id;
+   private final String destination;
+   private final boolean durable;
+   private final long timestamp;
+   private final byte type;
+   private final int size;
+   private final byte priority;
+   private final boolean expired;
+   private final long expiration;
+   private PropertiesInfo properties;
+
+   // Static --------------------------------------------------------
+
+   public static TabularData toTabularData(final MessageInfo[] infos)
+         throws OpenDataException
+   {
+      TabularData data = new TabularDataSupport(TABULAR_TYPE);
+      for (MessageInfo messageInfo : infos)
+      {
+         data.put(messageInfo.toCompositeData());
+      }
+      return data;
+   }
+
+   // Constructors --------------------------------------------------
+
+   public MessageInfo(final long id, final String destination,
+         final boolean durable, final long timestamp, final byte type,
+         final int size, final byte priority, final boolean expired,
+         final long expiration)
+   {
+      this.id = id;
+      this.destination = destination;
+      this.durable = durable;
+      this.timestamp = timestamp;
+      this.type = type;
+      this.size = size;
+      this.priority = priority;
+      this.expired = expired;
+      this.expiration = expiration;
+      this.properties = new PropertiesInfo();
+   }
+
+   // Public --------------------------------------------------------
+
+   public long getID()
+   {
+      return id;
+   }
+
+   public String getDestination()
+   {
+      return destination;
+   }
+
+   public boolean isDurable()
+   {
+      return durable;
+   }
+
+   public long getTimestamp()
+   {
+      return timestamp;
+   }
+
+   public byte getType()
+   {
+      return type;
+   }
+
+   public int getSize()
+   {
+      return size;
+   }
+
+   public byte getPriority()
+   {
+      return priority;
+   }
+
+   public boolean isExpired()
+   {
+      return expired;
+   }
+
+   public long getExpiration()
+   {
+      return expiration;
+   }
+
+   public void putProperty(final String key, final String value)
+   {
+      properties.put(key, value);
+   }
+
+   public Map<String, String> getProperties()
+   {
+      return properties.entries();
+   }
+
+   public CompositeData toCompositeData()
+   {
+      try
+      {
+
+         return new CompositeDataSupport(TYPE, ITEM_NAMES, new Object[] { id,
+               destination, durable, timestamp, type, size, priority, expired,
+               expiration, properties.toTabularData() });
+      } catch (OpenDataException e)
+      {
+         e.printStackTrace();
+         return null;
+      }
+   }
+}

Copied: trunk/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, 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.core.management;
+
+import static javax.management.MBeanOperationInfo.ACTION;
+
+import java.util.List;
+
+/**
+ * This interface describes the core management interface exposed by the server
+ */
+public interface MessagingServerControlMBean
+{
+   // Attributes ----------------------------------------------------
+
+   String getVersion();
+
+   int getConnectionCount();
+
+   boolean isStarted();
+
+   List<String> getInterceptorClassNames();
+
+   boolean isClustered();
+
+   int getScheduledThreadPoolMaxSize();
+
+   long getSecurityInvalidationInterval();
+
+   boolean isSecurityEnabled();
+
+   boolean isRequireDestinations();
+
+   String getLocation();
+
+   String getKeyStorePath();
+
+   String getTrustStorePath();
+
+   boolean isSSLEnabled();
+
+   String getBindingsDirectory();
+
+   String getJournalDirectory();
+
+   String getJournalType();
+
+   boolean isJournalSyncTransactional();
+
+   boolean isJournalSyncNonTransactional();
+
+   int getJournalFileSize();
+
+   int getJournalMinFiles();
+
+   int getJournalMaxAIO();
+
+   boolean isCreateBindingsDir();
+
+   boolean isCreateJournalDir();
+
+   // Operations ----------------------------------------------------
+
+   @Operation(desc = "Create a queue with the specified address", impact = ACTION)
+   void createQueue(
+         @Parameter(name = "address", desc = "Address of the queue") String address,
+         @Parameter(name = "name", desc = "Name of the queue") String name)
+         throws Exception;
+
+   @Operation(desc = "Create a queue", impact = ACTION)
+   void createQueue(
+         @Parameter(name = "address", desc = "Address of the queue") String address,
+         @Parameter(name = "name", desc = "Name of the queue") String name,
+         @Parameter(name = "filter", desc = "Filter of the queue") String filter,
+         @Parameter(name = "durable", desc = "Is the queue durable?") boolean durable,
+         @Parameter(name = "temporary", desc = "Is the queue temporary?") boolean temporary)
+         throws Exception;
+
+   @Operation(desc = "Destroy a queue", impact = ACTION)
+   void destroyQueue(
+         @Parameter(name = "name", desc = "Name of the queue to destroy") String name)
+         throws Exception;
+
+   @Operation(desc = "Add an address to the post office", impact = ACTION)
+   boolean addAddress(
+         @Parameter(name = "address", desc = "The address to add") String address)
+         throws Exception;
+
+   @Operation(desc = "Remove an address from the post office", impact = ACTION)
+   boolean removeAddress(
+         @Parameter(name = "address", desc = "The address to remove") String address)
+         throws Exception;
+}

Modified: trunk/src/main/org/jboss/messaging/core/management/MessagingServerManagement.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/MessagingServerManagement.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/core/management/MessagingServerManagement.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -26,6 +26,7 @@
 import java.util.Set;
 
 import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.filter.Filter;
 import org.jboss.messaging.core.security.Role;
 import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.core.settings.impl.QueueSettings;
@@ -36,6 +37,7 @@
  * 
  * @author <a href="ataylor at redhat.com">Andy Taylor</a>
  * @author <a href="tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
  */
 public interface MessagingServerManagement
 {
@@ -56,6 +58,17 @@
    void createQueue(SimpleString address, SimpleString name) throws Exception;
 
    /**
+    * @param address
+    * @param name
+    * @param filter
+    * @param durable
+    * @param temporary
+    * @throws Exception
+    */
+   void createQueue(SimpleString address, SimpleString name, SimpleString filter,
+         boolean durable, boolean temporary) throws Exception;
+
+   /**
     * destroy a particular queue
     * @param name the name of the queue
     * @throws Exception if a problem occurred
@@ -87,184 +100,79 @@
    List<Queue> getQueuesForAddress(SimpleString address) throws Exception;
 
    /**
+    * @param messageID
+    * @param simpleAddress
+    * @return
+    * @throws Exception 
+    */
+   boolean removeMessageFromAddress(long messageID, SimpleString address) throws Exception;
+
+   /**
     * remove all the messages for a specific address
     * @param address the address
     * @throws Exception if a problem occurred
     */
    void removeAllMessagesForAddress(SimpleString address) throws Exception;
 
-   void setSecurityForAddress(String address, Set<Role> roles) throws Exception;
+   void setSecurityForAddress(SimpleString address, Set<Role> roles) throws Exception;
    
-   void removeSecurityForAddress(String address) throws Exception;
+   void removeSecurityForAddress(SimpleString address) throws Exception;
    
-   Set<Role> getSecurityForAddress(String address) throws Exception;
+   Set<Role> getSecurityForAddress(SimpleString address) throws Exception;
    
-   void setQueueAttributes(String queueName, QueueSettings settings) throws Exception;
+   void setQueueAttributes(SimpleString queueName, QueueSettings settings) throws Exception;
    
-   /**
-    * remove all the messages for a specific binding
-    * @param name the name of the binding
-    * @throws Exception if a problem occurred
-    */
-   //void removeAllMessagesForBinding(SimpleString name) throws Exception;
+   Configuration getConfiguration();
 
    /**
-    * List all messages in a queue that match the filter provided
-    * @param queue the name of the queue
-    * @param filter the filter
-    * @return the messages
-    * @throws Exception if a problem occurred
+    * @param queueName
+    * @return
+    * @throws Exception 
     */
-   //List<Message> listMessages(SimpleString queue, Filter filter) throws Exception;
+   Queue getQueue(SimpleString queueName) throws Exception;
 
    /**
-    * remove the messages for a specific binding that match the specified filter
-    * @param binding the name of the binding
-    * @param filter the filter
-    * @throws Exception if a problem occurred
+    * @return
     */
-  /// void removeMessageForBinding(String binding, Filter filter) throws Exception;
+   String getVersion();
 
    /**
-    * remove the messages for a specific address that match the specified filter
-    * @param address the address
-    * @param filter the filter
-    * @throws Exception if a problem occurred
+    * @param messageID
+    * @param address
+    * @return
+    * @throws Exception 
     */
-  // void removeMessageForAddress(String address, Filter filter) throws Exception;
+   boolean expireMessage(long messageID, SimpleString address) throws Exception;
 
    /**
-    * count the number of messages in a queue
-    * @param queue the name of the queue
-    * @return the number of messages in a queue
-    * @throws Exception if a problem occurred
+    * @param filter
+    * @param address
+    * @return
+    * @throws Exception 
     */
-   int getMessageCountForQueue(SimpleString queue) throws Exception;
+   int expireMessages(Filter filter,
+         SimpleString address) throws Exception;
 
    /**
-    * register a message counter with a specific queue
-    * @param queue the name of the queue
-    * @throws Exception if a problem occurred
+    * @param simpleAddress
+    * @return
     */
-   //void registerMessageCounter(SimpleString queue) throws Exception;
+   QueueSettings getQueueSettings(SimpleString simpleAddress);
 
    /**
-    * unregister a message counter from a specific queue
-    * @param queue the name of the queue
-    * @throws Exception if a problem occurred
+    * @param filter
+    * @param simpleAddress
+    * @return
     */
-   //void unregisterMessageCounter(SimpleString queue) throws Exception;
+   int sendMessagesToDLQ(Filter filter,
+         SimpleString simpleAddress) throws Exception;
 
    /**
-    * start collection statistics on a message counter. The message counter must have been registered first.
-    * @param queue the name of the queue
-    * @param duration how long to take a sample for in seconds. 0 means indefinitely.
-    * @throws Exception if a problem occurred
+    * @param filter
+    * @param newPriority
+    * @param simpleAddress
+    * @return
     */
-   //void startMessageCounter(SimpleString queue, long duration) throws Exception;
-
-   /**
-    * stop a message counter on a specific queue. The message counter must be started to call this.
-    * @param queue the name of the queue
-    * @return the message counter stopped
-    * @throws Exception if a problem occurred
-    */
-   //MessageCounter stopMessageCounter(SimpleString queue) throws Exception;
-
-   /**
-    * get a message counter for a specific queue
-    * @param queue the name of the queue
-    * @return the message counter
-    */
-   //MessageCounter getMessageCounter(SimpleString queue);
-//
-   /**
-    * get all message counters
-    * @return the message counters
-    */
-   //Collection<MessageCounter> getMessageCounters();
-
-   /**
-    * reset a message counter for a specific queue
-    * @param queue the name of the queue
-    */
-   //void resetMessageCounter(SimpleString queue);
-
-   /**
-    * reset all message counters registered
-    */
-   //void resetMessageCounters();
-
-   /**
-    * reset the history for a message counter for a queue
-    * @param queue the name of the queue
-    */
-   //void resetMessageCounterHistory(SimpleString queue);
-
-   /**
-    * reset all message counter histories
-    */
-   //void resetMessageCounterHistories();
-
-   /**
-    * stop all message counters
-    * @return all message counters
-    * @throws Exception if a problem occurred
-    */
-   //List<MessageCounter> stopAllMessageCounters() throws Exception;
-
-   /**
-    * unregister all message counters
-    * @throws Exception if a problem occurred
-    */
-   //void unregisterAllMessageCounters() throws Exception;
-
-   /**
-    * get the number of consumers for a specific queue
-    * @param queue the name of the queue
-    * @return the count
-    * @throws Exception if a problem occurred
-    */
-   //public int getConsumerCountForQueue(SimpleString queue) throws Exception;
-
-   /**
-    * return all the active connections
-    * @return all connections
-    */
-   //List<ServerConnection> getActiveConnections();
-
-   /**
-    * move a set of messages from one queue to another
-    * @param toQueue the source queue
-    * @param fromQueue the destination queue
-    * @param filter the filter to use
-    * @throws Exception if a problem occurred
-    */
-   //void moveMessages(String toQueue, String fromQueue, String filter) throws Exception;
-
-   /**
-    * expire a set of messages for a specific queue
-    * @param queue the name of the queue
-    * @param filter the filter to use
-    * @throws Exception if a problem occurred
-    */
-   //void expireMessages(SimpleString queue,String filter) throws Exception;
-
-   /**
-    * change the message priority for a set of messages
-    * @param queue the name of the queue
-    * @param filter the filter to use
-    * @param priority the priority to change to
-    * @throws Exception if a problem occurred
-    */
-   //void changeMessagePriority(String queue, String filter, int priority) throws Exception;
-
-   /**
-    * list all available addresses
-    * @return the addresses
-    */
-   //Set<SimpleString> listAvailableAddresses();
-
-   Configuration getConfiguration();
-
+   int changeMessagesPriority(Filter filter,
+         byte newPriority, SimpleString address) throws Exception;
 }

Copied: trunk/src/main/org/jboss/messaging/core/management/Operation.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/Operation.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/Operation.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/Operation.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.core.management;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.management.MBeanOperationInfo;
+
+/**
+ * Info for a MBean Operation.
+ * 
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target(ElementType.METHOD)
+ at Inherited
+public @interface Operation
+{
+    String desc();
+    int impact() default MBeanOperationInfo.INFO;
+}

Copied: trunk/src/main/org/jboss/messaging/core/management/Parameter.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/Parameter.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/Parameter.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/Parameter.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.core.management;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Info for a MBean Operation Parameter.
+ * 
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target(ElementType.PARAMETER)
+public @interface Parameter {
+    String name();
+    String desc();
+}

Copied: trunk/src/main/org/jboss/messaging/core/management/PropertiesInfo.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/PropertiesInfo.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/PropertiesInfo.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/PropertiesInfo.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.core.management;
+
+import static javax.management.openmbean.SimpleType.STRING;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+/**
+ * Info for a Message property.
+ * 
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class PropertiesInfo
+{
+   // Constants -----------------------------------------------------
+
+   public static final TabularType TABULAR_TYPE;
+   private static CompositeType ROW_TYPE;
+
+   static
+   {
+      try
+      {
+         ROW_TYPE = new CompositeType("Property", "Property", new String[] {
+               "key", "value" }, new String[] { "Key of the property",
+               "Value of the property" }, new OpenType[] { STRING, STRING });
+         TABULAR_TYPE = new TabularType("PropertyInfo",
+               "Properties of the message", ROW_TYPE, new String[] { "key" });
+      } catch (OpenDataException e)
+      {
+         e.printStackTrace();
+         throw new IllegalStateException(e);
+      }
+   }
+
+   // Attributes ----------------------------------------------------
+
+   private final Map<String, String> properties = new HashMap<String, String>();
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public Map<String, String> entries()
+   {
+      return properties;
+   }
+
+   public void put(final String key, final String value)
+   {
+      properties.put(key, value);
+   }
+
+   public TabularData toTabularData()
+   {
+      try
+      {
+         TabularDataSupport data = new TabularDataSupport(TABULAR_TYPE);
+         for (Entry<String, String> entry : properties.entrySet())
+         {
+            data
+                  .put(new CompositeDataSupport(ROW_TYPE, new String[] { "key",
+                        "value" }, new Object[] { entry.getKey(),
+                        entry.getValue() }));
+         }
+         return data;
+      } catch (OpenDataException e)
+      {
+         e.printStackTrace();
+         return null;
+      }
+   }
+}
\ No newline at end of file

Copied: trunk/src/main/org/jboss/messaging/core/management/QueueControlMBean.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/QueueControlMBean.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/QueueControlMBean.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/QueueControlMBean.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.core.management;
+
+import static javax.management.MBeanOperationInfo.ACTION;
+import static javax.management.MBeanOperationInfo.INFO;
+
+import javax.management.openmbean.TabularData;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public interface QueueControlMBean
+{
+   // Attributes ----------------------------------------------------
+
+   String getName();
+
+   long getPersistenceID();
+
+   boolean isClustered();
+
+   boolean isTemporary();
+
+   boolean isDurable();
+
+   String getFilter();
+
+   long getSizeBytes();
+
+   int getMaxSizeBytes();
+
+   int getMessageCount();
+
+   long getScheduledCount();
+
+   int getConsumerCount();
+
+   int getDeliveringCount();
+
+   int getMessagesAdded();
+   
+   String getExpiryQueue();
+   
+   String getDLQ();
+
+   // Operations ----------------------------------------------------
+
+   @Operation(desc = "List all the messages in the queue", impact = INFO)
+   TabularData listAllMessages() throws Exception;
+
+   @Operation(desc = "List all the messages in the queue matching the given filter", impact = INFO)
+   TabularData listMessages(
+         @Parameter(name = "filter", desc = "A message filter") String filter)
+         throws Exception;
+
+   @Operation(desc = "Remove all the messages from the queue", impact = ACTION)
+   void removeAllMessages() throws Exception;
+
+   @Operation(desc = "Remove the message corresponding to the given messageID", impact = ACTION)
+   boolean removeMessage(
+         @Parameter(name = "messageID", desc = "A message ID") long messageID)
+         throws Exception;
+
+   @Operation(desc = "Remove the messages corresponding to the given filter (and returns the number of expired messages)", impact = ACTION)
+   int expireMessages(
+         @Parameter(name = "filter", desc = "A message filter") String filter)
+         throws Exception;
+
+   @Operation(desc = "Remove the message corresponding to the given messageID", impact = ACTION)
+   boolean expireMessage(
+         @Parameter(name = "messageID", desc = "A message ID") long messageID)
+         throws Exception;
+
+   @Operation(desc = "Move the message corresponding to the given messageID to another queue", impact = ACTION)
+   boolean moveMessage(
+         @Parameter(name = "messageID", desc = "A message ID") long messageID,
+         @Parameter(name = "otherQueueName", desc = "The name of the queue to move the message to") String otherQueueName)
+         throws Exception;
+
+   @Operation(desc = "Send the message corresponding to the given messageID to this queue's Dead Letter Queue", impact = ACTION)
+   boolean sendMessageToDLQ(
+         @Parameter(name = "messageID", desc = "A message ID") long messageID)
+         throws Exception;
+   
+   @Operation(desc = "Change the priority of the message corresponding to the given messageID", impact = ACTION)
+   boolean changeMessagePriority(
+         @Parameter(name = "messageID", desc = "A message ID") long messageID,
+         @Parameter(name = "newPriority", desc = "the new priority (between 0 and 9)") int newPriority)
+         throws Exception;
+
+}

Copied: trunk/src/main/org/jboss/messaging/core/management/RoleInfo.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/RoleInfo.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/RoleInfo.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/RoleInfo.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.core.management;
+
+import static javax.management.openmbean.SimpleType.BOOLEAN;
+import static javax.management.openmbean.SimpleType.STRING;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class RoleInfo
+{
+   // Constants -----------------------------------------------------
+
+   public static final CompositeType TYPE;
+   private static final String ROLE_TYPE_NAME = "RoleInfo";
+   private static final String ROLE_TABULAR_TYPE_NAME = "RoleTabularInfo";
+   private static final TabularType TABULAR_TYPE;
+   private static final String[] ITEM_NAMES = new String[] { "name", "create",
+         "read", "write" };
+   private static final String[] ITEM_DESCRIPTIONS = new String[] {
+         "Name of the role", "Can the role create?", "Can the role read?",
+         "Can the role write?" };
+   private static final OpenType[] ITEM_TYPES = new OpenType[] { STRING,
+         BOOLEAN, BOOLEAN, BOOLEAN };
+
+   static
+   {
+      try
+      {
+         TYPE = new CompositeType(ROLE_TYPE_NAME, "Information for a Role",
+               ITEM_NAMES, ITEM_DESCRIPTIONS, ITEM_TYPES);
+         TABULAR_TYPE = new TabularType(ROLE_TABULAR_TYPE_NAME,
+               "Table of RoleInfo", TYPE, new String[] { "name" });
+      } catch (OpenDataException e)
+      {
+         throw new IllegalStateException(e);
+      }
+   }
+
+   // Attributes ----------------------------------------------------
+
+   private final String name;
+   private final boolean create;
+   private final boolean read;
+   private final boolean write;
+
+   // Static --------------------------------------------------------
+
+   public static TabularData toTabularData(RoleInfo[] infos)
+   {
+      TabularData data = new TabularDataSupport(TABULAR_TYPE);
+      for (RoleInfo roleInfo : infos)
+      {
+         data.put(roleInfo.toCompositeData());
+      }
+      return data;
+   }
+
+   // Constructors --------------------------------------------------
+
+   public RoleInfo(String name, boolean create, boolean read, boolean write)
+   {
+      this.name = name;
+      this.create = create;
+      this.read = read;
+      this.write = write;
+   }
+
+   // Public --------------------------------------------------------
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public boolean isCreate()
+   {
+      return create;
+   }
+
+   public boolean isRead()
+   {
+      return read;
+   }
+
+   public boolean isWrite()
+   {
+      return write;
+   }
+
+   public CompositeData toCompositeData()
+   {
+      try
+      {
+         return new CompositeDataSupport(TYPE, ITEM_NAMES, new Object[] { name,
+               create, read, write });
+      } catch (OpenDataException e)
+      {
+         return null;
+      }
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/management/impl/AddressControl.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/AddressControl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/AddressControl.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/AddressControl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,172 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.core.management.impl;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.management.MBeanInfo;
+import javax.management.NotCompliantMBeanException;
+import javax.management.StandardMBean;
+import javax.management.openmbean.TabularData;
+
+import org.jboss.messaging.core.management.AddressControlMBean;
+import org.jboss.messaging.core.management.MessagingServerManagement;
+import org.jboss.messaging.core.management.RoleInfo;
+import org.jboss.messaging.core.security.CheckType;
+import org.jboss.messaging.core.security.Role;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class AddressControl extends StandardMBean implements
+      AddressControlMBean
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final SimpleString address;
+   private MessagingServerManagement server;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public AddressControl(final SimpleString address,
+         final MessagingServerManagement server)
+         throws NotCompliantMBeanException
+   {
+      super(AddressControlMBean.class);
+      this.address = address;
+      this.server = server;
+   }
+
+   // Public --------------------------------------------------------
+
+   // AddressControlMBean implementation ----------------------------
+
+   public String getAddress()
+   {
+      return address.toString();
+   }
+
+   public String[] getQueueNames() throws Exception
+   {
+      try
+      {
+         List<Queue> queues = server.getQueuesForAddress(address);
+         String[] queueNames = new String[queues.size()];
+         for (int i = 0; i < queues.size(); i++)
+         {
+            queueNames[i] = queues.get(i).getName().toString();
+         }
+         return queueNames;
+      } catch (Throwable t)
+      {
+         throw new IllegalStateException(t.getMessage());
+      }
+   }
+
+   public TabularData getRoles() throws Exception
+   {
+      return RoleInfo.toTabularData(getRoleInfos());
+   }
+
+   public RoleInfo[] getRoleInfos() throws Exception
+   {
+      Set<Role> roles = server.getSecurityForAddress(address);
+      RoleInfo[] roleInfos = new RoleInfo[roles.size()];
+      int i = 0;
+      for (Role role : roles)
+      {
+         roleInfos[i++] = new RoleInfo(role.getName(), role
+               .isCheckType(CheckType.CREATE),
+               role.isCheckType(CheckType.READ), role
+                     .isCheckType(CheckType.WRITE));
+      }
+      return roleInfos;
+   }
+
+   public void addRole(final String name, final boolean create,
+         final boolean read, final boolean write) throws Exception
+   {
+      Set<Role> roles = server.getSecurityForAddress(address);
+      Role newRole = new Role(name, read, write, create);
+      boolean added = roles.add(newRole);
+      if (!added)
+      {
+         throw new IllegalArgumentException("Role " + name + " already exists");
+      }
+      server.setSecurityForAddress(address, roles);
+   }
+
+   public void removeRole(final String role) throws Exception
+   {
+      Set<Role> roles = server.getSecurityForAddress(address);
+      Iterator<Role> it = roles.iterator();
+      boolean removed = false;
+      while (it.hasNext())
+      {
+         Role r = it.next();
+         if (r.getName().equals(role))
+         {
+            it.remove();
+            removed = true;
+            break;
+         }
+      }
+      if (!removed)
+      {
+         throw new IllegalArgumentException("Role " + role + " does not exist");
+      }
+      server.setSecurityForAddress(address, roles);
+   }
+
+   // StandardMBean overrides ---------------------------------------
+
+   @Override
+   public MBeanInfo getMBeanInfo()
+   {
+      MBeanInfo info = super.getMBeanInfo();
+      return new MBeanInfo(info.getClassName(), info.getDescription(), info
+            .getAttributes(), info.getConstructors(), MBeanInfoHelper
+            .getMBeanOperationsInfo(AddressControlMBean.class), info
+            .getNotifications());
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/management/impl/MBeanInfoHelper.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/MBeanInfoHelper.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/MBeanInfoHelper.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/MBeanInfoHelper.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,171 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.core.management.impl;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+
+import org.jboss.messaging.core.management.Operation;
+import org.jboss.messaging.core.management.Parameter;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class MBeanInfoHelper
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public static MBeanOperationInfo[] getMBeanOperationsInfo(
+         final Class mbeanInterface)
+   {
+      List<MBeanOperationInfo> operations = new ArrayList<MBeanOperationInfo>();
+
+      for (Method method : mbeanInterface.getMethods())
+      {
+         if (!isGetterMethod(method) && !isSetterMethod(method)
+               && !isIsBooleanMethod(method))
+         {
+            operations.add(getOperationInfo(method));
+         }
+      }
+
+      return operations.toArray(new MBeanOperationInfo[0]);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   private static boolean isGetterMethod(final Method method)
+   {
+      if (!(method.getName().equals("get"))
+            && method.getName().startsWith("get")
+            && method.getParameterTypes().length == 0
+            && !method.getReturnType().equals(void.class))
+      {
+         return true;
+      }
+
+      return false;
+   }
+
+   private static boolean isSetterMethod(final Method method)
+   {
+      if (!(method.getName().equals("set"))
+            && method.getName().startsWith("set")
+            && method.getParameterTypes().length == 1
+            && method.getReturnType().equals(void.class))
+      {
+         return true;
+      } else
+      {
+         return false;
+      }
+   }
+
+   private static boolean isIsBooleanMethod(final Method method)
+   {
+      if (!(method.getName().equals("is")) && method.getName().startsWith("is")
+            && method.getParameterTypes().length == 0
+            && method.getReturnType().equals(boolean.class))
+      {
+         return true;
+      } else
+      {
+         return false;
+      }
+   }
+
+   private static MBeanOperationInfo getOperationInfo(final Method operation)
+   {
+      MBeanOperationInfo info = null;
+      Class<?> returnType = operation.getReturnType();
+
+      MBeanParameterInfo[] paramsInfo = getParametersInfo(operation
+            .getParameterAnnotations(), operation.getParameterTypes());
+
+      String description = operation.getName();
+      int impact = MBeanOperationInfo.UNKNOWN;
+
+      if (operation.getAnnotation(Operation.class) != null)
+      {
+         description = operation.getAnnotation(Operation.class).desc();
+         impact = operation.getAnnotation(Operation.class).impact();
+      }
+      info = new MBeanOperationInfo(operation.getName(), description,
+            paramsInfo, returnType.getName(), impact);
+
+      return info;
+   }
+
+   private static MBeanParameterInfo[] getParametersInfo(
+         final Annotation[][] params, final Class<?>[] paramTypes)
+   {
+      MBeanParameterInfo[] paramsInfo = new MBeanParameterInfo[params.length];
+
+      for (int i = 0; i < params.length; i++)
+      {
+         MBeanParameterInfo paramInfo = null;
+         String type = paramTypes[i].getName();
+         for (Annotation anno : params[i])
+         {
+            if (Parameter.class.isInstance(anno))
+            {
+               String name = Parameter.class.cast(anno).name();
+               String description = Parameter.class.cast(anno).desc();
+               paramInfo = new MBeanParameterInfo(name, type, description);
+            }
+         }
+
+         if (paramInfo == null)
+         {
+            paramInfo = new MBeanParameterInfo("p " + (i + 1), type,
+                  "parameter " + (i + 1));
+         }
+
+         paramsInfo[i] = paramInfo;
+      }
+
+      return paramsInfo;
+   }
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,206 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.core.management.impl;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.management.AddressControlMBean;
+import org.jboss.messaging.core.management.ManagementService;
+import org.jboss.messaging.core.management.MessagingServerManagement;
+import org.jboss.messaging.core.management.QueueControlMBean;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.settings.HierarchicalRepository;
+import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class ManagementServiceImpl implements ManagementService
+{
+   // Constants -----------------------------------------------------
+
+   private static final Logger log = Logger
+         .getLogger(ManagementServiceImpl.class);
+   public static final String DOMAIN = "org.jboss.messaging";
+
+   // Attributes ----------------------------------------------------
+
+   private final MBeanServer mbeanServer;
+   private MessagingServerManagement server;
+   private PostOffice postOffice;
+   private HierarchicalRepository<QueueSettings> queueSettingsRepository;
+   private boolean managementEnabled;
+
+   // Static --------------------------------------------------------
+
+   public static ObjectName getMessagingServerObjectName() throws Exception
+   {
+      return ObjectName.getInstance(DOMAIN + ":module=Core,type=Server");
+   }
+
+   public static ObjectName getAddressObjectName(final SimpleString address)
+         throws Exception
+   {
+      return ObjectName.getInstance(String.format(
+            "%s:module=Core,type=Address,name=%s", DOMAIN, address));
+   }
+
+   public static ObjectName getQueueObjectName(final SimpleString address,
+         final SimpleString name) throws Exception
+   {
+      return ObjectName.getInstance(String.format(
+            "%s:module=Core,type=Queue,address=%s,name=%s", DOMAIN, address,
+            name));
+   }
+
+   // Constructors --------------------------------------------------
+
+   public ManagementServiceImpl(final MBeanServer mbeanServer,
+         final boolean managementEnabled)
+   {
+      this.mbeanServer = mbeanServer;
+      this.managementEnabled = managementEnabled;
+   }
+
+   // Public --------------------------------------------------------
+
+   // ManagementRegistration implementation -------------------------
+
+   public void setPostOffice(final PostOffice postOffice)
+   {
+      this.postOffice = postOffice;
+   }
+
+   public void setQueueSettingsRepository(
+         final HierarchicalRepository<QueueSettings> queueSettingsRepository)
+   {
+      this.queueSettingsRepository = queueSettingsRepository;
+   }
+
+   public void registerServer(final MessagingServerManagement server)
+         throws Exception
+   {
+      if (!managementEnabled)
+      {
+         return;
+      }
+      unregisterServer();
+      ObjectName objectName = getMessagingServerObjectName();
+      MessagingServerControl managedServer = new MessagingServerControl(server,
+            server.getConfiguration());
+      mbeanServer.registerMBean(managedServer, objectName);
+      this.server = server;
+      log.info("registered core server under " + objectName);
+   }
+
+   public void unregisterServer() throws Exception
+   {
+      if (!managementEnabled)
+      {
+         return;
+      }
+      ObjectName objectName = getMessagingServerObjectName();
+      if (mbeanServer.isRegistered(objectName))
+      {
+         mbeanServer.unregisterMBean(getMessagingServerObjectName());
+         this.server = null;
+      }
+   }
+
+   public void registerAddress(final SimpleString address) throws Exception
+   {
+      if (!managementEnabled)
+      {
+         return;
+      }
+      unregisterAddress(address);
+      ObjectName objectName = getAddressObjectName(address);
+      AddressControlMBean addressControl = new AddressControl(address, server);
+      mbeanServer.registerMBean(addressControl, objectName);
+      if (log.isDebugEnabled())
+      {
+         log.debug("registered address " + objectName);
+      }
+   }
+
+   public void unregisterAddress(final SimpleString address) throws Exception
+   {
+      if (!managementEnabled)
+      {
+         return;
+      }
+      ObjectName objectName = getAddressObjectName(address);
+      if (mbeanServer.isRegistered(objectName))
+      {
+         mbeanServer.unregisterMBean(objectName);
+      }
+   }
+
+   public void registerQueue(final Queue queue, final SimpleString address,
+         final StorageManager storageManager) throws Exception
+   {
+      if (!managementEnabled)
+      {
+         return;
+      }
+      unregisterQueue(queue.getName(), address);
+      ObjectName objectName = getQueueObjectName(address, queue.getName());
+      QueueControlMBean queueControl = new QueueControl(queue, storageManager,
+            postOffice, queueSettingsRepository);
+      mbeanServer.registerMBean(queueControl, objectName);
+      if (log.isDebugEnabled())
+      {
+         log.debug("registered queue " + objectName);
+      }
+   }
+
+   public void unregisterQueue(final SimpleString name,
+         final SimpleString address) throws Exception
+   {
+      if (!managementEnabled)
+      {
+         return;
+      }
+      ObjectName objectName = getQueueObjectName(address, name);
+      if (mbeanServer.isRegistered(objectName))
+      {
+         mbeanServer.unregisterMBean(objectName);
+      }
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,306 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.core.management.impl;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanNotificationInfo;
+import javax.management.NotCompliantMBeanException;
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.NotificationEmitter;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.StandardMBean;
+
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.management.MessagingServerControlMBean;
+import org.jboss.messaging.core.management.MessagingServerManagement;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class MessagingServerControl extends StandardMBean implements
+      MessagingServerControlMBean, NotificationEmitter
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final MessagingServerManagement server;
+   private final Configuration configuration;
+
+   private final NotificationBroadcasterSupport broadcaster;
+   private AtomicLong notifSeq = new AtomicLong(0);
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public MessagingServerControl(final MessagingServerManagement server,
+         final Configuration configuration) throws NotCompliantMBeanException
+   {
+      super(MessagingServerControlMBean.class);
+      this.server = server;
+      this.configuration = configuration;
+      broadcaster = new NotificationBroadcasterSupport();
+   }
+
+   // Public --------------------------------------------------------
+
+   // StandardMBean overrides ---------------------------------------
+
+   @Override
+   public MBeanInfo getMBeanInfo()
+   {
+      MBeanInfo info = super.getMBeanInfo();
+      return new MBeanInfo(info.getClassName(), info.getDescription(), info
+            .getAttributes(), info.getConstructors(), MBeanInfoHelper
+            .getMBeanOperationsInfo(MessagingServerControlMBean.class),
+            getNotificationInfo());
+   }
+
+   // MessagingServerControlMBean implementation --------------------
+
+   public boolean isStarted()
+   {
+      return server.isStarted();
+   }
+
+   public String getVersion()
+   {
+      return server.getVersion();
+   }
+
+   public String getBindingsDirectory()
+   {
+      return configuration.getBindingsDirectory();
+   }
+
+   public List<String> getInterceptorClassNames()
+   {
+      return configuration.getInterceptorClassNames();
+   }
+
+   public String getJournalDirectory()
+   {
+      return configuration.getJournalDirectory();
+   }
+
+   public int getJournalFileSize()
+   {
+      return configuration.getJournalFileSize();
+   }
+
+   public int getJournalMaxAIO()
+   {
+      return configuration.getJournalMaxAIO();
+   }
+
+   public int getJournalMinFiles()
+   {
+      return configuration.getJournalMinFiles();
+   }
+
+   public String getJournalType()
+   {
+      return configuration.getJournalType().toString();
+   }
+
+   public String getKeyStorePath()
+   {
+      return configuration.getKeyStorePath();
+   }
+
+   public String getLocation()
+   {
+      return configuration.getLocation().toString();
+   }
+
+   public int getScheduledThreadPoolMaxSize()
+   {
+      return configuration.getScheduledThreadPoolMaxSize();
+   }
+
+   public long getSecurityInvalidationInterval()
+   {
+      return configuration.getSecurityInvalidationInterval();
+   }
+
+   public String getTrustStorePath()
+   {
+      return configuration.getTrustStorePath();
+   }
+
+   public boolean isClustered()
+   {
+      return configuration.isClustered();
+   }
+
+   public boolean isCreateBindingsDir()
+   {
+      return configuration.isCreateBindingsDir();
+   }
+
+   public boolean isCreateJournalDir()
+   {
+      return configuration.isCreateJournalDir();
+   }
+
+   public boolean isJournalSyncNonTransactional()
+   {
+      return configuration.isJournalSyncNonTransactional();
+   }
+
+   public boolean isJournalSyncTransactional()
+   {
+      return configuration.isJournalSyncTransactional();
+   }
+
+   public boolean isRequireDestinations()
+   {
+      return configuration.isRequireDestinations();
+   }
+
+   public boolean isSSLEnabled()
+   {
+      return configuration.isSSLEnabled();
+   }
+
+   public boolean isSecurityEnabled()
+   {
+      return configuration.isSecurityEnabled();
+   }
+
+   public boolean addAddress(final String address) throws Exception
+   {
+      sendNotification(NotificationType.ADDRESS_ADDED, address);
+      return server.addDestination(new SimpleString(address));
+   }
+
+   public void createQueue(final String address, final String name)
+         throws Exception
+   {
+      server.createQueue(new SimpleString(address), new SimpleString(name));
+      sendNotification(NotificationType.ADDRESS_ADDED, address);
+      sendNotification(NotificationType.QUEUE_CREATED, name);
+   }
+
+   public void createQueue(final String address, final String name,
+         final String filter, final boolean durable, final boolean temporary)
+         throws Exception
+   {
+      if (temporary && durable)
+      {
+         throw new IllegalArgumentException(
+               "A queue can not be both temporary and durable");
+      }
+
+      SimpleString simpleFilter = (filter == null || filter.length() == 0) ? null
+            : new SimpleString(filter);
+      server.createQueue(new SimpleString(address), new SimpleString(name),
+            simpleFilter, durable, temporary);
+      sendNotification(NotificationType.ADDRESS_ADDED, address);
+      sendNotification(NotificationType.QUEUE_CREATED, name);
+   }
+
+   public void destroyQueue(final String name) throws Exception
+   {
+      server.destroyQueue(new SimpleString(name));
+      sendNotification(NotificationType.QUEUE_DESTROYED, name);
+   }
+
+   public int getConnectionCount()
+   {
+      return server.getConnectionCount();
+   }
+
+   public boolean removeAddress(final String address) throws Exception
+   {
+      sendNotification(NotificationType.ADDRESS_REMOVED, address);
+      return server.removeDestination(new SimpleString(address));
+   }
+
+   // NotificationEmitter implementation ----------------------------
+
+   public void removeNotificationListener(final NotificationListener listener,
+         final NotificationFilter filter, final Object handback)
+         throws ListenerNotFoundException
+   {
+      broadcaster.removeNotificationListener(listener, filter, handback);
+   }
+
+   public void removeNotificationListener(final NotificationListener listener)
+         throws ListenerNotFoundException
+   {
+      broadcaster.removeNotificationListener(listener);
+   }
+
+   public void addNotificationListener(final NotificationListener listener,
+         final NotificationFilter filter, final Object handback)
+         throws IllegalArgumentException
+   {
+      broadcaster.addNotificationListener(listener, filter, handback);
+   }
+
+   public MBeanNotificationInfo[] getNotificationInfo()
+   {
+      NotificationType[] values = NotificationType.values();
+      String[] names = new String[values.length];
+      for (int i = 0; i < values.length; i++)
+      {
+         names[i] = values[i].toString();
+      }
+      return new MBeanNotificationInfo[] { new MBeanNotificationInfo(names,
+            this.getClass().getName(), "Notifications emitted by a Core Server") };
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   private void sendNotification(final NotificationType type,
+         final String message)
+   {
+      Notification notif = new Notification(type.toString(), this, notifSeq
+            .incrementAndGet(), message);
+      broadcaster.sendNotification(notif);
+   }
+
+   // Inner classes -------------------------------------------------
+
+   public static enum NotificationType
+   {
+      QUEUE_CREATED, QUEUE_DESTROYED, ADDRESS_ADDED, ADDRESS_REMOVED;
+   }
+}

Modified: trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerManagementImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerManagementImpl.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerManagementImpl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -18,7 +18,7 @@
  * 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.core.management.impl;
 
@@ -27,11 +27,14 @@
 import java.util.Set;
 
 import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.filter.impl.FilterImpl;
 import org.jboss.messaging.core.management.MessagingServerManagement;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.Binding;
 import org.jboss.messaging.core.postoffice.PostOffice;
 import org.jboss.messaging.core.security.Role;
+import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.MessagingServer;
 import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.core.settings.HierarchicalRepository;
@@ -39,42 +42,33 @@
 import org.jboss.messaging.util.SimpleString;
 
 /**
- * This interface describes the properties and operations that comprise the management interface of the
- * Messaging Server.
- * <p/>
- * It includes operations to create and destroy queues and provides various statistics measures
- * such as message count for queues and topics.
- *
+ * This interface describes the properties and operations that comprise the
+ * management interface of the Messaging Server. <p/> It includes operations to
+ * create and destroy queues and provides various statistics measures such as
+ * message count for queues and topics.
+ * 
  * @author <a href="mailto:ataylor at redhat.com>Andy Taylor</a>
- * @author <a href="mailto:ataylor at redhat.com>Andy Taylor</a>
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
  */
-//@JMX(name = "jboss.messaging:service=MessagingServerManagement", exposedInterface = MessagingServerManagement.class)
 public class MessagingServerManagementImpl implements MessagingServerManagement
 {
-   //private MessagingServer messagingServer;
 
-//   private HashMap<String, MessageCounter> currentCounters = new HashMap<String, MessageCounter>();
-//
-//   private HashMap<String, ScheduledFuture> currentRunningCounters = new HashMap<String, ScheduledFuture>();
-//
-//   private ScheduledExecutorService scheduler;
-//
-//   private int maxMessageCounters = 20;
-   
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
    private final PostOffice postOffice;
-   
+
    private final StorageManager storageManager;
-   
+
    private final Configuration configuration;
-   
+
    private final MessagingServer server;
-   
+
    private HierarchicalRepository<Set<Role>> securityRepository;
+
+   private HierarchicalRepository<QueueSettings> queueSettingsRepository;   
    
-   private HierarchicalRepository<QueueSettings> queueSettingsRepository;
-   
-   
-   
    public MessagingServerManagementImpl(final PostOffice postOffice, final StorageManager storageManager,
                                         final Configuration configuration,                                                                             
                                         final HierarchicalRepository<Set<Role>> securityRepository,
@@ -82,37 +76,60 @@
                                         final MessagingServer server)
    {
       this.postOffice = postOffice;
-      
+
       this.storageManager = storageManager;
-      
+
       this.configuration = configuration;
-      
+
       this.server = server;
-      
+
       this.securityRepository = securityRepository;
-      
+
       this.queueSettingsRepository = queueSettingsRepository;
    }
 
+   // MessagingServerManagement implementation ----------------------
+
    public boolean isStarted()
    {
       return server.isStarted();
    }
 
-   public void createQueue(SimpleString address, SimpleString name) throws Exception
+   public String getVersion()
    {
+      return server.getVersion().getFullVersion();
+   }
+
+   public void createQueue(final SimpleString address, final SimpleString name)
+         throws Exception
+   {
       if (postOffice.getBinding(name) == null)
       {
          postOffice.addBinding(address, name, null, true, false);
       }
    }
-   
+
+   public void createQueue(final SimpleString address, final SimpleString name,
+         final SimpleString filterStr, final boolean durable,
+         final boolean temporary) throws Exception
+   {
+      if (postOffice.getBinding(name) == null)
+      {
+         Filter filter = null;
+         if (filterStr != null)
+         {
+            filter = new FilterImpl(filterStr);
+         }
+         postOffice.addBinding(address, name, filter, durable, temporary);
+      }
+   }
+
    public int getConnectionCount()
    {
       return server.getConnectionCount();
    }
 
-   public void destroyQueue(SimpleString name) throws Exception
+   public void destroyQueue(final SimpleString name) throws Exception
    {
       Binding binding = postOffice.getBinding(name);
 
@@ -121,22 +138,24 @@
          Queue queue = binding.getQueue();
 
          queue.deleteAllReferences(storageManager);
-         
+
          postOffice.removeBinding(queue.getName());
       }
    }
 
-   public boolean addDestination(SimpleString address) throws Exception
+   public boolean addDestination(final SimpleString address) throws Exception
    {
       return postOffice.addDestination(address, false);
    }
 
-   public boolean removeDestination(SimpleString address) throws Exception
+   public boolean removeDestination(final SimpleString address)
+         throws Exception
    {
       return postOffice.removeDestination(address, false);
    }
 
-   public void removeAllMessagesForAddress(SimpleString address) throws Exception
+   public void removeAllMessagesForAddress(final SimpleString address)
+         throws Exception
    {
       List<Binding> bindings = postOffice.getBindingsForAddress(address);
 
@@ -147,59 +166,95 @@
          queue.deleteAllReferences(storageManager);
       }
    }
-//
-//   public void removeAllMessagesForBinding(SimpleString name) throws Exception
-//   {
-//      Binding binding = messagingServer.getPostOffice().getBinding(name);
-//      if (binding != null)
-//      {
-//         Queue queue = binding.getQueue();
-//
-//         queue.deleteAllReferences(messagingServer.getStorageManager());
-//      }
-//   }
-//
-//   public List<Message> listMessages(SimpleString queueName, Filter filter) throws Exception
-//   {
-//      List<Message> msgs = new ArrayList<Message>();
-//      Queue queue = getQueue(queueName);
-//      if (queue != null)
-//      {
-//         List<MessageReference> allRefs = queue.list(filter);
-//         for (MessageReference allRef : allRefs)
-//         {
-//            msgs.add(allRef.getMessage());
-//         }
-//      }
-//      return msgs;
-//   }
 
-//   public void removeMessageForBinding(String name, Filter filter) throws Exception
-//   {
-//      Binding binding = messagingServer.getPostOffice().getBinding(name);
-//      if (binding != null)
-//      {
-//         Queue queue = binding.getQueue();
-//         List<MessageReference> allRefs = queue.list(filter);
-//         for (MessageReference messageReference : allRefs)
-//         {
-//            messagingServer.getPersistenceManager().deleteReference(messageReference);
-//            queue.removeReference(messageReference);
-//         }
-//      }
-//   }
+   public boolean removeMessageFromAddress(final long messageID,
+         SimpleString address) throws Exception
+   {
+      Binding binding = postOffice.getBinding(address);
+      if (binding != null)
+      {
+         Queue queue = binding.getQueue();
+         return queue.deleteReference(messageID, storageManager);
+      }
+      return false;
+   }
 
-//   public void removeMessageForAddress(String binding, Filter filter) throws Exception
-//   {
-//      List<Binding> bindings = messagingServer.getPostOffice().getBindingsForAddress(binding);
-//      for (Binding binding1 : bindings)
-//      {
-//         removeMessageForBinding(binding1.getQueue().getName(), filter);
-//      }
-//   }
+   public boolean expireMessage(final long messageID, final SimpleString address)
+         throws Exception
+   {
+      Binding binding = postOffice.getBinding(address);
+      if (binding != null)
+      {
+         Queue queue = binding.getQueue();
+         return queue.expireMessage(messageID, storageManager, postOffice,
+               queueSettingsRepository);
+      }
+      return false;
+   }
 
-   public List<Queue> getQueuesForAddress(SimpleString address) throws Exception
+   public int expireMessages(final Filter filter,
+         final SimpleString address) throws Exception
    {
+      Binding binding = postOffice.getBinding(address);
+      if (binding != null)
+      {
+         Queue queue = binding.getQueue();
+         List<MessageReference> refs = queue.list(filter);
+         for (MessageReference ref : refs)
+         {
+            queue.expireMessage(ref.getMessage().getMessageID(),
+                  storageManager, postOffice, queueSettingsRepository);
+         }
+         return refs.size();
+      }
+      return 0;
+   }
+
+   public int sendMessagesToDLQ(final Filter filter,
+         final SimpleString address) throws Exception
+   {
+      Binding binding = postOffice.getBinding(address);
+      if (binding != null)
+      {
+         Queue queue = binding.getQueue();
+         List<MessageReference> refs = queue.list(filter);
+         for (MessageReference ref : refs)
+         {
+            queue.sendMessageToDLQ(ref.getMessage().getMessageID(),
+                  storageManager, postOffice, queueSettingsRepository);
+         }
+         return refs.size();
+      }
+      return 0;
+   }
+
+   public int changeMessagesPriority(final Filter filter,
+         final byte newPriority, final SimpleString address) throws Exception
+   {
+      Binding binding = postOffice.getBinding(address);
+      if (binding != null)
+      {
+         Queue queue = binding.getQueue();
+         List<MessageReference> refs = queue.list(filter);
+         for (MessageReference ref : refs)
+         {
+            queue.changeMessagePriority(ref.getMessage().getMessageID(),
+                  newPriority, storageManager, postOffice,
+                  queueSettingsRepository);
+         }
+         return refs.size();
+      }
+      return 0;
+   }
+
+   public QueueSettings getQueueSettings(final SimpleString simpleAddress)
+   {
+      return queueSettingsRepository.getMatch(simpleAddress.toString());
+   }
+
+   public List<Queue> getQueuesForAddress(final SimpleString address)
+         throws Exception
+   {
       List<Queue> queues = new ArrayList<Queue>();
       List<Binding> bindings = postOffice.getBindingsForAddress(address);
 
@@ -211,258 +266,35 @@
       return queues;
    }
 
-   public int getMessageCountForQueue(SimpleString queue) throws Exception
+   public void setSecurityForAddress(final SimpleString address, final Set<Role> roles)
+         throws Exception
    {
-      return getQueue(queue).getMessageCount();
+      this.securityRepository.addMatch(address.toString(), roles);
    }
-   
-   public void setSecurityForAddress(String address, Set<Role> roles) throws Exception
+
+   public void removeSecurityForAddress(final SimpleString address) throws Exception
    {
-      this.securityRepository.addMatch(address, roles);
+      this.securityRepository.removeMatch(address.toString());
    }
-   
-   public void removeSecurityForAddress(String address) throws Exception
+
+   public Set<Role> getSecurityForAddress(final SimpleString address)
+         throws Exception
    {
-      this.securityRepository.removeMatch(address);
+      return this.securityRepository.getMatch(address.toString());
    }
-   
-   public Set<Role> getSecurityForAddress(String address) throws Exception
+
+   public void setQueueAttributes(final SimpleString queueName,
+         final QueueSettings settings) throws Exception
    {
-      return this.securityRepository.getMatch(address);
+      this.queueSettingsRepository.addMatch(queueName.toString(), settings);
    }
-   
-   public void setQueueAttributes(String queueName, QueueSettings settings) throws Exception
-   {
-      this.queueSettingsRepository.addMatch(queueName, settings);
-   }
-   
-   
-//
-//   public int getMaxMessageCounters()
-//   {
-//      return maxMessageCounters;
-//   }
-//
-//   public void setMaxMessageCounters(int maxMessageCounters)
-//   {
-//      this.maxMessageCounters = maxMessageCounters;
-//   }
-//
-//   public void registerMessageCounter(final SimpleString queueName) throws Exception
-//   {
-//      if (currentCounters.get(queueName) != null)
-//      {
-//         throw new IllegalStateException("Message Counter Already Registered");
-//      }
-//      Binding binding = messagingServer.getPostOffice().getBinding(queueName);
-//      if (binding == null)
-//      {
-//         throw new MessagingException(MessagingException.QUEUE_DOES_NOT_EXIST);
-//      }
-//      Queue queue = binding.getQueue();
-//      currentCounters.put(queueName, new MessageCounter(queue.getName(), queue, queue.isDurable(),
-//      		messagingServer.getQueueSettingsRepository().getMatch(queue.getName()).getMessageCounterHistoryDayLimit()));
-//   }
-//
-//   public void unregisterMessageCounter(final SimpleString queueName) throws Exception
-//   {
-//      if (currentCounters.get(queueName) == null)
-//      {
-//         throw new MessagingException(MessagingException.ILLEGAL_STATE, "Counter is not registered");
-//      }
-//      currentCounters.remove(queueName);
-//      if (currentRunningCounters.get(queueName) != null)
-//      {
-//         currentRunningCounters.get(queueName).cancel(true);
-//         currentRunningCounters.remove(queueName);
-//      }
-//   }
-//
-//   public void startMessageCounter(final String SimpleString, long duration) throws Exception
-//   {
-//      MessageCounter messageCounter = currentCounters.get(queueName);
-//      if (messageCounter == null)
-//      {
-//         Binding binding = messagingServer.getPostOffice().getBinding(queueName);
-//         if (binding == null)
-//         {
-//            throw new MessagingException(MessagingException.QUEUE_DOES_NOT_EXIST);
-//         }
-//         Queue queue = binding.getQueue();
-//         messageCounter = new MessageCounter(queue.getName(), queue, queue.isDurable(),
-//         		messagingServer.getQueueSettingsRepository().getMatch(queue.getName()).getMessageCounterHistoryDayLimit());
-//      }
-//      currentCounters.put(queueName, messageCounter);
-//      messageCounter.resetCounter();
-//      if (duration > 0)
-//      {
-//
-//         ScheduledFuture future = scheduler.schedule(new Runnable()
-//         {
-//            public void run()
-//            {
-//               currentCounters.get(queueName).sample();
-//            }
-//         }, duration, TimeUnit.SECONDS);
-//         currentRunningCounters.put(queueName, future);
-//      }
-//   }
-//
-//   public MessageCounter stopMessageCounter(SimpleString queueName) throws Exception
-//   {
-//      MessageCounter messageCounter = currentCounters.get(queueName);
-//      if (messageCounter == null)
-//      {
-//         throw new IllegalArgumentException(queueName + "counter not registered");
-//      }
-//      if (currentRunningCounters.get(queueName) != null)
-//      {
-//         currentRunningCounters.get(queueName).cancel(true);
-//         currentRunningCounters.remove(queueName);
-//      }
-//      messageCounter.sample();
-//      return messageCounter;
-//   }
-//
-//   public MessageCounter getMessageCounter(SimpleString queueName)
-//   {
-//      MessageCounter messageCounter = currentCounters.get(queueName);
-//      if (messageCounter != null && currentRunningCounters.get(queueName) == null)
-//      {
-//         messageCounter.sample();
-//      }
-//      return messageCounter;
-//   }
-//
-//
-//   public Collection<MessageCounter> getMessageCounters()
-//   {
-//      for (String s : currentCounters.keySet())
-//      {
-//         currentCounters.get(s).sample();
-//      }
-//      return currentCounters.values();
-//   }
-//
-//   public void resetMessageCounter(SimpleString queue)
-//   {
-//      MessageCounter messageCounter = currentCounters.get(queue);
-//      if (messageCounter != null)
-//      {
-//         messageCounter.resetCounter();
-//      }
-//   }
-//
-//   public void resetMessageCounters()
-//   {
-//      Set<String> counterNames = currentCounters.keySet();
-//      for (String counterName : counterNames)
-//      {
-//         resetMessageCounter(counterName);
-//      }
-//   }
-//
-//   public void resetMessageCounterHistory(SimpleString queue)
-//   {
-//      MessageCounter messageCounter = currentCounters.get(queue);
-//      if (messageCounter != null)
-//      {
-//         messageCounter.resetHistory();
-//      }
-//   }
-//
-//   public void resetMessageCounterHistories()
-//   {
-//      Set<String> counterNames = currentCounters.keySet();
-//      for (String counterName : counterNames)
-//      {
-//         resetMessageCounterHistory(counterName);
-//      }
-//   }
-//
-//   public List<MessageCounter> stopAllMessageCounters() throws Exception
-//   {
-//      Set<String> counterNames = currentCounters.keySet();
-//      List<MessageCounter> messageCounters = new ArrayList<MessageCounter>();
-//      for (String counterName : counterNames)
-//      {
-//         messageCounters.add(stopMessageCounter(counterName));
-//      }
-//      return messageCounters;
-//   }
-//
-//   public void unregisterAllMessageCounters() throws Exception
-//   {
-//      Set<String> counterNames = currentCounters.keySet();
-//      for (String counterName : counterNames)
-//      {
-//         unregisterMessageCounter(counterName);
-//      }
-//   }
-//
-//   public int getConsumerCountForQueue(SimpleString queue) throws Exception
-//   {
-//      return getQueue(queue).getConsumerCount();
-//   }
-//
-//   public List<ServerConnection> getActiveConnections()
-//   {
-//      return messagingServer.getConnectionManager().getActiveConnections();
-//   }
 
-//   public void moveMessages(String fromQueue, String toQueue, String filter) throws Exception
-//   {
-//      Filter actFilter = new FilterImpl(filter);
-//      Queue from = getQueue(fromQueue);
-//      Queue to = getQueue(toQueue);
-//      List<MessageReference> messageReferences = from.list(actFilter);
-//      for (MessageReference messageReference : messageReferences)
-//      {
-//         from.move(messageReference, to, messagingServer.getPersistenceManager());
-//      }
-//
-//   }
-//
-//   public void expireMessages(SimpleString queue, SimpleString filter) throws Exception
-//   {
-//      Filter actFilter = new FilterImpl(filter);
-//      List<MessageReference> allRefs = getQueue(queue).list(actFilter);
-//      for (MessageReference messageReference : allRefs)
-//      {
-//         messageReference.getMessage().setExpiration(System.currentTimeMillis());
-//      }
-//   }
-
-//   public void changeMessagePriority(String queue, String filter, int priority) throws Exception
-//   {
-//      Filter actFilter = new FilterImpl(filter);
-//      List<MessageReference> allRefs = getQueue(queue).list(actFilter);
-//      for (MessageReference messageReference : allRefs)
-//      {
-//         List<MessageReference> allRefsForMessage = messageReference.getMessage().getReferences();
-//         for (MessageReference reference : allRefsForMessage)
-//         {
-//            reference.getQueue().changePriority(reference, priority);
-//         }
-//         messageReference.getMessage().setPriority((byte) priority);
-//      }
-//
-//   }
-//
-//   public Set<SimpleString> listAvailableAddresses()
-//   {
-//      return messagingServer.getPostOffice().listAllDestinations();
-//   }
-
    public Configuration getConfiguration()
    {
       return configuration;
    }
 
-   // Private ---------------------------------------------------------------------------
-
-
-   private Queue getQueue(SimpleString queueName) throws Exception
+   public Queue getQueue(final SimpleString queueName) throws Exception
    {
       Binding binding = postOffice.getBinding(queueName);
       if (binding == null)
@@ -473,24 +305,11 @@
       return binding.getQueue();
    }
 
+   // Package protected ---------------------------------------------
 
+   // Protected -----------------------------------------------------
 
-//   public void start() throws Exception
-//   {
-//      //scheduler = Executors.newScheduledThreadPool(maxMessageCounters);
-//   }
-//
-//   public void stop() throws Exception
-//   {
-////      if (scheduler != null)
-////      {
-////         scheduler.shutdown();
-////      }
-//   }
+   // Private -------------------------------------------------------
 
-//   protected void finalize() throws Throwable
-//   {
-//      super.finalize();
-//
-//   }
+   // Inner classes -------------------------------------------------
 }

Copied: trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/core/management/impl/QueueControl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,299 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.core.management.impl;
+
+import java.util.List;
+
+import javax.management.MBeanInfo;
+import javax.management.NotCompliantMBeanException;
+import javax.management.StandardMBean;
+import javax.management.openmbean.TabularData;
+
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.filter.impl.FilterImpl;
+import org.jboss.messaging.core.management.MessageInfo;
+import org.jboss.messaging.core.management.QueueControlMBean;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.Binding;
+import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.MessageReference;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.core.settings.HierarchicalRepository;
+import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class QueueControl extends StandardMBean implements QueueControlMBean
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   public final Queue queue;
+   private final StorageManager storageManager;
+   private final PostOffice postOffice;
+   private final HierarchicalRepository<QueueSettings> queueSettingsRepository;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public QueueControl(final Queue queue, final StorageManager storageManager,
+         final PostOffice postOffice,
+         final HierarchicalRepository<QueueSettings> queueSettingsRepository)
+         throws NotCompliantMBeanException
+   {
+      super(QueueControlMBean.class);
+      this.queue = queue;
+      this.storageManager = storageManager;
+      this.postOffice = postOffice;
+      this.queueSettingsRepository = queueSettingsRepository;
+   }
+
+   // Public --------------------------------------------------------
+
+   // QueueControlMBean implementation ------------------------------
+
+   public String getName()
+   {
+      return queue.getName().toString();
+   }
+
+   public String getFilter()
+   {
+      Filter filter = queue.getFilter();
+      return (filter != null) ? filter.getFilterString().toString() : null;
+   }
+
+   public boolean isClustered()
+   {
+      return queue.isClustered();
+   }
+
+   public boolean isDurable()
+   {
+      return queue.isDurable();
+   }
+
+   public boolean isTemporary()
+   {
+      return queue.isTemporary();
+   }
+
+   public int getMessageCount()
+   {
+      return queue.getMessageCount();
+   }
+
+   public int getMaxSizeBytes()
+   {
+      return queue.getMaxSizeBytes();
+   }
+
+   public int getConsumerCount()
+   {
+      return queue.getConsumerCount();
+   }
+
+   public int getDeliveringCount()
+   {
+      return queue.getDeliveringCount();
+   }
+
+   public int getMessagesAdded()
+   {
+      return queue.getMessagesAdded();
+   }
+
+   public long getPersistenceID()
+   {
+      return queue.getPersistenceID();
+   }
+
+   public long getScheduledCount()
+   {
+      return queue.getScheduledCount();
+   }
+
+   public long getSizeBytes()
+   {
+      return queue.getSizeBytes();
+   }
+
+   public String getDLQ()
+   {
+      return queueSettingsRepository.getMatch(getName()).getDLQ().toString();
+   }
+
+   public String getExpiryQueue()
+   {
+      return queueSettingsRepository.getMatch(getName()).getExpiryQueue()
+            .toString();
+   }
+
+   public TabularData listAllMessages() throws Exception
+   {
+      return listMessages(null);
+   }
+
+   public TabularData listMessages(final String filterStr) throws Exception
+   {
+      try
+      {
+         Filter filter = filterStr == null ? null : new FilterImpl(
+               new SimpleString(filterStr));
+         List<MessageReference> refs = queue.list(filter);
+         MessageInfo[] infos = new MessageInfo[refs.size()];
+         for (int i = 0; i < refs.size(); i++)
+         {
+            MessageReference ref = refs.get(i);
+            ServerMessage message = ref.getMessage();
+            MessageInfo info = new MessageInfo(message.getMessageID(), message
+                  .getDestination().toString(), message.isDurable(), message
+                  .getTimestamp(), message.getType(), message.getEncodeSize(),
+                  message.getPriority(), message.isExpired(), message
+                        .getExpiration());
+            for (SimpleString key : message.getPropertyNames())
+            {
+               Object value = message.getProperty(key);
+               String valueStr = value == null ? null : value.toString();
+               info.putProperty(key.toString(), valueStr);
+            }
+            infos[i] = info;
+         }
+         return MessageInfo.toTabularData(infos);
+      } catch (MessagingException e)
+      {
+         throw new IllegalStateException(e.getMessage());
+      }
+   }
+
+   public void removeAllMessages() throws Exception
+   {
+      try
+      {
+         queue.deleteAllReferences(storageManager);
+      } catch (MessagingException e)
+      {
+         throw new IllegalStateException(e.getMessage());
+      }
+   }
+
+   public boolean removeMessage(final long messageID) throws Exception
+   {
+      try
+      {
+         return queue.deleteReference(messageID, storageManager);
+      } catch (MessagingException e)
+      {
+         throw new IllegalStateException(e.getMessage());
+      }
+   }
+
+   public boolean expireMessage(final long messageID) throws Exception
+   {
+      return queue.expireMessage(messageID, storageManager, postOffice,
+            queueSettingsRepository);
+   }
+
+   public int expireMessages(final String filterStr) throws Exception
+   {
+      try
+      {
+         Filter filter = null;
+         if (filterStr != null)
+         {
+            filter = new FilterImpl(new SimpleString(filterStr));
+         }
+         List<MessageReference> refs = queue.list(filter);
+         for (MessageReference ref : refs)
+         {
+            queue.expireMessage(ref.getMessage().getMessageID(),
+                  storageManager, postOffice, queueSettingsRepository);
+         }
+         return refs.size();
+      } catch (MessagingException e)
+      {
+         throw new IllegalStateException(e.getMessage());
+      }
+   }
+
+   public boolean moveMessage(final long messageID, final String otherQueueName)
+         throws Exception
+   {
+      Binding binding = postOffice.getBinding(new SimpleString(otherQueueName));
+      if (binding == null)
+      {
+         throw new IllegalArgumentException("No queue found for "
+               + otherQueueName);
+      }
+
+      return queue.moveMessage(messageID, binding, storageManager, postOffice);
+   }
+
+   public boolean sendMessageToDLQ(final long messageID) throws Exception
+   {
+      return queue.sendMessageToDLQ(messageID, storageManager, postOffice,
+            queueSettingsRepository);
+   }
+
+   public boolean changeMessagePriority(final long messageID,
+         final int newPriority) throws Exception
+   {
+      if (newPriority < 0 || newPriority > 9)
+      {
+         throw new IllegalArgumentException("invalid newPriority value: "
+               + newPriority + ". It must be between 0 and 9 (both included)");
+      }
+      return queue.changeMessagePriority(messageID, (byte) newPriority,
+            storageManager, postOffice, queueSettingsRepository);
+   }
+
+   // StandardMBean overrides ---------------------------------------
+
+   @Override
+   public MBeanInfo getMBeanInfo()
+   {
+      MBeanInfo info = super.getMBeanInfo();
+      return new MBeanInfo(info.getClassName(), info.getDescription(), info
+            .getAttributes(), info.getConstructors(), MBeanInfoHelper
+            .getMBeanOperationsInfo(QueueControlMBean.class), info
+            .getNotifications());
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Modified: trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -58,6 +58,8 @@
 
    public static final SimpleString HDR_ACTUAL_EXPIRY_TIME = new SimpleString("JBMActualExpiryTime");
 
+   public static final SimpleString HDR_ORIGIN_QUEUE = new SimpleString("JBMOriginQueue");
+
    // Attributes ----------------------------------------------------
 
    private SimpleString destination;

Modified: trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -47,6 +47,7 @@
 import org.jboss.messaging.core.journal.impl.JournalImpl;
 import org.jboss.messaging.core.journal.impl.NIOSequentialFileFactory;
 import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.management.ManagementService;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.Binding;
 import org.jboss.messaging.core.postoffice.PostOffice;
@@ -67,6 +68,7 @@
  * 
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
  *
  */
 public class JournalStorageManager implements StorageManager
@@ -109,8 +111,10 @@
 	private final ConcurrentMap<SimpleString, Long> destinationIDMap = new ConcurrentHashMap<SimpleString, Long>();
 	
 	private volatile boolean started;
-	
-	public JournalStorageManager(final Configuration config)
+
+   private final ManagementService managementService;
+   
+	public JournalStorageManager(final Configuration config, final ManagementService managementService)
 	{
 		if (config.getJournalType() != JournalType.NIO && config.getJournalType() != JournalType.ASYNCIO)
 		{
@@ -172,13 +176,16 @@
 	   		config.getJournalMinFiles(), config.isJournalSyncTransactional(),
 	   		config.isJournalSyncNonTransactional(), journalFF,
 	   		"jbm-data", "jbm", config.getJournalMaxAIO());
+	   
+	     this.managementService = managementService;
 	}
 	
 	/* This constructor is only used for testing */
-	public JournalStorageManager(final Journal messageJournal, final Journal bindingsJournal)
+	public JournalStorageManager(final Journal messageJournal, final Journal bindingsJournal, final ManagementService managementService)
    {
 	   this.messageJournal = messageJournal;
 	   this.bindingsJournal = bindingsJournal;
+	   this.managementService = managementService;
    }
 	
 	public long generateMessageID()
@@ -524,6 +531,8 @@
 				Queue queue = queueFactory.createQueue(id, queueName, filter, true, false);
 			
 				Binding binding = new BindingImpl(address, queue);
+				
+				managementService.registerQueue(queue, address, this);
 
 				bindings.add(binding);      
 			}

Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -22,9 +22,21 @@
 
 package org.jboss.messaging.core.postoffice.impl;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.filter.Filter;
 import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.management.ManagementService;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.Binding;
 import org.jboss.messaging.core.postoffice.FlowController;
@@ -37,24 +49,18 @@
 import org.jboss.messaging.util.ConcurrentSet;
 import org.jboss.messaging.util.SimpleString;
 
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
 /**
  * 
  * A PostOfficeImpl
  * 
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
  *
  */
 public class PostOfficeImpl implements PostOffice
 {  
    private static final Logger log = Logger.getLogger(PostOfficeImpl.class);
    
-   //private final int nodeID;
-   
    private final ConcurrentMap<SimpleString, List<Binding>> mappings = new ConcurrentHashMap<SimpleString, List<Binding>>();
    
    private final ConcurrentSet<SimpleString> destinations = new ConcurrentHashSet<SimpleString>();
@@ -70,14 +76,18 @@
    private final StorageManager storageManager;
    
    private volatile boolean started;
+
+   private ManagementService managementService;
     
    public PostOfficeImpl(final StorageManager storageManager,
-   		                final QueueFactory queueFactory, final boolean checkAllowable)
+   		                final QueueFactory queueFactory, final ManagementService managementService, final boolean checkAllowable)
    {
       this.storageManager = storageManager;
       
       this.queueFactory = queueFactory;
       
+      this.managementService = managementService;
+      
       this.checkAllowable = checkAllowable;
    }
       
@@ -120,6 +130,7 @@
       	}
       	 
          flowControllers.put(address, new FlowControllerImpl(address, this));
+         managementService.registerAddress(address);
    	}
    	
    	return added;
@@ -137,6 +148,7 @@
          {
       		storageManager.deleteDestination(address);
          }
+      	managementService.unregisterAddress(address);
       }
 
       return removed;
@@ -176,6 +188,8 @@
       	storageManager.deleteBinding(binding);
       }
       
+      managementService.unregisterQueue(queueName, binding.getAddress());
+      
       return binding;
    }
    
@@ -274,6 +288,15 @@
       
       Binding binding = new BindingImpl(address, queue);
       
+      try
+      {
+         managementService.registerQueue(queue, address, storageManager);
+      } catch (Exception e)
+      {
+         e.printStackTrace();
+         throw new IllegalStateException(e);
+      }
+
       return binding;
    }
    
@@ -286,6 +309,9 @@
       if (prevBindings != null)
       {
          bindings = prevBindings;
+      } else
+      {
+         managementService.registerAddress(binding.getAddress());
       }
                      
       bindings.add(binding);  
@@ -334,6 +360,8 @@
       {
          mappings.remove(binding.getAddress());
                            
+         managementService.unregisterAddress(binding.getAddress());
+         
          binding.getQueue().setFlowController(null);
       }
                

Modified: trunk/src/main/org/jboss/messaging/core/server/MessageReference.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/MessageReference.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/core/server/MessageReference.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -23,6 +23,7 @@
 package org.jboss.messaging.core.server;
 
 import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.Binding;
 import org.jboss.messaging.core.postoffice.PostOffice;
 import org.jboss.messaging.core.settings.HierarchicalRepository;
 import org.jboss.messaging.core.settings.impl.QueueSettings;
@@ -65,9 +66,15 @@
    boolean cancel(StorageManager persistenceManager, PostOffice postOffice,
    		         HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception;  
    
+   void sendToDLQ(StorageManager persistenceManager, PostOffice postOffice,
+                  HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception;
+   
    void expire(StorageManager persistenceManager, PostOffice postOffice,
    		      HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception;
+   
+   void move(Binding otherBinding, StorageManager persistenceManager, PostOffice postOffice) throws Exception;
 
+
 }
 
 

Modified: trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -25,6 +25,7 @@
 import java.util.Set;
 
 import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.management.ManagementService;
 import org.jboss.messaging.core.management.MessagingServerManagement;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.remoting.RemotingConnection;
@@ -62,10 +63,14 @@
       
    StorageManager getStorageManager();
 
-   public JBMSecurityManager getSecurityManager();
+   JBMSecurityManager getSecurityManager();
       
    void setSecurityManager(JBMSecurityManager securityManager);
 
+   ManagementService getManagementService();
+  
+   void setManagementService(ManagementService managementService);
+   
    Version getVersion();
   
    CreateConnectionResponse createConnection(String username, String password,                                          

Modified: trunk/src/main/org/jboss/messaging/core/server/Queue.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/Queue.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/core/server/Queue.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -28,7 +28,11 @@
 
 import org.jboss.messaging.core.filter.Filter;
 import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.Binding;
 import org.jboss.messaging.core.postoffice.FlowController;
+import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.settings.HierarchicalRepository;
+import org.jboss.messaging.core.settings.impl.QueueSettings;
 import org.jboss.messaging.util.SimpleString;
 
 
@@ -71,8 +75,6 @@
    
    Filter getFilter();
    
-   void setFilter(Filter filter);
-   
    int getMessageCount();
    
    int getDeliveringCount();
@@ -116,7 +118,28 @@
    MessageReference getReference(long id);
    
    void deleteAllReferences(StorageManager storageManager) throws Exception;
-   
+
+   boolean deleteReference(long messageID, StorageManager storageManager)
+         throws Exception;
+
+   boolean expireMessage(long messageID, StorageManager storageManager,
+         PostOffice postOffice,
+         HierarchicalRepository<QueueSettings> queueSettingsRepository)
+         throws Exception;
+
+   boolean sendMessageToDLQ(long messageID, StorageManager storageManager,
+         PostOffice postOffice,
+         HierarchicalRepository<QueueSettings> queueSettingsRepository)
+         throws Exception;
+
+   boolean changeMessagePriority(long messageID, byte newPriority,
+         StorageManager storageManager, PostOffice postOffice,
+         HierarchicalRepository<QueueSettings> queueSettingsRepository)
+         throws Exception;
+
+   boolean moveMessage(long messageID, Binding toBinding,
+         StorageManager storageManager, PostOffice postOffice) throws Exception;
+
    void lock();
    
    void unlock();

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessageReferenceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessageReferenceImpl.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessageReferenceImpl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -122,90 +122,153 @@
       return queue;
    }
    
-   public boolean cancel(final StorageManager persistenceManager, final PostOffice postOffice,
-   		                final HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
-   {      
+   public boolean cancel(final StorageManager persistenceManager,
+         final PostOffice postOffice,
+         final HierarchicalRepository<QueueSettings> queueSettingsRepository)
+         throws Exception
+   {
       if (message.isDurable() && queue.isDurable())
       {
          persistenceManager.updateDeliveryCount(this);
       }
-              
-      queue.referenceCancelled();
 
-      int maxDeliveries = queueSettingsRepository.getMatch(queue.getName().toString()).getMaxDeliveryAttempts();
-      
+      int maxDeliveries = queueSettingsRepository.getMatch(
+            queue.getName().toString()).getMaxDeliveryAttempts();
+
       if (maxDeliveries > 0 && deliveryCount >= maxDeliveries)
       {
-         SimpleString DLQ = queueSettingsRepository.getMatch(queue.getName().toString()).getDLQ();
-         
+         SimpleString DLQ = queueSettingsRepository.getMatch(
+               queue.getName().toString()).getDLQ();
+
          Transaction tx = new TransactionImpl(persistenceManager, postOffice);
-                  
+
          if (DLQ != null)
          {
-         	Binding binding = postOffice.getBinding(DLQ);
-         	
-         	if (binding == null)
-         	{
-         		binding = postOffice.addBinding(DLQ, DLQ, null, true, false);
-         	}
-         	
-            ServerMessage copyMessage = makeCopyForDLQOrExpiry(false, persistenceManager);
-            
+            Binding binding = postOffice.getBinding(DLQ);
+
+            if (binding == null)
+            {
+               binding = postOffice.addBinding(DLQ, DLQ, null, true, false);
+            }
+
+            ServerMessage copyMessage = makeCopyForDLQOrExpiry(false,
+                  persistenceManager);
+            copyMessage.setDestination(binding.getAddress());
+
             tx.addMessage(copyMessage);
-            
-            tx.addAcknowledgement(this);      
+
+            tx.addAcknowledgement(this);
+         } else
+         {
+            // No DLQ
+
+            log
+                  .warn("Message has reached maximum delivery attempts, no DLQ is configured so dropping it");
+
+            tx.addAcknowledgement(this);
          }
-         else
-         {
-            //No DLQ
-            
-            log.warn("Message has reached maximum delivery attempts, no DLQ is configured so dropping it");
-            
-            tx.addAcknowledgement(this);   
-         }       
-         
+
+         tx.commit();
+
          return false;
-      }
-      else
+      } else
       {
+         queue.referenceCancelled();
+
          return true;
       }
    }
+
+   public void sendToDLQ(final StorageManager persistenceManager,
+         final PostOffice postOffice,
+         final HierarchicalRepository<QueueSettings> queueSettingsRepository)
+         throws Exception
+   {
+      SimpleString dlq = queueSettingsRepository.getMatch(
+            queue.getName().toString()).getDLQ();
+
+      Transaction tx = new TransactionImpl(persistenceManager, postOffice);
+
+      if (dlq != null)
+      {
+         Binding binding = postOffice.getBinding(dlq);
+
+         if (binding == null)
+         {
+            binding = postOffice.addBinding(dlq, dlq, null, true, false);
+         }
+
+         ServerMessage copyMessage = makeCopyForDLQOrExpiry(false,
+               persistenceManager);
+         copyMessage.setDestination(binding.getAddress());
+
+         tx.addMessage(copyMessage);
+
+         tx.addAcknowledgement(this);
+
+         tx.commit();
+      } else
+      {
+         throw new IllegalStateException("No DLQ configured for queue "
+               + queue.getName());
+      }
+   }
    
-   public void expire(final StorageManager persistenceManager, final PostOffice postOffice,
-   		final HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
+   public void expire(final StorageManager persistenceManager,
+         final PostOffice postOffice,
+         final HierarchicalRepository<QueueSettings> queueSettingsRepository)
+         throws Exception
    {
-      SimpleString expiryQueue = queueSettingsRepository.getMatch(queue.getName().toString()).getExpiryQueue();
-      
+      SimpleString expiryQueue = queueSettingsRepository.getMatch(
+            queue.getName().toString()).getExpiryQueue();
+
       Transaction tx = new TransactionImpl(persistenceManager, postOffice);
-      
+
       if (expiryQueue != null)
       {
-      	Binding binding = postOffice.getBinding(expiryQueue);
+         Binding binding = postOffice.getBinding(expiryQueue);
 
-      	if (binding == null)
-      	{
-      		binding = postOffice.addBinding(expiryQueue, expiryQueue, null, true, false);
-      	}
-      	
-         ServerMessage copyMessage = makeCopyForDLQOrExpiry(true, persistenceManager);
-         
+         if (binding == null)
+         {
+            binding = postOffice.addBinding(expiryQueue, expiryQueue, null,
+                  true, false);
+         }
+
+         ServerMessage copyMessage = makeCopyForDLQOrExpiry(true,
+               persistenceManager);
+
          copyMessage.setDestination(binding.getAddress());
-         
+
          tx.addMessage(copyMessage);
-         
-         tx.addAcknowledgement(this);                 
-      }
-      else
+
+         tx.addAcknowledgement(this);
+      } else
       {
-         log.warn("Message has expired, no expiry queue is configured so dropping it");
-         
+         log
+               .warn("Message has expired, no expiry queue is configured so dropping it");
+
          tx.addAcknowledgement(this);
       }
-      
+
       tx.commit();
    }
+   
+   public void move(final Binding otherBinding,
+         final StorageManager persistenceManager, final PostOffice postOffice)
+         throws Exception
+   {
+      Transaction tx = new TransactionImpl(persistenceManager, postOffice);
 
+      ServerMessage copyMessage = message.copy();
+      copyMessage.setDestination(otherBinding.getAddress());
+
+      tx.addMessage(copyMessage);
+
+      tx.addAcknowledgement(this);
+
+      tx.commit();
+   }
+
    // Public --------------------------------------------------------
 
    public String toString()
@@ -236,9 +299,11 @@
       
       copy.setMessageID(newMessageId);
       
+      SimpleString originalQueue = copy.getDestination();      
+      copy.putStringProperty(MessageImpl.HDR_ORIGIN_QUEUE, originalQueue);
+
       // reset expiry
       copy.setExpiration(0);
-      
       if (expiry)
       {
          long actualExpiryTime = System.currentTimeMillis();

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -31,12 +31,12 @@
 import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.management.ManagementService;
 import org.jboss.messaging.core.management.MessagingServerManagement;
 import org.jboss.messaging.core.management.impl.MessagingServerManagementImpl;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.PostOffice;
 import org.jboss.messaging.core.postoffice.impl.PostOfficeImpl;
-import org.jboss.messaging.core.remoting.Interceptor;
 import org.jboss.messaging.core.remoting.PacketDispatcher;
 import org.jboss.messaging.core.remoting.RemotingConnection;
 import org.jboss.messaging.core.remoting.RemotingService;
@@ -102,6 +102,7 @@
    private RemotingService remotingService;
    private JBMSecurityManager securityManager;  
    private Configuration configuration;
+   private ManagementService managementService;
         
    // Constructors ---------------------------------------------------------------------------------
    
@@ -123,7 +124,7 @@
 
       /*
       The following components are pluggable on the messaging server:
-      Configuration, StorageManager, RemotingService and SecurityManager
+      Configuration, StorageManager, RemotingService, SecurityManager and ManagementRegistration
       They must already be injected by the time the messaging server starts
       It's up to the user to make sure the pluggable components are started - their
       lifecycle will not be controlled here
@@ -150,6 +151,11 @@
          throw new IllegalStateException("Must inject SecurityManager before starting MessagingServer");
       }      
       
+      if (managementService == null)
+      {
+         throw new IllegalStateException("Must inject ManagementRegistration before starting MessagingServer");
+      }   
+      
       if (!storageManager.isStarted())
       {
          throw new IllegalStateException("StorageManager must be started before MessagingServer is started");
@@ -164,9 +170,11 @@
 
       securityStore = new SecurityStoreImpl(configuration.getSecurityInvalidationInterval(), configuration.isSecurityEnabled());  
       queueSettingsRepository.setDefault(new QueueSettings());
+      managementService.setQueueSettingsRepository(queueSettingsRepository);
       scheduledExecutor = new ScheduledThreadPoolExecutor(configuration.getScheduledThreadPoolMaxSize(), new JBMThreadFactory("JBM-scheduled-threads"));                  
       queueFactory = new QueueFactoryImpl(scheduledExecutor, queueSettingsRepository);      
-      postOffice = new PostOfficeImpl(storageManager, queueFactory, configuration.isRequireDestinations());
+      postOffice = new PostOfficeImpl(storageManager, queueFactory, managementService, configuration.isRequireDestinations());
+      managementService.setPostOffice(postOffice);
                        
       securityRepository = new HierarchicalObjectRepository<Set<Role>>();
       securityRepository.setDefault(new HashSet<Role>());
@@ -174,12 +182,14 @@
       securityStore.setSecurityManager(securityManager);                       
       resourceManager = new ResourceManagerImpl(0);                           
       dispatcher = remotingService.getDispatcher();
+      serverManagement = new MessagingServerManagementImpl(postOffice, storageManager, configuration,
+                                                           securityRepository,
+                                                           queueSettingsRepository, this);
+      managementService.registerServer(serverManagement);
+
       postOffice.start();
       serverPacketHandler = new MessagingServerPacketHandler(this, remotingService);          
      
-      serverManagement = new MessagingServerManagementImpl(postOffice, storageManager, configuration,
-                                                           securityRepository,
-                                                           queueSettingsRepository, this);
       //Register the handler as the last thing - since after that users will be able to connect
       started = true;
       dispatcher.register(serverPacketHandler);      
@@ -271,6 +281,20 @@
       return securityManager;
    }
    
+   public void setManagementService(ManagementService managementService)
+   {
+      if (started)
+      {
+         throw new IllegalStateException("Cannot set management service when started");
+      }
+      this.managementService = managementService;
+   }
+   
+   public ManagementService getManagementService()
+   {
+      return managementService;
+   }
+   
    //This is needed for the security deployer
    public HierarchicalRepository<Set<Role>> getSecurityRepository()
    {

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServiceImpl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -21,8 +21,12 @@
   */
 package org.jboss.messaging.core.server.impl;
 
+import java.lang.management.ManagementFactory;
+
 import org.jboss.messaging.core.config.Configuration;
 import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.management.ManagementService;
+import org.jboss.messaging.core.management.impl.ManagementServiceImpl;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.persistence.impl.nullpm.NullStorageManager;
 import org.jboss.messaging.core.remoting.RemotingService;
@@ -36,6 +40,7 @@
 /**
  * 
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
  *
  */
 public class MessagingServiceImpl implements MessagingService
@@ -53,6 +58,8 @@
 
       JBMSecurityManager securityManager = new JBMSecurityManagerImpl(true);
       
+      ManagementService managementService = new ManagementServiceImpl(ManagementFactory.getPlatformMBeanServer(), false);
+      
       MessagingServer server = new MessagingServerImpl();
       
       server.setConfiguration(config);
@@ -63,6 +70,8 @@
       
       server.setSecurityManager(securityManager);
       
+      server.setManagementService(managementService);
+      
       return new MessagingServiceImpl(server, storageManager, remotingService);
    }
    

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -22,28 +22,42 @@
 
 package org.jboss.messaging.core.server.impl;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Set;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
 import org.jboss.messaging.core.filter.Filter;
 import org.jboss.messaging.core.list.PriorityLinkedList;
 import org.jboss.messaging.core.list.impl.PriorityLinkedListImpl;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.Binding;
 import org.jboss.messaging.core.postoffice.FlowController;
-import org.jboss.messaging.core.server.*;
+import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.Consumer;
+import org.jboss.messaging.core.server.DistributionPolicy;
+import org.jboss.messaging.core.server.HandleStatus;
+import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.core.settings.HierarchicalRepository;
+import org.jboss.messaging.core.settings.impl.QueueSettings;
 import org.jboss.messaging.core.transaction.Transaction;
 import org.jboss.messaging.core.transaction.impl.TransactionImpl;
 import org.jboss.messaging.util.SimpleString;
 
-import java.util.*;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Future;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
 /**
  * 
  * Implementation of a Queue
@@ -385,11 +399,6 @@
       return filter;
    }
 
-   public void setFilter(final Filter filter)
-   {
-      this.filter = filter;
-   }
-
    public synchronized int getMessageCount()
    {    
       return messageReferences.size() + getScheduledCount() + getDeliveringCount();
@@ -491,6 +500,116 @@
       tx.commit();
    }
    
+   public synchronized boolean deleteReference(final long messageID, final StorageManager storageManager) throws Exception
+   {
+      boolean deleted = false;
+      
+      Transaction tx = new TransactionImpl(storageManager, null);
+
+      Iterator<MessageReference> iter = messageReferences.iterator();
+
+      while (iter.hasNext())
+      {
+         MessageReference ref = iter.next();
+         if (ref.getMessage().getMessageID() == messageID)
+         {        
+            deliveringCount.incrementAndGet();
+            tx.addAcknowledgement(ref);
+            iter.remove();
+            deleted = true;
+            break;
+         }
+      }
+
+      tx.commit();
+      
+      return deleted;
+   }
+   
+   public boolean expireMessage(final long messageID,
+         final StorageManager storageManager, final PostOffice postOffice,
+         final HierarchicalRepository<QueueSettings> queueSettingsRepository)
+         throws Exception
+   {
+      Iterator<MessageReference> iter = messageReferences.iterator();
+
+      while (iter.hasNext())
+      {
+         MessageReference ref = iter.next();
+         if (ref.getMessage().getMessageID() == messageID)
+         {
+            deliveringCount.incrementAndGet();
+            ref.expire(storageManager, postOffice, queueSettingsRepository);
+            iter.remove();
+            return true;
+         }
+      }
+      return false;
+   }
+
+   public boolean sendMessageToDLQ(final long messageID,
+         final StorageManager storageManager, final PostOffice postOffice,
+         final HierarchicalRepository<QueueSettings> queueSettingsRepository)
+         throws Exception
+   {
+      Iterator<MessageReference> iter = messageReferences.iterator();
+
+      while (iter.hasNext())
+      {
+         MessageReference ref = iter.next();
+         if (ref.getMessage().getMessageID() == messageID)
+         {
+            deliveringCount.incrementAndGet();
+            ref.sendToDLQ(storageManager, postOffice, queueSettingsRepository);
+            iter.remove();
+            return true;
+         }
+      }
+      return false;
+   }
+
+   public boolean moveMessage(final long messageID,
+         final Binding toBinding, final StorageManager storageManager,
+         final PostOffice postOffice) throws Exception
+   {
+      Iterator<MessageReference> iter = messageReferences.iterator();
+
+      while (iter.hasNext())
+      {
+         MessageReference ref = iter.next();
+         if (ref.getMessage().getMessageID() == messageID)
+         {
+            deliveringCount.incrementAndGet();
+            ref.move(toBinding, storageManager, postOffice);
+            iter.remove();
+            return true;
+         }
+      }
+      return false;
+   }
+   
+   public boolean changeMessagePriority(final long messageID, final byte newPriority,
+         final StorageManager storageManager, final PostOffice postOffice,
+         final HierarchicalRepository<QueueSettings> queueSettingsRepository)
+         throws Exception
+   {
+      List<MessageReference> refs = list(null);
+      for (MessageReference ref : refs)
+      {
+         ServerMessage message = ref.getMessage();
+         if (message.getMessageID() == messageID)
+         {
+            message.setPriority(newPriority);
+            // delete and add the reference so that it
+            // goes to the right queues for the new priority
+            deleteReference(messageID, storageManager);
+            addLast(ref);
+            return true;
+         }
+      }
+      return false;
+   }
+   
    public void lock()
    {
       lock.lock();

Modified: trunk/src/main/org/jboss/messaging/jms/JBossQueue.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/JBossQueue.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/jms/JBossQueue.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -25,6 +25,8 @@
 import javax.jms.JMSException;
 import javax.jms.Queue;
 
+import org.jboss.messaging.util.SimpleString;
+
 /**
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -42,6 +44,11 @@
 
    // Static --------------------------------------------------------
    
+   public static SimpleString createAddressFromName(String name)
+   {
+      return new SimpleString(JMS_QUEUE_ADDRESS_PREFIX + name);
+   }
+
    // Attributes ----------------------------------------------------
    
    // Constructors --------------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/jms/JBossTopic.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/JBossTopic.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/jms/JBossTopic.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -26,6 +26,7 @@
 import javax.jms.Topic;
 
 import org.jboss.messaging.util.Pair;
+import org.jboss.messaging.util.SimpleString;
 
 /**
  * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
@@ -99,6 +100,11 @@
       return pair;
    }
          
+   public static SimpleString createAddressFromName(String name)
+   {
+      return new SimpleString(JMS_TOPIC_ADDRESS_PREFIX + name);
+   }
+
    // Attributes ----------------------------------------------------     
    
    // Constructors --------------------------------------------------
@@ -131,6 +137,7 @@
    {
       return "JBossTopic[" + name + "]";
    }
+
      
    // Package protected ---------------------------------------------
    

Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -235,6 +235,16 @@
    
    // Public ---------------------------------------------------------------------------------------
    
+   public String getClientID()
+   {
+      return clientID;
+   }
+   
+   public int getDupsOKBatchSize()
+   {
+      return dupsOKBatchSize;
+   }
+   
    public String toString()
    {
       return "JBossConnectionFactory->" + connectionFactory;

Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossMessage.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossMessage.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -59,7 +59,7 @@
 {
    // Constants -----------------------------------------------------
 
-   private static final SimpleString REPLYTO_HEADER_NAME = new SimpleString("JMSReplyTo");
+   public static final SimpleString REPLYTO_HEADER_NAME = new SimpleString("JMSReplyTo");
    
    public static final SimpleString CORRELATIONID_HEADER_NAME = new SimpleString("JMSCorrelationID");
 

Modified: trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -18,382 +18,178 @@
  * 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.jms.server;
 
-import java.io.Serializable;
 import java.util.List;
 
+import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.jms.JBossDestination;
 
 /**
  * The JMS Management interface.
- *
+ * 
  * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
  */
-public interface JMSServerManager extends Serializable
+public interface JMSServerManager
 {
-   public enum ListType
-   {
-      ALL, DURABLE, NON_DURABLE
-   }
 
+   String getVersion();
+
    /**
     * Has the Server been started.
+    * 
     * @return true if the server us running
     */
    boolean isStarted();
 
    /**
     * Creates a JMS Queue.
-    * @param queueName The name of the queue to create
-    * @param jndiBinding the name of the binding for JNDI
-    * @return true if the queue is created or if it existed and was added to JNDI
-    * @throws Exception if problems were encountered creating the queue.
+    * 
+    * @param queueName
+    *           The name of the queue to create
+    * @param jndiBinding
+    *           the name of the binding for JNDI
+    * @return true if the queue is created or if it existed and was added to
+    *         JNDI
+    * @throws Exception
+    *            if problems were encountered creating the queue.
     */
    boolean createQueue(String queueName, String jndiBinding) throws Exception;
 
    /**
     * Creates a JMS Topic
-    * @param topicName the name of the topic
-    * @param jndiBinding the name of the binding for JNDI
-    * @return true if the topic was created or if it existed and was added to JNDI
-    * @throws Exception if a problem occurred creating the topic
+    * 
+    * @param topicName
+    *           the name of the topic
+    * @param jndiBinding
+    *           the name of the binding for JNDI
+    * @return true if the topic was created or if it existed and was added to
+    *         JNDI
+    * @throws Exception
+    *            if a problem occurred creating the topic
     */
    boolean createTopic(String topicName, String jndiBinding) throws Exception;
 
    /**
     * destroys a queue and removes it from JNDI
-    * @param name the name of the queue to destroy
+    * 
+    * @param name
+    *           the name of the queue to destroy
     * @return true if destroyed
-    * @throws Exception if a problem occurred destroying the queue
+    * @throws Exception
+    *            if a problem occurred destroying the queue
     */
    boolean destroyQueue(String name) throws Exception;
 
    /**
     * destroys a topic and removes it from JNDI
-    * @param name the name of the topic to destroy
+    * 
+    * @param name
+    *           the name of the topic to destroy
     * @return true if the topic was destroyed
-    * @throws Exception if a problem occurred destroying the topic
+    * @throws Exception
+    *            if a problem occurred destroying the topic
     */
    boolean destroyTopic(String name) throws Exception;
 
-//   /**
-//    * returns a list of all the JMS queues
-//    * @return all queues
-//    */
-//   Set<String> listAllQueues();
-//
-//   /**
-//    * returns a list of all the JMS topics
-//    * @return all topics
-//    */
-//   Set<String> listAllTopics();
-//
-//   /**
-//    * returns all the temporary destinations
-//    * @return all temporary destinations
-//    */
-//   Set<String> listTemporaryDestinations();
-
    /**
     * Creates a connection factory
-    * @param name the name of this connection factory
-    * @param clientID the client id
-    * @param dupsOKBatchSize the bath size
-    * @param consumerWindowSize The consumer window size
-    * @param consumerMaxRate the Consumer max rate
-    * @param producerWindowSize the producer window size
-    * @param producerMaxRate the producer max rate
-    * @param jndiBinding the binding name for JNDI
+    * 
+    * @param name
+    *           the name of this connection factory
+    * @param clientID
+    *           the client id
+    * @param dupsOKBatchSize
+    *           the bath size
+    * @param consumerWindowSize
+    *           The consumer window size
+    * @param consumerMaxRate
+    *           the Consumer max rate
+    * @param producerWindowSize
+    *           the producer window size
+    * @param producerMaxRate
+    *           the producer max rate
+    * @param jndiBinding
+    *           the binding name for JNDI
     * @return true if the connection factory was created
-    * @throws Exception if a problem occurred creating the connection factory
+    * @throws Exception
+    *            if a problem occurred creating the connection factory
     */
    boolean createConnectionFactory(String name, String clientID,
-   		                          int dupsOKBatchSize,
-   		                          int consumerWindowSize, int consumerMaxRate,
-   		                          int producerWindowSize, int producerMaxRate,
-   		                          boolean blockOnAcknowledge,
-   		                          boolean defaultSendNonPersistentMessagesBlocking,
-   		                          boolean defaultSendPersistentMessagesBlocking,
-   		                          String jndiBinding) throws Exception;
+         int dupsOKBatchSize, int consumerWindowSize, int consumerMaxRate,
+         int producerWindowSize, int producerMaxRate,
+         boolean blockOnAcknowledge,
+         boolean defaultSendNonPersistentMessagesBlocking,
+         boolean defaultSendPersistentMessagesBlocking, String jndiBinding)
+         throws Exception;
 
    /**
     * Creates a connection factory
-    * @param name the name of this connection factory
-    * @param clientID the client id
-    * @param dupsOKBatchSize the bath size
-    * @param consumerWindowSize The consumer window size
-    * @param consumerMaxRate the Consumer max rate
-    * @param producerWindowSize the producer window size
-    * @param producerMaxRate the producer max rate
-    * @param jndiBindings the binding names for JNDI
+    * 
+    * @param name
+    *           the name of this connection factory
+    * @param clientID
+    *           the client id
+    * @param dupsOKBatchSize
+    *           the bath size
+    * @param consumerWindowSize
+    *           The consumer window size
+    * @param consumerMaxRate
+    *           the Consumer max rate
+    * @param producerWindowSize
+    *           the producer window size
+    * @param producerMaxRate
+    *           the producer max rate
+    * @param jndiBindings
+    *           the binding names for JNDI
     * @return true if the connection factory was created
-    * @throws Exception if a problem occurred creating the connection factory
+    * @throws Exception
+    *            if a problem occurred creating the connection factory
     */
-   boolean createConnectionFactory(String name, String clientID, int dupsOKBatchSize,
-   		                          int consumerWindowSize, int consumerMaxRate,
-   		                          int producerWindowSize, int producerMaxRate,
-   		                          boolean blockOnAcknowledge,
-   		                          boolean defaultSendNonPersistentMessagesBlocking,
-   		                          boolean defaultSendPersistentMessagesBlocking,
-   		                          List<String> jndiBindings) throws Exception;
+   boolean createConnectionFactory(String name, String clientID,
+         int dupsOKBatchSize, int consumerWindowSize, int consumerMaxRate,
+         int producerWindowSize, int producerMaxRate,
+         boolean blockOnAcknowledge,
+         boolean defaultSendNonPersistentMessagesBlocking,
+         boolean defaultSendPersistentMessagesBlocking,
+         List<String> jndiBindings) throws Exception;
 
    /**
     * destroys a connection factory.
-    * @param name the name of the connection factory to destroy
+    * 
+    * @param name
+    *           the name of the connection factory to destroy
     * @return true if the connection factory was destroyed
-    * @throws Exception if a problem occurred destroying the connection factory
+    * @throws Exception
+    *            if a problem occurred destroying the connection factory
     */
    boolean destroyConnectionFactory(String name) throws Exception;
 
-//   /**
-//    * list all messages for a specific queue
-//    * @param queue the queue to inspect
-//    * @return all messages
-//    * @throws Exception if a problem occurred
-//    */
-//   public List<Message> listMessagesForQueue(String queue) throws Exception;
-//
-//   /**
-//    * list the messages on a specific queue dependant on the ListType.
-//    * ListType.ALL returns all messages
-//    * ListType.DURABLE returns all durable messages
-//    * ListType.NON_DURABLE returns all non durable messages
-//    * @param queue the queue to inspect
-//    * @param listType the list type.
-//    * @return the messages
-//    * @throws Exception if a problem occurred
-//    */
-//   public List<Message> listMessagesForQueue(String queue, ListType listType) throws Exception;
-//
-//   /**
-//    * list all messages for a specific subscription
-//    * @param subscription the subscription to inspect
-//    * @return all messages
-//    * @throws Exception if a problem occurred
-//    */
-//   public List<Message> listMessagesForSubscription(String subscription) throws Exception;
-//
-//   /**
-//    * list the messages on a specific subscription dependant on the ListType.
-//    * ListType.ALL returns all messages
-//    * ListType.DURABLE returns all durable messages
-//    * ListType.NON_DURABLE returns all non durable messages
-//    * @param subscription the subscription to inspect
-//    * @param listType the list type
-//    * @return the messages
-//    * @throws Exception if a problem occurred
-//    */
-//   public List<Message> listMessagesForSubscription(String subscription, ListType listType) throws Exception;
-//
-//   /**
-//    * removes a particular message from a queue
-//    * @param queue the name of the queue
-//    * @param messageId the id of the message to remove
-//    * @throws Exception if a problem occurred
-//    */
-// //  void removeMessageFromQueue(String queue, String messageId) throws Exception;
-//
-//   /**
-//    * removes a particular message from a topic
-//    * @param topic the name of the topic
-//    * @param messageId the id of the message
-//    * @throws Exception if a problem occurred
-//    */
-// //  void removeMessageFromTopic(String topic, String messageId) throws Exception;
-
    /**
-    * removes all messages from a particular queue
-    * @param queue the name of the queue
-    * @throws Exception if a problem occurred
+    * removes all messages from a particular destination
+    * 
+    * @param queue
+    *           the destination
+    * @throws Exception
+    *            if a problem occurred
     */
-   void removeAllMessagesForQueue(String queue) throws Exception;
+   void removeAllMessages(JBossDestination destination) throws Exception;
 
-   /**
-    * removes all the messages from a topic
-    * @param topic the name of the topic
-    * @throws Exception if a problem occurred
-    */
-   void removeAllMessagesForTopic(String topic) throws Exception;
-//
-//   /**
-//    * moves a message from one queue to another
-//    * @param fromQueue the name of the queue to find the message
-//    * @param toQueue the name of the queue to move the message to
-//    * @param messageID the id of the message
-//    * @throws Exception if a problem occurred
-//    */
-//   //void moveMessage(String fromQueue, String toQueue, String messageID) throws Exception;
-//
-//   /**
-//    * expires a message
-//    * @param queue the name of the queue
-//    * @param messageId the message id
-//    * @throws Exception if a problem occurred
-//    */
-//   void expireMessage(String queue, String messageId) throws Exception;
-//
-//   /**
-//    * changes the priority of a message.
-//    * @param queue the name of the queue
-//    * @param messageId the id of the message
-//    * @param priority the priority to change the message to
-//    * @throws Exception if a problem occurred
-//    */
-// //  void changeMessagePriority(String queue, String messageId, int priority) throws Exception;
-//
-   /**
-    * returns how many messages a queue is currently holding
-    * @param queue the name of the queue
-    * @return the number of messages
-    * @throws Exception if a problem occurred
-    */
-   int getMessageCountForQueue(String queue) throws Exception;
+   boolean removeMessage(long messageID, JBossDestination destination)
+         throws Exception;
 
-   /**
-    * lists all the subscriptions for a specific topic
-    * @param topic the name of the topic
-    * @return the subscriptions
-    * @throws Exception if a problem occurred
-    */
-   List<SubscriptionInfo> listSubscriptions(String topic) throws Exception;
-//
-//   /**
-//    * lists all the subscriptions for a specific topic for a specific ListType.
-//    * ListType.ALL returns all subscriptions
-//    * ListType.DURABLE returns all durable subscriptions
-//    * ListType.NON_DURABLE returns all non durable subscriptions
-//    *
-//    * @param topicName the name of the topic
-//    * @param listType the list type
-//    * @return the subscriptions
-//    * @throws Exception if a problem occurred
-//    */
-//   List<SubscriptionInfo> listSubscriptions(String topicName, ListType listType) throws Exception;
-//
-//   /**
-//    * count the subscriptions a topic currently has
-//    * @param topic the name of the topic
-//    * @return the number of subscriptions
-//    * @throws Exception if a problem occurred
-//    */
-//   int getSubscriptionsCountForTopic(String topic) throws Exception;
-//
-//  /**
-//    * count the subscriptions a topic currently has of a specific type.
-//    * ListType.ALL returns all subscriptions
-//    * ListType.DURABLE returns all durable subscriptions
-//    * ListType.NON_DURABLE returns all non durable subscriptions
-//   *
-//    * @param topic the name of the topic
-//    * @param listType the list type
-//    * @return the number of subscriptions
-//    * @throws Exception if a problem occurred
-//    */
-//   int getSubscriptionsCountForTopic(String topic, ListType listType) throws Exception;
-//
-//   /**
-//    * drops a particular subscription
-//    *
-//    * @param subscription the id of the subscription
-//    * @throws Exception if a problem occurred
-//    */
-//   void dropSubscription(String subscription) throws Exception;
-//
-//   /**
-//    * count the consumers for a specific queue
-//    * @param queue the name of the queue
-//    * @return the number of consumers
-//    * @throws Exception if a problem occurred
-//    */
-//   int getConsumerCountForQueue(String queue) throws Exception;
-//
-//   /**
-//    * returns info on all the current active connections
-//    * @return the connections info
-//    * @throws Exception if a problem occurred
-//    */
-//   List<ConnectionInfo> getConnections() throws Exception;
-//
-//   /**
-//    * return the connections info for a particular user.
-//    * @param user the user
-//    * @return the connections info
-//    * @throws Exception if a problem occurred
-//    */
-//   List<ConnectionInfo> getConnectionsForUser(String user) throws Exception;
-//
-//   /**
-//    * drops the connection with the specified client id
-//    * @param clientId the client id
-//    * @throws Exception if a problem occurred
-//    */
-//   void dropConnection(long id) throws Exception;
-//
-//   /**
-//    * drop all the connections for a specific user
-//    * @param user the user
-//    * @throws Exception if a problem occurred
-//    */
-//   void dropConnectionsForUser(String user) throws Exception;
-//
-//   /**
-//    * list all the sessions info
-//    * @return the session info
-//    * @throws Exception if a problem occurred
-//    */
-//   //public List<SessionInfo> getSessions() throws Exception;
-//
-//   /**
-//    * get the session info for a particular connection with the specified client id
-//    * @param clientid the client id
-//    * @return the session info
-//    * @throws Exception if a problem occurred
-//    */
-//  // public List<SessionInfo> getSessionsForConnection(long id) throws Exception;
-//
-//   /**
-//    * get the session info for a particular user
-//    * @param user the user
-//    * @return the session info
-//    * @throws Exception if a problem occurred
-//    */
-//  // public List<SessionInfo> getSessionsForUser(String user) throws Exception;
-//
-//   /**
-//    * Start gathering delivery statistics for all queues
-//    * @throws Exception if a problem occurred
-//    */
-//   void startGatheringStatistics() throws Exception;
-//
-//   /**
-//    * Start gathering delivery statistics for a specified queue
-//    * @param queue the name of the queue
-//    * @throws Exception if a problem occurred
-//    */
-//   void startGatheringStatisticsForQueue(String queue) throws Exception;
-//
-//   /**
-//    * stop gathering delivery statistics for all queues
-//    * @return the delivery statistics at the time of stopping gathering
-//    * @throws Exception if a problem occurred
-//    */
-//   List<MessageStatistics> stopGatheringStatistics() throws Exception;
-//
-//   /**
-//    * stop gathering statistics for a specified queue
-//    * @param queue the name of the queue
-//    * @return the delivery statistics for that queue at the time of stopping gathering
-//    * @throws Exception if a problem occurred
-//    */
-//   MessageStatistics stopGatheringStatisticsForQueue(String queue) throws Exception;
-//
-//   /**
-//    * list all message delivery statistics. This will include statistics up to the point this method is called.
-//    * The gathering of statistics will carry on.
-//    * @return the delivery statistics
-//    * @throws Exception if a problem occurred
-//    */
-//   List<MessageStatistics> getStatistics() throws Exception;
+   int expireMessages(Filter filter, JBossDestination destination)
+         throws Exception;
+
+   public QueueSettings getSettings(JBossDestination destination);
+
+   int sendMessagesToDLQ(Filter filter, JBossDestination destination)
+         throws Exception;
+
+   int changeMessagesPriority(Filter filter, byte newPriority,
+         JBossDestination destination) throws Exception;
 }

Deleted: trunk/src/main/org/jboss/messaging/jms/server/SubscriptionInfo.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/SubscriptionInfo.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/jms/server/SubscriptionInfo.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,101 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, 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.jms.server;
-
-import java.io.Serializable;
-
-/**
- * A SubscriptionInfo
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1935 $</tt>
- *
- * $Id: SubscriptionInfo.java 1935 2007-01-09 23:29:20Z clebert.suconic at jboss.com $
- *
- */
-public class SubscriptionInfo implements Serializable
-{
-   private static final long serialVersionUID = -38689006079435295L;
-
-   private final String id;
-   
-   private final boolean durable;
-   
-   private final String name;
-   
-   private final String clientID;
-   
-   private final String selector;
-   
-   private final int messageCount;
-   
-   private final int maxSize;
-   
-   public SubscriptionInfo(final String id, final boolean durable, final String name,
-   		                  final String clientID, final String selector, final int messageCount, final int maxSize)
-   {
-      this.id = id;
-      this.durable = durable;
-      this.name = name;
-      this.clientID = clientID;
-      this.selector = selector;
-      this.messageCount = messageCount;
-      this.maxSize = maxSize;
-   }
-   
-   public String getId()
-   {
-      return id;
-   }
-
-   public String getClientID()
-   {
-      return clientID;
-   }
-
-   public boolean isDurable()
-   {
-      return durable;
-   }
-
-   public int getMaxSize()
-   {
-      return maxSize;
-   }
-
-   public int getMessageCount()
-   {
-      return messageCount;
-   }
-
-   public String getName()
-   {
-      return name;
-   }
-
-   public String getSelector()
-   {
-      return selector;
-   }
-
-}

Modified: trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -22,6 +22,9 @@
 
 package org.jboss.messaging.jms.server.impl;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.jboss.messaging.core.deployers.DeploymentManager;
 import org.jboss.messaging.core.deployers.impl.XmlDeployer;
 import org.jboss.messaging.core.logging.Logger;
@@ -148,6 +151,8 @@
          }
 
          NodeList children = node.getChildNodes();
+         String name = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
+         List<String> jndiBindings = new ArrayList<String>();
          for (int i = 0; i < children.getLength(); i++)
          {
             Node child = children.item(i);
@@ -155,13 +160,14 @@
             if (ENTRY_NODE_NAME.equalsIgnoreCase(children.item(i).getNodeName()))
             {
                String jndiName = child.getAttributes().getNamedItem("name").getNodeValue();
-               String name = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
-               jmsServerManager.createConnectionFactory(name, clientID, dupsOKBatchSize, 
-                     consumerWindowSize, consumerMaxRate, producerWindowSize, producerMaxRate, 
-               		blockOnAcknowledge, sendNonPersistentMessagesSynchronously, 
-               		sendPersistentMessagesSynchronously, jndiName);
+               jndiBindings.add(jndiName);
             }
          }
+         
+         jmsServerManager.createConnectionFactory(name, clientID, dupsOKBatchSize, 
+               consumerWindowSize, consumerMaxRate, producerWindowSize, producerMaxRate, 
+               blockOnAcknowledge, sendNonPersistentMessagesSynchronously, 
+               sendPersistentMessagesSynchronously, jndiBindings);
       }
       else if (node.getNodeName().equals(QUEUE_NODE_NAME))
       {

Modified: trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -18,7 +18,7 @@
  * 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.jms.server.impl;
 
@@ -31,26 +31,29 @@
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
+import org.jboss.messaging.core.filter.Filter;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.management.MessagingServerManagement;
-import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.jms.JBossDestination;
 import org.jboss.messaging.jms.JBossQueue;
 import org.jboss.messaging.jms.JBossTopic;
 import org.jboss.messaging.jms.client.JBossConnectionFactory;
 import org.jboss.messaging.jms.server.JMSServerManager;
-import org.jboss.messaging.jms.server.SubscriptionInfo;
+import org.jboss.messaging.jms.server.management.JMSManagementService;
 import org.jboss.messaging.util.JNDIUtil;
-import org.jboss.messaging.util.Pair;
 
 /**
- * A Deployer used to create and add to JNDI queues, topics and connection factories. Typically this would only be used
- * in an app server env.
- *
+ * A Deployer used to create and add to JNDI queues, topics and connection
+ * factories. Typically this would only be used in an app server env.
+ * 
  * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
  */
 public class JMSServerManagerImpl implements JMSServerManager
 {
-   private static final Logger log = Logger.getLogger(JMSServerManagerImpl.class);
+   private static final Logger log = Logger
+         .getLogger(JMSServerManagerImpl.class);
 
    /**
     * the initial context to bind to
@@ -64,83 +67,59 @@
    private final Map<String, List<String>> connectionFactoryBindings = new HashMap<String, List<String>>();
 
    private final MessagingServerManagement messagingServerManagement;
-   
-   public JMSServerManagerImpl(final MessagingServerManagement serverManager)
+
+   private JMSManagementService managementService;
+
+   public JMSServerManagerImpl(final MessagingServerManagement serverManager, final JMSManagementService managementService)
    {
       messagingServerManagement = serverManager;
+      this.managementService = managementService;
    }
 
-   /**
-    * lifecycle method
-    *
-    * @throws Exception ex
-    */
    public void start() throws Exception
    {
       try
       {
-         initialContext = new InitialContext();          
-      }
-      catch (NamingException e)
+         initialContext = new InitialContext();
+      } catch (NamingException e)
       {
          log.error("Unable to create Initial Context", e);
       }
+      managementService.registerJMSServer(this);
    }
 
+   // JMSServerManager implementation -------------------------------
 
-   private boolean bindToJndi(final String jndiName, final Object objectToBind) throws NamingException
+   public boolean isStarted()
    {
-      String parentContext;
-      String jndiNameInContext;
-      int sepIndex = jndiName.lastIndexOf('/');
-      if (sepIndex == -1)
-      {
-         parentContext = "";
-      }
-      else
-      {
-         parentContext = jndiName.substring(0, sepIndex);
-      }
-      jndiNameInContext = jndiName.substring(sepIndex + 1);
-      try
-      {
-         initialContext.lookup(jndiName);
-
-         log.warn("Binding for " + jndiName + " already exists");
-         return false;
-      }
-      catch (Throwable e)
-      {
-         // OK
-      }
-
-      Context c = JNDIUtil.createContext(initialContext, parentContext);
-
-      c.rebind(jndiNameInContext, objectToBind);
-      return true;
+      return messagingServerManagement.isStarted();
    }
 
-   // management operations
-
-   public boolean isStarted()
+   public String getVersion()
    {
-      return messagingServerManagement.isStarted();
+      return messagingServerManagement.getVersion();
    }
 
-   public boolean createQueue(String queueName, String jndiBinding) throws Exception
+   public boolean createQueue(final String queueName, final String jndiBinding)
+         throws Exception
    {
       JBossQueue jBossQueue = new JBossQueue(queueName);
       messagingServerManagement.addDestination(jBossQueue.getSimpleAddress());
-      messagingServerManagement.createQueue(jBossQueue.getSimpleAddress(), jBossQueue.getSimpleAddress());
+      messagingServerManagement.createQueue(jBossQueue.getSimpleAddress(),
+            jBossQueue.getSimpleAddress());
       boolean added = bindToJndi(jndiBinding, jBossQueue);
       if (added)
       {
          addToDestinationBindings(queueName, jndiBinding);
       }
+      managementService.registerQueue(jBossQueue,
+            messagingServerManagement.getQueue(jBossQueue.getSimpleAddress()),
+            jndiBinding, this);
       return added;
    }
 
-   public boolean createTopic(String topicName, String jndiBinding) throws Exception
+   public boolean createTopic(final String topicName, final String jndiBinding)
+         throws Exception
    {
       JBossTopic jBossTopic = new JBossTopic(topicName);
       messagingServerManagement.addDestination(jBossTopic.getSimpleAddress());
@@ -149,14 +128,13 @@
       {
          addToDestinationBindings(topicName, jndiBinding);
       }
+      managementService.registerTopic(jBossTopic,
+            messagingServerManagement, jndiBinding);
       return added;
    }
 
-   public boolean destroyQueue(String name) throws Exception
+   public boolean destroyQueue(final String name) throws Exception
    {
- //  	JBossQueue jBossQueue = new JBossQueue(name);
-//      messagingServerManagement.destroyQueue(new SimpleString(name));
-//      messagingServerManagement.removeDestination(jBossQueue.getSimpleAddress());
       List<String> jndiBindings = destinations.get(name);
       if (jndiBindings == null || jndiBindings.size() == 0)
       {
@@ -167,13 +145,17 @@
          initialContext.unbind(jndiBinding);
       }
       destinations.remove(name);
+      managementService.unregisterQueue(name);
+      messagingServerManagement.removeDestination(JBossQueue
+            .createAddressFromName(name));
+      messagingServerManagement.destroyQueue(JBossQueue
+            .createAddressFromName(name));
+
       return true;
    }
 
-   public boolean destroyTopic(String name) throws Exception
+   public boolean destroyTopic(final String name) throws Exception
    {
-   //   JBossTopic jBossTopic = new JBossTopic(name);
-    //  messagingServerManagement.removeDestination(jBossTopic.getSimpleAddress());
       List<String> jndiBindings = destinations.get(name);
       if (jndiBindings == null || jndiBindings.size() == 0)
       {
@@ -184,68 +166,39 @@
          initialContext.unbind(jndiBinding);
       }
       destinations.remove(name);
+      managementService.unregisterTopic(name);
+      messagingServerManagement.removeDestination(JBossTopic
+            .createAddressFromName(name));
+
       return true;
    }
 
-//   public Set<String> listAllQueues()
-//   {
-//      Set<String> availableAddresses = messagingServerManagement.listAvailableAddresses();
-//      Set<String> availableQueues = new HashSet<String>();
-//      for (String address : availableAddresses)
-//      {
-//         if (address.startsWith(JBossQueue.JMS_QUEUE_ADDRESS_PREFIX))
-//         {
-//            availableQueues.add(address.replace(JBossQueue.JMS_QUEUE_ADDRESS_PREFIX, ""));
-//         }
-//      }
-//      return availableQueues;
-//   }
-//
-//   public Set<String> listAllTopics()
-//   {
-//      Set<String> availableAddresses = messagingServerManagement.listAvailableAddresses();
-//      Set<String> availableTopics = new HashSet<String>();
-//      for (String address : availableAddresses)
-//      {
-//         if (address.startsWith(JBossTopic.JMS_TOPIC_ADDRESS_PREFIX))
-//         {
-//            availableTopics.add(address.replace(JBossTopic.JMS_TOPIC_ADDRESS_PREFIX, ""));
-//         }
-//      }
-//      return availableTopics;
-//   }
-//
-//   public Set<String> listTemporaryDestinations()
-//   {
-//      Set<String> availableAddresses = messagingServerManagement.listAvailableAddresses();
-//      Set<String> tempDests = new HashSet<String>();
-//      for (String address : availableAddresses)
-//      {
-//         if (address.startsWith(JBossTemporaryTopic.JMS_TOPIC_ADDRESS_PREFIX) || address.startsWith(JBossTemporaryQueue.JMS_QUEUE_ADDRESS_PREFIX))
-//         {
-//            tempDests.add(address.replace(JBossTopic.JMS_TOPIC_ADDRESS_PREFIX, ""));
-//         }
-//      }
-//      return tempDests;
-//   }
+   public QueueSettings getSettings(final JBossDestination destination)
+   {
+      return messagingServerManagement.getQueueSettings(destination
+            .getSimpleAddress());
+   }
 
-   public boolean createConnectionFactory(String name, String clientID,
-   		int dupsOKBatchSize, int consumerWindowSize, int consumerMaxRate,
-   		int producerWindowSize, int producerMaxRate, boolean blockOnAcknowledge,
-   		boolean defaultSendNonPersistentMessagesBlocking, boolean defaultSendPersistentMessagesBlocking,
-   		String jndiBinding) throws Exception
+   public boolean createConnectionFactory(final String name,
+         final String clientID, final int dupsOKBatchSize,
+         final int consumerWindowSize, final int consumerMaxRate,
+         final int producerWindowSize, final int producerMaxRate,
+         final boolean blockOnAcknowledge,
+         final boolean defaultSendNonPersistentMessagesBlocking,
+         final boolean defaultSendPersistentMessagesBlocking,
+         final String jndiBinding) throws Exception
    {
       JBossConnectionFactory cf = connectionFactories.get(name);
       if (cf == null)
       {
-         cf = new JBossConnectionFactory( clientID, dupsOKBatchSize,
-                 messagingServerManagement.getConfiguration().getLocation(),
-                 messagingServerManagement.getConfiguration().getConnectionParams(),                 
-                 consumerWindowSize, consumerMaxRate, producerWindowSize, producerMaxRate,
-                 blockOnAcknowledge,
-                 defaultSendNonPersistentMessagesBlocking,
-                 defaultSendPersistentMessagesBlocking
-                 );
+         cf = new JBossConnectionFactory(clientID, dupsOKBatchSize,
+               messagingServerManagement.getConfiguration().getLocation(),
+               messagingServerManagement.getConfiguration()
+                     .getConnectionParams(), consumerWindowSize,
+               consumerMaxRate, producerWindowSize, producerMaxRate,
+               blockOnAcknowledge, defaultSendNonPersistentMessagesBlocking,
+               defaultSendPersistentMessagesBlocking);
+         connectionFactories.put(name, cf);
       }
       if (!bindToJndi(jndiBinding, cf))
       {
@@ -256,27 +209,33 @@
          connectionFactoryBindings.put(name, new ArrayList<String>());
       }
       connectionFactoryBindings.get(name).add(jndiBinding);
+
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(jndiBinding);
+
+      managementService.registerConnectionFactory(name, cf, bindings);
       return true;
    }
 
-
-   public boolean createConnectionFactory(String name, String clientID, int dupsOKBatchSize,
-   		                                 int consumerWindowSize, int consumerMaxRate,
-   		                                 int producerWindowSize, int producerMaxRate, boolean blockOnAcknowledge,
-   		                                 boolean defaultSendNonPersistentMessagesBlocking,
-   		                                 boolean defaultSendPersistentMessagesBlocking,
-   		                                 List<String> jndiBindings) throws Exception
+   public boolean createConnectionFactory(final String name,
+         final String clientID, final int dupsOKBatchSize,
+         final int consumerWindowSize, final int consumerMaxRate,
+         final int producerWindowSize, final int producerMaxRate,
+         final boolean blockOnAcknowledge,
+         final boolean defaultSendNonPersistentMessagesBlocking,
+         final boolean defaultSendPersistentMessagesBlocking,
+         final List<String> jndiBindings) throws Exception
    {
       JBossConnectionFactory cf = connectionFactories.get(name);
       if (cf == null)
       {
-         cf = new JBossConnectionFactory( clientID, dupsOKBatchSize,
-                 messagingServerManagement.getConfiguration().getLocation(),
-                 messagingServerManagement.getConfiguration().getConnectionParams(),
-                 consumerWindowSize, consumerMaxRate, producerWindowSize, producerMaxRate,
-                 blockOnAcknowledge, defaultSendNonPersistentMessagesBlocking,
-                 defaultSendPersistentMessagesBlocking
-                 );
+         cf = new JBossConnectionFactory(clientID, dupsOKBatchSize,
+               messagingServerManagement.getConfiguration().getLocation(),
+               messagingServerManagement.getConfiguration()
+                     .getConnectionParams(), consumerWindowSize,
+               consumerMaxRate, producerWindowSize, producerMaxRate,
+               blockOnAcknowledge, defaultSendNonPersistentMessagesBlocking,
+               defaultSendPersistentMessagesBlocking);
       }
       for (String jndiBinding : jndiBindings)
       {
@@ -287,10 +246,13 @@
          }
          connectionFactoryBindings.get(name).add(jndiBinding);
       }
+
+      managementService.registerConnectionFactory(name, cf, jndiBindings);
+
       return true;
    }
 
-   public boolean destroyConnectionFactory(String name) throws Exception
+   public boolean destroyConnectionFactory(final String name) throws Exception
    {
       List<String> jndiBindings = connectionFactoryBindings.get(name);
       if (jndiBindings == null || jndiBindings.size() == 0)
@@ -303,368 +265,95 @@
       }
       connectionFactoryBindings.remove(name);
       connectionFactories.remove(name);
+
+      managementService.unregisterConnectionFactory(name);
+
       return true;
    }
 
-
-//   public List<Message> listMessagesForQueue(String queue) throws Exception
-//   {
-//      return listMessagesForQueue(queue, ListType.ALL);
-//   }
-//
-//   public List<Message> listMessagesForQueue(String queue, ListType listType) throws Exception
-//   {
-//      return listMessages(new JBossQueue(queue).getAddress(), listType);
-//   }
-//
-//   public List<Message> listMessagesForSubscription(String subscription) throws Exception
-//   {
-//      return listMessagesForSubscription(subscription, ListType.ALL);
-//   }
-//
-//   public List<Message> listMessagesForSubscription(String subscription, ListType listType) throws Exception
-//   {
-//      return listMessages(subscription, listType);
-//   }
-//
-////   public void removeMessageFromQueue(String queueName, String messageId) throws Exception
-////   {
-////      messagingServerManagement.removeMessageForBinding(new JBossQueue(queueName).getAddress(), new FilterImpl("JMSMessageID='" + messageId + "'"));
-////   }
-////
-////   public void removeMessageFromTopic(String topicName, String messageId) throws Exception
-////   {
-////      messagingServerManagement.removeMessageForAddress(new JBossTopic(topicName).getAddress(), new FilterImpl("JMSMessageID='" + messageId + "'"));
-////   }
-
-   public void removeAllMessagesForQueue(String queueName) throws Exception
+   public void removeAllMessages(final JBossDestination destination)
+         throws Exception
    {
-      JBossQueue jBossQueue = new JBossQueue(queueName);
-      removeAllMessages(jBossQueue);
+      messagingServerManagement.removeAllMessagesForAddress(destination
+            .getSimpleAddress());
    }
 
-   public void removeAllMessagesForTopic(String topicName) throws Exception
+   public boolean removeMessage(final long messageID,
+         final JBossDestination destination) throws Exception
    {
-      JBossTopic jBossTopic = new JBossTopic(topicName);
-      removeAllMessages(jBossTopic);
+      return messagingServerManagement.removeMessageFromAddress(messageID,
+            destination.getSimpleAddress());
    }
-//
-////   public void moveMessage(String fromQueue, String toQueue, String messageId) throws Exception
-////   {
-////      messagingServerManagement.moveMessages(new JBossQueue(fromQueue).getAddress(), new JBossQueue(toQueue).getAddress(),
-////              "JMSMessageID='" + messageId + "'");
-////   }
-//
-//   public void expireMessage(String queue, String messageId) throws Exception
-//   {
-//      messagingServerManagement.expireMessages(new JBossQueue(queue).getAddress(),
-//              "JMSMessageID='" + messageId + "'");
-//   }
-//
-////   public void changeMessagePriority(String queue, String messageId, int priority) throws Exception
-////   {
-////      messagingServerManagement.changeMessagePriority(new JBossQueue(queue).getAddress(),
-////              "JMSMessageID='" + messageId + "'", priority);
-////   }
-//
-   public int getMessageCountForQueue(String queue) throws Exception
+
+   public int expireMessages(final Filter filter,
+         final JBossDestination destination) throws Exception
    {
-      return getMessageCount(new JBossQueue(queue));
+      return messagingServerManagement.expireMessages(filter, destination
+            .getSimpleAddress());
    }
 
-   public List<SubscriptionInfo> listSubscriptions(String topicName) throws Exception
+   public int sendMessagesToDLQ(final Filter filter,
+         final JBossDestination destination) throws Exception
    {
-      return listSubscriptions(new JBossTopic(topicName));
+      return messagingServerManagement.sendMessagesToDLQ(filter, destination
+            .getSimpleAddress());
    }
-//
-//   public List<SubscriptionInfo> listSubscriptions(String topic, ListType type) throws Exception
-//   {
-//      return listSubscriptions(new JBossTopic(topic), type);
-//   }
-//
-//   public int getSubscriptionsCountForTopic(String topicName) throws Exception
-//   {
-//      return getSubscriptionsCount(new JBossTopic(topicName));
-//   }
-//
-//   public int getSubscriptionsCountForTopic(String topicName, ListType listType) throws Exception
-//   {
-//      return getSubscriptionsCount(new JBossTopic(topicName), listType);
-//   }
-//
-//   public void dropSubscription(String subscription) throws Exception
-//   {
-//      messagingServerManagement.destroyQueue(subscription);
-//   }
-//
-//   public int getConsumerCountForQueue(String queue) throws Exception
-//   {
-//      return getConsumerCount(new JBossQueue(queue));
-//   }
-//
-//   public List<ConnectionInfo> getConnections() throws Exception
-//   {
-//      return getConnectionsForUser(null);
-//   }
-//
-//   public List<ConnectionInfo> getConnectionsForUser(String user) throws Exception
-//   {
-//      List<ConnectionInfo> connectionInfos = new ArrayList<ConnectionInfo>();
-//      List<ServerConnection> endpoints = messagingServerManagement.getActiveConnections();
-//      for (ServerConnection endpoint : endpoints)
-//      {
-//         if (user == null || user.equals(endpoint.getUsername()))
-//         {
-//            connectionInfos.add(new ConnectionInfo(endpoint.getID(),
-//                    endpoint.getUsername(),
-//                    endpoint.getClientAddress(),
-//                    endpoint.isStarted(),
-//                    endpoint.getCreated()));
-//         }
-//      }
-//      return connectionInfos;
-//   }
-//
-//   public void dropConnection(long clientId) throws Exception
-//   {
-//      List<ServerConnection> endpoints = messagingServerManagement.getActiveConnections();
-//      for (ServerConnection endpoint : endpoints)
-//      {
-//         if (endpoint.getID() == clientId)
-//         {
-//            endpoint.close();
-//            break;
-//         }
-//      }
-//   }
-//
-//   public void dropConnectionsForUser(String user) throws Exception
-//   {
-//      List<ServerConnection> endpoints = messagingServerManagement.getActiveConnections();
-//      List<ConnectionInfo> connectionInfos = getConnectionsForUser(user);
-//      for (ConnectionInfo connectionInfo : connectionInfos)
-//      {
-//         for (ServerConnection endpoint : endpoints)
-//         {
-//            if (endpoint.getID() == connectionInfo.getId())
-//            {
-//               endpoint.close();
-//               break;
-//            }
-//         }
-//      }
-//   }
-//
-////   public List<SessionInfo> getSessions() throws Exception
-////   {
-////      return getSessionsForConnection(null);
-////   }
-////
-////   public List<SessionInfo> getSessionsForConnection(long id) throws Exception
-////   {
-////      List<SessionInfo> sessionInfos = new ArrayList<SessionInfo>();
-////      List<ServerConnection> endpoints = messagingServerManagement.getActiveConnections();
-////      for (ServerConnection endpoint : endpoints)
-////      {
-////         if (id == endpoint.getID())
-////         {
-////            Collection<ServerSession> serverSessionEndpoints = endpoint.getSessions();
-////            for (ServerSession serverSessionEndpoint : serverSessionEndpoints)
-////            {
-////               sessionInfos.add(new SessionInfo(serverSessionEndpoint.getID(),
-////                       endpoint.getID()));
-////            }
-////         }
-////      }
-////      return sessionInfos;
-////   }
-//
-////   public List<SessionInfo> getSessionsForUser(String user) throws Exception
-////   {
-////      List<SessionInfo> sessionInfos = new ArrayList<SessionInfo>();
-////      List<ServerConnection> endpoints = messagingServerManagement.getActiveConnections();
-////      for (ServerConnection endpoint : endpoints)
-////      {
-////         if (user == null || user.equals(endpoint.getUsername()))
-////         {
-////            sessionInfos.addAll(getSessionsForConnection(endpoint.getID()));
-////         }
-////      }
-////      return sessionInfos;
-////   }
-//
-//   public void startGatheringStatistics() throws Exception
-//   {
-//      Set<String> availableAddresses = messagingServerManagement.listAvailableAddresses();
-//      for (String address : availableAddresses)
-//      {
-//         if (address.startsWith(JBossQueue.JMS_QUEUE_ADDRESS_PREFIX))
-//         {
-//            messagingServerManagement.startMessageCounter(address, 0);
-//         }
-//      }
-//   }
-//
-//   public void startGatheringStatisticsForQueue(String queue) throws Exception
-//   {
-//      JBossQueue jBossQueue = new JBossQueue(queue);
-//      messagingServerManagement.startMessageCounter(jBossQueue.getAddress(), 0);
-//   }
-//
-//   public List<MessageStatistics> stopGatheringStatistics() throws Exception
-//   {
-//      List<MessageStatistics> messageStatisticses = createStats(messagingServerManagement.stopAllMessageCounters());
-//      messagingServerManagement.unregisterAllMessageCounters();
-//      return messageStatisticses;
-//   }
-//
-//   public MessageStatistics stopGatheringStatisticsForQueue(String queue) throws Exception
-//   {
-//      JBossQueue queue1 = new JBossQueue(queue);
-//      MessageCounter counter = messagingServerManagement.stopMessageCounter(queue1.getAddress());
-//
-//      MessageStatistics stats = new MessageStatistics();
-//      stats.setName(counter.getDestinationName());
-//      stats.setDurable(counter.getDestinationDurable());
-//      stats.setCount(counter.getMessageCount());
-//      stats.setTotalMessageCount(counter.getTotalMessages());
-//      stats.setCurrentMessageCount(counter.getCurrentMessageCount());
-//      stats.setTimeLastUpdate(counter.getLastUpdate());
-//      messagingServerManagement.unregisterMessageCounter(queue1.getAddress());
-//      return stats;
-//   }
-//
-//   public List<MessageStatistics> getStatistics() throws Exception
-//   {
-//      Collection<MessageCounter> counters = messagingServerManagement.getMessageCounters();
-//      return createStats(counters);
-//   }
-//
-//   private List<MessageStatistics> createStats(Collection<MessageCounter> counters)
-//   {
-//      List<MessageStatistics> list = new ArrayList<MessageStatistics>(counters.size());
-//      for (Object counter1 : counters)
-//      {
-//         MessageCounter counter = (MessageCounter) counter1;
-//
-//         MessageStatistics stats = new MessageStatistics();
-//         stats.setName(counter.getDestinationName());
-//         stats.setDurable(counter.getDestinationDurable());
-//         stats.setCount(counter.getMessageCount());
-//         stats.setTotalMessageCount(counter.getTotalMessages());
-//         stats.setCurrentMessageCount(counter.getCurrentMessageCount());
-//         stats.setTimeLastUpdate(counter.getLastUpdate());
-//
-//         list.add(stats);
-//      }
-//      return list;
-//   }
-//   //private
-//
-   private void addToDestinationBindings(String destination, String jndiBinding)
-   {
-      if (destinations.get(destination) == null)
-      {
-         destinations.put(destination, new ArrayList<String>());
-      }
-      destinations.get(destination).add(jndiBinding);
-   }
-//
-//
-//   private List<Message> listMessages(String queue, ListType listType) throws Exception
-//   {
-//      List<Message> messages = new ArrayList<Message>();
-//      Filter filter = null;
-//      switch (listType)
-//      {
-//         case DURABLE:
-//            filter = new FilterImpl("JBMDurable='DURABLE'");
-//            break;
-//         case NON_DURABLE:
-//            filter = new FilterImpl("JBMDurable='NON_DURABLE'");
-//            break;
-//      }
-//      List<org.jboss.messaging.core.message.Message> messageList = messagingServerManagement.listMessages(queue, filter);
-//      for (org.jboss.messaging.core.message.Message message : messageList)
-//      {
-//         messages.add(JBossMessage.createMessage(message, null));
-//      }
-//      return messages;
-//   }
-//
-//
-   private void removeAllMessages(JBossQueue queue) throws Exception
-   {
-      messagingServerManagement.removeAllMessagesForAddress(queue.getSimpleAddress());
-   }
 
-   private void removeAllMessages(JBossTopic topic) throws Exception
+   public int changeMessagesPriority(final Filter filter,
+         final byte newPriority, final JBossDestination destination)
+         throws Exception
    {
-      messagingServerManagement.removeAllMessagesForAddress(topic.getSimpleAddress());
+      return messagingServerManagement.changeMessagesPriority(filter,
+            newPriority, destination.getSimpleAddress());
    }
 
-   private int getMessageCount(JBossQueue queue) throws Exception
+   // Public --------------------------------------------------------
+
+   public void setInitialContext(final InitialContext initialContext)
    {
-      return messagingServerManagement.getMessageCountForQueue(queue.getSimpleAddress());
+      this.initialContext = initialContext;
    }
-//
-//   private int getMessageCount(JBossTopic topic) throws Exception
-//   {
-//      return 0;  //To change body of implemented methods use File | Settings | File Templates.
-//   }
-//
-   private List<SubscriptionInfo> listSubscriptions(JBossTopic topic) throws Exception
-   {
-      return listSubscriptions(topic, ListType.ALL);
-   }
 
-   private List<SubscriptionInfo> listSubscriptions(JBossTopic topic, ListType type) throws Exception
-   {
-      List<SubscriptionInfo> subs = new ArrayList<SubscriptionInfo>();
+   // Private -------------------------------------------------------
 
-      List<Queue> queues = messagingServerManagement.getQueuesForAddress(topic.getSimpleAddress());
-
-      for (Queue queue : queues)
+   private boolean bindToJndi(final String jndiName, final Object objectToBind)
+         throws NamingException
+   {
+      String parentContext;
+      String jndiNameInContext;
+      int sepIndex = jndiName.lastIndexOf('/');
+      if (sepIndex == -1)
       {
-         if (type == ListType.ALL || (type == ListType.DURABLE && queue.isDurable()) || (type == ListType.NON_DURABLE && !queue.isDurable()))
-         {
-            String subName = null;
-            String clientID = null;
+         parentContext = "";
+      } else
+      {
+         parentContext = jndiName.substring(0, sepIndex);
+      }
+      jndiNameInContext = jndiName.substring(sepIndex + 1);
+      try
+      {
+         initialContext.lookup(jndiName);
 
-            if (queue.isDurable())
-            {
-               Pair<String, String> pair = JBossTopic.decomposeQueueNameForDurableSubscription(queue.getName().toString());
-               clientID = pair.a;
-               subName = pair.b;
-            }
-
-            SubscriptionInfo info = new SubscriptionInfo(queue.getName().toString(), queue.isDurable(), subName, clientID,
-                    queue.getFilter() == null ? null : queue.getFilter().getFilterString().toString(), queue.getMessageCount(), queue.getMaxSizeBytes());
-
-            subs.add(info);
-         }
+         log.warn("Binding for " + jndiName + " already exists");
+         return false;
+      } catch (Throwable e)
+      {
+         // OK
       }
 
-      return subs;
+      Context c = JNDIUtil.createContext(initialContext, parentContext);
+
+      c.rebind(jndiNameInContext, objectToBind);
+      return true;
    }
-//
-//   private int getSubscriptionsCount(JBossTopic topic) throws Exception
-//   {
-//      return getSubscriptionsCount(topic, ListType.ALL);
-//   }
-//
-//   private int getSubscriptionsCount(JBossTopic topic, ListType listType) throws Exception
-//   {
-//      return listSubscriptions(topic, listType).size();
-//   }
-//
-//   private int getConsumerCount(JBossQueue queue) throws Exception
-//   {
-//      return messagingServerManagement.getConsumerCountForQueue(queue.getAddress());
-//   }
 
-   public void setInitialContext(InitialContext initialContext)
+   private void addToDestinationBindings(final String destination,
+         final String jndiBinding)
    {
-      this.initialContext = initialContext;
+      if (destinations.get(destination) == null)
+      {
+         destinations.put(destination, new ArrayList<String>());
+      }
+      destinations.get(destination).add(jndiBinding);
    }
 }

Copied: trunk/src/main/org/jboss/messaging/jms/server/management (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management)

Deleted: trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.jms.server.management;
-
-import java.util.List;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public interface ConnectionFactoryControlMBean
-{
-   String getURL();
-
-   List<String> getBindings();
-
-   String getClientID();
-
-   int getDupsOKBatchSize();
-
-   int getDefaultConsumerMaxRate();
-
-   int getDefaultConsumerWindowSize();
-
-   int getDefaultProducerMaxRate();
-
-   int getDefaultProducerWindowSize();
-
-   boolean isDefaultBlockOnAcknowledge();
-
-   boolean isDefaultBlockOnPersistentSend();
-
-   boolean isDefaultBlockOnNonPersistentSend();
-
-}

Copied: trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.jms.server.management;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public interface ConnectionFactoryControlMBean
+{
+   String getURL();
+
+   List<String> getBindings();
+
+   String getClientID();
+
+   int getDupsOKBatchSize();
+
+   int getDefaultConsumerMaxRate();
+
+   int getDefaultConsumerWindowSize();
+
+   int getDefaultProducerMaxRate();
+
+   int getDefaultProducerWindowSize();
+
+   boolean isDefaultBlockOnAcknowledge();
+
+   boolean isDefaultBlockOnPersistentSend();
+
+   boolean isDefaultBlockOnNonPersistentSend();
+
+}

Deleted: trunk/src/main/org/jboss/messaging/jms/server/management/DestinationControlMBean.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/DestinationControlMBean.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/DestinationControlMBean.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.jms.server.management;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public interface DestinationControlMBean
-{
-   // Attributes ----------------------------------------------------
-
-   String getName();
-
-   String getJNDIBinding();
-
-   String getAddress();
-
-   boolean isTemporary();
-
-   int getMessageCount() throws Exception;
-
-   // Operations ----------------------------------------------------
-
-   public void removeAllMessages() throws Exception;
-
-}
\ No newline at end of file

Copied: trunk/src/main/org/jboss/messaging/jms/server/management/DestinationControlMBean.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/DestinationControlMBean.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/DestinationControlMBean.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/DestinationControlMBean.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.jms.server.management;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public interface DestinationControlMBean
+{
+   // Attributes ----------------------------------------------------
+
+   String getName();
+
+   String getJNDIBinding();
+
+   String getAddress();
+
+   boolean isTemporary();
+
+   int getMessageCount() throws Exception;
+
+   // Operations ----------------------------------------------------
+
+   public void removeAllMessages() throws Exception;
+
+}
\ No newline at end of file

Deleted: trunk/src/main/org/jboss/messaging/jms/server/management/JMSManagementService.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSManagementService.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/JMSManagementService.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.jms.server.management;
-
-import java.util.List;
-
-import org.jboss.messaging.core.management.MessagingServerManagement;
-import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.jms.JBossQueue;
-import org.jboss.messaging.jms.JBossTopic;
-import org.jboss.messaging.jms.client.JBossConnectionFactory;
-import org.jboss.messaging.jms.server.JMSServerManager;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
- * @version <tt>$Revision$</tt>
- *
- */
-public interface JMSManagementService
-{
-   void registerJMSServer(JMSServerManager server) throws Exception;
-   
-   void unregisterJMSServer();
-
-   void registerQueue(JBossQueue queue, Queue coreQueue, String jndiBinding, JMSServerManager server) throws Exception;
-
-   void unregisterQueue(String name) throws Exception;
-
-   void registerTopic(JBossTopic topic, MessagingServerManagement serverManagement, String jndiBinding) throws Exception;
-
-   void unregisterTopic(String name) throws Exception;
-
-   void registerConnectionFactory(String name, JBossConnectionFactory connectionFactory, List<String> bindings) throws Exception;
-
-   void unregisterConnectionFactory(String name) throws Exception;
-}

Copied: trunk/src/main/org/jboss/messaging/jms/server/management/JMSManagementService.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSManagementService.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/JMSManagementService.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/JMSManagementService.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.jms.server.management;
+
+import java.util.List;
+
+import org.jboss.messaging.core.management.MessagingServerManagement;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.jms.JBossQueue;
+import org.jboss.messaging.jms.JBossTopic;
+import org.jboss.messaging.jms.client.JBossConnectionFactory;
+import org.jboss.messaging.jms.server.JMSServerManager;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public interface JMSManagementService
+{
+   void registerJMSServer(JMSServerManager server) throws Exception;
+   
+   void unregisterJMSServer() throws Exception;
+
+   void registerQueue(JBossQueue queue, Queue coreQueue, String jndiBinding, JMSServerManager server) throws Exception;
+
+   void unregisterQueue(String name) throws Exception;
+
+   void registerTopic(JBossTopic topic, MessagingServerManagement serverManagement, String jndiBinding) throws Exception;
+
+   void unregisterTopic(String name) throws Exception;
+
+   void registerConnectionFactory(String name, JBossConnectionFactory connectionFactory, List<String> bindings) throws Exception;
+
+   void unregisterConnectionFactory(String name) throws Exception;
+}

Deleted: trunk/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,242 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.jms.server.management;
-
-import static javax.management.openmbean.SimpleType.INTEGER;
-import static javax.management.openmbean.SimpleType.LONG;
-import static javax.management.openmbean.SimpleType.STRING;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.TabularData;
-import javax.management.openmbean.TabularDataSupport;
-import javax.management.openmbean.TabularType;
-
-import org.jboss.messaging.core.management.PropertiesInfo;
-import org.jboss.messaging.core.server.ServerMessage;
-import org.jboss.messaging.jms.client.JBossMessage;
-import org.jboss.messaging.util.SimpleString;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class JMSMessageInfo
-{
-   // Constants -----------------------------------------------------
-
-   public static final CompositeType TYPE;
-   private static final String MESSAGE_TYPE_NAME = "JMSMessageInfo";
-   private static final String MESSAGE_TABULAR_TYPE_NAME = "JMSMessageTabularInfo";
-   private static final String[] ITEM_NAMES = new String[] { "JMSMessageID",
-         "JMSCorrelationID", "JMSDeliveryMode", "JMSPriority", "JMSReplyTo",
-         "JMSTimestamp", "JMSType", "expiration", "properties" };
-   private static final String[] ITEM_DESCRIPTIONS = new String[] {
-         "Message ID", "Correlation ID", "Delivery Mode", "Priority",
-         "Reply To", "Timestamp", "JMS Type", "Expiration", "Properties" };
-   private static final OpenType[] TYPES;
-   private static final TabularType TABULAR_TYPE;
-
-   static
-   {
-      try
-      {
-         TYPES = new OpenType[] { STRING, STRING, STRING, INTEGER, STRING,
-               LONG, STRING, LONG, PropertiesInfo.TABULAR_TYPE };
-         TYPE = new CompositeType(MESSAGE_TYPE_NAME,
-               "Information for a JMS Message", ITEM_NAMES, ITEM_DESCRIPTIONS,
-               TYPES);
-         TABULAR_TYPE = new TabularType(MESSAGE_TABULAR_TYPE_NAME,
-               "Information for tabular JMSMessageInfo", TYPE,
-               new String[] { "JMSMessageID" });
-      } catch (OpenDataException e)
-      {
-         e.printStackTrace();
-         throw new IllegalStateException(e);
-      }
-   }
-
-   // Attributes ----------------------------------------------------
-
-   private final String messageID;
-   private final String correlationID;
-   private final String deliveryMode;
-   private final int priority;
-   private final String replyTo;
-   private final long timestamp;
-   private final long expiration;
-   private final String jmsType;
-   private PropertiesInfo properties;
-
-   // Static --------------------------------------------------------
-
-   public static TabularData toTabularData(JMSMessageInfo[] infos)
-         throws OpenDataException
-   {
-      TabularData data = new TabularDataSupport(TABULAR_TYPE);
-      for (JMSMessageInfo messageInfo : infos)
-      {
-         data.put(messageInfo.toCompositeData());
-      }
-      return data;
-   }
-
-   public static TabularData toTabularData(List<JMSMessageInfo> infos)
-   {
-      TabularData data = new TabularDataSupport(TABULAR_TYPE);
-      for (JMSMessageInfo messageInfo : infos)
-      {
-         data.put(messageInfo.toCompositeData());
-      }
-      return data;
-   }
-
-   public static JMSMessageInfo fromServerMessage(ServerMessage message)
-   {
-      String messageID = message.getProperty(JBossMessage.JBM_MESSAGE_ID)
-            .toString();
-      SimpleString simpleCorrelationID = (SimpleString) message
-            .getProperty(JBossMessage.CORRELATIONID_HEADER_NAME);
-      String correlationID = (simpleCorrelationID == null) ? null
-            : simpleCorrelationID.toString();
-      SimpleString simpleJMSType = (SimpleString) message
-            .getProperty(JBossMessage.TYPE_HEADER_NAME);
-      String jmsType = (simpleJMSType == null) ? null : simpleJMSType
-            .toString();
-      String deliveryMode = message.isDurable() ? "PERSISTENT"
-            : "NON_PERSISTENT";
-      int priority = message.getPriority();
-      SimpleString replyAddress = (SimpleString) message
-            .getProperty(JBossMessage.REPLYTO_HEADER_NAME);
-      String replyTo = (replyAddress == null) ? null : replyAddress.toString();
-      long timestamp = message.getTimestamp();
-      long expiration = message.getExpiration();
-
-      JMSMessageInfo info = new JMSMessageInfo(messageID, correlationID,
-            deliveryMode, priority, replyTo, timestamp, expiration, jmsType);
-      for (SimpleString key : message.getPropertyNames())
-      {
-         info.putProperty(key.toString(), message.getProperty(key).toString());
-      }
-      return info;
-   }
-
-   // Constructors --------------------------------------------------
-
-   public JMSMessageInfo(final String messageID, final String correlationID,
-         final String deliveryMode, final int priority, final String replyTo,
-         final long timestamp, final long expiration, final String jmsType)
-   {
-      this.messageID = messageID;
-      this.correlationID = correlationID;
-      this.deliveryMode = deliveryMode;
-      this.priority = priority;
-      this.replyTo = replyTo;
-      this.timestamp = timestamp;
-      this.expiration = expiration;
-      this.jmsType = jmsType;
-      this.properties = new PropertiesInfo();
-   }
-
-   // Public --------------------------------------------------------
-
-   public String getJMSMessageID()
-   {
-      return messageID;
-   }
-
-   public String getJMSCorrelationID()
-   {
-      return correlationID;
-   }
-
-   public String getJMSDeliveryMode()
-   {
-      return deliveryMode;
-   }
-
-   public int getJMSPriority()
-   {
-      return priority;
-   }
-
-   public String getJMSReplyTo()
-   {
-      return replyTo;
-   }
-
-   public long getJMSTimestamp()
-   {
-      return timestamp;
-   }
-
-   public long getExpiration()
-   {
-      return expiration;
-   }
-
-   public String getJMSType()
-   {
-      return jmsType;
-   }
-
-   public void putProperty(final String key, final String value)
-   {
-      properties.put(key, value);
-   }
-
-   public Map<String, String> getProperties()
-   {
-      return properties.entries();
-   }
-
-   public CompositeData toCompositeData()
-   {
-      try
-      {
-         return new CompositeDataSupport(TYPE, ITEM_NAMES, new Object[] {
-               messageID, correlationID, deliveryMode, priority, replyTo,
-               timestamp, jmsType, expiration, properties.toTabularData() });
-      } catch (OpenDataException e)
-      {
-         e.printStackTrace();
-         return null;
-      }
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: trunk/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/JMSMessageInfo.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,242 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.jms.server.management;
+
+import static javax.management.openmbean.SimpleType.INTEGER;
+import static javax.management.openmbean.SimpleType.LONG;
+import static javax.management.openmbean.SimpleType.STRING;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+import org.jboss.messaging.core.management.PropertiesInfo;
+import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.jms.client.JBossMessage;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class JMSMessageInfo
+{
+   // Constants -----------------------------------------------------
+
+   public static final CompositeType TYPE;
+   private static final String MESSAGE_TYPE_NAME = "JMSMessageInfo";
+   private static final String MESSAGE_TABULAR_TYPE_NAME = "JMSMessageTabularInfo";
+   private static final String[] ITEM_NAMES = new String[] { "JMSMessageID",
+         "JMSCorrelationID", "JMSDeliveryMode", "JMSPriority", "JMSReplyTo",
+         "JMSTimestamp", "JMSType", "expiration", "properties" };
+   private static final String[] ITEM_DESCRIPTIONS = new String[] {
+         "Message ID", "Correlation ID", "Delivery Mode", "Priority",
+         "Reply To", "Timestamp", "JMS Type", "Expiration", "Properties" };
+   private static final OpenType[] TYPES;
+   private static final TabularType TABULAR_TYPE;
+
+   static
+   {
+      try
+      {
+         TYPES = new OpenType[] { STRING, STRING, STRING, INTEGER, STRING,
+               LONG, STRING, LONG, PropertiesInfo.TABULAR_TYPE };
+         TYPE = new CompositeType(MESSAGE_TYPE_NAME,
+               "Information for a JMS Message", ITEM_NAMES, ITEM_DESCRIPTIONS,
+               TYPES);
+         TABULAR_TYPE = new TabularType(MESSAGE_TABULAR_TYPE_NAME,
+               "Information for tabular JMSMessageInfo", TYPE,
+               new String[] { "JMSMessageID" });
+      } catch (OpenDataException e)
+      {
+         e.printStackTrace();
+         throw new IllegalStateException(e);
+      }
+   }
+
+   // Attributes ----------------------------------------------------
+
+   private final String messageID;
+   private final String correlationID;
+   private final String deliveryMode;
+   private final int priority;
+   private final String replyTo;
+   private final long timestamp;
+   private final long expiration;
+   private final String jmsType;
+   private PropertiesInfo properties;
+
+   // Static --------------------------------------------------------
+
+   public static TabularData toTabularData(JMSMessageInfo[] infos)
+         throws OpenDataException
+   {
+      TabularData data = new TabularDataSupport(TABULAR_TYPE);
+      for (JMSMessageInfo messageInfo : infos)
+      {
+         data.put(messageInfo.toCompositeData());
+      }
+      return data;
+   }
+
+   public static TabularData toTabularData(List<JMSMessageInfo> infos)
+   {
+      TabularData data = new TabularDataSupport(TABULAR_TYPE);
+      for (JMSMessageInfo messageInfo : infos)
+      {
+         data.put(messageInfo.toCompositeData());
+      }
+      return data;
+   }
+
+   public static JMSMessageInfo fromServerMessage(ServerMessage message)
+   {
+      String messageID = message.getProperty(JBossMessage.JBM_MESSAGE_ID)
+            .toString();
+      SimpleString simpleCorrelationID = (SimpleString) message
+            .getProperty(JBossMessage.CORRELATIONID_HEADER_NAME);
+      String correlationID = (simpleCorrelationID == null) ? null
+            : simpleCorrelationID.toString();
+      SimpleString simpleJMSType = (SimpleString) message
+            .getProperty(JBossMessage.TYPE_HEADER_NAME);
+      String jmsType = (simpleJMSType == null) ? null : simpleJMSType
+            .toString();
+      String deliveryMode = message.isDurable() ? "PERSISTENT"
+            : "NON_PERSISTENT";
+      int priority = message.getPriority();
+      SimpleString replyAddress = (SimpleString) message
+            .getProperty(JBossMessage.REPLYTO_HEADER_NAME);
+      String replyTo = (replyAddress == null) ? null : replyAddress.toString();
+      long timestamp = message.getTimestamp();
+      long expiration = message.getExpiration();
+
+      JMSMessageInfo info = new JMSMessageInfo(messageID, correlationID,
+            deliveryMode, priority, replyTo, timestamp, expiration, jmsType);
+      for (SimpleString key : message.getPropertyNames())
+      {
+         info.putProperty(key.toString(), message.getProperty(key).toString());
+      }
+      return info;
+   }
+
+   // Constructors --------------------------------------------------
+
+   public JMSMessageInfo(final String messageID, final String correlationID,
+         final String deliveryMode, final int priority, final String replyTo,
+         final long timestamp, final long expiration, final String jmsType)
+   {
+      this.messageID = messageID;
+      this.correlationID = correlationID;
+      this.deliveryMode = deliveryMode;
+      this.priority = priority;
+      this.replyTo = replyTo;
+      this.timestamp = timestamp;
+      this.expiration = expiration;
+      this.jmsType = jmsType;
+      this.properties = new PropertiesInfo();
+   }
+
+   // Public --------------------------------------------------------
+
+   public String getJMSMessageID()
+   {
+      return messageID;
+   }
+
+   public String getJMSCorrelationID()
+   {
+      return correlationID;
+   }
+
+   public String getJMSDeliveryMode()
+   {
+      return deliveryMode;
+   }
+
+   public int getJMSPriority()
+   {
+      return priority;
+   }
+
+   public String getJMSReplyTo()
+   {
+      return replyTo;
+   }
+
+   public long getJMSTimestamp()
+   {
+      return timestamp;
+   }
+
+   public long getExpiration()
+   {
+      return expiration;
+   }
+
+   public String getJMSType()
+   {
+      return jmsType;
+   }
+
+   public void putProperty(final String key, final String value)
+   {
+      properties.put(key, value);
+   }
+
+   public Map<String, String> getProperties()
+   {
+      return properties.entries();
+   }
+
+   public CompositeData toCompositeData()
+   {
+      try
+      {
+         return new CompositeDataSupport(TYPE, ITEM_NAMES, new Object[] {
+               messageID, correlationID, deliveryMode, priority, replyTo,
+               timestamp, jmsType, expiration, properties.toTabularData() });
+      } catch (OpenDataException e)
+      {
+         e.printStackTrace();
+         return null;
+      }
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Deleted: trunk/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,86 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.jms.server.management;
-
-import static javax.management.MBeanOperationInfo.ACTION;
-import static javax.management.MBeanOperationInfo.INFO;
-
-import javax.management.openmbean.TabularData;
-
-import org.jboss.messaging.core.management.Operation;
-import org.jboss.messaging.core.management.Parameter;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public interface JMSQueueControlMBean extends DestinationControlMBean
-{
-   // Attributes ----------------------------------------------------
-   
-   String getExpiryQueue();
-   
-   String getDLQ();
-   
-   // Operations ----------------------------------------------------
-   
-   @Operation(desc = "List all messages in the queue", impact = INFO)
-   TabularData listAllMessages() throws Exception;
-
-   @Operation(desc = "List all messages in the queue which matches the filter", impact = INFO)
-   TabularData listMessages(
-         @Parameter(name = "filter", desc = "A JMS Message filter") String filter)
-         throws Exception;
-
-   @Operation(desc = "Remove all the messages from the queue", impact = ACTION)
-   void removeAllMessages() throws Exception;
-
-   @Operation(desc = "Remove the message corresponding to the given messageID", impact = ACTION)
-   boolean removeMessage(
-         @Parameter(name = "messageID", desc = "A message ID") String messageID)
-         throws Exception;
-   
-   @Operation(desc = "Expire the messages corresponding to the given filter (and returns the number of expired messages)", impact = ACTION)
-   int expireMessages(
-         @Parameter(name = "filter", desc = "A message filter") String filter)
-         throws Exception;
-
-   @Operation(desc = "Expire the message corresponding to the given messageID", impact = ACTION)
-   boolean expireMessage(
-         @Parameter(name = "messageID", desc = "A message ID") String messageID)
-         throws Exception;
-   
-   @Operation(desc = "Send the message corresponding to the given messageID to the queue's Dead Letter Queue", impact = ACTION)
-   boolean sendMessageTDLQ(
-         @Parameter(name = "messageID", desc = "A message ID") String messageID)
-         throws Exception;
-   
-   @Operation(desc = "Change the priority of the message corresponding to the given messageID", impact = ACTION)
-   boolean changeMessagePriority(
-         @Parameter(name = "messageID", desc = "A message ID") String messageID,
-         @Parameter(name = "newPriority", desc = "the new priority (between 0 and 9)") int newPriority)
-         throws Exception;
-
-}

Copied: trunk/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/JMSQueueControlMBean.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.jms.server.management;
+
+import static javax.management.MBeanOperationInfo.ACTION;
+import static javax.management.MBeanOperationInfo.INFO;
+
+import javax.management.openmbean.TabularData;
+
+import org.jboss.messaging.core.management.Operation;
+import org.jboss.messaging.core.management.Parameter;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public interface JMSQueueControlMBean extends DestinationControlMBean
+{
+   // Attributes ----------------------------------------------------
+   
+   String getExpiryQueue();
+   
+   String getDLQ();
+   
+   // Operations ----------------------------------------------------
+   
+   @Operation(desc = "List all messages in the queue", impact = INFO)
+   TabularData listAllMessages() throws Exception;
+
+   @Operation(desc = "List all messages in the queue which matches the filter", impact = INFO)
+   TabularData listMessages(
+         @Parameter(name = "filter", desc = "A JMS Message filter") String filter)
+         throws Exception;
+
+   @Operation(desc = "Remove all the messages from the queue", impact = ACTION)
+   void removeAllMessages() throws Exception;
+
+   @Operation(desc = "Remove the message corresponding to the given messageID", impact = ACTION)
+   boolean removeMessage(
+         @Parameter(name = "messageID", desc = "A message ID") String messageID)
+         throws Exception;
+   
+   @Operation(desc = "Expire the messages corresponding to the given filter (and returns the number of expired messages)", impact = ACTION)
+   int expireMessages(
+         @Parameter(name = "filter", desc = "A message filter") String filter)
+         throws Exception;
+
+   @Operation(desc = "Expire the message corresponding to the given messageID", impact = ACTION)
+   boolean expireMessage(
+         @Parameter(name = "messageID", desc = "A message ID") String messageID)
+         throws Exception;
+   
+   @Operation(desc = "Send the message corresponding to the given messageID to the queue's Dead Letter Queue", impact = ACTION)
+   boolean sendMessageTDLQ(
+         @Parameter(name = "messageID", desc = "A message ID") String messageID)
+         throws Exception;
+   
+   @Operation(desc = "Change the priority of the message corresponding to the given messageID", impact = ACTION)
+   boolean changeMessagePriority(
+         @Parameter(name = "messageID", desc = "A message ID") String messageID,
+         @Parameter(name = "newPriority", desc = "the new priority (between 0 and 9)") int newPriority)
+         throws Exception;
+
+}

Deleted: trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,87 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.jms.server.management;
-
-import static javax.management.MBeanOperationInfo.ACTION;
-
-import org.jboss.messaging.core.management.Operation;
-import org.jboss.messaging.core.management.Parameter;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public interface JMSServerControlMBean
-{
-   // Attributes ----------------------------------------------------
-
-   boolean isStarted();
-
-   String getVersion();
-
-   // Operations ----------------------------------------------------
-
-   @Operation(desc = "Create a JMS Queue", impact = ACTION)
-   boolean createQueue(
-         @Parameter(name = "name", desc = "Name of the queue to create") String name,
-         @Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndiBinding)
-         throws Exception;
-
-   @Operation(desc = "Destroy a JMS Queue", impact = ACTION)
-   boolean destroyQueue(
-         @Parameter(name = "name", desc = "Name of the queue to destroy") String name)
-         throws Exception;
-
-   @Operation(desc = "Create a JMS Topic", impact = ACTION)
-   boolean createTopic(
-         @Parameter(name = "name", desc = "Name of the topic to create") String name,
-         @Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndiBinding)
-         throws Exception;
-
-   @Operation(desc = "Destroy a JMS Topic", impact = ACTION)
-   boolean destroyTopic(
-         @Parameter(name = "name", desc = "Name of the topic to destroy") String name)
-         throws Exception;
-
-   @Operation(desc = "Create a JMS ConnectionFactory", impact = ACTION)
-   void createConnectionFactory(
-         @Parameter(name = "name", desc = "Name of the ConnectionFactory to create") String name,
-         @Parameter(name = "jndiBinding", desc = "JNDI Binding") String jndiBinding,
-         @Parameter(name = "clientID", desc = "ClientID for created connections") String clientID,
-         @Parameter(name = "dupsOKBatchSize", desc = "Size of the batch when using DUPS_OK") int dupsOKBatchSize,
-         @Parameter(name = "consumerWindowSize", desc = "Consumer's window size") int consumerWindowSize,
-         @Parameter(name = "consumerMaxRate", desc = "Consumer's max rate") int consumerMaxRate,
-         @Parameter(name = "producerWindowSize", desc = "Producer's window size") int producerWindowSize,
-         @Parameter(name = "producerMaxRate", desc = "Producer's max rate") int producerMaxRate,
-         @Parameter(name = "blockOnAcknowledge", desc = "Does acknowlegment block?") boolean blockOnAcknowledge,
-         @Parameter(name = "defaultSendNonPersistentMessagesBlocking", desc = "Does sending non persistent messages block?") boolean defaultSendNonPersistentMessagesBlocking,
-         @Parameter(name = "defaultSendPersistentMessagesBlocking", desc = "Does sending persistent messages block") boolean defaultSendPersistentMessagesBlocking)
-         throws Exception;
-
-   @Operation(desc = "Create a JMS ConnectionFactory", impact = ACTION)
-   void destroyConnectionFactory(
-         @Parameter(name = "name", desc = "Name of the ConnectionFactory to create") String name)
-         throws Exception;
-}

Copied: trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.jms.server.management;
+
+import static javax.management.MBeanOperationInfo.ACTION;
+
+import org.jboss.messaging.core.management.Operation;
+import org.jboss.messaging.core.management.Parameter;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public interface JMSServerControlMBean
+{
+   // Attributes ----------------------------------------------------
+
+   boolean isStarted();
+
+   String getVersion();
+
+   // Operations ----------------------------------------------------
+
+   @Operation(desc = "Create a JMS Queue", impact = ACTION)
+   boolean createQueue(
+         @Parameter(name = "name", desc = "Name of the queue to create") String name,
+         @Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndiBinding)
+         throws Exception;
+
+   @Operation(desc = "Destroy a JMS Queue", impact = ACTION)
+   boolean destroyQueue(
+         @Parameter(name = "name", desc = "Name of the queue to destroy") String name)
+         throws Exception;
+
+   @Operation(desc = "Create a JMS Topic", impact = ACTION)
+   boolean createTopic(
+         @Parameter(name = "name", desc = "Name of the topic to create") String name,
+         @Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndiBinding)
+         throws Exception;
+
+   @Operation(desc = "Destroy a JMS Topic", impact = ACTION)
+   boolean destroyTopic(
+         @Parameter(name = "name", desc = "Name of the topic to destroy") String name)
+         throws Exception;
+
+   @Operation(desc = "Create a JMS ConnectionFactory", impact = ACTION)
+   void createConnectionFactory(
+         @Parameter(name = "name", desc = "Name of the ConnectionFactory to create") String name,
+         @Parameter(name = "jndiBinding", desc = "JNDI Binding") String jndiBinding,
+         @Parameter(name = "clientID", desc = "ClientID for created connections") String clientID,
+         @Parameter(name = "dupsOKBatchSize", desc = "Size of the batch when using DUPS_OK") int dupsOKBatchSize,
+         @Parameter(name = "consumerWindowSize", desc = "Consumer's window size") int consumerWindowSize,
+         @Parameter(name = "consumerMaxRate", desc = "Consumer's max rate") int consumerMaxRate,
+         @Parameter(name = "producerWindowSize", desc = "Producer's window size") int producerWindowSize,
+         @Parameter(name = "producerMaxRate", desc = "Producer's max rate") int producerMaxRate,
+         @Parameter(name = "blockOnAcknowledge", desc = "Does acknowlegment block?") boolean blockOnAcknowledge,
+         @Parameter(name = "defaultSendNonPersistentMessagesBlocking", desc = "Does sending non persistent messages block?") boolean defaultSendNonPersistentMessagesBlocking,
+         @Parameter(name = "defaultSendPersistentMessagesBlocking", desc = "Does sending persistent messages block") boolean defaultSendPersistentMessagesBlocking)
+         throws Exception;
+
+   @Operation(desc = "Create a JMS ConnectionFactory", impact = ACTION)
+   void destroyConnectionFactory(
+         @Parameter(name = "name", desc = "Name of the ConnectionFactory to create") String name)
+         throws Exception;
+}

Deleted: trunk/src/main/org/jboss/messaging/jms/server/management/SubscriberInfo.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/SubscriberInfo.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/SubscriberInfo.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,182 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.jms.server.management;
-
-import static javax.management.openmbean.SimpleType.BOOLEAN;
-import static javax.management.openmbean.SimpleType.INTEGER;
-import static javax.management.openmbean.SimpleType.STRING;
-
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.TabularData;
-import javax.management.openmbean.TabularDataSupport;
-import javax.management.openmbean.TabularType;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class SubscriberInfo
-{
-   // Constants -----------------------------------------------------
-
-   public static final CompositeType TYPE;
-   private static final TabularType TABULAR_TYPE;
-   private static final String SUBSCRIBER_TYPE_NAME = "SubscriberInfo";
-   private static final String SUBSCRIBER_TABULAR_TYPE_NAME = "SubscriberTabularInfo";
-   private static final String[] ITEM_NAMES = new String[] { "id", "clientID",
-         "name", "durable", "selector", "messageCount", "maxSizeBytes" };
-   private static final String[] ITEM_DESCRIPTIONS = new String[] {
-         "ID of the subscriber", "ClientID of the subscription",
-         "name of the subscription", "Is the subscriber durable?", "Selector",
-         "Number of messages", "Maximum size in bytes" };
-   private static final OpenType[] ITEM_TYPES = new OpenType[] { STRING,
-         STRING, STRING, BOOLEAN, STRING, INTEGER, INTEGER };
-
-   static
-   {
-      try
-      {
-         TYPE = createSubscriberInfoType();
-         TABULAR_TYPE = createSubscriberInfoTabularType();
-      } catch (OpenDataException e)
-      {
-         throw new IllegalStateException(e);
-      }
-   }
-
-   // Attributes ----------------------------------------------------
-
-   private final String id;
-   private final String clientID;
-   private final String name;
-   private final boolean durable;
-   private final String selector;
-   private final int messageCount;
-   private final int maxSizeBytes;
-
-   // Static --------------------------------------------------------
-
-   public static TabularData toTabularData(final SubscriberInfo[] infos)
-   {
-      TabularData data = new TabularDataSupport(TABULAR_TYPE);
-      for (SubscriberInfo subscriberInfo : infos)
-      {
-         data.put(subscriberInfo.toCompositeData());
-      }
-      return data;
-   }
-
-   private static CompositeType createSubscriberInfoType()
-         throws OpenDataException
-   {
-      return new CompositeType(SUBSCRIBER_TYPE_NAME,
-            "Information for a Topic Subscriber", ITEM_NAMES,
-            ITEM_DESCRIPTIONS, ITEM_TYPES);
-   }
-
-   private static TabularType createSubscriberInfoTabularType()
-         throws OpenDataException
-   {
-      return new TabularType(SUBSCRIBER_TABULAR_TYPE_NAME,
-            "Table of SubscriberInfo", TYPE, new String[] { "id" });
-   }
-
-   // Constructors --------------------------------------------------
-
-   public SubscriberInfo(final String id, final String clientID,
-         final String name, final boolean durable, final String selector,
-         final int messageCount, final int maxSizeBytes)
-   {
-      this.id = id;
-      this.clientID = clientID;
-      this.name = name;
-      this.durable = durable;
-      this.selector = selector;
-      this.messageCount = messageCount;
-      this.maxSizeBytes = maxSizeBytes;
-   }
-
-   // Public --------------------------------------------------------
-
-   public String getID()
-   {
-      return id;
-   }
-
-   public String getClientID()
-   {
-      return clientID;
-   }
-
-   public String getName()
-   {
-      return name;
-   }
-
-   public boolean isDurable()
-   {
-      return durable;
-   }
-
-   public String getSelector()
-   {
-      return selector;
-   }
-
-   public int getMessageCount()
-   {
-      return messageCount;
-   }
-
-   public int getMaxSizeBytes()
-   {
-      return maxSizeBytes;
-   }
-
-   public CompositeData toCompositeData()
-   {
-      try
-      {
-         return new CompositeDataSupport(TYPE, ITEM_NAMES, new Object[] { id,
-               clientID, name, durable, selector, messageCount, maxSizeBytes });
-      } catch (OpenDataException e)
-      {
-         e.printStackTrace();
-         return null;
-      }
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: trunk/src/main/org/jboss/messaging/jms/server/management/SubscriberInfo.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/SubscriberInfo.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/SubscriberInfo.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/SubscriberInfo.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,182 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.jms.server.management;
+
+import static javax.management.openmbean.SimpleType.BOOLEAN;
+import static javax.management.openmbean.SimpleType.INTEGER;
+import static javax.management.openmbean.SimpleType.STRING;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class SubscriberInfo
+{
+   // Constants -----------------------------------------------------
+
+   public static final CompositeType TYPE;
+   private static final TabularType TABULAR_TYPE;
+   private static final String SUBSCRIBER_TYPE_NAME = "SubscriberInfo";
+   private static final String SUBSCRIBER_TABULAR_TYPE_NAME = "SubscriberTabularInfo";
+   private static final String[] ITEM_NAMES = new String[] { "id", "clientID",
+         "name", "durable", "selector", "messageCount", "maxSizeBytes" };
+   private static final String[] ITEM_DESCRIPTIONS = new String[] {
+         "ID of the subscriber", "ClientID of the subscription",
+         "name of the subscription", "Is the subscriber durable?", "Selector",
+         "Number of messages", "Maximum size in bytes" };
+   private static final OpenType[] ITEM_TYPES = new OpenType[] { STRING,
+         STRING, STRING, BOOLEAN, STRING, INTEGER, INTEGER };
+
+   static
+   {
+      try
+      {
+         TYPE = createSubscriberInfoType();
+         TABULAR_TYPE = createSubscriberInfoTabularType();
+      } catch (OpenDataException e)
+      {
+         throw new IllegalStateException(e);
+      }
+   }
+
+   // Attributes ----------------------------------------------------
+
+   private final String id;
+   private final String clientID;
+   private final String name;
+   private final boolean durable;
+   private final String selector;
+   private final int messageCount;
+   private final int maxSizeBytes;
+
+   // Static --------------------------------------------------------
+
+   public static TabularData toTabularData(final SubscriberInfo[] infos)
+   {
+      TabularData data = new TabularDataSupport(TABULAR_TYPE);
+      for (SubscriberInfo subscriberInfo : infos)
+      {
+         data.put(subscriberInfo.toCompositeData());
+      }
+      return data;
+   }
+
+   private static CompositeType createSubscriberInfoType()
+         throws OpenDataException
+   {
+      return new CompositeType(SUBSCRIBER_TYPE_NAME,
+            "Information for a Topic Subscriber", ITEM_NAMES,
+            ITEM_DESCRIPTIONS, ITEM_TYPES);
+   }
+
+   private static TabularType createSubscriberInfoTabularType()
+         throws OpenDataException
+   {
+      return new TabularType(SUBSCRIBER_TABULAR_TYPE_NAME,
+            "Table of SubscriberInfo", TYPE, new String[] { "id" });
+   }
+
+   // Constructors --------------------------------------------------
+
+   public SubscriberInfo(final String id, final String clientID,
+         final String name, final boolean durable, final String selector,
+         final int messageCount, final int maxSizeBytes)
+   {
+      this.id = id;
+      this.clientID = clientID;
+      this.name = name;
+      this.durable = durable;
+      this.selector = selector;
+      this.messageCount = messageCount;
+      this.maxSizeBytes = maxSizeBytes;
+   }
+
+   // Public --------------------------------------------------------
+
+   public String getID()
+   {
+      return id;
+   }
+
+   public String getClientID()
+   {
+      return clientID;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public boolean isDurable()
+   {
+      return durable;
+   }
+
+   public String getSelector()
+   {
+      return selector;
+   }
+
+   public int getMessageCount()
+   {
+      return messageCount;
+   }
+
+   public int getMaxSizeBytes()
+   {
+      return maxSizeBytes;
+   }
+
+   public CompositeData toCompositeData()
+   {
+      try
+      {
+         return new CompositeDataSupport(TYPE, ITEM_NAMES, new Object[] { id,
+               clientID, name, durable, selector, messageCount, maxSizeBytes });
+      } catch (OpenDataException e)
+      {
+         e.printStackTrace();
+         return null;
+      }
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Deleted: trunk/src/main/org/jboss/messaging/jms/server/management/TopicControlMBean.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/TopicControlMBean.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/TopicControlMBean.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.jms.server.management;
-
-import javax.management.openmbean.TabularData;
-
-import org.jboss.messaging.core.management.Operation;
-import org.jboss.messaging.core.management.Parameter;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public interface TopicControlMBean extends DestinationControlMBean
-{
-   // Attributes ----------------------------------------------------
-
-   int getSubcribersCount();
-
-   int getDurableSubcribersCount();
-
-   int getNonDurableSubcribersCount();
-
-   int getDurableMessageCount();
-
-   int getNonDurableMessageCount();
-
-   // Operations ----------------------------------------------------
-
-   // Open Type API
-
-   @Operation(desc = "List all subscribers")
-   TabularData listAllSubscribers();
-
-   @Operation(desc = "List only the durable subscribers")
-   TabularData listDurableSubscribers();
-
-   @Operation(desc = "List only the non durable subscribers")
-   TabularData listNonDurableSubscribers();
-
-   @Operation(desc = "List all the message for the given subscriber")
-   public TabularData listMessagesForSubscriber(
-         @Parameter(name = "subscriberID", desc = "Subscriber's ID") String subscriberID)
-         throws Exception;
-
-   // Specific API
-
-   @Operation(desc = "List all subscribers")
-   SubscriberInfo[] listAllSubscriberInfos();
-
-   @Operation(desc = "List only the durable subscribers")
-   SubscriberInfo[] listDurableSubscriberInfos();
-
-   @Operation(desc = "List only the non durable subscribers")
-   SubscriberInfo[] listNonDurableSubscriberInfos();
-
-}

Copied: trunk/src/main/org/jboss/messaging/jms/server/management/TopicControlMBean.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/TopicControlMBean.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/TopicControlMBean.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/TopicControlMBean.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.jms.server.management;
+
+import javax.management.openmbean.TabularData;
+
+import org.jboss.messaging.core.management.Operation;
+import org.jboss.messaging.core.management.Parameter;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public interface TopicControlMBean extends DestinationControlMBean
+{
+   // Attributes ----------------------------------------------------
+
+   int getSubcribersCount();
+
+   int getDurableSubcribersCount();
+
+   int getNonDurableSubcribersCount();
+
+   int getDurableMessageCount();
+
+   int getNonDurableMessageCount();
+
+   // Operations ----------------------------------------------------
+
+   // Open Type API
+
+   @Operation(desc = "List all subscribers")
+   TabularData listAllSubscribers();
+
+   @Operation(desc = "List only the durable subscribers")
+   TabularData listDurableSubscribers();
+
+   @Operation(desc = "List only the non durable subscribers")
+   TabularData listNonDurableSubscribers();
+
+   @Operation(desc = "List all the message for the given subscriber")
+   public TabularData listMessagesForSubscriber(
+         @Parameter(name = "subscriberID", desc = "Subscriber's ID") String subscriberID)
+         throws Exception;
+
+   // Specific API
+
+   @Operation(desc = "List all subscribers")
+   SubscriberInfo[] listAllSubscriberInfos();
+
+   @Operation(desc = "List only the durable subscribers")
+   SubscriberInfo[] listDurableSubscriberInfos();
+
+   @Operation(desc = "List only the non durable subscribers")
+   SubscriberInfo[] listNonDurableSubscriberInfos();
+
+}

Copied: trunk/src/main/org/jboss/messaging/jms/server/management/impl (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl)

Deleted: trunk/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,138 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.jms.server.management.impl;
-
-import java.util.List;
-
-import javax.management.NotCompliantMBeanException;
-import javax.management.StandardMBean;
-
-import org.jboss.messaging.core.client.ClientConnectionFactory;
-import org.jboss.messaging.jms.client.JBossConnectionFactory;
-import org.jboss.messaging.jms.server.management.ConnectionFactoryControlMBean;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class ConnectionFactoryControl extends StandardMBean implements
-      ConnectionFactoryControlMBean
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final JBossConnectionFactory cf;
-   private ClientConnectionFactory coreCF;
-   private final List<String> bindings;
-   private String name;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public ConnectionFactoryControl(final JBossConnectionFactory cf,
-         final ClientConnectionFactory coreCF, final String name, final List<String> bindings)
-         throws NotCompliantMBeanException
-   {
-      super(ConnectionFactoryControlMBean.class);
-      this.cf = cf;
-      this.coreCF = coreCF;
-      this.name = name;
-      this.bindings = bindings;
-   }
-
-   // Public --------------------------------------------------------
-
-   // ManagedConnectionFactoryMBean implementation ------------------
-
-   public String getURL()
-   {
-      return coreCF.getLocation().toString();
-   }
-
-   public List<String> getBindings()
-   {
-      return bindings;
-   }
-
-   public String getClientID()
-   {
-      return cf.getClientID();
-   }
-
-   public int getDefaultConsumerMaxRate()
-   {
-      return coreCF.getDefaultConsumerMaxRate();
-   }
-
-   public int getDefaultConsumerWindowSize()
-   {
-      return coreCF.getDefaultConsumerWindowSize();
-   }
-
-   public int getDefaultProducerMaxRate()
-   {
-      return coreCF.getDefaultProducerMaxRate();
-   }
-
-   public int getDefaultProducerWindowSize()
-   {
-      return coreCF.getDefaultProducerWindowSize();
-   }
-
-   public int getDupsOKBatchSize()
-   {
-      return cf.getDupsOKBatchSize();
-   }
-
-   public boolean isDefaultBlockOnAcknowledge()
-   {
-      return coreCF.isDefaultBlockOnAcknowledge();
-   }
-
-   public boolean isDefaultBlockOnNonPersistentSend()
-   {
-      return coreCF.isDefaultBlockOnNonPersistentSend();
-   }
-
-   public boolean isDefaultBlockOnPersistentSend()
-   {
-      return coreCF.isDefaultBlockOnPersistentSend();
-   }
-
-   public String getName()
-   {
-      return name;
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: trunk/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/ConnectionFactoryControl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.jms.server.management.impl;
+
+import java.util.List;
+
+import javax.management.NotCompliantMBeanException;
+import javax.management.StandardMBean;
+
+import org.jboss.messaging.core.client.ClientConnectionFactory;
+import org.jboss.messaging.jms.client.JBossConnectionFactory;
+import org.jboss.messaging.jms.server.management.ConnectionFactoryControlMBean;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class ConnectionFactoryControl extends StandardMBean implements
+      ConnectionFactoryControlMBean
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final JBossConnectionFactory cf;
+   private ClientConnectionFactory coreCF;
+   private final List<String> bindings;
+   private String name;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public ConnectionFactoryControl(final JBossConnectionFactory cf,
+         final ClientConnectionFactory coreCF, final String name, final List<String> bindings)
+         throws NotCompliantMBeanException
+   {
+      super(ConnectionFactoryControlMBean.class);
+      this.cf = cf;
+      this.coreCF = coreCF;
+      this.name = name;
+      this.bindings = bindings;
+   }
+
+   // Public --------------------------------------------------------
+
+   // ManagedConnectionFactoryMBean implementation ------------------
+
+   public String getURL()
+   {
+      return coreCF.getLocation().toString();
+   }
+
+   public List<String> getBindings()
+   {
+      return bindings;
+   }
+
+   public String getClientID()
+   {
+      return cf.getClientID();
+   }
+
+   public int getDefaultConsumerMaxRate()
+   {
+      return coreCF.getDefaultConsumerMaxRate();
+   }
+
+   public int getDefaultConsumerWindowSize()
+   {
+      return coreCF.getDefaultConsumerWindowSize();
+   }
+
+   public int getDefaultProducerMaxRate()
+   {
+      return coreCF.getDefaultProducerMaxRate();
+   }
+
+   public int getDefaultProducerWindowSize()
+   {
+      return coreCF.getDefaultProducerWindowSize();
+   }
+
+   public int getDupsOKBatchSize()
+   {
+      return cf.getDupsOKBatchSize();
+   }
+
+   public boolean isDefaultBlockOnAcknowledge()
+   {
+      return coreCF.isDefaultBlockOnAcknowledge();
+   }
+
+   public boolean isDefaultBlockOnNonPersistentSend()
+   {
+      return coreCF.isDefaultBlockOnNonPersistentSend();
+   }
+
+   public boolean isDefaultBlockOnPersistentSend()
+   {
+      return coreCF.isDefaultBlockOnPersistentSend();
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Deleted: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementServiceImpl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementServiceImpl.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementServiceImpl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,200 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.jms.server.management.impl;
-
-import java.util.List;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import org.jboss.messaging.core.management.MessagingServerManagement;
-import org.jboss.messaging.core.management.impl.ManagementServiceImpl;
-import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.jms.JBossQueue;
-import org.jboss.messaging.jms.JBossTopic;
-import org.jboss.messaging.jms.client.JBossConnectionFactory;
-import org.jboss.messaging.jms.server.JMSServerManager;
-import org.jboss.messaging.jms.server.management.JMSManagementService;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class JMSManagementServiceImpl implements JMSManagementService
-{
-
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   public final MBeanServer mbeanServer;
-   private final boolean managementEnabled;
-
-   // Static --------------------------------------------------------
-
-   public static ObjectName getJMSServerObjectName() throws Exception
-   {
-      return ObjectName.getInstance(ManagementServiceImpl.DOMAIN
-            + ":module=JMS,type=Server");
-   }
-
-   public static ObjectName getJMSQueueObjectName(final String name)
-         throws Exception
-   {
-      return ObjectName.getInstance(ManagementServiceImpl.DOMAIN
-            + ":module=JMS,type=Queue,name=" + name.toString());
-   }
-
-   public static ObjectName getJMSTopicObjectName(final String name)
-         throws Exception
-   {
-      return ObjectName.getInstance(ManagementServiceImpl.DOMAIN
-            + ":module=JMS,type=Topic,name=" + name.toString());
-   }
-
-   private ObjectName getConnectionFactoryObjectName(final String name)
-         throws Exception
-   {
-      return ObjectName.getInstance(ManagementServiceImpl.DOMAIN
-            + ":module=JMS,type=ConnectionFactory,name=" + name);
-   }
-
-   // Constructors --------------------------------------------------
-
-   public JMSManagementServiceImpl(final MBeanServer mbeanServer,
-         final boolean managementEnabled)
-   {
-      this.mbeanServer = mbeanServer;
-      this.managementEnabled = managementEnabled;
-   }
-
-   // Public --------------------------------------------------------
-
-   // JMSManagementRegistration implementation ----------------------
-
-   public void registerJMSServer(final JMSServerManager server)
-         throws Exception
-   {
-      if (!managementEnabled)
-      {
-         return;
-      }
-      ObjectName objectName = getJMSServerObjectName();
-      if (mbeanServer.isRegistered(objectName))
-      {
-         mbeanServer.unregisterMBean(objectName);
-      }
-      mbeanServer.registerMBean(new JMSServerControl(server), objectName);
-   }
-
-   public void unregisterJMSServer()
-   {
-      // TODO Auto-generated method stub
-
-   }
-
-   public void registerQueue(final JBossQueue queue, final Queue coreQueue,
-         final String jndiBinding, final JMSServerManager server)
-         throws Exception
-   {
-      if (!managementEnabled)
-      {
-         return;
-      }
-      ObjectName objectName = getJMSQueueObjectName(queue.getQueueName());
-      if (mbeanServer.isRegistered(objectName))
-      {
-         mbeanServer.unregisterMBean(objectName);
-      }
-      mbeanServer.registerMBean(new JMSQueueControl(queue, coreQueue,
-            jndiBinding, server), getJMSQueueObjectName(queue.getQueueName()));
-   }
-
-   public void unregisterQueue(final String name) throws Exception
-   {
-      if (!managementEnabled)
-      {
-         return;
-      }
-      mbeanServer.unregisterMBean(getJMSQueueObjectName(name));
-   }
-
-   public void registerTopic(final JBossTopic topic,
-         final MessagingServerManagement serverManagement,
-         final String jndiBinding) throws Exception
-   {
-      if (!managementEnabled)
-      {
-         return;
-      }
-      ObjectName objectName = getJMSTopicObjectName(topic.getTopicName());
-      if (mbeanServer.isRegistered(objectName))
-      {
-         mbeanServer.unregisterMBean(objectName);
-      }
-      mbeanServer.registerMBean(new TopicControl(topic, serverManagement,
-            jndiBinding), objectName);
-   }
-
-   public void unregisterTopic(final String name) throws Exception
-   {
-      if (!managementEnabled)
-      {
-         return;
-      }
-      mbeanServer.unregisterMBean(getJMSTopicObjectName(name));
-   }
-
-   public void registerConnectionFactory(final String name,
-         final JBossConnectionFactory connectionFactory,
-         final List<String> bindings) throws Exception
-   {
-      if (!managementEnabled)
-      {
-         return;
-      }
-      ObjectName objectName = getConnectionFactoryObjectName(name);
-      mbeanServer.registerMBean(new ConnectionFactoryControl(connectionFactory,
-            connectionFactory.getCoreConnection(), name, bindings), objectName);
-   }
-
-   public void unregisterConnectionFactory(final String name) throws Exception
-   {
-      if (!managementEnabled)
-      {
-         return;
-      }
-      ObjectName objectName = getConnectionFactoryObjectName(name);
-      mbeanServer.unregisterMBean(objectName);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementServiceImpl.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementServiceImpl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementServiceImpl.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementServiceImpl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,206 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.jms.server.management.impl;
+
+import java.util.List;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.messaging.core.management.MessagingServerManagement;
+import org.jboss.messaging.core.management.impl.ManagementServiceImpl;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.jms.JBossQueue;
+import org.jboss.messaging.jms.JBossTopic;
+import org.jboss.messaging.jms.client.JBossConnectionFactory;
+import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.management.JMSManagementService;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class JMSManagementServiceImpl implements JMSManagementService
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   public final MBeanServer mbeanServer;
+   private final boolean managementEnabled;
+
+   // Static --------------------------------------------------------
+
+   public static ObjectName getJMSServerObjectName() throws Exception
+   {
+      return ObjectName.getInstance(ManagementServiceImpl.DOMAIN
+            + ":module=JMS,type=Server");
+   }
+
+   public static ObjectName getJMSQueueObjectName(final String name)
+         throws Exception
+   {
+      return ObjectName.getInstance(ManagementServiceImpl.DOMAIN
+            + ":module=JMS,type=Queue,name=" + name.toString());
+   }
+
+   public static ObjectName getJMSTopicObjectName(final String name)
+         throws Exception
+   {
+      return ObjectName.getInstance(ManagementServiceImpl.DOMAIN
+            + ":module=JMS,type=Topic,name=" + name.toString());
+   }
+
+   public static ObjectName getConnectionFactoryObjectName(final String name)
+         throws Exception
+   {
+      return ObjectName.getInstance(ManagementServiceImpl.DOMAIN
+            + ":module=JMS,type=ConnectionFactory,name=" + name);
+   }
+
+   // Constructors --------------------------------------------------
+
+   public JMSManagementServiceImpl(final MBeanServer mbeanServer,
+         final boolean managementEnabled)
+   {
+      this.mbeanServer = mbeanServer;
+      this.managementEnabled = managementEnabled;
+   }
+
+   // Public --------------------------------------------------------
+
+   // JMSManagementRegistration implementation ----------------------
+
+   public void registerJMSServer(final JMSServerManager server)
+         throws Exception
+   {
+      if (!managementEnabled)
+      {
+         return;
+      }
+      ObjectName objectName = getJMSServerObjectName();
+      unregisterJMSServer();
+      mbeanServer.registerMBean(new JMSServerControl(server), objectName);
+   }
+
+   public void unregisterJMSServer() throws Exception
+   {
+      ObjectName objectName = getJMSServerObjectName();
+      if (mbeanServer.isRegistered(objectName))
+      {
+         mbeanServer.unregisterMBean(objectName);
+      }
+   }
+
+   public void registerQueue(final JBossQueue queue, final Queue coreQueue,
+         final String jndiBinding, final JMSServerManager server)
+         throws Exception
+   {
+      if (!managementEnabled)
+      {
+         return;
+      }
+      ObjectName objectName = getJMSQueueObjectName(queue.getQueueName());
+      unregisterQueue(queue.getQueueName());
+      mbeanServer.registerMBean(new JMSQueueControl(queue, coreQueue,
+            jndiBinding, server), objectName);
+   }
+
+   public void unregisterQueue(final String name) throws Exception
+   {
+      if (!managementEnabled)
+      {
+         return;
+      }
+      ObjectName objectName = getJMSQueueObjectName(name);
+      if (mbeanServer.isRegistered(objectName))
+      {
+         mbeanServer.unregisterMBean(objectName);
+      }
+   }
+
+   public void registerTopic(final JBossTopic topic,
+         final MessagingServerManagement serverManagement,
+         final String jndiBinding) throws Exception
+   {
+      if (!managementEnabled)
+      {
+         return;
+      }
+      ObjectName objectName = getJMSTopicObjectName(topic.getTopicName());
+      unregisterTopic(topic.getTopicName());
+      mbeanServer.registerMBean(new TopicControl(topic, serverManagement,
+            jndiBinding), objectName);
+   }
+
+   public void unregisterTopic(final String name) throws Exception
+   {
+      if (!managementEnabled)
+      {
+         return;
+      }
+      ObjectName objectName = getJMSTopicObjectName(name);
+      if (mbeanServer.isRegistered(objectName))
+      {
+         mbeanServer.unregisterMBean(getJMSTopicObjectName(name));
+      }
+   }
+
+   public void registerConnectionFactory(final String name,
+         final JBossConnectionFactory connectionFactory,
+         final List<String> bindings) throws Exception
+   {
+      if (!managementEnabled)
+      {
+         return;
+      }
+      ObjectName objectName = getConnectionFactoryObjectName(name);
+      unregisterConnectionFactory(name);
+      mbeanServer.registerMBean(new ConnectionFactoryControl(connectionFactory,
+            connectionFactory.getCoreConnection(), name, bindings), objectName);
+   }
+
+   public void unregisterConnectionFactory(final String name) throws Exception
+   {
+      if (!managementEnabled)
+      {
+         return;
+      }
+      ObjectName objectName = getConnectionFactoryObjectName(name);
+      if (mbeanServer.isRegistered(objectName))
+      {
+         mbeanServer.unregisterMBean(objectName);
+      }
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Deleted: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,268 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.jms.server.management.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.management.MBeanInfo;
-import javax.management.NotCompliantMBeanException;
-import javax.management.StandardMBean;
-import javax.management.openmbean.TabularData;
-
-import org.jboss.messaging.core.exception.MessagingException;
-import org.jboss.messaging.core.filter.Filter;
-import org.jboss.messaging.core.filter.impl.FilterImpl;
-import org.jboss.messaging.core.management.impl.MBeanInfoHelper;
-import org.jboss.messaging.core.server.MessageReference;
-import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.ServerMessage;
-import org.jboss.messaging.core.settings.impl.QueueSettings;
-import org.jboss.messaging.jms.JBossDestination;
-import org.jboss.messaging.jms.JBossQueue;
-import org.jboss.messaging.jms.client.JBossMessage;
-import org.jboss.messaging.jms.client.SelectorTranslator;
-import org.jboss.messaging.jms.server.JMSServerManager;
-import org.jboss.messaging.jms.server.management.JMSMessageInfo;
-import org.jboss.messaging.jms.server.management.JMSQueueControlMBean;
-import org.jboss.messaging.util.SimpleString;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class JMSQueueControl extends StandardMBean implements
-      JMSQueueControlMBean
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final JBossQueue managedQueue;
-   private Queue coreQueue;
-   private final String binding;
-   private JMSServerManager server;
-
-   // Static --------------------------------------------------------
-
-   private static Filter createFilterForJMSMessageID(String jmsMessageID)
-         throws Exception
-   {
-      return new FilterImpl(new SimpleString(JBossMessage.JBM_MESSAGE_ID
-            + " = '" + jmsMessageID + "'"));
-   }
-
-   // Constructors --------------------------------------------------
-
-   public JMSQueueControl(final JBossQueue queue, final Queue coreQueue,
-         final String jndiBinding, final JMSServerManager server)
-         throws NotCompliantMBeanException
-   {
-      super(JMSQueueControlMBean.class);
-      this.managedQueue = queue;
-      this.coreQueue = coreQueue;
-      this.binding = jndiBinding;
-      this.server = server;
-   }
-
-   // Public --------------------------------------------------------
-
-   // ManagedJMSQueueMBean implementation ---------------------------
-
-   public String getName()
-   {
-      return managedQueue.getName();
-   }
-
-   public String getAddress()
-   {
-      return managedQueue.getAddress();
-   }
-
-   public boolean isTemporary()
-   {
-      return managedQueue.isTemporary();
-   }
-
-   public int getMessageCount() throws Exception
-   {
-      return coreQueue.getMessageCount();
-   }
-
-   public String getJNDIBinding()
-   {
-      return binding;
-   }
-
-   public String getDLQ()
-   {
-      QueueSettings settings = server.getSettings(managedQueue);
-      if (settings != null && settings.getDLQ() != null)
-      {
-         return JBossDestination.fromAddress(settings.getDLQ().toString())
-               .getName();
-      } else
-      {
-         return null;
-      }
-   }
-
-   public String getExpiryQueue()
-   {
-      QueueSettings settings = server.getSettings(managedQueue);
-      if (settings != null && settings.getExpiryQueue() != null)
-      {
-         return JBossDestination.fromAddress(
-               settings.getExpiryQueue().toString()).getName();
-      } else
-      {
-         return null;
-      }
-   }
-
-   public boolean removeMessage(final String messageID) throws Exception
-   {
-      Filter filter = createFilterForJMSMessageID(messageID);
-      List<MessageReference> refs = coreQueue.list(filter);
-      if (refs.size() != 1)
-      {
-         throw new IllegalArgumentException(
-               "No message found for JMSMessageID: " + messageID);
-      }
-      return server.removeMessage(refs.get(0).getMessage().getMessageID(),
-            managedQueue);
-   }
-
-   public void removeAllMessages() throws Exception
-   {
-      server.removeAllMessages(managedQueue);
-   }
-
-   public TabularData listAllMessages() throws Exception
-   {
-      return listMessages(null);
-   }
-
-   public TabularData listMessages(final String filterStr) throws Exception
-   {
-      try
-      {
-         Filter filter = filterStr == null ? null : new FilterImpl(
-               new SimpleString(SelectorTranslator
-                     .convertToJBMFilterString(filterStr)));
-
-         List<MessageReference> messageRefs = coreQueue.list(filter);
-         List<JMSMessageInfo> infos = new ArrayList<JMSMessageInfo>(messageRefs
-               .size());
-         for (MessageReference messageRef : messageRefs)
-         {
-            ServerMessage message = messageRef.getMessage();
-            JMSMessageInfo info = JMSMessageInfo.fromServerMessage(message);
-            infos.add(info);
-         }
-         return JMSMessageInfo.toTabularData(infos);
-      } catch (MessagingException e)
-      {
-         throw new IllegalStateException(e.getMessage());
-      }
-   }
-
-   public boolean expireMessage(final String messageID) throws Exception
-   {
-      Filter filter = createFilterForJMSMessageID(messageID);
-      List<MessageReference> refs = coreQueue.list(filter);
-      if (refs.size() != 1)
-      {
-         throw new IllegalArgumentException(
-               "No message found for JMSMessageID: " + messageID);
-      }
-      return server.expireMessages(filter, managedQueue) == 1;
-   }
-
-   public int expireMessages(final String filterStr) throws Exception
-   {
-      try
-      {
-         Filter filter = filterStr == null ? null : new FilterImpl(
-               new SimpleString(SelectorTranslator
-                     .convertToJBMFilterString(filterStr)));
-         return server.expireMessages(filter, managedQueue);
-      } catch (MessagingException e)
-      {
-         throw new IllegalStateException(e.getMessage());
-      }
-   }
-
-   public boolean sendMessageTDLQ(final String messageID) throws Exception
-   {
-      Filter filter = createFilterForJMSMessageID(messageID);
-      List<MessageReference> refs = coreQueue.list(filter);
-      if (refs.size() != 1)
-      {
-         throw new IllegalArgumentException(
-               "No message found for JMSMessageID: " + messageID);
-      }
-      return server.sendMessagesToDLQ(filter, managedQueue) == 1;
-   }
-
-   public boolean changeMessagePriority(final String messageID,
-         final int newPriority) throws Exception
-   {
-      if (newPriority < 0 || newPriority > 9)
-      {
-         throw new IllegalArgumentException("invalid newPriority value: "
-               + newPriority + ". It must be between 0 and 9 (both included)");
-      }
-      Filter filter = createFilterForJMSMessageID(messageID);
-      List<MessageReference> refs = coreQueue.list(filter);
-      if (refs.size() != 1)
-      {
-         throw new IllegalArgumentException(
-               "No message found for JMSMessageID: " + messageID);
-      }
-      return server.changeMessagesPriority(filter, (byte) newPriority,
-            managedQueue) == 1;
-   }
-
-   // StandardMBean overrides ---------------------------------------
-
-   @Override
-   public MBeanInfo getMBeanInfo()
-   {
-      MBeanInfo info = super.getMBeanInfo();
-      return new MBeanInfo(info.getClassName(), info.getDescription(), info
-            .getAttributes(), info.getConstructors(), MBeanInfoHelper
-            .getMBeanOperationsInfo(JMSQueueControlMBean.class), info
-            .getNotifications());
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,268 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.jms.server.management.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.MBeanInfo;
+import javax.management.NotCompliantMBeanException;
+import javax.management.StandardMBean;
+import javax.management.openmbean.TabularData;
+
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.filter.impl.FilterImpl;
+import org.jboss.messaging.core.management.impl.MBeanInfoHelper;
+import org.jboss.messaging.core.server.MessageReference;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.jms.JBossDestination;
+import org.jboss.messaging.jms.JBossQueue;
+import org.jboss.messaging.jms.client.JBossMessage;
+import org.jboss.messaging.jms.client.SelectorTranslator;
+import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.management.JMSMessageInfo;
+import org.jboss.messaging.jms.server.management.JMSQueueControlMBean;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class JMSQueueControl extends StandardMBean implements
+      JMSQueueControlMBean
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final JBossQueue managedQueue;
+   private Queue coreQueue;
+   private final String binding;
+   private JMSServerManager server;
+
+   // Static --------------------------------------------------------
+
+   private static Filter createFilterForJMSMessageID(String jmsMessageID)
+         throws Exception
+   {
+      return new FilterImpl(new SimpleString(JBossMessage.JBM_MESSAGE_ID
+            + " = '" + jmsMessageID + "'"));
+   }
+
+   // Constructors --------------------------------------------------
+
+   public JMSQueueControl(final JBossQueue queue, final Queue coreQueue,
+         final String jndiBinding, final JMSServerManager server)
+         throws NotCompliantMBeanException
+   {
+      super(JMSQueueControlMBean.class);
+      this.managedQueue = queue;
+      this.coreQueue = coreQueue;
+      this.binding = jndiBinding;
+      this.server = server;
+   }
+
+   // Public --------------------------------------------------------
+
+   // ManagedJMSQueueMBean implementation ---------------------------
+
+   public String getName()
+   {
+      return managedQueue.getName();
+   }
+
+   public String getAddress()
+   {
+      return managedQueue.getAddress();
+   }
+
+   public boolean isTemporary()
+   {
+      return managedQueue.isTemporary();
+   }
+
+   public int getMessageCount() throws Exception
+   {
+      return coreQueue.getMessageCount();
+   }
+
+   public String getJNDIBinding()
+   {
+      return binding;
+   }
+
+   public String getDLQ()
+   {
+      QueueSettings settings = server.getSettings(managedQueue);
+      if (settings != null && settings.getDLQ() != null)
+      {
+         return JBossDestination.fromAddress(settings.getDLQ().toString())
+               .getName();
+      } else
+      {
+         return null;
+      }
+   }
+
+   public String getExpiryQueue()
+   {
+      QueueSettings settings = server.getSettings(managedQueue);
+      if (settings != null && settings.getExpiryQueue() != null)
+      {
+         return JBossDestination.fromAddress(
+               settings.getExpiryQueue().toString()).getName();
+      } else
+      {
+         return null;
+      }
+   }
+
+   public boolean removeMessage(final String messageID) throws Exception
+   {
+      Filter filter = createFilterForJMSMessageID(messageID);
+      List<MessageReference> refs = coreQueue.list(filter);
+      if (refs.size() != 1)
+      {
+         throw new IllegalArgumentException(
+               "No message found for JMSMessageID: " + messageID);
+      }
+      return server.removeMessage(refs.get(0).getMessage().getMessageID(),
+            managedQueue);
+   }
+
+   public void removeAllMessages() throws Exception
+   {
+      server.removeAllMessages(managedQueue);
+   }
+
+   public TabularData listAllMessages() throws Exception
+   {
+      return listMessages(null);
+   }
+
+   public TabularData listMessages(final String filterStr) throws Exception
+   {
+      try
+      {
+         Filter filter = filterStr == null ? null : new FilterImpl(
+               new SimpleString(SelectorTranslator
+                     .convertToJBMFilterString(filterStr)));
+
+         List<MessageReference> messageRefs = coreQueue.list(filter);
+         List<JMSMessageInfo> infos = new ArrayList<JMSMessageInfo>(messageRefs
+               .size());
+         for (MessageReference messageRef : messageRefs)
+         {
+            ServerMessage message = messageRef.getMessage();
+            JMSMessageInfo info = JMSMessageInfo.fromServerMessage(message);
+            infos.add(info);
+         }
+         return JMSMessageInfo.toTabularData(infos);
+      } catch (MessagingException e)
+      {
+         throw new IllegalStateException(e.getMessage());
+      }
+   }
+
+   public boolean expireMessage(final String messageID) throws Exception
+   {
+      Filter filter = createFilterForJMSMessageID(messageID);
+      List<MessageReference> refs = coreQueue.list(filter);
+      if (refs.size() != 1)
+      {
+         throw new IllegalArgumentException(
+               "No message found for JMSMessageID: " + messageID);
+      }
+      return server.expireMessages(filter, managedQueue) == 1;
+   }
+
+   public int expireMessages(final String filterStr) throws Exception
+   {
+      try
+      {
+         Filter filter = filterStr == null ? null : new FilterImpl(
+               new SimpleString(SelectorTranslator
+                     .convertToJBMFilterString(filterStr)));
+         return server.expireMessages(filter, managedQueue);
+      } catch (MessagingException e)
+      {
+         throw new IllegalStateException(e.getMessage());
+      }
+   }
+
+   public boolean sendMessageTDLQ(final String messageID) throws Exception
+   {
+      Filter filter = createFilterForJMSMessageID(messageID);
+      List<MessageReference> refs = coreQueue.list(filter);
+      if (refs.size() != 1)
+      {
+         throw new IllegalArgumentException(
+               "No message found for JMSMessageID: " + messageID);
+      }
+      return server.sendMessagesToDLQ(filter, managedQueue) == 1;
+   }
+
+   public boolean changeMessagePriority(final String messageID,
+         final int newPriority) throws Exception
+   {
+      if (newPriority < 0 || newPriority > 9)
+      {
+         throw new IllegalArgumentException("invalid newPriority value: "
+               + newPriority + ". It must be between 0 and 9 (both included)");
+      }
+      Filter filter = createFilterForJMSMessageID(messageID);
+      List<MessageReference> refs = coreQueue.list(filter);
+      if (refs.size() != 1)
+      {
+         throw new IllegalArgumentException(
+               "No message found for JMSMessageID: " + messageID);
+      }
+      return server.changeMessagesPriority(filter, (byte) newPriority,
+            managedQueue) == 1;
+   }
+
+   // StandardMBean overrides ---------------------------------------
+
+   @Override
+   public MBeanInfo getMBeanInfo()
+   {
+      MBeanInfo info = super.getMBeanInfo();
+      return new MBeanInfo(info.getClassName(), info.getDescription(), info
+            .getAttributes(), info.getConstructors(), MBeanInfoHelper
+            .getMBeanOperationsInfo(JMSQueueControlMBean.class), info
+            .getNotifications());
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Deleted: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,235 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.jms.server.management.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanNotificationInfo;
-import javax.management.NotCompliantMBeanException;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.StandardMBean;
-
-import org.jboss.messaging.core.management.impl.MBeanInfoHelper;
-import org.jboss.messaging.jms.server.JMSServerManager;
-import org.jboss.messaging.jms.server.management.JMSServerControlMBean;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class JMSServerControl extends StandardMBean implements
-      JMSServerControlMBean, NotificationEmitter
-{
-
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final JMSServerManager server;
-   private NotificationBroadcasterSupport broadcaster;
-   private AtomicLong notifSeq = new AtomicLong(0);
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public JMSServerControl(final JMSServerManager server)
-         throws NotCompliantMBeanException
-   {
-      super(JMSServerControlMBean.class);
-      this.server = server;
-      broadcaster = new NotificationBroadcasterSupport();
-   }
-
-   // Public --------------------------------------------------------
-
-   // JMSServerControlMBean implementation --------------------------
-
-   public void createConnectionFactory(final String name,
-         final String jndiBinding, final String clientID,
-         final int dupsOKBatchSize, final int consumerWindowSize,
-         final int consumerMaxRate, final int producerWindowSize,
-         final int producerMaxRate, final boolean blockOnAcknowledge,
-         final boolean defaultSendNonPersistentMessagesBlocking,
-         final boolean defaultSendPersistentMessagesBlocking) throws Exception
-   {
-      List<String> bindings = new ArrayList<String>();
-      bindings.add(jndiBinding);
-
-      boolean created = server.createConnectionFactory(name, clientID,
-            dupsOKBatchSize, consumerWindowSize, consumerMaxRate,
-            producerWindowSize, producerMaxRate, blockOnAcknowledge,
-            defaultSendNonPersistentMessagesBlocking,
-            defaultSendPersistentMessagesBlocking, bindings);
-      if (created)
-      {
-         sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
-      }
-   }
-
-   public boolean createQueue(final String name, final String jndiBinding)
-         throws Exception
-   {
-      boolean created = server.createQueue(name, jndiBinding);
-      if (created)
-      {
-         sendNotification(NotificationType.QUEUE_CREATED, name);
-      }
-      return created;
-   }
-
-   public boolean destroyQueue(final String name) throws Exception
-   {
-      boolean destroyed = server.destroyQueue(name);
-      if (destroyed)
-      {
-         sendNotification(NotificationType.QUEUE_DESTROYED, name);
-      }
-      return destroyed;
-   }
-
-   public boolean createTopic(final String topicName, final String jndiBinding)
-         throws Exception
-   {
-      boolean created = server.createTopic(topicName, jndiBinding);
-      if (created)
-      {
-         sendNotification(NotificationType.TOPIC_CREATED, topicName);
-      }
-      return created;
-   }
-
-   public boolean destroyTopic(final String name) throws Exception
-   {
-      boolean destroyed = server.destroyTopic(name);
-      if (destroyed)
-      {
-         sendNotification(NotificationType.TOPIC_DESTROYED, name);
-      }
-      return destroyed;
-   }
-
-   public void destroyConnectionFactory(final String name) throws Exception
-   {
-      boolean destroyed = server.destroyConnectionFactory(name);
-      if (destroyed)
-      {
-         sendNotification(NotificationType.CONNECTION_FACTORY_DESTROYED, name);
-      }
-   }
-
-   public boolean isStarted()
-   {
-      return server.isStarted();
-   }
-
-   public String getVersion()
-   {
-      return server.getVersion();
-   }
-
-   // NotificationEmitter implementation ----------------------------
-
-   public void removeNotificationListener(final NotificationListener listener,
-         final NotificationFilter filter, final Object handback)
-         throws ListenerNotFoundException
-   {
-      broadcaster.removeNotificationListener(listener, filter, handback);
-   }
-
-   public void removeNotificationListener(final NotificationListener listener)
-         throws ListenerNotFoundException
-   {
-      broadcaster.removeNotificationListener(listener);
-   }
-
-   public void addNotificationListener(final NotificationListener listener,
-         final NotificationFilter filter, final Object handback)
-         throws IllegalArgumentException
-   {
-      broadcaster.addNotificationListener(listener, filter, handback);
-   }
-
-   public MBeanNotificationInfo[] getNotificationInfo()
-   {
-      NotificationType[] values = NotificationType.values();
-      String[] names = new String[values.length];
-      for (int i = 0; i < values.length; i++)
-      {
-         names[i] = values[i].toString();
-      }
-      return new MBeanNotificationInfo[] { new MBeanNotificationInfo(names,
-            this.getClass().getName(), "Notifications emitted by a JMS Server") };
-   }
-
-   // StandardMBean overrides
-   // ---------------------------------------------------
-
-   /*
-    * overrides getMBeanInfo to add operations info using annotations
-    * 
-    * @see Operation
-    * 
-    * @see Parameter
-    */
-   @Override
-   public MBeanInfo getMBeanInfo()
-   {
-      MBeanInfo info = super.getMBeanInfo();
-      return new MBeanInfo(info.getClassName(), info.getDescription(), info
-            .getAttributes(), info.getConstructors(), MBeanInfoHelper
-            .getMBeanOperationsInfo(JMSServerControlMBean.class),
-            getNotificationInfo());
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   private void sendNotification(final NotificationType type,
-         final String message)
-   {
-      Notification notif = new Notification(type.toString(), this, notifSeq
-            .incrementAndGet(), message);
-      broadcaster.sendNotification(notif);
-   }
-
-   // Inner classes -------------------------------------------------
-
-   public static enum NotificationType
-   {
-      QUEUE_CREATED, QUEUE_DESTROYED, TOPIC_CREATED, TOPIC_DESTROYED, CONNECTION_FACTORY_CREATED, CONNECTION_FACTORY_DESTROYED;
-   }
-}

Copied: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,235 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.jms.server.management.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanNotificationInfo;
+import javax.management.NotCompliantMBeanException;
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.NotificationEmitter;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.StandardMBean;
+
+import org.jboss.messaging.core.management.impl.MBeanInfoHelper;
+import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.management.JMSServerControlMBean;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class JMSServerControl extends StandardMBean implements
+      JMSServerControlMBean, NotificationEmitter
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final JMSServerManager server;
+   private NotificationBroadcasterSupport broadcaster;
+   private AtomicLong notifSeq = new AtomicLong(0);
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public JMSServerControl(final JMSServerManager server)
+         throws NotCompliantMBeanException
+   {
+      super(JMSServerControlMBean.class);
+      this.server = server;
+      broadcaster = new NotificationBroadcasterSupport();
+   }
+
+   // Public --------------------------------------------------------
+
+   // JMSServerControlMBean implementation --------------------------
+
+   public void createConnectionFactory(final String name,
+         final String jndiBinding, final String clientID,
+         final int dupsOKBatchSize, final int consumerWindowSize,
+         final int consumerMaxRate, final int producerWindowSize,
+         final int producerMaxRate, final boolean blockOnAcknowledge,
+         final boolean defaultSendNonPersistentMessagesBlocking,
+         final boolean defaultSendPersistentMessagesBlocking) throws Exception
+   {
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(jndiBinding);
+
+      boolean created = server.createConnectionFactory(name, clientID,
+            dupsOKBatchSize, consumerWindowSize, consumerMaxRate,
+            producerWindowSize, producerMaxRate, blockOnAcknowledge,
+            defaultSendNonPersistentMessagesBlocking,
+            defaultSendPersistentMessagesBlocking, bindings);
+      if (created)
+      {
+         sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
+      }
+   }
+
+   public boolean createQueue(final String name, final String jndiBinding)
+         throws Exception
+   {
+      boolean created = server.createQueue(name, jndiBinding);
+      if (created)
+      {
+         sendNotification(NotificationType.QUEUE_CREATED, name);
+      }
+      return created;
+   }
+
+   public boolean destroyQueue(final String name) throws Exception
+   {
+      boolean destroyed = server.destroyQueue(name);
+      if (destroyed)
+      {
+         sendNotification(NotificationType.QUEUE_DESTROYED, name);
+      }
+      return destroyed;
+   }
+
+   public boolean createTopic(final String topicName, final String jndiBinding)
+         throws Exception
+   {
+      boolean created = server.createTopic(topicName, jndiBinding);
+      if (created)
+      {
+         sendNotification(NotificationType.TOPIC_CREATED, topicName);
+      }
+      return created;
+   }
+
+   public boolean destroyTopic(final String name) throws Exception
+   {
+      boolean destroyed = server.destroyTopic(name);
+      if (destroyed)
+      {
+         sendNotification(NotificationType.TOPIC_DESTROYED, name);
+      }
+      return destroyed;
+   }
+
+   public void destroyConnectionFactory(final String name) throws Exception
+   {
+      boolean destroyed = server.destroyConnectionFactory(name);
+      if (destroyed)
+      {
+         sendNotification(NotificationType.CONNECTION_FACTORY_DESTROYED, name);
+      }
+   }
+
+   public boolean isStarted()
+   {
+      return server.isStarted();
+   }
+
+   public String getVersion()
+   {
+      return server.getVersion();
+   }
+
+   // NotificationEmitter implementation ----------------------------
+
+   public void removeNotificationListener(final NotificationListener listener,
+         final NotificationFilter filter, final Object handback)
+         throws ListenerNotFoundException
+   {
+      broadcaster.removeNotificationListener(listener, filter, handback);
+   }
+
+   public void removeNotificationListener(final NotificationListener listener)
+         throws ListenerNotFoundException
+   {
+      broadcaster.removeNotificationListener(listener);
+   }
+
+   public void addNotificationListener(final NotificationListener listener,
+         final NotificationFilter filter, final Object handback)
+         throws IllegalArgumentException
+   {
+      broadcaster.addNotificationListener(listener, filter, handback);
+   }
+
+   public MBeanNotificationInfo[] getNotificationInfo()
+   {
+      NotificationType[] values = NotificationType.values();
+      String[] names = new String[values.length];
+      for (int i = 0; i < values.length; i++)
+      {
+         names[i] = values[i].toString();
+      }
+      return new MBeanNotificationInfo[] { new MBeanNotificationInfo(names,
+            this.getClass().getName(), "Notifications emitted by a JMS Server") };
+   }
+
+   // StandardMBean overrides
+   // ---------------------------------------------------
+
+   /*
+    * overrides getMBeanInfo to add operations info using annotations
+    * 
+    * @see Operation
+    * 
+    * @see Parameter
+    */
+   @Override
+   public MBeanInfo getMBeanInfo()
+   {
+      MBeanInfo info = super.getMBeanInfo();
+      return new MBeanInfo(info.getClassName(), info.getDescription(), info
+            .getAttributes(), info.getConstructors(), MBeanInfoHelper
+            .getMBeanOperationsInfo(JMSServerControlMBean.class),
+            getNotificationInfo());
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   private void sendNotification(final NotificationType type,
+         final String message)
+   {
+      Notification notif = new Notification(type.toString(), this, notifSeq
+            .incrementAndGet(), message);
+      broadcaster.sendNotification(notif);
+   }
+
+   // Inner classes -------------------------------------------------
+
+   public static enum NotificationType
+   {
+      QUEUE_CREATED, QUEUE_DESTROYED, TOPIC_CREATED, TOPIC_DESTROYED, CONNECTION_FACTORY_CREATED, CONNECTION_FACTORY_DESTROYED;
+   }
+}

Deleted: trunk/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,280 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.jms.server.management.impl;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.management.MBeanInfo;
-import javax.management.NotCompliantMBeanException;
-import javax.management.StandardMBean;
-import javax.management.openmbean.TabularData;
-
-import org.jboss.messaging.core.management.MessagingServerManagement;
-import org.jboss.messaging.core.management.Operation;
-import org.jboss.messaging.core.management.Parameter;
-import org.jboss.messaging.core.management.impl.MBeanInfoHelper;
-import org.jboss.messaging.core.server.MessageReference;
-import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.ServerMessage;
-import org.jboss.messaging.jms.JBossTopic;
-import org.jboss.messaging.jms.server.management.JMSMessageInfo;
-import org.jboss.messaging.jms.server.management.SubscriberInfo;
-import org.jboss.messaging.jms.server.management.TopicControlMBean;
-import org.jboss.messaging.util.Pair;
-import org.jboss.messaging.util.SimpleString;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class TopicControl extends StandardMBean implements TopicControlMBean
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private final JBossTopic managedTopic;
-   private final MessagingServerManagement server;
-   private final String binding;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public TopicControl(final JBossTopic topic,
-         final MessagingServerManagement server, final String jndiBinding)
-         throws NotCompliantMBeanException
-   {
-      super(TopicControlMBean.class);
-      this.managedTopic = topic;
-      this.server = server;
-      this.binding = jndiBinding;
-   }
-
-   // Public --------------------------------------------------------
-
-   // StandardMBean overrides ---------------------------------------
-
-   /**
-    * overrides getMBeanInfo to add operations info using annotations
-    * 
-    * @see Operation
-    * @see Parameter
-    */
-   @Override
-   public MBeanInfo getMBeanInfo()
-   {
-      MBeanInfo info = super.getMBeanInfo();
-      return new MBeanInfo(info.getClassName(), info.getDescription(), info
-            .getAttributes(), info.getConstructors(), MBeanInfoHelper
-            .getMBeanOperationsInfo(TopicControlMBean.class), info
-            .getNotifications());
-   }
-
-   // TopicControlMBean implementation ------------------------------
-
-   public String getName()
-   {
-      return managedTopic.getName();
-   }
-
-   public boolean isTemporary()
-   {
-      return managedTopic.isTemporary();
-   }
-
-   public String getAddress()
-   {
-      return managedTopic.getAddress();
-   }
-
-   public String getJNDIBinding()
-   {
-      return binding;
-   }
-
-   public int getMessageCount()
-   {
-      return getMessageCount(DurabilityType.ALL);
-   }
-
-   public int getDurableMessageCount()
-   {
-      return getMessageCount(DurabilityType.DURABLE);
-   }
-
-   public int getNonDurableMessageCount()
-   {
-      return getMessageCount(DurabilityType.NON_DURABLE);
-   }
-
-   public int getSubcribersCount()
-   {
-      return getQueues(DurabilityType.ALL).size();
-   }
-
-   public int getDurableSubcribersCount()
-   {
-      return getQueues(DurabilityType.DURABLE).size();
-   }
-
-   public int getNonDurableSubcribersCount()
-   {
-      return getQueues(DurabilityType.NON_DURABLE).size();
-   }
-
-   public TabularData listAllSubscribers()
-   {
-      return SubscriberInfo.toTabularData(listAllSubscriberInfos());
-   }
-
-   public TabularData listDurableSubscribers()
-   {
-      return SubscriberInfo.toTabularData(listDurableSubscriberInfos());
-   }
-
-   public TabularData listNonDurableSubscribers()
-   {
-      return SubscriberInfo.toTabularData(listNonDurableSubscriberInfos());
-   }
-
-   public SubscriberInfo[] listAllSubscriberInfos()
-   {
-      return listSubscribersInfos(DurabilityType.ALL);
-   }
-
-   public SubscriberInfo[] listDurableSubscriberInfos()
-   {
-      return listSubscribersInfos(DurabilityType.DURABLE);
-   }
-
-   public SubscriberInfo[] listNonDurableSubscriberInfos()
-   {
-      return listSubscribersInfos(DurabilityType.NON_DURABLE);
-   }
-
-   public TabularData listMessagesForSubscriber(final String subscriberID)
-         throws Exception
-   {
-      Queue queue = server.getQueue(new SimpleString(subscriberID));
-      List<MessageReference> messageRefs = queue.list(null);
-      List<JMSMessageInfo> infos = new ArrayList<JMSMessageInfo>(messageRefs
-            .size());
-
-      for (MessageReference messageRef : messageRefs)
-      {
-         ServerMessage message = messageRef.getMessage();
-         JMSMessageInfo info = JMSMessageInfo.fromServerMessage(message);
-         infos.add(info);
-      }
-      return JMSMessageInfo.toTabularData(infos);
-   }
-
-   public void removeAllMessages() throws Exception
-   {
-      server.removeAllMessagesForAddress(managedTopic.getSimpleAddress());
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   private SubscriberInfo[] listSubscribersInfos(final DurabilityType durability)
-   {
-      List<Queue> queues = getQueues(durability);
-      List<SubscriberInfo> subInfos = new ArrayList<SubscriberInfo>(queues
-            .size());
-      for (Queue queue : queues)
-      {
-         String clientID = null;
-         String subName = null;
-
-         if (queue.isDurable())
-         {
-            Pair<String, String> pair = JBossTopic
-                  .decomposeQueueNameForDurableSubscription(queue.getName()
-                        .toString());
-            clientID = pair.a;
-            subName = pair.b;
-         }
-
-         String filter = queue.getFilter() != null ? queue.getFilter()
-               .getFilterString().toString() : null;
-         SubscriberInfo info = new SubscriberInfo(queue.getName().toString(),
-               clientID, subName, queue.isDurable(), filter, queue
-                     .getMessageCount(), queue.getMaxSizeBytes());
-         subInfos.add(info);
-      }
-      return (SubscriberInfo[]) subInfos.toArray(new SubscriberInfo[subInfos
-            .size()]);
-   }
-
-   private int getMessageCount(final DurabilityType durability)
-   {
-      List<Queue> queues = getQueues(durability);
-      int count = 0;
-      for (Queue queue : queues)
-      {
-         count += queue.getMessageCount();
-      }
-      return count;
-   }
-
-   private List<Queue> getQueues(final DurabilityType durability)
-   {
-      try
-      {
-         List<Queue> queues = server.getQueuesForAddress(managedTopic
-               .getSimpleAddress());
-         List<Queue> matchingQueues = new ArrayList<Queue>();
-         for (Queue queue : queues)
-         {
-            if (durability == DurabilityType.ALL
-                  || (durability == DurabilityType.DURABLE && queue.isDurable())
-                  || (durability == DurabilityType.NON_DURABLE && !queue
-                        .isDurable()))
-            {
-               matchingQueues.add(queue);
-            }
-         }
-         return matchingQueues;
-      } catch (Exception e)
-      {
-         e.printStackTrace();
-         return Collections.emptyList();
-      }
-   }
-
-   // Inner classes -------------------------------------------------
-
-   private enum DurabilityType
-   {
-      ALL, DURABLE, NON_DURABLE
-   }
-}

Copied: trunk/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java (from rev 4779, branches/Branch_JBMESSAGING-1303/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,280 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.jms.server.management.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.management.MBeanInfo;
+import javax.management.NotCompliantMBeanException;
+import javax.management.StandardMBean;
+import javax.management.openmbean.TabularData;
+
+import org.jboss.messaging.core.management.MessagingServerManagement;
+import org.jboss.messaging.core.management.Operation;
+import org.jboss.messaging.core.management.Parameter;
+import org.jboss.messaging.core.management.impl.MBeanInfoHelper;
+import org.jboss.messaging.core.server.MessageReference;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.jms.JBossTopic;
+import org.jboss.messaging.jms.server.management.JMSMessageInfo;
+import org.jboss.messaging.jms.server.management.SubscriberInfo;
+import org.jboss.messaging.jms.server.management.TopicControlMBean;
+import org.jboss.messaging.util.Pair;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class TopicControl extends StandardMBean implements TopicControlMBean
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final JBossTopic managedTopic;
+   private final MessagingServerManagement server;
+   private final String binding;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public TopicControl(final JBossTopic topic,
+         final MessagingServerManagement server, final String jndiBinding)
+         throws NotCompliantMBeanException
+   {
+      super(TopicControlMBean.class);
+      this.managedTopic = topic;
+      this.server = server;
+      this.binding = jndiBinding;
+   }
+
+   // Public --------------------------------------------------------
+
+   // StandardMBean overrides ---------------------------------------
+
+   /**
+    * overrides getMBeanInfo to add operations info using annotations
+    * 
+    * @see Operation
+    * @see Parameter
+    */
+   @Override
+   public MBeanInfo getMBeanInfo()
+   {
+      MBeanInfo info = super.getMBeanInfo();
+      return new MBeanInfo(info.getClassName(), info.getDescription(), info
+            .getAttributes(), info.getConstructors(), MBeanInfoHelper
+            .getMBeanOperationsInfo(TopicControlMBean.class), info
+            .getNotifications());
+   }
+
+   // TopicControlMBean implementation ------------------------------
+
+   public String getName()
+   {
+      return managedTopic.getName();
+   }
+
+   public boolean isTemporary()
+   {
+      return managedTopic.isTemporary();
+   }
+
+   public String getAddress()
+   {
+      return managedTopic.getAddress();
+   }
+
+   public String getJNDIBinding()
+   {
+      return binding;
+   }
+
+   public int getMessageCount()
+   {
+      return getMessageCount(DurabilityType.ALL);
+   }
+
+   public int getDurableMessageCount()
+   {
+      return getMessageCount(DurabilityType.DURABLE);
+   }
+
+   public int getNonDurableMessageCount()
+   {
+      return getMessageCount(DurabilityType.NON_DURABLE);
+   }
+
+   public int getSubcribersCount()
+   {
+      return getQueues(DurabilityType.ALL).size();
+   }
+
+   public int getDurableSubcribersCount()
+   {
+      return getQueues(DurabilityType.DURABLE).size();
+   }
+
+   public int getNonDurableSubcribersCount()
+   {
+      return getQueues(DurabilityType.NON_DURABLE).size();
+   }
+
+   public TabularData listAllSubscribers()
+   {
+      return SubscriberInfo.toTabularData(listAllSubscriberInfos());
+   }
+
+   public TabularData listDurableSubscribers()
+   {
+      return SubscriberInfo.toTabularData(listDurableSubscriberInfos());
+   }
+
+   public TabularData listNonDurableSubscribers()
+   {
+      return SubscriberInfo.toTabularData(listNonDurableSubscriberInfos());
+   }
+
+   public SubscriberInfo[] listAllSubscriberInfos()
+   {
+      return listSubscribersInfos(DurabilityType.ALL);
+   }
+
+   public SubscriberInfo[] listDurableSubscriberInfos()
+   {
+      return listSubscribersInfos(DurabilityType.DURABLE);
+   }
+
+   public SubscriberInfo[] listNonDurableSubscriberInfos()
+   {
+      return listSubscribersInfos(DurabilityType.NON_DURABLE);
+   }
+
+   public TabularData listMessagesForSubscriber(final String subscriberID)
+         throws Exception
+   {
+      Queue queue = server.getQueue(new SimpleString(subscriberID));
+      List<MessageReference> messageRefs = queue.list(null);
+      List<JMSMessageInfo> infos = new ArrayList<JMSMessageInfo>(messageRefs
+            .size());
+
+      for (MessageReference messageRef : messageRefs)
+      {
+         ServerMessage message = messageRef.getMessage();
+         JMSMessageInfo info = JMSMessageInfo.fromServerMessage(message);
+         infos.add(info);
+      }
+      return JMSMessageInfo.toTabularData(infos);
+   }
+
+   public void removeAllMessages() throws Exception
+   {
+      server.removeAllMessagesForAddress(managedTopic.getSimpleAddress());
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   private SubscriberInfo[] listSubscribersInfos(final DurabilityType durability)
+   {
+      List<Queue> queues = getQueues(durability);
+      List<SubscriberInfo> subInfos = new ArrayList<SubscriberInfo>(queues
+            .size());
+      for (Queue queue : queues)
+      {
+         String clientID = null;
+         String subName = null;
+
+         if (queue.isDurable())
+         {
+            Pair<String, String> pair = JBossTopic
+                  .decomposeQueueNameForDurableSubscription(queue.getName()
+                        .toString());
+            clientID = pair.a;
+            subName = pair.b;
+         }
+
+         String filter = queue.getFilter() != null ? queue.getFilter()
+               .getFilterString().toString() : null;
+         SubscriberInfo info = new SubscriberInfo(queue.getName().toString(),
+               clientID, subName, queue.isDurable(), filter, queue
+                     .getMessageCount(), queue.getMaxSizeBytes());
+         subInfos.add(info);
+      }
+      return (SubscriberInfo[]) subInfos.toArray(new SubscriberInfo[subInfos
+            .size()]);
+   }
+
+   private int getMessageCount(final DurabilityType durability)
+   {
+      List<Queue> queues = getQueues(durability);
+      int count = 0;
+      for (Queue queue : queues)
+      {
+         count += queue.getMessageCount();
+      }
+      return count;
+   }
+
+   private List<Queue> getQueues(final DurabilityType durability)
+   {
+      try
+      {
+         List<Queue> queues = server.getQueuesForAddress(managedTopic
+               .getSimpleAddress());
+         List<Queue> matchingQueues = new ArrayList<Queue>();
+         for (Queue queue : queues)
+         {
+            if (durability == DurabilityType.ALL
+                  || (durability == DurabilityType.DURABLE && queue.isDurable())
+                  || (durability == DurabilityType.NON_DURABLE && !queue
+                        .isDurable()))
+            {
+               matchingQueues.add(queue);
+            }
+         }
+         return matchingQueues;
+      } catch (Exception e)
+      {
+         e.printStackTrace();
+         return Collections.emptyList();
+      }
+   }
+
+   // Inner classes -------------------------------------------------
+
+   private enum DurabilityType
+   {
+      ALL, DURABLE, NON_DURABLE
+   }
+}

Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/JBMServerTestCase.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/JBMServerTestCase.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/JBMServerTestCase.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -39,8 +39,11 @@
 
 import org.jboss.messaging.core.security.Role;
 import org.jboss.messaging.core.server.MessagingServer;
+import org.jboss.messaging.jms.JBossQueue;
+import org.jboss.messaging.jms.JBossTopic;
 import org.jboss.messaging.jms.client.JBossConnectionFactory;
 import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.management.SubscriberInfo;
 import org.jboss.test.messaging.tools.ServerManagement;
 import org.jboss.test.messaging.tools.container.DatabaseClearer;
 import org.jboss.test.messaging.tools.container.Server;
@@ -584,11 +587,11 @@
    {
       if (isQueue)
       {
-         servers.get(server).removeAllMessagesForQueue(destName);
+         servers.get(server).removeAllMessages(new JBossQueue(destName));
       }
       else
       {
-         servers.get(server).removeAllMessagesForTopic(destName);
+         servers.get(server).removeAllMessages(new JBossTopic(destName));
       }
    }
 
@@ -795,9 +798,9 @@
       servers.get(server).undeployConnectionFactory(objectName);
    }
 
-   protected List listAllSubscriptionsForTopic(String s) throws Exception
+   protected List<SubscriberInfo> listAllSubscribersForTopic(String s) throws Exception
    {
-      return servers.get(0).listAllSubscriptionsForTopic(s);
+      return servers.get(0).listAllSubscribersForTopic(s);
    }
 
    protected Integer getMessageCountForQueue(String s) throws Exception

Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -36,7 +36,7 @@
 import javax.jms.Topic;
 import javax.jms.TopicSubscriber;
 
-import org.jboss.messaging.jms.server.SubscriptionInfo;
+import org.jboss.messaging.jms.server.management.SubscriberInfo;
 
 
 /**
@@ -81,13 +81,13 @@
 	
 	      s.createDurableSubscriber(topic1, "monicabelucci");
 
-	      List subs = listAllSubscriptionsForTopic("Topic1");
+	      List<SubscriberInfo> subs = listAllSubscribersForTopic("Topic1");
 	      
 	      assertNotNull(subs);
 	      
 	      assertEquals(1, subs.size());
 	      
-	      SubscriptionInfo info = (SubscriptionInfo)subs.get(0);
+	      SubscriberInfo info = subs.get(0);
 	
 	      assertEquals("monicabelucci", info.getName());
 	
@@ -95,11 +95,11 @@
 	
 	      conn.close();
 	
-	      subs = listAllSubscriptionsForTopic("Topic1");
+	      subs = listAllSubscribersForTopic("Topic1");
 	
 	      assertEquals(1, subs.size());
 	      
-	      info = (SubscriptionInfo)subs.get(0);
+	      info = subs.get(0);
 	
 	      assertEquals("monicabelucci", info.getName());
 	

Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -22,15 +22,18 @@
 package org.jboss.test.messaging.tools.container;
 
 import java.io.File;
+import java.lang.management.ManagementFactory;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 
+import javax.management.MBeanServerInvocationHandler;
 import javax.management.NotificationListener;
 import javax.management.ObjectName;
 import javax.naming.InitialContext;
@@ -43,7 +46,12 @@
 import org.jboss.messaging.core.security.Role;
 import org.jboss.messaging.core.server.MessagingServer;
 import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.jms.JBossDestination;
 import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.management.JMSQueueControlMBean;
+import org.jboss.messaging.jms.server.management.SubscriberInfo;
+import org.jboss.messaging.jms.server.management.TopicControlMBean;
+import org.jboss.messaging.jms.server.management.impl.JMSManagementServiceImpl;
 import org.jboss.messaging.microcontainer.JBMBootstrapServer;
 import org.jboss.messaging.util.SimpleString;
 import org.jboss.test.messaging.tools.ConfigurationHelper;
@@ -529,14 +537,14 @@
 
    public void configureSecurityForDestination(String destName, boolean isQueue, Set<Role> roles) throws Exception
    {
-      String prefix = isQueue ? "queuejms." : "topicjms.";
+      SimpleString destination = new SimpleString((isQueue ? "queuejms." : "topicjms.") + destName);
       if (roles != null)
       {
-         getMessagingServer().getServerManagement().setSecurityForAddress(prefix + destName, roles);
+         getMessagingServer().getServerManagement().setSecurityForAddress(destination, roles);
       }
       else
       {
-         getMessagingServer().getServerManagement().removeSecurityForAddress(prefix + destName);
+         getMessagingServer().getServerManagement().removeSecurityForAddress(destination);
       }
    }
 
@@ -630,40 +638,40 @@
 
    public Integer getMessageCountForQueue(String queueName) throws Exception
    {
-      return getJMSServerManager().getMessageCountForQueue(queueName);
+      ObjectName objectName = JMSManagementServiceImpl.getJMSQueueObjectName(queueName);
+      JMSQueueControlMBean queue = (JMSQueueControlMBean) MBeanServerInvocationHandler.newProxyInstance(
+            ManagementFactory.getPlatformMBeanServer(), objectName, JMSQueueControlMBean.class, false);
+      return queue.getMessageCount();
    }
 
-   public void removeAllMessagesForQueue(String destName) throws Exception
+   public void removeAllMessages(JBossDestination destination) throws Exception
    {
-      getJMSServerManager().removeAllMessagesForQueue(destName);
+      getJMSServerManager().removeAllMessages(destination);
    }
 
-   public void removeAllMessagesForTopic(String destName) throws Exception
+   public List<SubscriberInfo> listAllSubscribersForTopic(String s) throws Exception
    {
-      getJMSServerManager().removeAllMessagesForTopic(destName);
+      ObjectName objectName = JMSManagementServiceImpl.getJMSTopicObjectName(s);
+      TopicControlMBean topic = (TopicControlMBean) MBeanServerInvocationHandler.newProxyInstance(
+            ManagementFactory.getPlatformMBeanServer(), objectName, TopicControlMBean.class, false);
+      return Arrays.asList(topic.listAllSubscriberInfos());
    }
 
 
-   public List listAllSubscriptionsForTopic(String s) throws Exception
-   {
-      return getJMSServerManager().listSubscriptions(s);
-   }
-
-
    public Set<Role> getSecurityConfig() throws Exception
    {
-      return getMessagingServer().getServerManagement().getSecurityForAddress("*");
+      return getMessagingServer().getServerManagement().getSecurityForAddress(new SimpleString("*"));
    }
 
    public void setSecurityConfig(Set<Role> defConfig) throws Exception
    {
-      getMessagingServer().getServerManagement().removeSecurityForAddress("*");
-      getMessagingServer().getServerManagement().setSecurityForAddress("*", defConfig);      
+      getMessagingServer().getServerManagement().removeSecurityForAddress(new SimpleString("*"));
+      getMessagingServer().getServerManagement().setSecurityForAddress(new SimpleString("*"), defConfig);      
    }
 
    public void setRedeliveryDelayOnDestination(String dest, boolean queue, long delay) throws Exception
    {
-      String condition = (queue ? "queuejms." : "topicjms.") + dest;
+      SimpleString condition = new SimpleString((queue ? "queuejms." : "topicjms.") + dest);
       QueueSettings queueSettings = new QueueSettings();
       queueSettings.setRedeliveryDelay(delay);
       getMessagingServer().getServerManagement().setQueueAttributes(condition, queueSettings);      

Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -21,9 +21,11 @@
   */
 package org.jboss.test.messaging.tools.container;
 
+import java.lang.management.ManagementFactory;
 import java.rmi.registry.LocateRegistry;
 import java.rmi.registry.Registry;
 import java.rmi.server.UnicastRemoteObject;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Hashtable;
@@ -31,6 +33,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import javax.management.MBeanServerInvocationHandler;
 import javax.management.NotificationListener;
 import javax.management.ObjectName;
 import javax.naming.InitialContext;
@@ -40,7 +43,12 @@
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.security.Role;
 import org.jboss.messaging.core.server.MessagingServer;
+import org.jboss.messaging.jms.JBossDestination;
 import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.management.JMSQueueControlMBean;
+import org.jboss.messaging.jms.server.management.SubscriberInfo;
+import org.jboss.messaging.jms.server.management.TopicControlMBean;
+import org.jboss.messaging.jms.server.management.impl.JMSManagementServiceImpl;
 
 /**
  * An RMI wrapper to access the ServiceContainer from a different address space.
@@ -450,26 +458,26 @@
       return server.getJMSServerManager();
    }
 
-   public void removeAllMessagesForQueue(String destName) throws Exception
+   public void removeAllMessages(JBossDestination destination) throws Exception
    {
-      server.removeAllMessagesForQueue(destName);
+      server.removeAllMessages(destination);
    }
 
-   public void removeAllMessagesForTopic(String destName) throws Exception
-   {
-      server.removeAllMessagesForTopic(destName);
-   }
-
-
    public Integer getMessageCountForQueue(String queueName) throws Exception
    {
-      return getJMSServerManager().getMessageCountForQueue(queueName);
+      ObjectName objectName = JMSManagementServiceImpl.getJMSQueueObjectName(queueName);
+      JMSQueueControlMBean queue = (JMSQueueControlMBean) MBeanServerInvocationHandler.newProxyInstance(
+            ManagementFactory.getPlatformMBeanServer(), objectName, JMSQueueControlMBean.class, false);
+      return queue.getMessageCount();
    }
 
 
-   public List listAllSubscriptionsForTopic(String s) throws Exception
+   public List<SubscriberInfo> listAllSubscribersForTopic(String s) throws Exception
    {
-      return server.listAllSubscriptionsForTopic(s);
+      ObjectName objectName = JMSManagementServiceImpl.getJMSTopicObjectName(s);
+      TopicControlMBean topic = (TopicControlMBean) MBeanServerInvocationHandler.newProxyInstance(
+            ManagementFactory.getPlatformMBeanServer(), objectName, TopicControlMBean.class, false);
+      return Arrays.asList(topic.listAllSubscriberInfos());
    }
 
 

Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/Server.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/Server.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/Server.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -34,7 +34,9 @@
 import org.jboss.kernel.spi.deployment.KernelDeployment;
 import org.jboss.messaging.core.security.Role;
 import org.jboss.messaging.core.server.MessagingServer;
+import org.jboss.messaging.jms.JBossDestination;
 import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.management.SubscriberInfo;
 
 /**
  * The remote interface exposed by TestServer.
@@ -254,13 +256,11 @@
 
    InitialContext getInitialContext() throws Exception;
 
-   void removeAllMessagesForQueue(String destName) throws Exception;
+   void removeAllMessages(JBossDestination destination) throws Exception;
 
-   void removeAllMessagesForTopic(String destName) throws Exception;
-
    Integer getMessageCountForQueue(String queueName) throws Exception;
 
-   List listAllSubscriptionsForTopic(String s) throws Exception;
+   List<SubscriberInfo> listAllSubscribersForTopic(String s) throws Exception;
 
    Set<Role> getSecurityConfig() throws Exception;
 

Modified: trunk/tests/src/org/jboss/messaging/tests/performance/persistence/StorageManagerTimingTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/persistence/StorageManagerTimingTest.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/persistence/StorageManagerTimingTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -23,6 +23,7 @@
 package org.jboss.messaging.tests.performance.persistence;
 
 import java.io.File;
+import java.lang.management.ManagementFactory;
 import java.nio.ByteBuffer;
 import java.util.HashMap;
 import java.util.concurrent.atomic.AtomicLong;
@@ -30,6 +31,7 @@
 import org.jboss.messaging.core.asyncio.impl.AsynchronousFileImpl;
 import org.jboss.messaging.core.config.impl.FileConfiguration;
 import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.management.impl.ManagementServiceImpl;
 import org.jboss.messaging.core.persistence.impl.journal.JournalStorageManager;
 import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
 import org.jboss.messaging.core.remoting.impl.mina.IoBufferWrapper;
@@ -127,7 +129,7 @@
       
       configuration.setJournalType(journalType);
       
-      final JournalStorageManager journal = new JournalStorageManager(configuration);
+      final JournalStorageManager journal = new JournalStorageManager(configuration, new ManagementServiceImpl(ManagementFactory.getPlatformMBeanServer(), false));
       journal.start();
       
       FakePostOffice office = new FakePostOffice();

Copied: trunk/tests/src/org/jboss/messaging/tests/unit/core/management/MessageInfoTest.java (from rev 4779, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/MessageInfoTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/management/MessageInfoTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/management/MessageInfoTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.unit.core.management;
+
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomByte;
+import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
+import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.util.Collection;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.management.MessageInfo;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class MessageInfoTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   private static void assertEquals(MessageInfo expected, CompositeData actual)
+   {
+      assertTrue(actual.getCompositeType().equals(MessageInfo.TYPE));
+
+      assertEquals(expected.getID(), actual.get("id"));
+      assertEquals(expected.getDestination(), actual.get("destination"));
+      assertEquals(expected.isDurable(), actual.get("durable"));
+      assertEquals(expected.getTimestamp(), actual.get("timestamp"));
+      assertEquals(expected.getType(), actual.get("type"));
+      assertEquals(expected.getSize(), actual.get("size"));
+      assertEquals(expected.getPriority(), actual.get("priority"));
+      assertEquals(expected.isExpired(), actual.get("expired"));
+      assertEquals(expected.getExpiration(), actual.get("expiration"));
+      
+      TabularData propsDatas = (TabularData) actual.get("properties");
+      Collection<CompositeData> props = propsDatas.values();
+      assertEquals(expected.getProperties().size(), props.size());
+      for (CompositeData prop : props)
+      {
+         String actualKey = (String) prop.get("key");
+         String actualValue = (String) prop.get("value");
+         
+         assertTrue(expected.getProperties().containsKey(actualKey));
+         assertEquals(expected.getProperties().get(actualKey), actualValue);
+      }
+   }
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testToCompositeData() throws Exception
+   {
+      MessageInfo info = new MessageInfo(randomLong(), randomString(),
+            randomBoolean(), randomLong(), randomByte(), randomInt(),
+            randomByte(), randomBoolean(), randomLong());
+      CompositeData data = info.toCompositeData();
+
+      assertEquals(info, data);
+   }
+
+   public void testToTabularData() throws Exception
+   {
+      MessageInfo info_1 = new MessageInfo(randomLong(), randomString(),
+            randomBoolean(), randomLong(), randomByte(), randomInt(),
+            randomByte(), randomBoolean(), randomLong());
+      info_1.putProperty(randomString(), randomString());
+      info_1.putProperty(randomString(), randomString());
+      MessageInfo info_2 = new MessageInfo(randomLong(), randomString(),
+            randomBoolean(), randomLong(), randomByte(), randomInt(),
+            randomByte(), randomBoolean(), randomLong());
+      info_2.putProperty(randomString(), randomString());
+      MessageInfo[] messages = new MessageInfo[] { info_1, info_2 };
+
+      TabularData data = MessageInfo.toTabularData(messages);
+      assertEquals(2, data.size());
+      CompositeData data_1 = data.get(new Object[] { info_1.getID() });
+      CompositeData data_2 = data.get(new Object[] { info_2.getID() });
+
+      assertEquals(info_1, data_1);
+      assertEquals(info_2, data_2);
+   }
+
+   public void testToTabularDataWithEmptyMessages() throws Exception
+   {
+      TabularData data = MessageInfo.toTabularData(new MessageInfo[0]);
+      assertEquals(0, data.size());
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/tests/src/org/jboss/messaging/tests/unit/core/management/RoleInfoTest.java (from rev 4779, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/RoleInfoTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/management/RoleInfoTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/management/RoleInfoTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.unit.core.management;
+
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.management.RoleInfo;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class RoleInfoTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   private static void assertEquals(RoleInfo expected, CompositeData actual)
+   {
+      assertTrue(actual.getCompositeType().equals(RoleInfo.TYPE));
+
+      assertEquals(expected.getName(), actual.get("name"));
+      assertEquals(expected.isCreate(), actual.get("create"));
+      assertEquals(expected.isRead(), actual.get("read"));
+      assertEquals(expected.isWrite(), actual.get("write"));
+   }
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testToCompositeData() throws Exception
+   {
+      String name = randomString();
+      boolean create = randomBoolean();
+      boolean read = randomBoolean();
+      boolean write = randomBoolean();
+
+      RoleInfo info = new RoleInfo(name, create, read, write);
+      CompositeData data = info.toCompositeData();
+
+      assertEquals(info, data);
+   }
+
+   public void testToTabularData() throws Exception
+   {
+      RoleInfo info_1 = new RoleInfo(randomString(), randomBoolean(),
+            randomBoolean(), randomBoolean());
+      RoleInfo info_2 = new RoleInfo(randomString(), randomBoolean(),
+            randomBoolean(), randomBoolean());
+      RoleInfo[] roles = new RoleInfo[] { info_1, info_2 };
+
+      TabularData data = RoleInfo.toTabularData(roles);
+      assertEquals(2, data.size());
+      CompositeData data_1 = data.get(new String[] { info_1.getName() });
+      CompositeData data_2 = data.get(new String[] { info_2.getName() });
+
+      assertEquals(info_1, data_1);
+      assertEquals(info_2, data_2);
+   }
+
+   public void testToTabularDataWithEmptyRoles() throws Exception
+   {
+      TabularData data = RoleInfo.toTabularData(new RoleInfo[0]);
+      assertEquals(0, data.size());
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/AddressControlTest.java (from rev 4779, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/impl/AddressControlTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/AddressControlTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/AddressControlTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,270 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.unit.core.management.impl;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.management.MessagingServerManagement;
+import org.jboss.messaging.core.management.RoleInfo;
+import org.jboss.messaging.core.management.impl.AddressControl;
+import org.jboss.messaging.core.security.CheckType;
+import org.jboss.messaging.core.security.Role;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class AddressControlTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   private static void assertRoleEquals(Role expected, RoleInfo actual)
+   {
+      assertEquals(expected.getName(), actual.getName());
+      assertEquals(expected.isCheckType(CheckType.CREATE), actual.isCreate());
+      assertEquals(expected.isCheckType(CheckType.READ), actual.isRead());
+      assertEquals(expected.isCheckType(CheckType.WRITE), actual.isWrite());
+   }
+
+   private static void assertRoleEquals(Role expected, CompositeData actual)
+   {
+      assertTrue(actual.getCompositeType().equals(RoleInfo.TYPE));
+
+      assertEquals(expected.getName(), actual.get("name"));
+      assertEquals(expected.isCheckType(CheckType.CREATE), actual.get("create"));
+      assertEquals(expected.isCheckType(CheckType.READ), actual.get("read"));
+      assertEquals(expected.isCheckType(CheckType.WRITE), actual.get("write"));
+   }
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testGetAddress() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+
+      replay(server);
+
+      AddressControl control = new AddressControl(address, server);
+      assertEquals(address.toString(), control.getAddress());
+
+      verify(server);
+   }
+
+   public void testGetQueueNames() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      List<Queue> queues = new ArrayList<Queue>();
+      Queue queue_1 = createMock(Queue.class);
+      expect(queue_1.getName()).andStubReturn(randomSimpleString());
+      Queue queue_2 = createMock(Queue.class);
+      expect(queue_2.getName()).andStubReturn(randomSimpleString());
+      queues.add(queue_1);
+      queues.add(queue_2);
+      expect(server.getQueuesForAddress(address)).andReturn(queues);
+
+      replay(server, queue_1, queue_2);
+
+      AddressControl control = new AddressControl(address, server);
+      String[] queueNames = control.getQueueNames();
+      assertEquals(2, queueNames.length);
+      assertEquals(queue_1.getName().toString(), queueNames[0]);
+      assertEquals(queue_2.getName().toString(), queueNames[1]);
+
+      verify(server, queue_1, queue_2);
+   }
+
+   public void testGetRoleInfos() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Set<Role> roles = new HashSet<Role>();
+      Role role_1 = new Role(randomString(), randomBoolean(), randomBoolean(),
+            randomBoolean());
+      Role role_2 = new Role(randomString(), randomBoolean(), randomBoolean(),
+            randomBoolean());
+      roles.add(role_1);
+      roles.add(role_2);
+      expect(server.getSecurityForAddress(address)).andReturn(roles);
+
+      replay(server);
+
+      AddressControl control = new AddressControl(address, server);
+      RoleInfo[] infos = control.getRoleInfos();
+      assertEquals(2, infos.length);
+      if (infos[0].getName().equals(role_1.getName()))
+      {
+         assertRoleEquals(role_1, infos[0]);
+         assertRoleEquals(role_2, infos[1]);
+      } else
+      {
+         assertRoleEquals(role_2, infos[0]);
+         assertRoleEquals(role_1, infos[1]);
+      }
+
+      verify(server);
+   }
+
+   public void testGetRoles() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Set<Role> roles = new HashSet<Role>();
+      Role role_1 = new Role(randomString(), randomBoolean(), randomBoolean(),
+            randomBoolean());
+      Role role_2 = new Role(randomString(), randomBoolean(), randomBoolean(),
+            randomBoolean());
+      roles.add(role_1);
+      roles.add(role_2);
+      expect(server.getSecurityForAddress(address)).andReturn(roles);
+
+      replay(server);
+
+      AddressControl control = new AddressControl(address, server);
+      TabularData data = control.getRoles();
+      assertEquals(2, data.size());
+      CompositeData roleData_1 = data.get(new Object[] { role_1.getName() });
+      CompositeData roleData_2 = data.get(new Object[] { role_2.getName() });
+      assertRoleEquals(role_1, roleData_1);
+      assertRoleEquals(role_2, roleData_2);
+
+      verify(server);
+   }
+
+   public void testAddRole() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      expect(server.getSecurityForAddress(address)).andReturn(
+            new HashSet<Role>());
+      server.setSecurityForAddress(eq(address), isA(Set.class));
+      replay(server);
+
+      AddressControl control = new AddressControl(address, server);
+      control.addRole(randomString(), randomBoolean(), randomBoolean(),
+            randomBoolean());
+
+      verify(server);
+   }
+
+   public void testAddRoleWhichAlreadExists() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Set<Role> roles = new HashSet<Role>();
+      Role role = new Role(randomString(), randomBoolean(), randomBoolean(),
+            randomBoolean());
+      roles.add(role);
+      expect(server.getSecurityForAddress(address)).andReturn(roles);
+
+      replay(server);
+
+      AddressControl control = new AddressControl(address, server);
+      try
+      {
+         control.addRole(role.getName(), role.isCheckType(CheckType.CREATE),
+               role.isCheckType(CheckType.READ), role
+                     .isCheckType(CheckType.WRITE));
+         fail("role already exists");
+      } catch (IllegalArgumentException e)
+      {
+      }
+
+      verify(server);
+   }
+
+   public void testRemoveRole() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Set<Role> roles = new HashSet<Role>();
+      Role role = new Role(randomString(), randomBoolean(), randomBoolean(),
+            randomBoolean());
+      roles.add(role);
+      expect(server.getSecurityForAddress(address)).andReturn(roles);
+      server.setSecurityForAddress(eq(address), isA(Set.class));
+      replay(server);
+
+      AddressControl control = new AddressControl(address, server);
+      control.removeRole(role.getName());
+
+      verify(server);
+   }
+
+   public void testRemoveRoleFromEmptySet() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      expect(server.getSecurityForAddress(address)).andReturn(
+            new HashSet<Role>());
+      replay(server);
+
+      AddressControl control = new AddressControl(address, server);
+      try
+      {
+         control.removeRole(randomString());
+         fail("role does not exisits");
+      } catch (IllegalArgumentException e)
+      {
+      }
+
+      verify(server);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/ManagementServiceImplTest.java (from rev 4779, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/impl/ManagementServiceImplTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/ManagementServiceImplTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/ManagementServiceImplTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,279 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.unit.core.management.impl;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.management.AddressControlMBean;
+import org.jboss.messaging.core.management.ManagementService;
+import org.jboss.messaging.core.management.MessagingServerControlMBean;
+import org.jboss.messaging.core.management.MessagingServerManagement;
+import org.jboss.messaging.core.management.QueueControlMBean;
+import org.jboss.messaging.core.management.impl.AddressControl;
+import org.jboss.messaging.core.management.impl.ManagementServiceImpl;
+import org.jboss.messaging.core.management.impl.MessagingServerControl;
+import org.jboss.messaging.core.management.impl.QueueControl;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class ManagementServiceImplTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testRegisterMessagingServer() throws Exception
+   {
+      ObjectName objectName = ManagementServiceImpl
+            .getMessagingServerObjectName();
+      ObjectInstance objectInstance = new ObjectInstance(objectName,
+            MessagingServerControl.class.getName());
+
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      Configuration configuration = createMock(Configuration.class);
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      expect(server.getConfiguration()).andReturn(configuration);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(false);
+      expect(
+            mbeanServer.registerMBean(isA(MessagingServerControlMBean.class),
+                  eq(objectName))).andReturn(objectInstance);
+
+      replay(mbeanServer, server);
+
+      ManagementService service = new ManagementServiceImpl(mbeanServer, true);
+      service.registerServer(server);
+
+      verify(mbeanServer, server);
+   }
+
+   public void testRegisterAlreadyRegisteredMessagingServer() throws Exception
+   {
+      ObjectName objectName = ManagementServiceImpl
+            .getMessagingServerObjectName();
+      ObjectInstance objectInstance = new ObjectInstance(objectName,
+            MessagingServerControl.class.getName());
+
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      Configuration configuration = createMock(Configuration.class);
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      expect(server.getConfiguration()).andReturn(configuration);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(true);
+      mbeanServer.unregisterMBean(objectName);
+      expect(
+            mbeanServer.registerMBean(isA(MessagingServerControlMBean.class),
+                  eq(objectName))).andReturn(objectInstance);
+
+      replay(mbeanServer, server);
+
+      ManagementService service = new ManagementServiceImpl(mbeanServer, true);
+      service.registerServer(server);
+
+      verify(mbeanServer, server);
+   }
+
+   public void testUnregisterMessagingServer() throws Exception
+   {
+      ObjectName objectName = ManagementServiceImpl
+            .getMessagingServerObjectName();
+
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(true);
+      mbeanServer.unregisterMBean(objectName);
+
+      replay(mbeanServer);
+
+      ManagementService service = new ManagementServiceImpl(mbeanServer, true);
+      service.unregisterServer();
+
+      verify(mbeanServer);
+   }
+
+   public void testRegisterAddress() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      ObjectName objectName = ManagementServiceImpl
+            .getAddressObjectName(address);
+      ObjectInstance objectInstance = new ObjectInstance(objectName,
+            AddressControl.class.getName());
+
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(false);
+      expect(
+            mbeanServer.registerMBean(isA(AddressControlMBean.class),
+                  eq(objectName))).andReturn(objectInstance);
+
+      replay(mbeanServer);
+
+      ManagementService service = new ManagementServiceImpl(mbeanServer, true);
+      service.registerAddress(address);
+
+      verify(mbeanServer);
+   }
+
+   public void testRegisterAlreadyRegisteredAddress() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      ObjectName objectName = ManagementServiceImpl
+            .getAddressObjectName(address);
+      ObjectInstance objectInstance = new ObjectInstance(objectName,
+            AddressControl.class.getName());
+
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(true);
+      mbeanServer.unregisterMBean(objectName);
+      expect(
+            mbeanServer.registerMBean(isA(AddressControlMBean.class),
+                  eq(objectName))).andReturn(objectInstance);
+
+      replay(mbeanServer);
+
+      ManagementService service = new ManagementServiceImpl(mbeanServer, true);
+      service.registerAddress(address);
+
+      verify(mbeanServer);
+   }
+
+   public void testUnregisterAddress() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      ObjectName objectName = ManagementServiceImpl
+            .getAddressObjectName(address);
+
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(true);
+      mbeanServer.unregisterMBean(objectName);
+
+      replay(mbeanServer);
+
+      ManagementService service = new ManagementServiceImpl(mbeanServer, true);
+      service.unregisterAddress(address);
+
+      verify(mbeanServer);
+   }
+
+   public void testRegisterQueue() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      SimpleString name = randomSimpleString();
+      ObjectName objectName = ManagementServiceImpl.getQueueObjectName(address,
+            name);
+      ObjectInstance objectInstance = new ObjectInstance(objectName,
+            QueueControl.class.getName());
+
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      Queue queue = createMock(Queue.class);
+      expect(queue.getName()).andStubReturn(name);
+      StorageManager storageManager = createMock(StorageManager.class);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(false);
+      expect(
+            mbeanServer.registerMBean(isA(QueueControlMBean.class),
+                  eq(objectName))).andReturn(objectInstance);
+
+      replay(mbeanServer, queue, storageManager);
+
+      ManagementService service = new ManagementServiceImpl(mbeanServer, true);
+      service.registerQueue(queue, address, storageManager);
+
+      verify(mbeanServer, queue, storageManager);
+   }
+
+   public void testRegisterAlreadyRegisteredQueue() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      SimpleString name = randomSimpleString();
+      ObjectName objectName = ManagementServiceImpl.getQueueObjectName(address,
+            name);
+      ObjectInstance objectInstance = new ObjectInstance(objectName,
+            QueueControl.class.getName());
+
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      Queue queue = createMock(Queue.class);
+      expect(queue.getName()).andStubReturn(name);
+      StorageManager storageManager = createMock(StorageManager.class);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(true);
+      mbeanServer.unregisterMBean(objectName);
+      expect(
+            mbeanServer.registerMBean(isA(QueueControlMBean.class),
+                  eq(objectName))).andReturn(objectInstance);
+
+      replay(mbeanServer, queue, storageManager);
+
+      ManagementService service = new ManagementServiceImpl(mbeanServer, true);
+      service.registerQueue(queue, address, storageManager);
+
+      verify(mbeanServer, queue, storageManager);
+   }
+
+   public void testUnregisterQueue() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      SimpleString name = randomSimpleString();
+      ObjectName objectName = ManagementServiceImpl.getQueueObjectName(address,
+            name);
+
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(true);
+      mbeanServer.unregisterMBean(objectName);
+
+      replay(mbeanServer);
+
+      ManagementService service = new ManagementServiceImpl(mbeanServer, true);
+      service.unregisterQueue(name, address);
+
+      verify(mbeanServer);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerControlTest.java (from rev 4779, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerControlTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerControlTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerControlTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,746 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.unit.core.management.impl;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
+import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+
+import javax.management.MBeanServer;
+import javax.management.Notification;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.client.Location;
+import org.jboss.messaging.core.client.impl.LocationImpl;
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.management.MessagingServerManagement;
+import org.jboss.messaging.core.management.impl.ManagementServiceImpl;
+import org.jboss.messaging.core.management.impl.MessagingServerControl;
+import org.jboss.messaging.core.management.impl.MessagingServerControl.NotificationType;
+import org.jboss.messaging.core.remoting.TransportType;
+import org.jboss.messaging.core.server.JournalType;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * t
+ * 
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class MessagingServerControlTest extends TestCase
+{
+   private MBeanServer mbeanServer;
+   private ObjectName serverON;
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   private static void assertGotNotification(NotificationType expectedType,
+         NotificationListenerWithLatch listener, CountDownLatch latch)
+         throws Exception
+   {
+      boolean gotNotification = latch.await(500, MILLISECONDS);
+      assertTrue(gotNotification);
+      Notification notification = listener.getNotification();
+      assertNotNull(notification);
+      assertEquals(expectedType.toString(), notification.getType());
+   }
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testIsStarted() throws Exception
+   {
+      boolean started = randomBoolean();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      expect(server.isStarted()).andStubReturn(started);
+      Configuration configuration = createMock(Configuration.class);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(started, control.isStarted());
+
+      verify(server, configuration);
+   }
+
+   public void testGetVersion() throws Exception
+   {
+      String version = randomString();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      expect(server.getVersion()).andStubReturn(version);
+      Configuration configuration = createMock(Configuration.class);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(version, control.getVersion());
+
+      verify(server, configuration);
+   }
+
+   public void testGetBindingsDirectory() throws Exception
+   {
+      String dir = randomString();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.getBindingsDirectory()).andReturn(dir);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(dir, control.getBindingsDirectory());
+
+      verify(server, configuration);
+   }
+
+   public void testGetInterceptorClassNames() throws Exception
+   {
+      List<String> list = new ArrayList<String>();
+      list.add(randomString());
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.getInterceptorClassNames()).andReturn(list);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(list, control.getInterceptorClassNames());
+
+      verify(server, configuration);
+   }
+
+   public void testGetJournalDirectory() throws Exception
+   {
+      String dir = randomString();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.getJournalDirectory()).andReturn(dir);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(dir, control.getJournalDirectory());
+
+      verify(server, configuration);
+   }
+
+   public void testGetJournalFileSize() throws Exception
+   {
+      int size = randomInt();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.getJournalFileSize()).andReturn(size);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(size, control.getJournalFileSize());
+
+      verify(server, configuration);
+   }
+
+   public void testGetJournalMaxAIO() throws Exception
+   {
+      int max = randomInt();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.getJournalMaxAIO()).andReturn(max);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(max, control.getJournalMaxAIO());
+
+      verify(server, configuration);
+   }
+
+   public void testGetJournalMinFiles() throws Exception
+   {
+      int minFiles = randomInt();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.getJournalMinFiles()).andReturn(minFiles);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(minFiles, control.getJournalMinFiles());
+
+      verify(server, configuration);
+   }
+
+   public void testGetJournalType() throws Exception
+   {
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.getJournalType()).andReturn(JournalType.ASYNCIO);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(JournalType.ASYNCIO.toString(), control.getJournalType());
+
+      verify(server, configuration);
+   }
+
+   public void testGetKeyStorePath() throws Exception
+   {
+      String path = randomString();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.getKeyStorePath()).andReturn(path);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(path, control.getKeyStorePath());
+
+      verify(server, configuration);
+   }
+
+   public void testGetLocation() throws Exception
+   {
+      Location location = new LocationImpl(TransportType.TCP, "localhost");
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.getLocation()).andReturn(location);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(location.toString(), control.getLocation());
+
+      verify(server, configuration);
+   }
+
+   public void testGetScheduledThreadPoolMaxSize() throws Exception
+   {
+      int size = randomInt();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.getScheduledThreadPoolMaxSize()).andReturn(size);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(size, control.getScheduledThreadPoolMaxSize());
+
+      verify(server, configuration);
+   }
+
+   public void testGetSecurityInvalidationInterval() throws Exception
+   {
+      long interval = randomLong();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.getSecurityInvalidationInterval()).andReturn(
+            interval);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(interval, control.getSecurityInvalidationInterval());
+
+      verify(server, configuration);
+   }
+
+   public void testGetTrustStorePath() throws Exception
+   {
+      String path = randomString();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.getTrustStorePath()).andReturn(path);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(path, control.getTrustStorePath());
+
+      verify(server, configuration);
+   }
+
+   public void testIsClustered() throws Exception
+   {
+      boolean clustered = randomBoolean();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.isClustered()).andReturn(clustered);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(clustered, control.isClustered());
+
+      verify(server, configuration);
+   }
+
+   public void testIsCreateBindingsDir() throws Exception
+   {
+      boolean createBindingsDir = randomBoolean();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.isCreateBindingsDir()).andReturn(createBindingsDir);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(createBindingsDir, control.isCreateBindingsDir());
+
+      verify(server, configuration);
+   }
+
+   public void testIsCreateJournalDir() throws Exception
+   {
+      boolean createJournalDir = randomBoolean();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.isCreateJournalDir()).andReturn(createJournalDir);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(createJournalDir, control.isCreateJournalDir());
+
+      verify(server, configuration);
+   }
+
+   public void testIsJournalSyncNonTransactional() throws Exception
+   {
+      boolean journalSyncNonTransactional = randomBoolean();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.isJournalSyncNonTransactional()).andReturn(
+            journalSyncNonTransactional);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(journalSyncNonTransactional, control
+            .isJournalSyncNonTransactional());
+
+      verify(server, configuration);
+   }
+
+   public void testIsJournalSyncTransactional() throws Exception
+   {
+      boolean journalSyncTransactional = randomBoolean();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.isJournalSyncTransactional()).andReturn(
+            journalSyncTransactional);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(journalSyncTransactional, control
+            .isJournalSyncTransactional());
+
+      verify(server, configuration);
+   }
+
+   public void testIsRequireDestinations() throws Exception
+   {
+      boolean requireDestinations = randomBoolean();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.isRequireDestinations()).andReturn(
+            requireDestinations);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(requireDestinations, control.isRequireDestinations());
+
+      verify(server, configuration);
+   }
+
+   public void testIsSSLEnabled() throws Exception
+   {
+      boolean sslEnabled = randomBoolean();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.isSSLEnabled()).andReturn(sslEnabled);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(sslEnabled, control.isSSLEnabled());
+
+      verify(server, configuration);
+   }
+
+   public void testIsSecurityEnabled() throws Exception
+   {
+      boolean securityEnabled = randomBoolean();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(configuration.isSecurityEnabled()).andReturn(securityEnabled);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(securityEnabled, control.isSecurityEnabled());
+
+      verify(server, configuration);
+   }
+
+   public void testAddDestination() throws Exception
+   {
+      String address = randomString();
+      boolean added = randomBoolean();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      expect(server.addDestination(new SimpleString(address))).andReturn(added);
+      Configuration configuration = createMock(Configuration.class);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      mbeanServer.registerMBean(control, serverON);
+
+      final CountDownLatch latch = new CountDownLatch(1);
+      NotificationListenerWithLatch listener = new NotificationListenerWithLatch(
+            latch);
+      mbeanServer.addNotificationListener(serverON, listener, null, null);
+
+      assertEquals(added, control.addAddress(address));
+
+      assertGotNotification(
+            MessagingServerControl.NotificationType.ADDRESS_ADDED, listener,
+            latch);
+
+      verify(server, configuration);
+
+      mbeanServer.removeNotificationListener(serverON, listener);
+
+      verify(server, configuration);
+   }
+
+   public void testRemoveAddress() throws Exception
+   {
+      String address = randomString();
+      boolean removed = randomBoolean();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      expect(server.removeDestination(new SimpleString(address))).andReturn(
+            removed);
+      Configuration configuration = createMock(Configuration.class);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      mbeanServer.registerMBean(control, serverON);
+
+      final CountDownLatch latch = new CountDownLatch(1);
+      NotificationListenerWithLatch listener = new NotificationListenerWithLatch(
+            latch);
+      mbeanServer.addNotificationListener(serverON, listener, null, null);
+
+      assertEquals(removed, control.removeAddress(address));
+
+      assertGotNotification(
+            MessagingServerControl.NotificationType.ADDRESS_REMOVED, listener,
+            latch);
+
+      verify(server, configuration);
+
+      mbeanServer.removeNotificationListener(serverON, listener);
+   }
+
+   public void testCreateQueue() throws Exception
+   {
+      String address = randomString();
+      String name = randomString();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      server.createQueue(new SimpleString(address), new SimpleString(name));
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      control.createQueue(address, name);
+
+      verify(server, configuration);
+   }
+
+   public void testCreateQueueAndReceiveNotification() throws Exception
+   {
+      String address = randomString();
+      String name = randomString();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      server.createQueue(new SimpleString(address), new SimpleString(name));
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      mbeanServer.registerMBean(control, serverON);
+
+      final CountDownLatch latch = new CountDownLatch(1);
+      NotificationListenerWithLatch listener = new NotificationListenerWithLatch(
+            latch);
+
+      mbeanServer.addNotificationListener(serverON, listener, null, null);
+      control.createQueue(address, name);
+
+      assertGotNotification(
+            MessagingServerControl.NotificationType.QUEUE_CREATED, listener,
+            latch);
+
+      verify(server, configuration);
+
+      mbeanServer.removeNotificationListener(serverON, listener);
+   }
+
+   public void testCreateQueueWithAllParameters() throws Exception
+   {
+      String address = randomString();
+      String name = randomString();
+      String filter = "color = 'green'";
+      boolean durable = true;
+      boolean temporary = false;
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      server.createQueue(new SimpleString(address), new SimpleString(name),
+            new SimpleString(filter), durable, temporary);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      control.createQueue(address, name, filter, durable, temporary);
+
+      verify(server, configuration);
+   }
+
+   public void testCreateQueueWithEmptyFilter() throws Exception
+   {
+      String address = randomString();
+      String name = randomString();
+      String filter = "";
+      boolean durable = true;
+      boolean temporary = false;
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      server.createQueue(new SimpleString(address), new SimpleString(name),
+            null, durable, temporary);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      control.createQueue(address, name, filter, durable, temporary);
+
+      verify(server, configuration);
+   }
+
+   public void testCreateQueueWithNullFilter() throws Exception
+   {
+      String address = randomString();
+      String name = randomString();
+      String filter = null;
+      boolean durable = true;
+      boolean temporary = false;
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      server.createQueue(new SimpleString(address), new SimpleString(name),
+            null, durable, temporary);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      control.createQueue(address, name, filter, durable, temporary);
+
+      verify(server, configuration);
+   }
+
+   public void testCreateQueueWithBothDurableAndTemporarySetToTrueFails()
+         throws Exception
+   {
+      String address = randomString();
+      String name = randomString();
+      boolean durable = true;
+      boolean temporary = true;
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      try
+      {
+         control.createQueue(address, name, null, durable, temporary);
+         fail("a queue can not be both durable and temporary");
+      } catch (IllegalArgumentException e)
+      {
+      }
+
+      verify(server, configuration);
+   }
+
+   public void testDestroyQueueAndReceiveNotification() throws Exception
+   {
+      String name = randomString();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      server.destroyQueue(new SimpleString(name));
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      mbeanServer.registerMBean(control, serverON);
+
+      final CountDownLatch latch = new CountDownLatch(1);
+      NotificationListenerWithLatch listener = new NotificationListenerWithLatch(
+            latch);
+
+      mbeanServer.addNotificationListener(serverON, listener, null, null);
+      control.destroyQueue(name);
+
+      assertGotNotification(
+            MessagingServerControl.NotificationType.QUEUE_DESTROYED, listener,
+            latch);
+
+      verify(server, configuration);
+
+      mbeanServer.removeNotificationListener(serverON, listener);
+   }
+
+   public void testGetConnectionCount() throws Exception
+   {
+      int count = randomInt();
+
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Configuration configuration = createMock(Configuration.class);
+      expect(server.getConnectionCount()).andReturn(count);
+      replay(server, configuration);
+
+      MessagingServerControl control = new MessagingServerControl(server,
+            configuration);
+      assertEquals(count, control.getConnectionCount());
+
+      verify(server, configuration);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      mbeanServer = ManagementFactory.getPlatformMBeanServer();
+      serverON = ManagementServiceImpl.getMessagingServerObjectName();
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      if (mbeanServer.isRegistered(serverON))
+      {
+         mbeanServer.unregisterMBean(serverON);
+      }
+
+      serverON = null;
+      mbeanServer = null;
+
+      super.tearDown();
+   }
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+   private final class NotificationListenerWithLatch implements
+         NotificationListener
+   {
+      private final CountDownLatch latch;
+      private Notification notification;
+
+      private NotificationListenerWithLatch(CountDownLatch latch)
+      {
+         this.latch = latch;
+      }
+
+      public void handleNotification(Notification notification, Object handback)
+      {
+         this.notification = notification;
+         latch.countDown();
+      }
+
+      public Notification getNotification()
+      {
+         return notification;
+      }
+   }
+
+}

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerManagementImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerManagementImplTest.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerManagementImplTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -22,20 +22,37 @@
 
 package org.jboss.messaging.tests.unit.core.management.impl;
 
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
+import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
 import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 import org.easymock.EasyMock;
 import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.filter.impl.FilterImpl;
 import org.jboss.messaging.core.management.impl.MessagingServerManagementImpl;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.Binding;
 import org.jboss.messaging.core.postoffice.PostOffice;
 import org.jboss.messaging.core.security.Role;
+import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.MessagingServer;
 import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.settings.HierarchicalRepository;
 import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.core.version.Version;
 import org.jboss.messaging.tests.util.RandomUtil;
 import org.jboss.messaging.tests.util.UnitTestCase;
 import org.jboss.messaging.util.SimpleString;
@@ -43,37 +60,40 @@
 /**
  * 
  * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
- *
+ * 
  */
 public class MessagingServerManagementImplTest extends UnitTestCase
 {
    // Constants -----------------------------------------------------
-   
+
    // Attributes ----------------------------------------------------
-   
+
    private PostOffice mockPostOffice;
    private StorageManager mockStorageManager;
    private Configuration mockConfiguration;
    private HierarchicalRepository<Set<Role>> mockSecurityRepository;
    private HierarchicalRepository<QueueSettings> mockQueueSettingsRepository;
    private MessagingServer mockServer;
+
    // Static --------------------------------------------------------
-   
+
    // Constructors --------------------------------------------------
-   
+
    // Public --------------------------------------------------------
-   
+
    public void setUp() throws Exception
    {
       super.setUp();
-      
+
       mockPostOffice = EasyMock.createNiceMock(PostOffice.class);
       mockStorageManager = EasyMock.createNiceMock(StorageManager.class);
       mockConfiguration = EasyMock.createNiceMock(Configuration.class);
-      mockSecurityRepository = EasyMock.createNiceMock(HierarchicalRepository.class);
-      mockQueueSettingsRepository = EasyMock.createNiceMock(HierarchicalRepository.class);
+      mockSecurityRepository = EasyMock
+            .createNiceMock(HierarchicalRepository.class);
+      mockQueueSettingsRepository = EasyMock
+            .createNiceMock(HierarchicalRepository.class);
       mockServer = EasyMock.createNiceMock(MessagingServer.class);
-      
+
    }
 
    public void testcreateQueue() throws Exception
@@ -84,219 +104,624 @@
       mockPostOffice = EasyMock.createMock(PostOffice.class);
 
       EasyMock.expect(mockPostOffice.getBinding(name)).andReturn(null);
-      
-      EasyMock.expect(mockPostOffice.addBinding(destination, name, null, true, false)).andReturn(null);
-      
+
+      EasyMock.expect(
+            mockPostOffice.addBinding(destination, name, null, true, false))
+            .andReturn(null);
+
       EasyMock.replay(mockPostOffice);
-      
+
       MessagingServerManagementImpl impl = createImpl();
-      
+
       impl.createQueue(destination, name);
-      
+
       EasyMock.verify(mockPostOffice);
 
       EasyMock.reset(mockPostOffice);
-      
-      EasyMock.expect(mockPostOffice.getBinding(name)).andReturn(EasyMock.createNiceMock(Binding.class));
-      
+
+      EasyMock.expect(mockPostOffice.getBinding(name)).andReturn(
+            EasyMock.createNiceMock(Binding.class));
+
       EasyMock.replay(mockPostOffice);
 
       impl.createQueue(destination, name);
-      
+
       EasyMock.verify(mockPostOffice);
-      
+
    }
 
+   public void testCreateQueueWithFullParameters() throws Exception
+   {
+      SimpleString destination = RandomUtil.randomSimpleString();
+      SimpleString name = RandomUtil.randomSimpleString();
+      SimpleString filterStr = new SimpleString("color = 'green'");
+      boolean durable = false;
+      boolean temporary = true;
+
+      mockPostOffice = EasyMock.createMock(PostOffice.class);
+
+      EasyMock.expect(mockPostOffice.getBinding(name)).andReturn(null);
+
+      EasyMock.expect(
+            mockPostOffice.addBinding(eq(destination), eq(name),
+                  isA(Filter.class), eq(durable), eq(temporary))).andReturn(
+            null);
+
+      EasyMock.replay(mockPostOffice);
+
+      MessagingServerManagementImpl impl = createImpl();
+
+      impl.createQueue(destination, name, filterStr, durable, temporary);
+
+      EasyMock.verify(mockPostOffice);
+
+      EasyMock.reset(mockPostOffice);
+
+      EasyMock.expect(mockPostOffice.getBinding(name)).andReturn(
+            EasyMock.createNiceMock(Binding.class));
+
+      EasyMock.replay(mockPostOffice);
+
+      impl.createQueue(destination, name, filterStr, durable, temporary);
+
+      EasyMock.verify(mockPostOffice);
+
+   }
+
    public void testConnectionCount() throws Exception
    {      
       MessagingServerManagementImpl impl = createImpl();
-      
+
       assertEquals(impl.getConnectionCount(), 0);      
    }
-   
+
    public void testDestroyQueue() throws Exception
    {
       SimpleString name = RandomUtil.randomSimpleString();
-      
+
       mockPostOffice = EasyMock.createMock(PostOffice.class);
-      
+
       Binding binding = EasyMock.createMock(Binding.class);
-      
+
       Queue queue = EasyMock.createMock(Queue.class);
 
-      
       EasyMock.expect(mockPostOffice.getBinding(name)).andReturn(binding);
       EasyMock.expect(binding.getQueue()).andReturn(queue);
-      
+
       queue.deleteAllReferences(mockStorageManager);
-      
-      
+
       EasyMock.expect(queue.getName()).andReturn(name).atLeastOnce();
-      
+
       EasyMock.expect(mockPostOffice.removeBinding(name)).andReturn(binding);
-      
+
       EasyMock.replay(mockPostOffice, binding, queue);
-      
+
       MessagingServerManagementImpl impl = createImpl();
-      
+
       impl.destroyQueue(name);
-      
+
       EasyMock.verify(mockPostOffice, binding, queue);
-      
+
       EasyMock.reset(mockPostOffice, binding, queue);
-      
+
       EasyMock.expect(mockPostOffice.getBinding(name)).andReturn(null);
-      
+
       EasyMock.replay(mockPostOffice, binding, queue);
 
       impl.destroyQueue(name);
-      
+
       EasyMock.verify(mockPostOffice, binding, queue);
-      
+
    }
-   
+
    public void testAddDestination() throws Exception
    {
       SimpleString address = RandomUtil.randomSimpleString();
-      
+
       mockPostOffice = EasyMock.createMock(PostOffice.class);
-      
-      EasyMock.expect(mockPostOffice.addDestination(address, false)).andReturn(false);
-      
+
+      EasyMock.expect(mockPostOffice.addDestination(address, false)).andReturn(
+            false);
+
       EasyMock.replay(mockPostOffice);
-      
+
       MessagingServerManagementImpl impl = createImpl();
       assertFalse(impl.addDestination(address));
-      
+
       EasyMock.reset(mockPostOffice);
-      
-      EasyMock.expect(mockPostOffice.addDestination(address, false)).andReturn(true);
-      
+
+      EasyMock.expect(mockPostOffice.addDestination(address, false)).andReturn(
+            true);
+
       EasyMock.replay(mockPostOffice);
 
       assertTrue(impl.addDestination(address));
-      
+
       EasyMock.verify(mockPostOffice);
-      
+
    }
-   
+
    public void testRemoveDestination() throws Exception
    {
       SimpleString address = RandomUtil.randomSimpleString();
-      
+
       mockPostOffice = EasyMock.createMock(PostOffice.class);
-      
-      EasyMock.expect(mockPostOffice.removeDestination(address, false)).andReturn(false);
-      
+
+      EasyMock.expect(mockPostOffice.removeDestination(address, false))
+            .andReturn(false);
+
       EasyMock.replay(mockPostOffice);
-      
+
       MessagingServerManagementImpl impl = createImpl();
       assertFalse(impl.removeDestination(address));
-      
+
       EasyMock.reset(mockPostOffice);
-      
-      EasyMock.expect(mockPostOffice.removeDestination(address, false)).andReturn(true);
-      
+
+      EasyMock.expect(mockPostOffice.removeDestination(address, false))
+            .andReturn(true);
+
       EasyMock.replay(mockPostOffice);
 
       assertTrue(impl.removeDestination(address));
-      
+
       EasyMock.verify(mockPostOffice);
-      
+
    }
 
-   
    public void testRemoveAllMessagesForAddress() throws Exception
    {
       SimpleString address = RandomUtil.randomSimpleString();
 
       int numberOfQueues = 10;
-      
+
       ArrayList<Queue> queues = new ArrayList<Queue>();
       ArrayList<Binding> bindings = new ArrayList<Binding>();
-      
+
       for (int i = 0; i < numberOfQueues; i++)
       {
          Queue queue = EasyMock.createMock(Queue.class);
          queues.add(queue);
-         
+
          Binding binding = EasyMock.createMock(Binding.class);
          bindings.add(binding);
-         
+
          EasyMock.expect(binding.getQueue()).andReturn(queue);
-         
+
          queue.deleteAllReferences(mockStorageManager);
       }
-      
+
       mockPostOffice = EasyMock.createMock(PostOffice.class);
-      
-      EasyMock.expect(mockPostOffice.getBindingsForAddress(address)).andReturn(bindings);
 
+      EasyMock.expect(mockPostOffice.getBindingsForAddress(address)).andReturn(
+            bindings);
+
       EasyMock.replay(mockPostOffice);
-      
+
       EasyMock.replay(queues.toArray());
-      
+
       EasyMock.replay(bindings.toArray());
-      
+
       MessagingServerManagementImpl impl = createImpl();
-      
+
       impl.removeAllMessagesForAddress(address);
 
       EasyMock.verify(mockPostOffice);
-      
+
       EasyMock.verify(queues.toArray());
-      
+
       EasyMock.verify(bindings.toArray());
-      
-   
+
    }
-   
-   
+
+   public void testRemoveMessageForAddress() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      long messageID = randomLong();
+
+      mockPostOffice = createMock(PostOffice.class);
+      Binding binding = createMock(Binding.class);
+      Queue queue = createMock(Queue.class);
+      expect(mockPostOffice.getBinding(address)).andReturn(binding);
+      expect(binding.getQueue()).andReturn(queue);
+      expect(queue.deleteReference(messageID, mockStorageManager)).andReturn(
+            true);
+
+      replay(mockPostOffice, binding, queue, mockStorageManager);
+
+      MessagingServerManagementImpl impl = createImpl();
+      assertTrue(impl.removeMessageFromAddress(messageID, address));
+
+      verify(mockPostOffice, binding, queue, mockStorageManager);
+   }
+
+   public void testRemoveMessageForUnkownAddress() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      long messageID = randomLong();
+
+      mockPostOffice = createMock(PostOffice.class);
+      expect(mockPostOffice.getBinding(address)).andReturn(null);
+
+      replay(mockPostOffice);
+
+      MessagingServerManagementImpl impl = createImpl();
+      assertFalse(impl.removeMessageFromAddress(messageID, address));
+
+      verify(mockPostOffice);
+   }
+
+   public void testExpireMessage() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      long messageID = randomLong();
+
+      mockPostOffice = createMock(PostOffice.class);
+      Binding binding = createMock(Binding.class);
+      Queue queue = createMock(Queue.class);
+      expect(mockPostOffice.getBinding(address)).andReturn(binding);
+      expect(binding.getQueue()).andReturn(queue);
+      expect(
+            queue.expireMessage(messageID, mockStorageManager, mockPostOffice,
+                  mockQueueSettingsRepository)).andReturn(true);
+
+      replay(mockPostOffice, binding, queue, mockStorageManager);
+
+      MessagingServerManagementImpl impl = createImpl();
+      assertTrue(impl.expireMessage(messageID, address));
+
+      verify(mockPostOffice, binding, queue, mockStorageManager);
+   }
+
+   public void testExpireMessageForUnkownAddress() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      long messageID = randomLong();
+
+      mockPostOffice = createMock(PostOffice.class);
+      expect(mockPostOffice.getBinding(address)).andReturn(null);
+
+      replay(mockPostOffice);
+
+      MessagingServerManagementImpl impl = createImpl();
+      assertFalse(impl.expireMessage(messageID, address));
+
+      verify(mockPostOffice);
+   }
+
+   public void testExpireMessages() throws Exception
+   {
+      Filter filter = new FilterImpl(new SimpleString("color = 'green'"));
+      SimpleString address = randomSimpleString();
+      long messageID = randomLong();
+
+      mockPostOffice = createMock(PostOffice.class);
+      Binding binding = createMock(Binding.class);
+      Queue queue = createMock(Queue.class);
+      expect(mockPostOffice.getBinding(address)).andReturn(binding);
+      expect(binding.getQueue()).andReturn(queue);
+      List<MessageReference> refs = new ArrayList<MessageReference>();
+      MessageReference ref = createMock(MessageReference.class);
+      refs.add(ref);
+      ServerMessage message = createMock(ServerMessage.class);
+      expect(message.getMessageID()).andReturn(messageID);
+      expect(ref.getMessage()).andReturn(message);
+      expect(queue.list(filter)).andReturn(refs);
+      expect(
+            queue.expireMessage(messageID, mockStorageManager, mockPostOffice,
+                  mockQueueSettingsRepository)).andReturn(true);
+
+      replay(mockPostOffice, binding, queue, mockStorageManager, ref, message);
+
+      MessagingServerManagementImpl impl = createImpl();
+      assertEquals(1, impl.expireMessages(filter, address));
+
+      verify(mockPostOffice, binding, queue, mockStorageManager, ref, message);
+   }
+
+   public void testExpireMessagesForUnknownAddress() throws Exception
+   {
+      Filter filter = new FilterImpl(new SimpleString("color = 'green'"));
+      SimpleString address = randomSimpleString();
+
+      mockPostOffice = createMock(PostOffice.class);
+      Binding binding = createMock(Binding.class);
+      Queue queue = createMock(Queue.class);
+      expect(mockPostOffice.getBinding(address)).andReturn(null);
+
+      replay(mockPostOffice, binding, queue, mockStorageManager);
+
+      MessagingServerManagementImpl impl = createImpl();
+      assertEquals(0, impl.expireMessages(filter, address));
+
+      verify(mockPostOffice, binding, queue, mockStorageManager);
+   }
+
+   public void testSendMessagesToDLQ() throws Exception
+   {
+      Filter filter = new FilterImpl(new SimpleString("color = 'green'"));
+      SimpleString address = randomSimpleString();
+      long messageID = randomLong();
+
+      mockPostOffice = createMock(PostOffice.class);
+      Binding binding = createMock(Binding.class);
+      Queue queue = createMock(Queue.class);
+      expect(mockPostOffice.getBinding(address)).andReturn(binding);
+      expect(binding.getQueue()).andReturn(queue);
+      List<MessageReference> refs = new ArrayList<MessageReference>();
+      MessageReference ref = createMock(MessageReference.class);
+      refs.add(ref);
+      ServerMessage message = createMock(ServerMessage.class);
+      expect(message.getMessageID()).andReturn(messageID);
+      expect(ref.getMessage()).andReturn(message);
+      expect(queue.list(filter)).andReturn(refs);
+      expect(
+            queue.sendMessageToDLQ(messageID, mockStorageManager,
+                  mockPostOffice, mockQueueSettingsRepository)).andReturn(true);
+
+      replay(mockPostOffice, binding, queue, mockStorageManager, ref, message);
+
+      MessagingServerManagementImpl impl = createImpl();
+      assertEquals(1, impl.sendMessagesToDLQ(filter, address));
+
+      verify(mockPostOffice, binding, queue, mockStorageManager, ref, message);
+   }
+
+   public void testSendMessagesToDLQForUnknownAddress() throws Exception
+   {
+      Filter filter = new FilterImpl(new SimpleString("color = 'green'"));
+      SimpleString address = randomSimpleString();
+
+      mockPostOffice = createMock(PostOffice.class);
+      expect(mockPostOffice.getBinding(address)).andReturn(null);
+
+      replay(mockPostOffice);
+
+      MessagingServerManagementImpl impl = createImpl();
+      assertEquals(0, impl.sendMessagesToDLQ(filter, address));
+
+      verify(mockPostOffice);
+   }
+
+   public void testChangeMessagesPriority() throws Exception
+   {
+      Filter filter = new FilterImpl(new SimpleString("color = 'green'"));
+      SimpleString address = randomSimpleString();
+      long messageID = randomLong();
+      byte newPriority = (byte) 9;
+
+      mockPostOffice = createMock(PostOffice.class);
+      Binding binding = createMock(Binding.class);
+      Queue queue = createMock(Queue.class);
+      expect(mockPostOffice.getBinding(address)).andReturn(binding);
+      expect(binding.getQueue()).andReturn(queue);
+      List<MessageReference> refs = new ArrayList<MessageReference>();
+      MessageReference ref = createMock(MessageReference.class);
+      refs.add(ref);
+      ServerMessage message = createMock(ServerMessage.class);
+      expect(message.getMessageID()).andReturn(messageID);
+      expect(ref.getMessage()).andReturn(message);
+      expect(queue.list(filter)).andReturn(refs);
+      expect(
+            queue.changeMessagePriority(messageID, newPriority,
+                  mockStorageManager, mockPostOffice,
+                  mockQueueSettingsRepository)).andReturn(true);
+
+      replay(mockPostOffice, binding, queue, mockStorageManager, ref, message);
+
+      MessagingServerManagementImpl impl = createImpl();
+      assertEquals(1, impl.changeMessagesPriority(filter, newPriority, address));
+
+      verify(mockPostOffice, binding, queue, mockStorageManager, ref, message);
+   }
+
+   public void testChangeMessagesPriorityForUnknownAddress() throws Exception
+   {
+      Filter filter = new FilterImpl(new SimpleString("color = 'green'"));
+      SimpleString address = randomSimpleString();
+      byte newPriority = (byte) 9;
+
+      mockPostOffice = createMock(PostOffice.class);
+      expect(mockPostOffice.getBinding(address)).andReturn(null);
+
+      replay(mockPostOffice);
+
+      MessagingServerManagementImpl impl = createImpl();
+      assertEquals(0, impl.changeMessagesPriority(filter, newPriority, address));
+
+      verify(mockPostOffice);
+   }
+
    public void testGetQueuesForAddress() throws Exception
    {
-      
+
       int numberOfQueues = 10;
-      
+
       ArrayList<Queue> queues = new ArrayList<Queue>();
       ArrayList<Binding> bindings = new ArrayList<Binding>();
-      
+
       for (int i = 0; i < numberOfQueues; i++)
       {
          Queue queue = EasyMock.createMock(Queue.class);
 
          queues.add(queue);
-         
+
          Binding binding = EasyMock.createMock(Binding.class);
-         
+
          bindings.add(binding);
-         
+
          EasyMock.expect(binding.getQueue()).andReturn(queue);
       }
-      
 
       SimpleString address = RandomUtil.randomSimpleString();
-      
-      EasyMock.expect(mockPostOffice.getBindingsForAddress(address)).andReturn(bindings);
-      
+
+      EasyMock.expect(mockPostOffice.getBindingsForAddress(address)).andReturn(
+            bindings);
+
       EasyMock.replay(mockPostOffice);
       EasyMock.replay(queues.toArray());
       EasyMock.replay(bindings.toArray());
-      
+
       MessagingServerManagementImpl impl = createImpl();
       assertEquals(numberOfQueues, impl.getQueuesForAddress(address).size());
 
       EasyMock.verify(mockPostOffice);
       EasyMock.verify(queues.toArray());
       EasyMock.verify(bindings.toArray());
-      
+
    }
 
-   
-   
+   public void testIsStarted() throws Exception
+   {
+      expect(mockServer.isStarted()).andReturn(true);
+
+      replay(mockServer);
+      MessagingServerManagementImpl impl = createImpl();
+      assertTrue(impl.isStarted());
+
+      verify(mockServer);
+   }
+
+   public void testGetVersion() throws Exception
+   {
+      String fullVersion = randomString();
+      Version version = createMock(Version.class);
+      expect(version.getFullVersion()).andReturn(fullVersion);
+      expect(mockServer.getVersion()).andReturn(version);
+
+      replay(mockServer, version);
+      MessagingServerManagementImpl impl = createImpl();
+      assertEquals(fullVersion, impl.getVersion());
+
+      verify(mockServer, version);
+   }
+
+   public void testGetConfiguration() throws Exception
+   {
+      replay(mockConfiguration);
+
+      MessagingServerManagementImpl impl = createImpl();
+      assertEquals(mockConfiguration, impl.getConfiguration());
+
+      verify(mockConfiguration);
+   }
+
+   public void testGetQueueSettings() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      QueueSettings settings = new QueueSettings();
+      expect(mockQueueSettingsRepository.getMatch(address.toString()))
+            .andReturn(settings);
+
+      replay(mockQueueSettingsRepository);
+
+      MessagingServerManagementImpl impl = createImpl();
+      assertEquals(settings, impl.getQueueSettings(address));
+
+      verify(mockQueueSettingsRepository);
+   }
+
+   public void testSetQueueAttributes() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      QueueSettings settings = new QueueSettings();
+      mockQueueSettingsRepository.addMatch(address.toString(), settings);
+
+      replay(mockQueueSettingsRepository);
+
+      MessagingServerManagementImpl impl = createImpl();
+      impl.setQueueAttributes(address, settings);
+
+      verify(mockQueueSettingsRepository);
+   }
+
+   public void testSetSecurityForAddress() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      Set<Role> roles = new HashSet<Role>();
+      roles.add(new Role(randomString()));
+      mockSecurityRepository.addMatch(address.toString(), roles);
+
+      replay(mockSecurityRepository);
+
+      MessagingServerManagementImpl impl = createImpl();
+      impl.setSecurityForAddress(address, roles);
+
+      verify(mockSecurityRepository);
+   }
+
+   public void testGetSecurityForAddress() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      Set<Role> roles = new HashSet<Role>();
+      Role role = new Role(randomString());
+      roles.add(role);
+      expect(mockSecurityRepository.getMatch(address.toString())).andReturn(
+            roles);
+
+      replay(mockSecurityRepository);
+
+      MessagingServerManagementImpl impl = createImpl();
+      Set<Role> matchedRoles = impl.getSecurityForAddress(address);
+      assertNotNull(matchedRoles);
+      assertEquals(1, matchedRoles.size());
+
+      verify(mockSecurityRepository);
+   }
+
+   public void testRemoveSecurityForAddress() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      Set<Role> roles = new HashSet<Role>();
+      roles.add(new Role(randomString()));
+      mockSecurityRepository.removeMatch(address.toString());
+
+      replay(mockSecurityRepository);
+
+      MessagingServerManagementImpl impl = createImpl();
+      impl.removeSecurityForAddress(address);
+
+      verify(mockSecurityRepository);
+   }
+
+   public void testGetQueue() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      Queue queue = createMock(Queue.class);
+      Binding binding = createMock(Binding.class);
+      expect(binding.getQueue()).andReturn(queue);
+      expect(mockPostOffice.getBinding(address)).andReturn(binding);
+
+      replay(mockPostOffice, binding, queue);
+
+      MessagingServerManagementImpl impl = createImpl();
+      assertEquals(queue, impl.getQueue(address));
+
+      verify(mockPostOffice, binding, queue);
+   }
+
+   public void testGetQueueForUnknownAddress() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      expect(mockPostOffice.getBinding(address)).andReturn(null);
+
+      replay(mockPostOffice);
+
+      MessagingServerManagementImpl impl = createImpl();
+      try
+      {
+         impl.getQueue(address);
+         fail("IllegalArgumentExcepion");
+      } catch (IllegalArgumentException e)
+      {
+      }
+
+      verify(mockPostOffice);
+   }
+
    // Package protected ---------------------------------------------
-   
+
    // Protected -----------------------------------------------------
-   
+
    // Private -------------------------------------------------------
 
    private MessagingServerManagementImpl createImpl()
@@ -307,5 +732,5 @@
    }
 
    // Inner classes -------------------------------------------------
-   
+
 }

Copied: trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/QueueControlTest.java (from rev 4779, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/core/management/impl/QueueControlTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/QueueControlTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/QueueControlTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,812 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.unit.core.management.impl;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomByte;
+import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
+import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
+import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.management.QueueControlMBean;
+import org.jboss.messaging.core.management.impl.QueueControl;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.Binding;
+import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.HandleStatus;
+import org.jboss.messaging.core.server.MessageReference;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.core.settings.HierarchicalRepository;
+import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class QueueControlTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testGetName() throws Exception
+   {
+      String name = randomString();
+
+      Queue queue = createMock(Queue.class);
+      expect(queue.getName()).andReturn(new SimpleString(name));
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(name, control.getName());
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testGetFilter() throws Exception
+   {
+      String filterStr = "color = 'green'";
+      Queue queue = createMock(Queue.class);
+      Filter filter = createMock(Filter.class);
+      expect(filter.getFilterString()).andReturn(new SimpleString(filterStr));
+      expect(queue.getFilter()).andReturn(filter);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository, filter);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(filterStr, control.getFilter());
+
+      verify(queue, storageManager, postOffice, repository, filter);
+   }
+
+   public void testGetFilterWithNull() throws Exception
+   {
+      Queue queue = createMock(Queue.class);
+      expect(queue.getFilter()).andReturn(null);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertNull(control.getFilter());
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testIsClustered() throws Exception
+   {
+      boolean clustered = randomBoolean();
+
+      Queue queue = createMock(Queue.class);
+      expect(queue.isClustered()).andReturn(clustered);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(clustered, control.isClustered());
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testIsDurable() throws Exception
+   {
+      boolean durable = randomBoolean();
+
+      Queue queue = createMock(Queue.class);
+      expect(queue.isDurable()).andReturn(durable);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(durable, control.isDurable());
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testIsTemporary() throws Exception
+   {
+      boolean temp = randomBoolean();
+
+      Queue queue = createMock(Queue.class);
+      expect(queue.isTemporary()).andReturn(temp);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(temp, control.isTemporary());
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testGetMessageCount() throws Exception
+   {
+      int count = randomInt();
+
+      Queue queue = createMock(Queue.class);
+      expect(queue.getMessageCount()).andReturn(count);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(count, control.getMessageCount());
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testGetMessagesAdded() throws Exception
+   {
+      int count = randomInt();
+
+      Queue queue = createMock(Queue.class);
+      expect(queue.getMessagesAdded()).andReturn(count);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(count, control.getMessagesAdded());
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testGetMaxSizeBytes() throws Exception
+   {
+      int size = randomInt();
+
+      Queue queue = createMock(Queue.class);
+      expect(queue.getMaxSizeBytes()).andReturn(size);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(size, control.getMaxSizeBytes());
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testGetSizeBytes() throws Exception
+   {
+      int size = randomInt();
+
+      Queue queue = createMock(Queue.class);
+      expect(queue.getSizeBytes()).andReturn(size);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(size, control.getSizeBytes());
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testGetScheduledCount() throws Exception
+   {
+      int count = randomInt();
+
+      Queue queue = createMock(Queue.class);
+      expect(queue.getScheduledCount()).andReturn(count);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(count, control.getScheduledCount());
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testGetConsumerCount() throws Exception
+   {
+      int count = randomInt();
+
+      Queue queue = createMock(Queue.class);
+      expect(queue.getConsumerCount()).andReturn(count);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(count, control.getConsumerCount());
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testGetDeliveringCount() throws Exception
+   {
+      int count = randomInt();
+
+      Queue queue = createMock(Queue.class);
+      expect(queue.getDeliveringCount()).andReturn(count);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(count, control.getDeliveringCount());
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testGetPersistenceID() throws Exception
+   {
+      long id = randomLong();
+
+      Queue queue = createMock(Queue.class);
+      expect(queue.getPersistenceID()).andReturn(id);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(id, control.getPersistenceID());
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testGetDLQ() throws Exception
+   {
+      String queueName = randomString();
+      final String dlqName = randomString();
+
+      Queue queue = createMock(Queue.class);
+      expect(queue.getName()).andReturn(new SimpleString(queueName));
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+      QueueSettings queueSettings = new QueueSettings()
+      {
+         @Override
+         public SimpleString getDLQ()
+         {
+            return new SimpleString(dlqName);
+         }
+      };
+      expect(repository.getMatch(queueName)).andReturn(queueSettings);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(dlqName, control.getDLQ());
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testGetExpiryQueue() throws Exception
+   {
+      String queueName = randomString();
+      final String expiryQueueName = randomString();
+
+      Queue queue = createMock(Queue.class);
+      expect(queue.getName()).andReturn(new SimpleString(queueName));
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+      QueueSettings queueSettings = new QueueSettings()
+      {
+         @Override
+         public SimpleString getExpiryQueue()
+         {
+            return new SimpleString(expiryQueueName);
+         }
+      };
+      expect(repository.getMatch(queueName)).andReturn(queueSettings);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(expiryQueueName, control.getExpiryQueue());
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testRemoveAllMessages() throws Exception
+   {
+      Queue queue = createMock(Queue.class);
+      StorageManager storageManager = createMock(StorageManager.class);
+      queue.deleteAllReferences(storageManager);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      control.removeAllMessages();
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testRemoveAllMessagesThrowsException() throws Exception
+   {
+      Queue queue = createMock(Queue.class);
+      StorageManager storageManager = createMock(StorageManager.class);
+      queue.deleteAllReferences(storageManager);
+      expectLastCall().andThrow(new MessagingException());
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      try
+      {
+         control.removeAllMessages();
+         fail("IllegalStateException");
+      } catch (IllegalStateException e)
+      {
+
+      }
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testRemoveMessage() throws Exception
+   {
+      long messageID = randomLong();
+      boolean deleted = randomBoolean();
+
+      Queue queue = createMock(Queue.class);
+      StorageManager storageManager = createMock(StorageManager.class);
+      expect(queue.deleteReference(messageID, storageManager)).andReturn(
+            deleted);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(deleted, control.removeMessage(messageID));
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testRemoveMessageThrowsException() throws Exception
+   {
+      long messageID = randomLong();
+
+      Queue queue = createMock(Queue.class);
+      StorageManager storageManager = createMock(StorageManager.class);
+      expect(queue.deleteReference(messageID, storageManager)).andThrow(
+            new MessagingException());
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      try
+      {
+         control.removeMessage(messageID);
+         fail("IllegalStateException");
+      } catch (IllegalStateException e)
+      {
+
+      }
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testListMessages() throws Exception
+   {
+      String filterStr = "color = 'green'";
+      List<MessageReference> refs = new ArrayList<MessageReference>();
+
+      MessageReference ref = createMock(MessageReference.class);
+      ServerMessage message = createMock(ServerMessage.class);
+      expect(message.getMessageID()).andStubReturn(randomLong());
+      expect(message.getDestination()).andStubReturn(randomSimpleString());
+      expect(message.isDurable()).andStubReturn(randomBoolean());
+      expect(message.getTimestamp()).andStubReturn(randomLong());
+      expect(message.getType()).andStubReturn(randomByte());
+      expect(message.getEncodeSize()).andStubReturn(randomInt());
+      expect(message.getPriority()).andStubReturn(randomByte());
+      expect(message.isExpired()).andStubReturn(randomBoolean());
+      expect(message.getExpiration()).andStubReturn(randomLong());
+      expect(message.getPropertyNames()).andReturn(new HashSet<SimpleString>());
+      expect(ref.getMessage()).andReturn(message);
+      refs.add(ref);
+      Queue queue = createMock(Queue.class);
+      StorageManager storageManager = createMock(StorageManager.class);
+      expect(queue.list(isA(Filter.class))).andReturn(refs);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository, ref, message);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      TabularData data = control.listMessages(filterStr);
+      assertEquals(1, data.size());
+      CompositeData info = data.get(new Object[] { message.getMessageID() });
+      assertNotNull(info);
+      assertEquals(message.getMessageID(), info.get("id"));
+      assertEquals(message.getDestination().toString(), info.get("destination"));
+      assertEquals(message.isDurable(), info.get("durable"));
+      assertEquals(message.getTimestamp(), info.get("timestamp"));
+      assertEquals(message.getType(), info.get("type"));
+      assertEquals(message.getEncodeSize(), info.get("size"));
+      assertEquals(message.getPriority(), info.get("priority"));
+      assertEquals(message.isExpired(), info.get("expired"));
+      assertEquals(message.getExpiration(), info.get("expiration"));
+
+      verify(queue, storageManager, postOffice, repository, ref, message);
+   }
+
+   public void testExpireMessageWithMessageID() throws Exception
+   {
+      long messageID = randomLong();
+
+      Queue queue = createMock(Queue.class);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+      expect(
+            queue.expireMessage(messageID, storageManager, postOffice,
+                  repository)).andReturn(true);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertTrue(control.expireMessage(messageID));
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testExpireMessageWithNoMatch() throws Exception
+   {
+      long messageID = randomLong();
+
+      Queue queue = createMock(Queue.class);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+      expect(
+            queue.expireMessage(messageID, storageManager, postOffice,
+                  repository)).andReturn(false);
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertFalse(control.expireMessage(messageID));
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testExpireMessagesWithFilter() throws Exception
+   {
+      long messageID_1 = randomLong();
+      long messageID_2 = randomLong();
+
+      List<MessageReference> refs = new ArrayList<MessageReference>();
+      MessageReference ref_1 = createMock(MessageReference.class);
+      ServerMessage message_1 = createMock(ServerMessage.class);
+      expect(message_1.getMessageID()).andStubReturn(messageID_1);
+      expect(ref_1.getMessage()).andReturn(message_1);
+      MessageReference ref_2 = createMock(MessageReference.class);
+      ServerMessage message_2 = createMock(ServerMessage.class);
+      expect(message_2.getMessageID()).andStubReturn(messageID_2);
+      expect(ref_2.getMessage()).andReturn(message_2);
+      refs.add(ref_1);
+      refs.add(ref_2);
+      Queue queue = createMock(Queue.class);
+      StorageManager storageManager = createMock(StorageManager.class);
+      expect(queue.list(isA(Filter.class))).andReturn(refs);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+      expect(
+            queue.expireMessage(messageID_1, storageManager, postOffice,
+                  repository)).andReturn(true);
+      expect(
+            queue.expireMessage(messageID_2, storageManager, postOffice,
+                  repository)).andReturn(true);
+
+      replay(queue, storageManager, postOffice, repository, ref_1, ref_2,
+            message_1, message_2);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertEquals(2, control.expireMessages("foo = true"));
+
+      verify(queue, storageManager, postOffice, repository, ref_1, ref_2,
+            message_1, message_2);
+   }
+
+   public void testMoveMessage() throws Exception
+   {
+      long messageID = randomLong();
+      SimpleString otherQueueName = randomSimpleString();
+      Queue queue = createMock(Queue.class);
+      Binding otherBinding = createMock(Binding.class);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      expect(postOffice.getBinding(otherQueueName)).andReturn(otherBinding);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+      expect(
+            queue.moveMessage(messageID, otherBinding, storageManager,
+                  postOffice)).andReturn(true);
+
+      replay(queue, storageManager, postOffice, repository, otherBinding);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertTrue(control.moveMessage(messageID, otherQueueName.toString()));
+
+      verify(queue, storageManager, postOffice, repository, otherBinding);
+   }
+
+   public void testMoveMessageWithNoQueue() throws Exception
+   {
+      long messageID = randomLong();
+      SimpleString otherQueueName = randomSimpleString();
+
+      Queue queue = createMock(Queue.class);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      expect(postOffice.getBinding(otherQueueName)).andReturn(null);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControl control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      try
+      {
+         control.moveMessage(messageID, otherQueueName.toString());
+         fail("IllegalArgumentException");
+      } catch (IllegalArgumentException e)
+      {
+
+      }
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testMoveMessageWithNoMessageID() throws Exception
+   {
+      long messageID = randomLong();
+      SimpleString otherQueueName = randomSimpleString();
+      Queue queue = createMock(Queue.class);
+      Binding otherBinding = createMock(Binding.class);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      expect(postOffice.getBinding(otherQueueName)).andReturn(otherBinding);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+      expect(queue.moveMessage(messageID, otherBinding, storageManager, postOffice)).andReturn(false);
+      
+      replay(queue, storageManager, postOffice, repository, otherBinding);
+
+      QueueControl control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertFalse(control.moveMessage(messageID, otherQueueName.toString()));
+
+      verify(queue, storageManager, postOffice, repository, otherBinding);
+   }
+
+   public void testChangeMessagePriority() throws Exception
+   {
+      long messageID = randomLong();
+      byte newPriority = 5;
+      List<MessageReference> refs = new ArrayList<MessageReference>();
+      MessageReference ref = createMock(MessageReference.class);
+      refs.add(ref);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+      Queue queue = createMock(Queue.class);
+      expect(queue.changeMessagePriority(messageID, newPriority, storageManager, postOffice, repository)).andReturn(true);
+
+      replay(queue, storageManager, postOffice, repository, ref);
+
+      QueueControl control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertTrue(control.changeMessagePriority(messageID, newPriority));
+
+      verify(queue, storageManager, postOffice, repository, ref);
+   }
+
+   public void testChangeMessagePriorityWithInvalidPriorityValues()
+         throws Exception
+   {
+      long messageID = randomLong();
+      Queue queue = createMock(Queue.class);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControl control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+
+      try
+      {
+         control.changeMessagePriority(messageID, -1);
+         fail("IllegalArgumentException");
+      } catch (IllegalArgumentException e)
+      {
+      }
+
+      try
+      {
+         control.changeMessagePriority(messageID, 10);
+         fail("IllegalArgumentException");
+      } catch (IllegalArgumentException e)
+      {
+      }
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testChangeMessagePriorityWithNoMessageID() throws Exception
+   {
+      long messageID = randomLong();
+      byte newPriority = 5;
+      Queue queue = createMock(Queue.class);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+      expect(queue.changeMessagePriority(messageID, newPriority, storageManager, postOffice, repository)).andReturn(false);
+      
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControl control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertFalse(control.changeMessagePriority(messageID, newPriority));
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testSendMessageToDLQ() throws Exception
+   {
+      long messageID = randomLong();
+
+      Queue queue = createMock(Queue.class);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+      expect(
+            queue.sendMessageToDLQ(messageID, storageManager, postOffice,
+                  repository)).andReturn(true);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertTrue(control.sendMessageToDLQ(messageID));
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   public void testSendMessageToDLQWithNoMessageID() throws Exception
+   {
+      long messageID = randomLong();
+
+      Queue queue = createMock(Queue.class);
+      StorageManager storageManager = createMock(StorageManager.class);
+      PostOffice postOffice = createMock(PostOffice.class);
+      HierarchicalRepository<QueueSettings> repository = createMock(HierarchicalRepository.class);
+      expect(
+            queue.sendMessageToDLQ(messageID, storageManager, postOffice,
+                  repository)).andReturn(false);
+
+      replay(queue, storageManager, postOffice, repository);
+
+      QueueControlMBean control = new QueueControl(queue, storageManager,
+            postOffice, repository);
+      assertFalse(control.sendMessageToDLQ(messageID));
+
+      verify(queue, storageManager, postOffice, repository);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -41,6 +41,7 @@
 import org.jboss.messaging.core.journal.RecordInfo;
 import org.jboss.messaging.core.journal.TestableJournal;
 import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.management.ManagementService;
 import org.jboss.messaging.core.persistence.impl.journal.JournalStorageManager;
 import org.jboss.messaging.core.postoffice.Binding;
 import org.jboss.messaging.core.postoffice.PostOffice;
@@ -71,9 +72,11 @@
    public void testStoreMessage() throws Exception
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
-      Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
       
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
+      
       ServerMessage msg = EasyMock.createStrictMock(ServerMessage.class);      
       long msgID = 1021092;      
       EasyMock.expect(msg.getMessageID()).andReturn(msgID);
@@ -87,7 +90,9 @@
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
       Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
       
       final long queueID = 1210981;
       final long messageID = 101921092;
@@ -107,7 +112,9 @@
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
       Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
       
       final long messageID = 101921092;
       
@@ -120,8 +127,10 @@
    public void testStoreMessageTransactional() throws Exception
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
-      Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);     
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
       
       ServerMessage msg = EasyMock.createStrictMock(ServerMessage.class);      
       long msgID = 1021092;      
@@ -136,8 +145,10 @@
    public void testStoreAcknowledgeTransactional() throws Exception
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
-      Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);   
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
       
       final long queueID = 1210981;
       final long messageID = 101921092;
@@ -157,8 +168,10 @@
    public void testStoreDeleteTransactional() throws Exception
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
-      Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);  
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
       
       final long messageID = 101921092;
       final long txID = 1209373;
@@ -173,7 +186,9 @@
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
       Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
       
       final long txID = 1209373;
       
@@ -187,7 +202,9 @@
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
       Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
       
       final long txID = 1209373;
       
@@ -201,7 +218,9 @@
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
       Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
       
       final long txID = 1209373;
       
@@ -215,7 +234,9 @@
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
       Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
       
       final long msgID = 120912901;
       final long queueID = 1283743;
@@ -246,7 +267,9 @@
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
       Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
      
       messageJournal.load((List<RecordInfo>) EasyMock.anyObject(), (List<PreparedTransactionInfo>) EasyMock.anyObject());
       
@@ -409,7 +432,9 @@
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
       Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
            
       Queue queue = EasyMock.createStrictMock(Queue.class);
       SimpleString queueName = new SimpleString("saiohsiudh");
@@ -477,7 +502,9 @@
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
       Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
       
       Binding binding = EasyMock.createStrictMock(Binding.class);
       Queue queue = EasyMock.createStrictMock(Queue.class);
@@ -498,7 +525,9 @@
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
       Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
       
       Binding binding = EasyMock.createStrictMock(Binding.class);
       Queue queue = EasyMock.createStrictMock(Queue.class);
@@ -525,7 +554,9 @@
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
       Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
       
       SimpleString dest = new SimpleString("oaskokas");
       
@@ -642,7 +673,9 @@
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
       Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
      
       bindingsJournal.load((List<RecordInfo>) EasyMock.anyObject(), (List<PreparedTransactionInfo>) EasyMock.anyObject());
       
@@ -704,7 +737,9 @@
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
       Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
       
       assertFalse(jsm.isStarted());
       bindingsJournal.start();
@@ -759,7 +794,9 @@
       
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
       Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
       
       assertEquals(id++, jsm.generateMessageID());
       assertEquals(id++, jsm.generateMessageID());
@@ -772,7 +809,9 @@
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);      
       Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);      
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal);
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, managementService);
       
       long id = 1212;
       EasyMock.expect(messageJournal.getTransactionID()).andReturn(id);
@@ -787,9 +826,10 @@
    public void testConstructor()
    {
       Configuration config = new ConfigurationImpl();
-      
-      JournalStorageManager jsm = new JournalStorageManager(config);
-      
+      ManagementService managementService = EasyMock.createNiceMock(ManagementService.class);
+
+      JournalStorageManager jsm = new JournalStorageManager(config, managementService);
+     
       assertNotNull(jsm.getMessageJournal());
       
       TestableJournal messageJournal = (TestableJournal)jsm.getMessageJournal();

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -31,6 +31,7 @@
 import org.easymock.IAnswer;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.management.ManagementService;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.Binding;
 import org.jboss.messaging.core.postoffice.FlowController;
@@ -59,7 +60,8 @@
    {
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.replay(pm, qf);
@@ -72,7 +74,8 @@
    {
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.replay(pm, qf);
@@ -99,7 +102,8 @@
       EasyMock.expect(queue.getName()).andStubReturn(queueName);
       queue.setFlowController(null);
       EasyMock.expect(queue.getPersistenceID()).andStubReturn(1);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       EasyMock.expectLastCall().andAnswer(new LoadBindingsIAnswer(bindingArrayList, null));
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
@@ -141,9 +145,9 @@
 
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 
-
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       EasyMock.expectLastCall().andAnswer(new LoadBindingsIAnswer(bindingArrayList, null));
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
@@ -172,6 +176,7 @@
       Queue queue = EasyMock.createStrictMock(Queue.class);
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 
       SimpleString address1 = new SimpleString("testAddress1");
       EasyMock.expect(binding.getAddress()).andStubReturn(address1);
@@ -182,7 +187,8 @@
       EasyMock.expect(queue.getName()).andStubReturn(queueName);
       queue.setFlowController(null);
       EasyMock.expect(queue.getPersistenceID()).andStubReturn(1);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       EasyMock.expectLastCall().andAnswer(new LoadBindingsIAnswer(bindingArrayList, null));
 
@@ -191,10 +197,10 @@
       try
       {
          postOffice.start();
+         fail("IllegalStateException");
       }
       catch (IllegalStateException e)
       {
-         e.printStackTrace();
       }
 
       EasyMock.verify(pm, qf, binding, binding2, queue);
@@ -227,9 +233,9 @@
 
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 
-
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       EasyMock.expectLastCall().andAnswer(new LoadBindingsIAnswer(bindingArrayList, null));
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
@@ -257,6 +263,7 @@
       Queue queue = EasyMock.createStrictMock(Queue.class);
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 
       SimpleString address1 = new SimpleString("testAddress1");
       dests.add(address1);
@@ -266,7 +273,8 @@
       EasyMock.expect(queue.getName()).andStubReturn(queueName);
       queue.setFlowController((FlowController) EasyMock.anyObject());
       EasyMock.expect(queue.getPersistenceID()).andStubReturn(1);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       EasyMock.expectLastCall().andAnswer(new LoadBindingsIAnswer(bindingArrayList, dests));
       EasyMock.expect(pm.addDestination(address1)).andReturn(true);
@@ -289,7 +297,8 @@
 
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       ArrayList<Binding> bindingArrayList = new ArrayList<Binding>();
       List<SimpleString> dests = new ArrayList<SimpleString>();
       Binding[] bindings = new Binding[100];
@@ -341,7 +350,9 @@
 
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       ArrayList<Binding> bindingArrayList = new ArrayList<Binding>();
       List<SimpleString> dests = new ArrayList<SimpleString>();
       Binding[] bindings = new Binding[100];
@@ -393,7 +404,9 @@
 
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       ArrayList<Binding> bindingArrayList = new ArrayList<Binding>();
       List<SimpleString> dests = new ArrayList<SimpleString>();
       Binding[] bindings = new Binding[100];
@@ -444,7 +457,9 @@
 
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       ArrayList<Binding> bindingArrayList = new ArrayList<Binding>();
       List<SimpleString> dests = new ArrayList<SimpleString>();
       Binding[] bindings = new Binding[100];
@@ -492,14 +507,14 @@
    public void testAddQueue() throws Exception
    {
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 
-      PostOffice po = new PostOfficeImpl(pm, qf, false);
+      PostOffice po = new PostOfficeImpl(pm, qf, ms, false);
 
       final long id = 324;
       final SimpleString name = new SimpleString("wibb22");
-      final Filter filter = new FakeFilter();
+      final Filter filter = EasyMock.createMock(Filter.class);
       final boolean durable = true;
       final boolean temporary = true;
 
@@ -513,42 +528,35 @@
 
       pm.addBinding(EasyMock.eq(expected));
 
-      EasyMock.replay(qf);
+      EasyMock.replay(qf, pm, filter);
 
-      EasyMock.replay(pm);
-
       po.addBinding(condition, name, filter, durable, temporary);
 
-      EasyMock.verify(qf);
+      EasyMock.verify(qf, pm, filter);
 
-      EasyMock.verify(pm);
+      EasyMock.reset(qf, pm, filter);
 
-      EasyMock.reset(qf);
-
-      EasyMock.reset(pm);
-
       final boolean durable2 = false;
 
       queue = queueFactory.createQueue(id, name, filter, durable2, temporary);
 
       EasyMock.expect(qf.createQueue(-1, name, filter, durable2, temporary)).andReturn(queue);
 
-      EasyMock.replay(qf);
+      EasyMock.replay(qf, pm, filter);
 
-      EasyMock.replay(pm);
    }
 
    public void testRemoveQueue() throws Exception
    {
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 
-      PostOffice po = new PostOfficeImpl(pm, qf, false);
+      PostOffice po = new PostOfficeImpl(pm, qf, ms, false);
 
       final long id = 324;
       final SimpleString name = new SimpleString("wibb22");
-      final Filter filter = new FakeFilter();
+      final Filter filter = EasyMock.createMock(Filter.class);
       final boolean durable = true;
       final boolean temporary = true;
 
@@ -564,48 +572,38 @@
 
       pm.deleteBinding(EasyMock.eq(expected));
 
-      EasyMock.replay(qf);
+      EasyMock.replay(qf, pm, filter);
 
-      EasyMock.replay(pm);
-
       po.addBinding(condition, name, filter, durable, temporary);
 
       po.removeBinding(name);
 
-      EasyMock.verify(qf);
+      EasyMock.verify(qf, pm, filter);
 
-      EasyMock.verify(pm);
+      EasyMock.reset(qf, pm, filter);
 
-      EasyMock.reset(qf);
-
-      EasyMock.reset(pm);
-
       final boolean durable2 = false;
 
       queue = queueFactory.createQueue(id, name, filter, durable2, temporary);
 
       EasyMock.expect(qf.createQueue(-1, name, filter, durable2, temporary)).andReturn(queue);
 
-      EasyMock.replay(qf);
+      EasyMock.replay(qf, pm, filter);
 
-      EasyMock.replay(pm);
-
       po.addBinding(condition, name, filter, durable2, temporary);
 
       po.removeBinding(name);
 
-      EasyMock.verify(qf);
-
-      EasyMock.verify(pm);
+      EasyMock.verify(qf, pm, filter);
    }
 
    public void testAddRemoveMultipleWithDifferentConditions() throws Exception
    {
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-
       QueueFactory qf = new FakeQueueFactory();
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 
-      PostOffice po = new PostOfficeImpl(pm, qf, false);
+      PostOffice po = new PostOfficeImpl(pm, qf, ms, false);
 
       final SimpleString condition1 = new SimpleString("queue.wibble");
 
@@ -691,7 +689,8 @@
       SimpleString address = new SimpleString("testAddress");
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.expect(pm.addDestination(address)).andReturn(true);
@@ -711,7 +710,8 @@
       SimpleString address3 = new SimpleString("testAddress3");
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.expect(pm.addDestination(address)).andReturn(true);
@@ -737,7 +737,8 @@
       SimpleString address = new SimpleString("testAddress");
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.expect(pm.addDestination(address)).andReturn(true);
@@ -760,7 +761,8 @@
       SimpleString address3 = new SimpleString("testAddress3");
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.expect(pm.addDestination(address)).andReturn(true);
@@ -796,7 +798,8 @@
       SimpleString address = new SimpleString("testAddress");
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.replay(pm, qf);
@@ -815,7 +818,8 @@
       SimpleString address3 = new SimpleString("testAddress3");
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.replay(pm, qf);
@@ -838,7 +842,8 @@
       SimpleString address = new SimpleString("testAddress");
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.replay(pm, qf);
@@ -859,7 +864,8 @@
       SimpleString address3 = new SimpleString("testAddress3");
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.replay(pm, qf);
@@ -891,7 +897,8 @@
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
       Filter filter = EasyMock.createStrictMock(Filter.class);
       Queue queue = EasyMock.createStrictMock(Queue.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.expect(qf.createQueue(-1, queueName, filter, true, false)).andReturn(queue);
@@ -917,7 +924,8 @@
       Queue queue = EasyMock.createStrictMock(Queue.class);
       Queue queue2 = EasyMock.createStrictMock(Queue.class);
       Queue queue3 = EasyMock.createStrictMock(Queue.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.expect(qf.createQueue(-1, queueName, filter, true, false)).andReturn(queue);
@@ -951,7 +959,8 @@
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
       Filter filter = EasyMock.createStrictMock(Filter.class);
       Queue queue = EasyMock.createStrictMock(Queue.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.expect(qf.createQueue(-1, queueName, filter, false, false)).andReturn(queue);
@@ -976,7 +985,8 @@
       Queue queue = EasyMock.createStrictMock(Queue.class);
       Queue queue2 = EasyMock.createStrictMock(Queue.class);
       Queue queue3 = EasyMock.createStrictMock(Queue.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.expect(qf.createQueue(-1, queueName, filter, false, false)).andReturn(queue);
@@ -1007,7 +1017,8 @@
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
       Filter filter = EasyMock.createStrictMock(Filter.class);
       Queue queue = EasyMock.createStrictMock(Queue.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.expect(qf.createQueue(-1, queueName, filter, true, false)).andReturn(queue);
@@ -1039,7 +1050,8 @@
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
       Filter filter = EasyMock.createStrictMock(Filter.class);
       Queue queue = EasyMock.createStrictMock(Queue.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.expect(qf.createQueue(-1, queueName, filter, true, false)).andReturn(queue);
@@ -1069,7 +1081,8 @@
       Queue queue = EasyMock.createStrictMock(Queue.class);
       Queue queue2 = EasyMock.createStrictMock(Queue.class);
       Queue queue3 = EasyMock.createStrictMock(Queue.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.expect(qf.createQueue(-1, queueName, filter, true, false)).andReturn(queue);
@@ -1111,7 +1124,8 @@
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
       Filter filter = EasyMock.createStrictMock(Filter.class);
       Queue queue = EasyMock.createStrictMock(Queue.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.expect(qf.createQueue(-1, queueName, filter, false, false)).andReturn(queue);
@@ -1139,7 +1153,8 @@
       Queue queue = EasyMock.createStrictMock(Queue.class);
       Queue queue2 = EasyMock.createStrictMock(Queue.class);
       Queue queue3 = EasyMock.createStrictMock(Queue.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.expect(qf.createQueue(-1, queueName, filter, false, false)).andReturn(queue);
@@ -1177,7 +1192,8 @@
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
       Filter filter = EasyMock.createStrictMock(Filter.class);
       Queue queue = EasyMock.createStrictMock(Queue.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.expect(queue.getName()).andStubReturn(queueName);
@@ -1203,7 +1219,8 @@
       ServerMessage message = EasyMock.createStrictMock(ServerMessage.class);
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, true);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, true);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.expect(message.getDestination()).andStubReturn(new SimpleString("testtDestination"));
@@ -1228,7 +1245,8 @@
       ServerMessage message = EasyMock.createStrictMock(ServerMessage.class);
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, false);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, false);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       EasyMock.expect(message.getDestination()).andStubReturn(new SimpleString("testtDestination"));
@@ -1247,7 +1265,8 @@
       Queue queue = EasyMock.createStrictMock(Queue.class);
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, false);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, false);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       SimpleString address = new SimpleString("testtDestination");
@@ -1276,7 +1295,8 @@
       Queue queue = EasyMock.createStrictMock(Queue.class);
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, false);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, false);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       SimpleString address = new SimpleString("testtDestination");
@@ -1306,7 +1326,8 @@
       Queue queue = EasyMock.createStrictMock(Queue.class);
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, false);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, false);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       SimpleString address = new SimpleString("testtDestination");
@@ -1339,7 +1360,8 @@
       Queue queue3 = EasyMock.createStrictMock(Queue.class);
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
       QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-      PostOffice postOffice = new PostOfficeImpl(pm, qf, false);
+      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+      PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, false);
       pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
       pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
       SimpleString address = new SimpleString("testtDestination");
@@ -1389,7 +1411,8 @@
          Queue queue3 = EasyMock.createStrictMock(Queue.class);
          StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
          QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-         PostOffice postOffice = new PostOfficeImpl(pm, qf, false);
+         ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+         PostOffice postOffice = new PostOfficeImpl(pm, qf, ms, false);
          pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
          pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject());
          SimpleString address = new SimpleString("testtDestination");
@@ -1423,21 +1446,6 @@
          assertEquals(messageReference3, references.get(1));
       }
 
-
-   class FakeFilter implements Filter
-   {
-      public SimpleString getFilterString()
-      {
-         return new SimpleString("aardvark");
-      }
-
-      public boolean match(ServerMessage message)
-      {
-         return true;
-      }
-
-   }
-
    class LoadBindingsIAnswer implements IAnswer
    {
       List<Binding> bindings;

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessageReferenceImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessageReferenceImplTest.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessageReferenceImplTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -34,6 +34,7 @@
 import org.jboss.messaging.core.server.impl.MessageReferenceImpl;
 import org.jboss.messaging.core.settings.HierarchicalRepository;
 import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.tests.util.RandomUtil;
 import org.jboss.messaging.tests.util.UnitTestCase;
 import org.jboss.messaging.util.SimpleString;
 
@@ -84,7 +85,7 @@
       MessageReferenceImpl messageReference = new DummyMessageReference(serverMessage, queue);
       SimpleString queueName = new SimpleString("queueName");
       queue.referenceCancelled();
-      EasyMock.expect(queue.getName()).andReturn(queueName);
+      EasyMock.expect(queue.getName()).andStubReturn(queueName);
       EasyMock.expect(repos.getMatch(queueName.toString())).andStubReturn(queueSettings);
       EasyMock.expect(serverMessage.isDurable()).andStubReturn(true);
       EasyMock.expect(serverMessage.getMessageID()).andStubReturn(999l);
@@ -106,7 +107,7 @@
       MessageReferenceImpl messageReference = new DummyMessageReference(serverMessage, queue);
       SimpleString queueName = new SimpleString("queueName");
       queue.referenceCancelled();
-      EasyMock.expect(queue.getName()).andReturn(queueName);
+      EasyMock.expect(queue.getName()).andStubReturn(queueName);
       EasyMock.expect(repos.getMatch(queueName.toString())).andStubReturn(queueSettings);
       EasyMock.expect(serverMessage.isDurable()).andStubReturn(false);
       EasyMock.expect(serverMessage.getMessageID()).andStubReturn(999l);
@@ -123,6 +124,7 @@
       SimpleString dlqName = new SimpleString("testDLQ");
       queueSettings.setDLQ(dlqName);
       Binding dlqBinding = EasyMock.createStrictMock(Binding.class);
+      EasyMock.expect(dlqBinding.getAddress()).andReturn(dlqName);
       StorageManager sm = EasyMock.createNiceMock(StorageManager.class);
       PostOffice po = EasyMock.createStrictMock(PostOffice.class);
       HierarchicalRepository<QueueSettings> repos = EasyMock.createStrictMock(HierarchicalRepository.class);
@@ -131,7 +133,7 @@
       MessageReferenceImpl messageReference = new DummyMessageReference(serverMessage, queue);
       messageReference.setDeliveryCount(1);
       SimpleString queueName = new SimpleString("queueName");
-      queue.referenceCancelled();
+      queue.referenceAcknowledged(messageReference);
       EasyMock.expect(queue.getName()).andStubReturn(queueName);
       EasyMock.expect(repos.getMatch(queueName.toString())).andStubReturn(queueSettings);
       EasyMock.expect(serverMessage.isDurable()).andStubReturn(true);
@@ -142,14 +144,17 @@
       EasyMock.expect(serverMessage.copy()).andReturn(serverMessage);
       EasyMock.expect(sm.generateMessageID()).andReturn(2l);
       serverMessage.setMessageID(2);
+      EasyMock.expect(serverMessage.getDestination()).andReturn(queueName);
+      serverMessage.putStringProperty(MessageImpl.HDR_ORIGIN_QUEUE, queueName);
       serverMessage.setExpiration(0);
+      serverMessage.setDestination(dlqName);
       EasyMock.expect(po.route(serverMessage)).andReturn(new ArrayList<MessageReference>());
       EasyMock.expect(serverMessage.getDurableRefCount()).andReturn(0);
       EasyMock.expect(serverMessage.decrementDurableRefCount()).andReturn(0);
       EasyMock.expect(sm.generateTransactionID()).andReturn(1l);
-      EasyMock.replay(sm, po, repos, serverMessage, queue);
+      EasyMock.replay(sm, po, repos, serverMessage, queue, dlqBinding);
       assertFalse(messageReference.cancel(sm, po, repos));
-      EasyMock.verify(sm, po, repos, serverMessage, queue);
+      EasyMock.verify(sm, po, repos, serverMessage, queue, dlqBinding);
    }
 
    public void testCancelToDLQDoesntExist() throws Exception
@@ -159,6 +164,7 @@
       SimpleString dlqName = new SimpleString("testDLQ");
       queueSettings.setDLQ(dlqName);
       Binding dlqBinding = EasyMock.createStrictMock(Binding.class);
+      EasyMock.expect(dlqBinding.getAddress()).andReturn(dlqName);
       StorageManager sm = EasyMock.createNiceMock(StorageManager.class);
       PostOffice po = EasyMock.createStrictMock(PostOffice.class);
       HierarchicalRepository<QueueSettings> repos = EasyMock.createStrictMock(HierarchicalRepository.class);
@@ -167,7 +173,7 @@
       MessageReferenceImpl messageReference = new DummyMessageReference(serverMessage, queue);
       messageReference.setDeliveryCount(1);
       SimpleString queueName = new SimpleString("queueName");
-      queue.referenceCancelled();
+      queue.referenceAcknowledged(messageReference);
       EasyMock.expect(queue.getName()).andStubReturn(queueName);
       EasyMock.expect(repos.getMatch(queueName.toString())).andStubReturn(queueSettings);
       EasyMock.expect(serverMessage.isDurable()).andStubReturn(true);
@@ -179,14 +185,20 @@
       EasyMock.expect(serverMessage.copy()).andReturn(serverMessage);
       EasyMock.expect(sm.generateMessageID()).andReturn(2l);
       serverMessage.setMessageID(2);
+      EasyMock.expect(serverMessage.getDestination()).andReturn(queueName);
+      serverMessage.putStringProperty(MessageImpl.HDR_ORIGIN_QUEUE, queueName);
       serverMessage.setExpiration(0);
+      serverMessage.setDestination(dlqName);
       EasyMock.expect(po.route(serverMessage)).andReturn(new ArrayList<MessageReference>());
       EasyMock.expect(serverMessage.getDurableRefCount()).andReturn(0);
       EasyMock.expect(serverMessage.decrementDurableRefCount()).andReturn(0);
       EasyMock.expect(sm.generateTransactionID()).andReturn(1l);
-      EasyMock.replay(sm, po, repos, serverMessage, queue);
+      
+      EasyMock.replay(sm, po, repos, serverMessage, queue, dlqBinding);
+      
       assertFalse(messageReference.cancel(sm, po, repos));
-      EasyMock.verify(sm, po, repos, serverMessage, queue);
+      
+      EasyMock.verify(sm, po, repos, serverMessage, queue, dlqBinding);
    }
 
    public void testExpire() throws Exception
@@ -243,6 +255,8 @@
       EasyMock.expect(po.getBinding(expQName)).andReturn(expQBinding);
       EasyMock.expect(serverMessage.copy()).andReturn(serverMessage);
       serverMessage.setMessageID(2);
+      EasyMock.expect(serverMessage.getDestination()).andReturn(queueName);
+      serverMessage.putStringProperty(MessageImpl.HDR_ORIGIN_QUEUE, queueName);
       serverMessage.setExpiration(0);
       serverMessage.putLongProperty(EasyMock.eq(MessageImpl.HDR_ACTUAL_EXPIRY_TIME), EasyMock.anyLong());
       EasyMock.expect(expQBinding.getAddress()).andStubReturn(expQName);
@@ -250,8 +264,11 @@
       EasyMock.expect(po.route(serverMessage)).andReturn(new ArrayList<MessageReference>());
       EasyMock.expect(serverMessage.getDurableRefCount()).andReturn(0);
       EasyMock.expect(serverMessage.decrementDurableRefCount()).andReturn(0);
+
       EasyMock.replay(sm, po, repos, serverMessage, queue, expQBinding);
+      
       messageReference.expire(sm, po, repos);
+
       EasyMock.verify(sm, po, repos, serverMessage, queue, expQBinding);
    }
 
@@ -282,6 +299,8 @@
       EasyMock.expect(po.addBinding(expQName, expQName, null, true, false)).andReturn(expQBinding);
       EasyMock.expect(serverMessage.copy()).andReturn(serverMessage);
       serverMessage.setMessageID(2);
+      EasyMock.expect(serverMessage.getDestination()).andReturn(queueName);
+      serverMessage.putStringProperty(MessageImpl.HDR_ORIGIN_QUEUE, queueName);
       serverMessage.setExpiration(0);
       serverMessage.putLongProperty(EasyMock.eq(MessageImpl.HDR_ACTUAL_EXPIRY_TIME), EasyMock.anyLong());
       EasyMock.expect(expQBinding.getAddress()).andStubReturn(expQName);
@@ -289,11 +308,46 @@
       EasyMock.expect(po.route(serverMessage)).andReturn(new ArrayList<MessageReference>());
       EasyMock.expect(serverMessage.getDurableRefCount()).andReturn(0);
       EasyMock.expect(serverMessage.decrementDurableRefCount()).andReturn(0);
+
       EasyMock.replay(sm, po, repos, serverMessage, queue, expQBinding);
+      
       messageReference.expire(sm, po, repos);
+      
       EasyMock.verify(sm, po, repos, serverMessage, queue, expQBinding);
    }
 
+   public void testMove() throws Exception
+   {
+      SimpleString toAddress = RandomUtil.randomSimpleString();
+      long tid = RandomUtil.randomLong();
+      long messageID = RandomUtil.randomLong();
+      
+      Queue queue = EasyMock.createStrictMock(Queue.class);
+      Binding toBinding = EasyMock.createStrictMock(Binding.class);
+      Queue toQueue = EasyMock.createStrictMock(Queue.class);
+      PostOffice postOffice = EasyMock.createMock(PostOffice.class);
+      StorageManager persistenceManager = EasyMock.createMock(StorageManager.class);
+      ServerMessage serverMessage = EasyMock.createStrictMock(ServerMessage.class);
+      MessageReferenceImpl messageReference = new DummyMessageReference(serverMessage, queue);
+      ServerMessage copyMessage = EasyMock.createStrictMock(ServerMessage.class);
+
+      EasyMock.expect(persistenceManager.generateTransactionID()).andReturn(tid);
+      EasyMock.expect(serverMessage.copy()).andReturn(copyMessage);
+      EasyMock.expect(toBinding.getAddress()).andStubReturn(toAddress);
+      copyMessage.setDestination(toAddress);
+      EasyMock.expect(postOffice.route(copyMessage)).andReturn(new ArrayList<MessageReference>());
+      EasyMock.expect(copyMessage.getDurableRefCount()).andReturn(0);
+      EasyMock.expect(serverMessage.isDurable()).andStubReturn(false);
+      EasyMock.expect(serverMessage.getMessageID()).andReturn(messageID);
+      queue.referenceAcknowledged(messageReference);
+
+      EasyMock.replay(queue, toBinding, toQueue, postOffice, persistenceManager, serverMessage, copyMessage);
+      
+      messageReference.move(toBinding, persistenceManager, postOffice);
+      
+      EasyMock.verify(queue, toBinding, toQueue, postOffice, persistenceManager, serverMessage, copyMessage);
+   }
+   
    //we need to override the constructor for creation
    class DummyMessageReference extends MessageReferenceImpl
    {

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessagingServerImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessagingServerImplTest.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessagingServerImplTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -30,7 +30,10 @@
 import org.jboss.messaging.core.config.impl.ConfigurationImpl;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.management.ManagementService;
+import org.jboss.messaging.core.management.MessagingServerManagement;
 import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.PostOffice;
 import org.jboss.messaging.core.postoffice.impl.PostOfficeImpl;
 import org.jboss.messaging.core.remoting.PacketDispatcher;
 import org.jboss.messaging.core.remoting.RemotingConnection;
@@ -45,6 +48,7 @@
 import org.jboss.messaging.core.server.impl.QueueFactoryImpl;
 import org.jboss.messaging.core.server.impl.ServerConnectionImpl;
 import org.jboss.messaging.core.server.impl.ServerConnectionPacketHandler;
+import org.jboss.messaging.core.settings.HierarchicalRepository;
 import org.jboss.messaging.core.version.Version;
 import org.jboss.messaging.tests.util.UnitTestCase;
 import org.jboss.messaging.util.VersionLoader;
@@ -163,11 +167,25 @@
          //Ok
       }
       
-      EasyMock.reset(sm, rs);
+      ManagementService mr = EasyMock.createMock(ManagementService.class);
       
+      server.setManagementService(mr);
+      
+      try
+      {
+         server.start();
+         fail("Should throw exception");
+      }
+      catch (IllegalStateException e)
+      {
+         //Ok
+      }
+      
+      EasyMock.reset(sm, rs, mr);
+      
       EasyMock.expect(sm.isStarted()).andStubReturn(true);
       EasyMock.expect(rs.isStarted()).andStubReturn(false);
-      
+
       EasyMock.replay(sm, rs);
       
       try
@@ -361,6 +379,12 @@
       };
       
       server.setSecurityManager(sem);
+
+      ManagementService mr = EasyMock.createMock(ManagementService.class);
+      mr.setQueueSettingsRepository(EasyMock.isA(HierarchicalRepository.class));
+      mr.setPostOffice(EasyMock.isA(PostOffice.class));
+      mr.registerServer(EasyMock.isA(MessagingServerManagement.class));
+      server.setManagementService(mr);
       
       sm.loadBindings(EasyMock.isA(QueueFactoryImpl.class), EasyMock.isA(ArrayList.class), EasyMock.isA(ArrayList.class));
       sm.loadMessages(EasyMock.isA(PostOfficeImpl.class), EasyMock.isA(Map.class));
@@ -370,11 +394,11 @@
       EasyMock.expect(sm.isStarted()).andStubReturn(true);
       EasyMock.expect(rs.isStarted()).andStubReturn(true);
       
-      EasyMock.replay(rs, sm, pd);
+      EasyMock.replay(rs, sm, pd, mr);
       
       server.start();
       
-      EasyMock.verify(rs, sm, pd);
+      EasyMock.verify(rs, sm, pd, mr);
       
       
       try
@@ -412,6 +436,12 @@
       
       server.setSecurityManager(sem);
       
+      ManagementService mr = EasyMock.createMock(ManagementService.class);
+      mr.setQueueSettingsRepository(EasyMock.isA(HierarchicalRepository.class));
+      mr.setPostOffice(EasyMock.isA(PostOffice.class));
+      mr.registerServer(EasyMock.isA(MessagingServerManagement.class));
+      server.setManagementService(mr);
+
       PacketDispatcher pd = EasyMock.createMock(PacketDispatcher.class);
       EasyMock.expect(rs.getDispatcher()).andReturn(pd);
       

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java	2008-08-07 11:36:43 UTC (rev 4780)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -22,6 +22,15 @@
 
 package org.jboss.messaging.tests.unit.core.server.impl;
 
+import static org.easymock.EasyMock.anyLong;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
+
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
@@ -34,13 +43,18 @@
 import org.easymock.EasyMock;
 import org.jboss.messaging.core.filter.Filter;
 import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.Binding;
+import org.jboss.messaging.core.postoffice.PostOffice;
 import org.jboss.messaging.core.server.Consumer;
 import org.jboss.messaging.core.server.DistributionPolicy;
 import org.jboss.messaging.core.server.HandleStatus;
 import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.server.impl.QueueImpl;
 import org.jboss.messaging.core.server.impl.RoundRobinDistributionPolicy;
+import org.jboss.messaging.core.settings.HierarchicalRepository;
+import org.jboss.messaging.core.settings.impl.QueueSettings;
 import org.jboss.messaging.tests.unit.core.server.impl.fakes.FakeConsumer;
 import org.jboss.messaging.tests.unit.core.server.impl.fakes.FakeFilter;
 import org.jboss.messaging.tests.util.UnitTestCase;
@@ -191,21 +205,20 @@
       assertEquals(policy, queue.getDistributionPolicy());
    }
 
-   public void testGetSetFilter()
+   public void testGetFilter()
    {
       Queue queue = new QueueImpl(1, queue1, null, false, true, false, -1, scheduledExecutor);
 
       assertNull(queue.getFilter());
 
-      Filter filter = new FakeFilter();
+      Filter filter = createMock(Filter.class);
+      replay(filter);
 
-      queue.setFilter(filter);
-
-      assertEquals(filter, queue.getFilter());
-
       queue = new QueueImpl(1, queue1, filter, false, true, false, -1, scheduledExecutor);
 
       assertEquals(filter, queue.getFilter());
+      
+      verify(filter);
    }
 
    public void testDefaultMaxSize()
@@ -1403,8 +1416,144 @@
       EasyMock.verify(consumer);
 
    }
+   
+   public void testExpireMessage() throws Exception
+   {
+      long messageID = randomLong();
+      final SimpleString expiryQueue = new SimpleString("expiryQueue");
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, -1, scheduledExecutor);
+      MessageReference messageReference = generateReference(queue, messageID);
+      StorageManager storageManager = EasyMock.createMock(StorageManager.class);
+      EasyMock.expect(storageManager.generateTransactionID()).andReturn(randomLong());
+      EasyMock.expect(storageManager.generateMessageID()).andReturn(randomLong());
+      storageManager.storeDeleteTransactional(EasyMock.anyLong(), EasyMock.eq(messageID));
+      storageManager.commit(EasyMock.anyLong());
+      PostOffice postOffice = createMock(PostOffice.class);      
+      Binding expiryBinding = createMock(Binding.class);
+      EasyMock.expect(expiryBinding.getAddress()).andStubReturn(expiryQueue);
+      EasyMock.expect(postOffice.getBinding(expiryQueue)).andReturn(expiryBinding );
+      EasyMock.expect(postOffice.route(EasyMock.isA(ServerMessage.class))).andReturn(new ArrayList<MessageReference>());
+      HierarchicalRepository<QueueSettings> queueSettingsRepository = createMock(HierarchicalRepository.class);
+      QueueSettings queueSettings = new QueueSettings() 
+      {
+         @Override
+         public SimpleString getExpiryQueue()
+         {
+            return expiryQueue;
+         } 
+      };
+      EasyMock.expect(queueSettingsRepository.getMatch(queue1.toString())).andStubReturn(queueSettings);
 
+      EasyMock.replay(storageManager, postOffice, queueSettingsRepository, expiryBinding);
 
+      assertEquals(0, queue.getMessageCount());
+      assertEquals(0, queue.getDeliveringCount());
+      assertEquals(0, queue.getSizeBytes());
+      
+      queue.addLast(messageReference);
+      
+      assertEquals(1, queue.getMessageCount());
+      assertEquals(0, queue.getDeliveringCount());
+      assertTrue(queue.getSizeBytes() > 0);
+      
+      queue.expireMessage(messageID, storageManager , postOffice, queueSettingsRepository);
+      
+      assertEquals(0, queue.getMessageCount());
+      assertEquals(0, queue.getDeliveringCount());
+      assertEquals(0, queue.getSizeBytes());
+
+      EasyMock.verify(storageManager, postOffice, queueSettingsRepository, expiryBinding);
+   }
+
+   public void testSendMessageToDLQ() throws Exception
+   {
+      long messageID = randomLong();
+      final SimpleString dlqName = new SimpleString("dlq");
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, -1, scheduledExecutor);
+      MessageReference messageReference = generateReference(queue, messageID);
+      StorageManager storageManager = createMock(StorageManager.class);
+      expect(storageManager.generateTransactionID()).andReturn(randomLong());
+      expect(storageManager.generateMessageID()).andReturn(randomLong());
+      storageManager.storeDeleteTransactional(anyLong(), eq(messageID));
+      storageManager.commit(anyLong());
+      PostOffice postOffice = createMock(PostOffice.class);      
+      Binding dlqBinding = createMock(Binding.class);
+      expect(dlqBinding.getAddress()).andStubReturn(dlqName);
+      expect(postOffice.getBinding(dlqName)).andReturn(dlqBinding );
+      expect(postOffice.route(isA(ServerMessage.class))).andReturn(new ArrayList<MessageReference>());
+      HierarchicalRepository<QueueSettings> queueSettingsRepository = createMock(HierarchicalRepository.class);
+      QueueSettings queueSettings = new QueueSettings() 
+      {
+         @Override
+         public SimpleString getDLQ()
+         {
+            return dlqName;
+         } 
+      };
+      EasyMock.expect(queueSettingsRepository.getMatch(queue1.toString())).andStubReturn(queueSettings);
+
+      EasyMock.replay(storageManager, postOffice, queueSettingsRepository, dlqBinding);
+
+      assertEquals(0, queue.getMessageCount());
+      assertEquals(0, queue.getDeliveringCount());
+      assertEquals(0, queue.getSizeBytes());
+      
+      queue.addLast(messageReference);
+      
+      assertEquals(1, queue.getMessageCount());
+      assertEquals(0, queue.getDeliveringCount());
+      assertTrue(queue.getSizeBytes() > 0);
+      
+      queue.sendMessageToDLQ(messageID, storageManager , postOffice, queueSettingsRepository);
+      
+      assertEquals(0, queue.getMessageCount());
+      assertEquals(0, queue.getDeliveringCount());
+      assertEquals(0, queue.getSizeBytes());
+
+      EasyMock.verify(storageManager, postOffice, queueSettingsRepository, dlqBinding);
+   }
+   
+   public void testMoveMessage() throws Exception
+   {
+      long messageID = randomLong();
+      long tid = randomLong();
+      final SimpleString toQueueName = new SimpleString("toQueueName");
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, -1, scheduledExecutor);
+      Queue toQueue = createMock(Queue.class);
+    
+      MessageReference messageReference = generateReference(queue, messageID);
+      StorageManager storageManager = EasyMock.createMock(StorageManager.class);
+      EasyMock.expect(storageManager.generateTransactionID()).andReturn(tid);
+      storageManager.storeDeleteTransactional(EasyMock.anyLong(), EasyMock.eq(messageID));
+      storageManager.commit(EasyMock.anyLong());
+      PostOffice postOffice = EasyMock.createMock(PostOffice.class);      
+      Binding toBinding = EasyMock.createMock(Binding.class);
+      EasyMock.expect(toBinding.getAddress()).andStubReturn(toQueueName);
+      EasyMock.expect(toBinding.getQueue()).andStubReturn(toQueue);
+      EasyMock.expect(postOffice.route(EasyMock.isA(ServerMessage.class))).andReturn(new ArrayList<MessageReference>());
+      HierarchicalRepository<QueueSettings> queueSettingsRepository = EasyMock.createMock(HierarchicalRepository.class);
+
+      EasyMock.replay(storageManager, postOffice, queueSettingsRepository, toBinding);
+
+      assertEquals(0, queue.getMessageCount());
+      assertEquals(0, queue.getDeliveringCount());
+      assertEquals(0, queue.getSizeBytes());
+      
+      queue.addLast(messageReference);
+      
+      assertEquals(1, queue.getMessageCount());
+      assertEquals(0, queue.getDeliveringCount());
+      assertTrue(queue.getSizeBytes() > 0);
+      
+      queue.moveMessage(messageID, toBinding, storageManager, postOffice);
+      
+      assertEquals(0, queue.getMessageCount());
+      assertEquals(0, queue.getDeliveringCount());
+      assertEquals(0, queue.getSizeBytes());
+
+      EasyMock.verify(storageManager, postOffice, queueSettingsRepository, toBinding);
+   }
+   
    // Inner classes ---------------------------------------------------------------
 
    class AddtoQueueRunner implements Runnable

Copied: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server (from rev 4779, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server)

Copied: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management (from rev 4779, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management)

Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/JMSMessageInfoTest.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/JMSMessageInfoTest.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/JMSMessageInfoTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,167 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.unit.jms.server.management;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
-import static org.jboss.messaging.tests.util.RandomUtil.randomByte;
-import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
-import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
-import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
-import static org.jboss.messaging.tests.util.RandomUtil.randomString;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularData;
-
-import junit.framework.TestCase;
-
-import org.jboss.messaging.core.server.ServerMessage;
-import org.jboss.messaging.jms.server.management.JMSMessageInfo;
-import org.jboss.messaging.util.SimpleString;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class JMSMessageInfoTest extends TestCase
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   public static void assertJMSMessageInfoEquals(JMSMessageInfo expected,
-         CompositeData actual)
-   {
-      assertTrue(actual.getCompositeType().equals(JMSMessageInfo.TYPE));
-
-      assertEquals(expected.getJMSMessageID(), actual.get("JMSMessageID"));
-      assertEquals(expected.getJMSCorrelationID(), actual
-            .get("JMSCorrelationID"));
-      assertEquals(expected.getJMSDeliveryMode(), actual.get("JMSDeliveryMode"));
-      assertEquals(expected.getJMSPriority(), actual.get("JMSPriority"));
-      assertEquals(expected.getJMSReplyTo(), actual.get("JMSReplyTo"));
-      assertEquals(expected.getJMSTimestamp(), actual.get("JMSTimestamp"));
-      assertEquals(expected.getJMSType(), actual.get("JMSType"));
-      assertEquals(expected.getExpiration(), actual.get("expiration"));
-
-      TabularData propsDatas = (TabularData) actual.get("properties");
-      Collection<CompositeData> props = propsDatas.values();
-      assertEquals(expected.getProperties().size(), props.size());
-      for (CompositeData prop : props)
-      {
-         String actualKey = (String) prop.get("key");
-         String actualValue = (String) prop.get("value");
-
-         assertTrue(expected.getProperties().containsKey(actualKey));
-         assertEquals(expected.getProperties().get(actualKey), actualValue);
-      }
-   }
-
-   // Constructors --------------------------------------------------
-
-   // Public --------------------------------------------------------
-
-   public void testToCompositeData() throws Exception
-   {
-      JMSMessageInfo info = new JMSMessageInfo(randomString(), randomString(),
-            randomString(), randomInt(), randomString(), randomLong(),
-            randomLong(), randomString());
-      info.putProperty(randomString(), randomString());
-      CompositeData data = info.toCompositeData();
-
-      assertJMSMessageInfoEquals(info, data);
-   }
-
-   public void testToTabularData() throws Exception
-   {
-      JMSMessageInfo info_1 = new JMSMessageInfo(randomString(),
-            randomString(), randomString(), randomInt(), randomString(),
-            randomLong(), randomLong(), randomString());
-      info_1.putProperty(randomString(), randomString());
-      info_1.putProperty(randomString(), randomString());
-      JMSMessageInfo info_2 = new JMSMessageInfo(randomString(),
-            randomString(), randomString(), randomInt(), randomString(),
-            randomLong(), randomLong(), randomString());
-      info_2.putProperty(randomString(), randomString());
-      JMSMessageInfo[] messages = new JMSMessageInfo[] { info_1, info_2 };
-
-      TabularData data = JMSMessageInfo.toTabularData(messages);
-      assertEquals(2, data.size());
-      CompositeData data_1 = data
-            .get(new Object[] { info_1.getJMSMessageID() });
-      CompositeData data_2 = data
-            .get(new Object[] { info_2.getJMSMessageID() });
-
-      assertJMSMessageInfoEquals(info_1, data_1);
-      assertJMSMessageInfoEquals(info_2, data_2);
-   }
-
-   public void testToTabularDataWithEmptyMessages() throws Exception
-   {
-      TabularData data = JMSMessageInfo.toTabularData(new JMSMessageInfo[0]);
-      assertEquals(0, data.size());
-   }
-   
-   public void testFromServerMessage() throws Exception
-   {
-      ServerMessage message = createMock(ServerMessage.class);
-      expect(message.getProperty(new SimpleString("JMSMessageID"))).andStubReturn(randomSimpleString());
-      expect(message.getProperty(new SimpleString("JMSCorrelationID"))).andStubReturn(randomSimpleString());
-      expect(message.getProperty(new SimpleString("JMSType"))).andStubReturn(randomSimpleString());
-      expect(message.isDurable()).andStubReturn(randomBoolean());
-      expect(message.getPriority()).andStubReturn(randomByte());
-      expect(message.getProperty(new SimpleString("JMSReplyTo"))).andStubReturn(randomSimpleString());
-      expect(message.getTimestamp()).andStubReturn(randomLong());
-      expect(message.getExpiration()).andStubReturn(randomLong());
-      Set<SimpleString> propNames = new HashSet<SimpleString>();
-      propNames.add(new SimpleString("foo"));
-      expect(message.getPropertyNames()).andStubReturn(propNames);
-      expect(message.getProperty(new SimpleString("foo"))).andStubReturn(randomSimpleString());
-      
-      replay(message);
-      JMSMessageInfo info = JMSMessageInfo.fromServerMessage(message );
-      
-      verify(message);
-      
-   }
-
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/JMSMessageInfoTest.java (from rev 4779, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/JMSMessageInfoTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/JMSMessageInfoTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/JMSMessageInfoTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,167 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.unit.jms.server.management;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomByte;
+import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
+import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
+import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.jms.server.management.JMSMessageInfo;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class JMSMessageInfoTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   public static void assertJMSMessageInfoEquals(JMSMessageInfo expected,
+         CompositeData actual)
+   {
+      assertTrue(actual.getCompositeType().equals(JMSMessageInfo.TYPE));
+
+      assertEquals(expected.getJMSMessageID(), actual.get("JMSMessageID"));
+      assertEquals(expected.getJMSCorrelationID(), actual
+            .get("JMSCorrelationID"));
+      assertEquals(expected.getJMSDeliveryMode(), actual.get("JMSDeliveryMode"));
+      assertEquals(expected.getJMSPriority(), actual.get("JMSPriority"));
+      assertEquals(expected.getJMSReplyTo(), actual.get("JMSReplyTo"));
+      assertEquals(expected.getJMSTimestamp(), actual.get("JMSTimestamp"));
+      assertEquals(expected.getJMSType(), actual.get("JMSType"));
+      assertEquals(expected.getExpiration(), actual.get("expiration"));
+
+      TabularData propsDatas = (TabularData) actual.get("properties");
+      Collection<CompositeData> props = propsDatas.values();
+      assertEquals(expected.getProperties().size(), props.size());
+      for (CompositeData prop : props)
+      {
+         String actualKey = (String) prop.get("key");
+         String actualValue = (String) prop.get("value");
+
+         assertTrue(expected.getProperties().containsKey(actualKey));
+         assertEquals(expected.getProperties().get(actualKey), actualValue);
+      }
+   }
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testToCompositeData() throws Exception
+   {
+      JMSMessageInfo info = new JMSMessageInfo(randomString(), randomString(),
+            randomString(), randomInt(), randomString(), randomLong(),
+            randomLong(), randomString());
+      info.putProperty(randomString(), randomString());
+      CompositeData data = info.toCompositeData();
+
+      assertJMSMessageInfoEquals(info, data);
+   }
+
+   public void testToTabularData() throws Exception
+   {
+      JMSMessageInfo info_1 = new JMSMessageInfo(randomString(),
+            randomString(), randomString(), randomInt(), randomString(),
+            randomLong(), randomLong(), randomString());
+      info_1.putProperty(randomString(), randomString());
+      info_1.putProperty(randomString(), randomString());
+      JMSMessageInfo info_2 = new JMSMessageInfo(randomString(),
+            randomString(), randomString(), randomInt(), randomString(),
+            randomLong(), randomLong(), randomString());
+      info_2.putProperty(randomString(), randomString());
+      JMSMessageInfo[] messages = new JMSMessageInfo[] { info_1, info_2 };
+
+      TabularData data = JMSMessageInfo.toTabularData(messages);
+      assertEquals(2, data.size());
+      CompositeData data_1 = data
+            .get(new Object[] { info_1.getJMSMessageID() });
+      CompositeData data_2 = data
+            .get(new Object[] { info_2.getJMSMessageID() });
+
+      assertJMSMessageInfoEquals(info_1, data_1);
+      assertJMSMessageInfoEquals(info_2, data_2);
+   }
+
+   public void testToTabularDataWithEmptyMessages() throws Exception
+   {
+      TabularData data = JMSMessageInfo.toTabularData(new JMSMessageInfo[0]);
+      assertEquals(0, data.size());
+   }
+   
+   public void testFromServerMessage() throws Exception
+   {
+      ServerMessage message = createMock(ServerMessage.class);
+      expect(message.getProperty(new SimpleString("JMSMessageID"))).andStubReturn(randomSimpleString());
+      expect(message.getProperty(new SimpleString("JMSCorrelationID"))).andStubReturn(randomSimpleString());
+      expect(message.getProperty(new SimpleString("JMSType"))).andStubReturn(randomSimpleString());
+      expect(message.isDurable()).andStubReturn(randomBoolean());
+      expect(message.getPriority()).andStubReturn(randomByte());
+      expect(message.getProperty(new SimpleString("JMSReplyTo"))).andStubReturn(randomSimpleString());
+      expect(message.getTimestamp()).andStubReturn(randomLong());
+      expect(message.getExpiration()).andStubReturn(randomLong());
+      Set<SimpleString> propNames = new HashSet<SimpleString>();
+      propNames.add(new SimpleString("foo"));
+      expect(message.getPropertyNames()).andStubReturn(propNames);
+      expect(message.getProperty(new SimpleString("foo"))).andStubReturn(randomSimpleString());
+      
+      replay(message);
+      JMSMessageInfo info = JMSMessageInfo.fromServerMessage(message );
+      
+      verify(message);
+      
+   }
+
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/SubscriberInfoTest.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/SubscriberInfoTest.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/SubscriberInfoTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,110 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.unit.jms.server.management;
-
-import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
-import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
-import static org.jboss.messaging.tests.util.RandomUtil.randomString;
-
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularData;
-
-import junit.framework.TestCase;
-
-import org.jboss.messaging.jms.server.management.SubscriberInfo;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class SubscriberInfoTest extends TestCase
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   public static void assertEquals(SubscriberInfo expected,
-         CompositeData actual)
-   {
-      assertTrue(actual.getCompositeType().equals(SubscriberInfo.TYPE));
-
-      assertEquals(expected.getID(), actual.get("id"));
-      assertEquals(expected.getClientID(), actual.get("clientID"));
-      assertEquals(expected.getName(), actual.get("name"));
-      assertEquals(expected.isDurable(), actual.get("durable"));
-      assertEquals(expected.getSelector(), actual.get("selector"));
-      assertEquals(expected.getMessageCount(), actual.get("messageCount"));
-      assertEquals(expected.getMaxSizeBytes(), actual.get("maxSizeBytes"));
-   }
-
-   // Constructors --------------------------------------------------
-
-   // Public --------------------------------------------------------
-
-   public void testToCompositeData() throws Exception
-   {
-      SubscriberInfo info = new SubscriberInfo(randomString(), randomString(),
-            randomString(), randomBoolean(), randomString(), randomInt(),
-            randomInt());
-      CompositeData data = info.toCompositeData();
-
-      assertEquals(info, data);
-   }
-
-   public void testToTabularData() throws Exception
-   {
-      SubscriberInfo info_1 = new SubscriberInfo(randomString(), randomString(),
-            randomString(), randomBoolean(), randomString(), randomInt(),
-            randomInt());
-      SubscriberInfo info_2 = new SubscriberInfo(randomString(), randomString(),
-            randomString(), randomBoolean(), randomString(), randomInt(),
-            randomInt());
-      SubscriberInfo[] infos = new SubscriberInfo[] { info_1, info_2 };
-
-      TabularData data = SubscriberInfo.toTabularData(infos);
-      assertEquals(2, data.size());
-      CompositeData data_1 = data.get(new Object[] { info_1.getID() });
-      CompositeData data_2 = data.get(new Object[] { info_2.getID() });
-
-      assertEquals(info_1, data_1);
-      assertEquals(info_2, data_2);
-   }
-
-   public void testToTabularDataWithEmptyMessages() throws Exception
-   {
-      TabularData data = SubscriberInfo.toTabularData(new SubscriberInfo[0]);
-      assertEquals(0, data.size());
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/SubscriberInfoTest.java (from rev 4779, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/SubscriberInfoTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/SubscriberInfoTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/SubscriberInfoTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.unit.jms.server.management;
+
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.jms.server.management.SubscriberInfo;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class SubscriberInfoTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   public static void assertEquals(SubscriberInfo expected,
+         CompositeData actual)
+   {
+      assertTrue(actual.getCompositeType().equals(SubscriberInfo.TYPE));
+
+      assertEquals(expected.getID(), actual.get("id"));
+      assertEquals(expected.getClientID(), actual.get("clientID"));
+      assertEquals(expected.getName(), actual.get("name"));
+      assertEquals(expected.isDurable(), actual.get("durable"));
+      assertEquals(expected.getSelector(), actual.get("selector"));
+      assertEquals(expected.getMessageCount(), actual.get("messageCount"));
+      assertEquals(expected.getMaxSizeBytes(), actual.get("maxSizeBytes"));
+   }
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testToCompositeData() throws Exception
+   {
+      SubscriberInfo info = new SubscriberInfo(randomString(), randomString(),
+            randomString(), randomBoolean(), randomString(), randomInt(),
+            randomInt());
+      CompositeData data = info.toCompositeData();
+
+      assertEquals(info, data);
+   }
+
+   public void testToTabularData() throws Exception
+   {
+      SubscriberInfo info_1 = new SubscriberInfo(randomString(), randomString(),
+            randomString(), randomBoolean(), randomString(), randomInt(),
+            randomInt());
+      SubscriberInfo info_2 = new SubscriberInfo(randomString(), randomString(),
+            randomString(), randomBoolean(), randomString(), randomInt(),
+            randomInt());
+      SubscriberInfo[] infos = new SubscriberInfo[] { info_1, info_2 };
+
+      TabularData data = SubscriberInfo.toTabularData(infos);
+      assertEquals(2, data.size());
+      CompositeData data_1 = data.get(new Object[] { info_1.getID() });
+      CompositeData data_2 = data.get(new Object[] { info_2.getID() });
+
+      assertEquals(info_1, data_1);
+      assertEquals(info_2, data_2);
+   }
+
+   public void testToTabularDataWithEmptyMessages() throws Exception
+   {
+      TabularData data = SubscriberInfo.toTabularData(new SubscriberInfo[0]);
+      assertEquals(0, data.size());
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl (from rev 4779, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl)

Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/ConnectionFactoryControlTest.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/ConnectionFactoryControlTest.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/ConnectionFactoryControlTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,311 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.unit.jms.server.management.impl;
-
-import static org.easymock.EasyMock.expect;
-import static org.easymock.classextension.EasyMock.createMock;
-import static org.easymock.classextension.EasyMock.replay;
-import static org.easymock.classextension.EasyMock.verify;
-import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
-import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
-import static org.jboss.messaging.tests.util.RandomUtil.randomString;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.easymock.classextension.EasyMock;
-import org.jboss.messaging.core.client.ClientConnectionFactory;
-import org.jboss.messaging.core.client.Location;
-import org.jboss.messaging.jms.client.JBossConnectionFactory;
-import org.jboss.messaging.jms.server.management.impl.ConnectionFactoryControl;
-import org.jboss.messaging.tests.util.RandomUtil;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class ConnectionFactoryControlTest extends TestCase
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   // Public --------------------------------------------------------
-
-   public void testGetName() throws Exception
-   {
-      String name = randomString();
-      List<String> bindings = new ArrayList<String>();
-      bindings.add(randomString());
-      bindings.add(randomString());
-
-      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
-      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
-      replay(cf, coreCF);
-
-      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
-            coreCF, name, bindings);
-      assertEquals(name, control.getName());
-
-      verify(cf, coreCF);
-   }
-
-   public void testGetBindings() throws Exception
-   {
-      String name = randomString();
-      List<String> bindings = new ArrayList<String>();
-      bindings.add(randomString());
-      bindings.add(randomString());
-
-      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
-      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
-      replay(cf, coreCF);
-
-      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
-            coreCF, name, bindings);
-      assertEquals(bindings, control.getBindings());
-
-      verify(cf, coreCF);
-   }
-
-   public void testGetURL() throws Exception
-   {
-      String name = randomString();
-      List<String> bindings = new ArrayList<String>();
-      bindings.add(randomString());
-      bindings.add(randomString());
-
-      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
-      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
-      Location location = createMock(Location.class);
-      expect(coreCF.getLocation()).andReturn(location);
-      replay(cf, coreCF, location);
-
-      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
-            coreCF, name, bindings);
-      assertEquals(location.toString(), control.getURL());
-
-      verify(cf, coreCF, location);
-   }
-
-   public void testGetClientID() throws Exception
-   {
-      String name = randomString();
-      List<String> bindings = new ArrayList<String>();
-      bindings.add(randomString());
-      bindings.add(randomString());
-      String clientID = randomString();
-
-      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
-      expect(cf.getClientID()).andReturn(clientID);
-      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
-      replay(cf, coreCF);
-
-      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
-            coreCF, name, bindings);
-      assertEquals(clientID, control.getClientID());
-
-      verify(cf, coreCF);
-   }
-
-   public void testGetDefaultConsumerMaxRate() throws Exception
-   {
-      String name = randomString();
-      List<String> bindings = new ArrayList<String>();
-      bindings.add(randomString());
-      bindings.add(randomString());
-      int rate = randomInt();
-
-      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
-      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
-      expect(coreCF.getDefaultConsumerMaxRate()).andReturn(rate);
-      replay(cf, coreCF);
-
-      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
-            coreCF, name, bindings);
-      assertEquals(rate, control.getDefaultConsumerMaxRate());
-
-      verify(cf, coreCF);
-   }
-
-   public void testGetDefaultConsumerWindowSize() throws Exception
-   {
-      String name = randomString();
-      List<String> bindings = new ArrayList<String>();
-      bindings.add(randomString());
-      bindings.add(randomString());
-      int size = randomInt();
-
-      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
-      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
-      expect(coreCF.getDefaultConsumerWindowSize()).andReturn(size);
-      replay(cf, coreCF);
-
-      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
-            coreCF, name, bindings);
-      assertEquals(size, control.getDefaultConsumerWindowSize());
-
-      verify(cf, coreCF);
-   }
-
-   public void testGetDefaultProducerMaxRate() throws Exception
-   {
-      String name = randomString();
-      List<String> bindings = new ArrayList<String>();
-      bindings.add(randomString());
-      bindings.add(randomString());
-      int rate = randomInt();
-
-      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
-      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
-      expect(coreCF.getDefaultProducerMaxRate()).andReturn(rate);
-      replay(cf, coreCF);
-
-      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
-            coreCF, name, bindings);
-      assertEquals(rate, control.getDefaultProducerMaxRate());
-
-      verify(cf, coreCF);
-   }
-
-   public void testGetDefaultProducerWindowSize() throws Exception
-   {
-      String name = randomString();
-      List<String> bindings = new ArrayList<String>();
-      bindings.add(randomString());
-      bindings.add(randomString());
-      int size = randomInt();
-
-      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
-      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
-      expect(coreCF.getDefaultProducerWindowSize()).andReturn(size);
-      replay(cf, coreCF);
-
-      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
-            coreCF, name, bindings);
-      assertEquals(size, control.getDefaultProducerWindowSize());
-
-      verify(cf, coreCF);
-   }
-
-   public void testGetDupsOKBatchSize() throws Exception
-   {
-      String name = randomString();
-      List<String> bindings = new ArrayList<String>();
-      bindings.add(randomString());
-      bindings.add(randomString());
-      int size = randomInt();
-
-      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
-      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
-      expect(cf.getDupsOKBatchSize()).andReturn(size);
-      replay(cf, coreCF);
-
-      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
-            coreCF, name, bindings);
-      assertEquals(size, control.getDupsOKBatchSize());
-
-      verify(cf, coreCF);
-   }
-
-   public void testIsDefaultBlockOnAcknowledge() throws Exception
-   {
-      String name = randomString();
-      List<String> bindings = new ArrayList<String>();
-      bindings.add(randomString());
-      bindings.add(randomString());
-      boolean blockOnAcknowledge = randomBoolean();
-
-      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
-      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
-      expect(coreCF.isDefaultBlockOnAcknowledge())
-            .andReturn(blockOnAcknowledge);
-      replay(cf, coreCF);
-
-      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
-            coreCF, name, bindings);
-      assertEquals(blockOnAcknowledge, control.isDefaultBlockOnAcknowledge());
-
-      verify(cf, coreCF);
-   }
-
-   public void testIsDefaultBlockOnNonPersistentSend() throws Exception
-   {
-      String name = randomString();
-      List<String> bindings = new ArrayList<String>();
-      bindings.add(randomString());
-      bindings.add(randomString());
-      boolean blockOnNonPersistentSend = randomBoolean();
-
-      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
-      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
-      expect(coreCF.isDefaultBlockOnNonPersistentSend()).andReturn(
-            blockOnNonPersistentSend);
-      replay(cf, coreCF);
-
-      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
-            coreCF, name, bindings);
-      assertEquals(blockOnNonPersistentSend, control
-            .isDefaultBlockOnNonPersistentSend());
-
-      verify(cf, coreCF);
-   }
-
-   public void testIsDefaultBlockOnPersistentSend() throws Exception
-   {
-      String name = randomString();
-      List<String> bindings = new ArrayList<String>();
-      bindings.add(randomString());
-      bindings.add(randomString());
-      boolean blockOnPersistentSend = randomBoolean();
-
-      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
-      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
-      expect(coreCF.isDefaultBlockOnPersistentSend()).andReturn(
-            blockOnPersistentSend);
-      replay(cf, coreCF);
-
-      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
-            coreCF, name, bindings);
-      assertEquals(blockOnPersistentSend, control
-            .isDefaultBlockOnPersistentSend());
-
-      verify(cf, coreCF);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/ConnectionFactoryControlTest.java (from rev 4779, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/ConnectionFactoryControlTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/ConnectionFactoryControlTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/ConnectionFactoryControlTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,311 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.unit.jms.server.management.impl;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.easymock.classextension.EasyMock;
+import org.jboss.messaging.core.client.ClientConnectionFactory;
+import org.jboss.messaging.core.client.Location;
+import org.jboss.messaging.jms.client.JBossConnectionFactory;
+import org.jboss.messaging.jms.server.management.impl.ConnectionFactoryControl;
+import org.jboss.messaging.tests.util.RandomUtil;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class ConnectionFactoryControlTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testGetName() throws Exception
+   {
+      String name = randomString();
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(randomString());
+      bindings.add(randomString());
+
+      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
+      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
+      replay(cf, coreCF);
+
+      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
+            coreCF, name, bindings);
+      assertEquals(name, control.getName());
+
+      verify(cf, coreCF);
+   }
+
+   public void testGetBindings() throws Exception
+   {
+      String name = randomString();
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(randomString());
+      bindings.add(randomString());
+
+      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
+      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
+      replay(cf, coreCF);
+
+      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
+            coreCF, name, bindings);
+      assertEquals(bindings, control.getBindings());
+
+      verify(cf, coreCF);
+   }
+
+   public void testGetURL() throws Exception
+   {
+      String name = randomString();
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(randomString());
+      bindings.add(randomString());
+
+      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
+      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
+      Location location = createMock(Location.class);
+      expect(coreCF.getLocation()).andReturn(location);
+      replay(cf, coreCF, location);
+
+      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
+            coreCF, name, bindings);
+      assertEquals(location.toString(), control.getURL());
+
+      verify(cf, coreCF, location);
+   }
+
+   public void testGetClientID() throws Exception
+   {
+      String name = randomString();
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(randomString());
+      bindings.add(randomString());
+      String clientID = randomString();
+
+      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
+      expect(cf.getClientID()).andReturn(clientID);
+      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
+      replay(cf, coreCF);
+
+      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
+            coreCF, name, bindings);
+      assertEquals(clientID, control.getClientID());
+
+      verify(cf, coreCF);
+   }
+
+   public void testGetDefaultConsumerMaxRate() throws Exception
+   {
+      String name = randomString();
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(randomString());
+      bindings.add(randomString());
+      int rate = randomInt();
+
+      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
+      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
+      expect(coreCF.getDefaultConsumerMaxRate()).andReturn(rate);
+      replay(cf, coreCF);
+
+      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
+            coreCF, name, bindings);
+      assertEquals(rate, control.getDefaultConsumerMaxRate());
+
+      verify(cf, coreCF);
+   }
+
+   public void testGetDefaultConsumerWindowSize() throws Exception
+   {
+      String name = randomString();
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(randomString());
+      bindings.add(randomString());
+      int size = randomInt();
+
+      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
+      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
+      expect(coreCF.getDefaultConsumerWindowSize()).andReturn(size);
+      replay(cf, coreCF);
+
+      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
+            coreCF, name, bindings);
+      assertEquals(size, control.getDefaultConsumerWindowSize());
+
+      verify(cf, coreCF);
+   }
+
+   public void testGetDefaultProducerMaxRate() throws Exception
+   {
+      String name = randomString();
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(randomString());
+      bindings.add(randomString());
+      int rate = randomInt();
+
+      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
+      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
+      expect(coreCF.getDefaultProducerMaxRate()).andReturn(rate);
+      replay(cf, coreCF);
+
+      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
+            coreCF, name, bindings);
+      assertEquals(rate, control.getDefaultProducerMaxRate());
+
+      verify(cf, coreCF);
+   }
+
+   public void testGetDefaultProducerWindowSize() throws Exception
+   {
+      String name = randomString();
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(randomString());
+      bindings.add(randomString());
+      int size = randomInt();
+
+      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
+      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
+      expect(coreCF.getDefaultProducerWindowSize()).andReturn(size);
+      replay(cf, coreCF);
+
+      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
+            coreCF, name, bindings);
+      assertEquals(size, control.getDefaultProducerWindowSize());
+
+      verify(cf, coreCF);
+   }
+
+   public void testGetDupsOKBatchSize() throws Exception
+   {
+      String name = randomString();
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(randomString());
+      bindings.add(randomString());
+      int size = randomInt();
+
+      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
+      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
+      expect(cf.getDupsOKBatchSize()).andReturn(size);
+      replay(cf, coreCF);
+
+      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
+            coreCF, name, bindings);
+      assertEquals(size, control.getDupsOKBatchSize());
+
+      verify(cf, coreCF);
+   }
+
+   public void testIsDefaultBlockOnAcknowledge() throws Exception
+   {
+      String name = randomString();
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(randomString());
+      bindings.add(randomString());
+      boolean blockOnAcknowledge = randomBoolean();
+
+      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
+      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
+      expect(coreCF.isDefaultBlockOnAcknowledge())
+            .andReturn(blockOnAcknowledge);
+      replay(cf, coreCF);
+
+      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
+            coreCF, name, bindings);
+      assertEquals(blockOnAcknowledge, control.isDefaultBlockOnAcknowledge());
+
+      verify(cf, coreCF);
+   }
+
+   public void testIsDefaultBlockOnNonPersistentSend() throws Exception
+   {
+      String name = randomString();
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(randomString());
+      bindings.add(randomString());
+      boolean blockOnNonPersistentSend = randomBoolean();
+
+      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
+      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
+      expect(coreCF.isDefaultBlockOnNonPersistentSend()).andReturn(
+            blockOnNonPersistentSend);
+      replay(cf, coreCF);
+
+      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
+            coreCF, name, bindings);
+      assertEquals(blockOnNonPersistentSend, control
+            .isDefaultBlockOnNonPersistentSend());
+
+      verify(cf, coreCF);
+   }
+
+   public void testIsDefaultBlockOnPersistentSend() throws Exception
+   {
+      String name = randomString();
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(randomString());
+      bindings.add(randomString());
+      boolean blockOnPersistentSend = randomBoolean();
+
+      JBossConnectionFactory cf = createMock(JBossConnectionFactory.class);
+      ClientConnectionFactory coreCF = createMock(ClientConnectionFactory.class);
+      expect(coreCF.isDefaultBlockOnPersistentSend()).andReturn(
+            blockOnPersistentSend);
+      replay(cf, coreCF);
+
+      ConnectionFactoryControl control = new ConnectionFactoryControl(cf,
+            coreCF, name, bindings);
+      assertEquals(blockOnPersistentSend, control
+            .isDefaultBlockOnPersistentSend());
+
+      verify(cf, coreCF);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Copied: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSManagementServiceImplTest.java (from rev 4780, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSManagementServiceImplTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSManagementServiceImplTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSManagementServiceImplTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,305 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.unit.jms.server.management.impl;
+
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.client.ClientConnectionFactory;
+import org.jboss.messaging.core.management.MessagingServerManagement;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.jms.JBossQueue;
+import org.jboss.messaging.jms.JBossTopic;
+import org.jboss.messaging.jms.client.JBossConnectionFactory;
+import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.management.ConnectionFactoryControlMBean;
+import org.jboss.messaging.jms.server.management.JMSManagementService;
+import org.jboss.messaging.jms.server.management.JMSQueueControlMBean;
+import org.jboss.messaging.jms.server.management.JMSServerControlMBean;
+import org.jboss.messaging.jms.server.management.TopicControlMBean;
+import org.jboss.messaging.jms.server.management.impl.ConnectionFactoryControl;
+import org.jboss.messaging.jms.server.management.impl.JMSManagementServiceImpl;
+import org.jboss.messaging.jms.server.management.impl.JMSQueueControl;
+import org.jboss.messaging.jms.server.management.impl.TopicControl;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class JMSManagementServiceImplTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testRegisterJMSServer() throws Exception
+   {
+      ObjectName objectName = JMSManagementServiceImpl
+            .getJMSServerObjectName();
+      ObjectInstance objectInstance = new ObjectInstance(objectName,
+            JMSServerManager.class.getName());
+
+      JMSServerManager server = createMock(JMSServerManager.class);
+
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(false);
+      expect(
+            mbeanServer.registerMBean(isA(JMSServerControlMBean.class),
+                  eq(objectName))).andReturn(objectInstance);
+
+      replay(mbeanServer, server);
+
+      JMSManagementService service = new JMSManagementServiceImpl(mbeanServer,
+            true);
+      service.registerJMSServer(server);
+      
+      verify(mbeanServer, server);
+   }
+
+   public void testRegisterAlreadyRegisteredJMSServer() throws Exception
+   {
+      ObjectName objectName = JMSManagementServiceImpl
+            .getJMSServerObjectName();
+      ObjectInstance objectInstance = new ObjectInstance(objectName,
+            JMSServerManager.class.getName());
+
+      JMSServerManager server = createMock(JMSServerManager.class);
+
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(true);
+      mbeanServer.unregisterMBean(objectName);
+      expect(
+            mbeanServer.registerMBean(isA(JMSServerControlMBean.class),
+                  eq(objectName))).andReturn(objectInstance);
+
+      replay(mbeanServer, server);
+
+      JMSManagementService service = new JMSManagementServiceImpl(mbeanServer,
+            true);
+      service.registerJMSServer(server);
+      
+      verify(mbeanServer, server);
+   }
+   
+   public void testRegisterQueue() throws Exception
+   {
+      String name = randomString();
+      String jndiBinding = randomString();
+      ObjectName objectName = JMSManagementServiceImpl
+            .getJMSQueueObjectName(name);
+      ObjectInstance objectInstance = new ObjectInstance(objectName,
+            JMSQueueControl.class.getName());
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager server = createMock(JMSServerManager.class);
+
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(false);
+      expect(
+            mbeanServer.registerMBean(isA(JMSQueueControlMBean.class),
+                  eq(objectName))).andReturn(objectInstance);
+
+      replay(mbeanServer, coreQueue, server);
+
+      JMSManagementService service = new JMSManagementServiceImpl(mbeanServer,
+            true);
+      service.registerQueue(queue, coreQueue, jndiBinding, server);
+
+      verify(mbeanServer, coreQueue, server);
+   }
+
+   public void testRegisterAlreadyRegisteredQueue() throws Exception
+   {
+      String name = randomString();
+      String jndiBinding = randomString();
+      ObjectName objectName = JMSManagementServiceImpl
+            .getJMSQueueObjectName(name);
+      ObjectInstance objectInstance = new ObjectInstance(objectName,
+            JMSQueueControl.class.getName());
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager server = createMock(JMSServerManager.class);
+
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(true);
+      mbeanServer.unregisterMBean(objectName);
+      expect(
+            mbeanServer.registerMBean(isA(JMSQueueControlMBean.class),
+                  eq(objectName))).andReturn(objectInstance);
+
+      replay(mbeanServer, coreQueue, server);
+
+      JMSManagementService service = new JMSManagementServiceImpl(mbeanServer,
+            true);
+      service.registerQueue(queue, coreQueue, jndiBinding, server);
+
+      verify(mbeanServer, coreQueue, server);
+   }
+
+   public void testRegisterTopic() throws Exception
+   {
+      String name = randomString();
+      String jndiBinding = randomString();
+      ObjectName objectName = JMSManagementServiceImpl
+            .getJMSTopicObjectName(name);
+      ObjectInstance objectInstance = new ObjectInstance(objectName,
+            TopicControl.class.getName());
+
+      JBossTopic topic = new JBossTopic(name);
+      MessagingServerManagement serverManagement = createMock(MessagingServerManagement.class);
+
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(false);
+      expect(
+            mbeanServer.registerMBean(isA(TopicControlMBean.class),
+                  eq(objectName))).andReturn(objectInstance);
+
+      replay(mbeanServer, serverManagement);
+
+      JMSManagementService service = new JMSManagementServiceImpl(mbeanServer,
+            true);
+      service.registerTopic(topic, serverManagement, jndiBinding);
+
+      verify(mbeanServer, serverManagement);
+   }
+
+   public void testRegisterAlreadyRegisteredTopic() throws Exception
+   {
+      String name = randomString();
+      String jndiBinding = randomString();
+      ObjectName objectName = JMSManagementServiceImpl
+            .getJMSTopicObjectName(name);
+      ObjectInstance objectInstance = new ObjectInstance(objectName,
+            TopicControl.class.getName());
+
+      JBossTopic topic = new JBossTopic(name);
+      MessagingServerManagement serverManagement = createMock(MessagingServerManagement.class);
+
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(true);
+      mbeanServer.unregisterMBean(objectName);
+      expect(
+            mbeanServer.registerMBean(isA(TopicControlMBean.class),
+                  eq(objectName))).andReturn(objectInstance);
+
+      replay(mbeanServer, serverManagement);
+
+      JMSManagementService service = new JMSManagementServiceImpl(mbeanServer,
+            true);
+      service.registerTopic(topic, serverManagement, jndiBinding);
+
+      verify(mbeanServer, serverManagement);
+   }
+
+   public void testRegisterConnectionFactory() throws Exception
+   {
+      String name = randomString();
+      String jndiBinding = randomString();
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(jndiBinding);
+
+      ObjectName objectName = JMSManagementServiceImpl
+            .getConnectionFactoryObjectName(name);
+      ObjectInstance objectInstance = new ObjectInstance(objectName,
+            ConnectionFactoryControl.class.getName());
+
+      JBossConnectionFactory connectionFactory = createMock(JBossConnectionFactory.class);
+      ClientConnectionFactory coreConnection = createMock(ClientConnectionFactory.class);
+      expect(connectionFactory.getCoreConnection()).andReturn(coreConnection);
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(false);
+      expect(
+            mbeanServer.registerMBean(isA(ConnectionFactoryControlMBean.class),
+                  eq(objectName))).andReturn(objectInstance);
+
+      replay(mbeanServer, connectionFactory, coreConnection);
+
+      JMSManagementService service = new JMSManagementServiceImpl(mbeanServer,
+            true);
+      service.registerConnectionFactory(name, connectionFactory, bindings);
+
+      verify(mbeanServer, connectionFactory, coreConnection);
+   }
+
+   public void testRegisterAlreadyRegisteredConnectionFactory() throws Exception
+   {
+      String name = randomString();
+      String jndiBinding = randomString();
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(jndiBinding);
+
+      ObjectName objectName = JMSManagementServiceImpl
+            .getConnectionFactoryObjectName(name);
+      ObjectInstance objectInstance = new ObjectInstance(objectName,
+            ConnectionFactoryControl.class.getName());
+
+      JBossConnectionFactory connectionFactory = createMock(JBossConnectionFactory.class);
+      ClientConnectionFactory coreConnection = createMock(ClientConnectionFactory.class);
+      expect(connectionFactory.getCoreConnection()).andReturn(coreConnection);
+      MBeanServer mbeanServer = createMock(MBeanServer.class);
+      expect(mbeanServer.isRegistered(objectName)).andReturn(true);
+      mbeanServer.unregisterMBean(objectName);
+      expect(
+            mbeanServer.registerMBean(isA(ConnectionFactoryControlMBean.class),
+                  eq(objectName))).andReturn(objectInstance);
+
+      replay(mbeanServer, connectionFactory, coreConnection);
+
+      JMSManagementService service = new JMSManagementServiceImpl(mbeanServer,
+            true);
+      service.registerConnectionFactory(name, connectionFactory, bindings);
+
+      verify(mbeanServer, connectionFactory, coreConnection);
+   }
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,562 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.unit.jms.server.management.impl;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.isA;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
-import static org.jboss.messaging.tests.util.RandomUtil.randomByte;
-import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
-import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
-import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
-import static org.jboss.messaging.tests.util.RandomUtil.randomString;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularData;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-import org.jboss.messaging.core.filter.Filter;
-import org.jboss.messaging.core.server.MessageReference;
-import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.ServerMessage;
-import org.jboss.messaging.core.settings.impl.QueueSettings;
-import org.jboss.messaging.jms.JBossQueue;
-import org.jboss.messaging.jms.server.JMSServerManager;
-import org.jboss.messaging.jms.server.management.impl.JMSQueueControl;
-import org.jboss.messaging.util.SimpleString;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class JMSQueueControlTest extends TestCase
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   // Public --------------------------------------------------------
-
-   public void testGetName() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-
-      replay(coreQueue, serverManager);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      assertEquals(name, control.getName());
-
-      verify(coreQueue, serverManager);
-   }
-
-   public void testGetAddress() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-
-      replay(coreQueue, serverManager);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      assertEquals(queue.getAddress(), control.getAddress());
-
-      verify(coreQueue, serverManager);
-   }
-
-   public void testGetJNDIBinding() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-
-      replay(coreQueue, serverManager);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      assertEquals(jndiBinding, control.getJNDIBinding());
-
-      verify(coreQueue, serverManager);
-   }
-
-   public void testIsTemporary() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-
-      replay(coreQueue, serverManager);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      assertEquals(queue.isTemporary(), control.isTemporary());
-
-      verify(coreQueue, serverManager);
-   }
-
-   public void testGetMessageCount() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-      int count = randomInt();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      expect(coreQueue.getMessageCount()).andReturn(count);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-
-      replay(coreQueue, serverManager);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      assertEquals(count, control.getMessageCount());
-
-      verify(coreQueue, serverManager);
-   }
-
-   public void testGetDLQ() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-      final String dlq = randomString();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      QueueSettings settings = new QueueSettings()
-      {
-         @Override
-         public SimpleString getDLQ()
-         {
-            return new SimpleString(JBossQueue.JMS_QUEUE_ADDRESS_PREFIX + dlq);
-         }
-      };
-      expect(serverManager.getSettings(queue)).andReturn(settings);
-
-      replay(coreQueue, serverManager);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      assertEquals(dlq, control.getDLQ());
-
-      verify(coreQueue, serverManager);
-   }
-
-   public void testGetExpiryQueue() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-      final String expiryQueue = randomString();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      QueueSettings settings = new QueueSettings()
-      {
-         @Override
-         public SimpleString getExpiryQueue()
-         {
-            return new SimpleString(JBossQueue.JMS_QUEUE_ADDRESS_PREFIX
-                  + expiryQueue);
-         }
-      };
-      expect(serverManager.getSettings(queue)).andReturn(settings);
-
-      replay(coreQueue, serverManager);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      assertEquals(expiryQueue, control.getExpiryQueue());
-
-      verify(coreQueue, serverManager);
-   }
-
-   public void testRemoveMessage() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-      String jmsMessageID = randomString();
-      long messageID = randomLong();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      List<MessageReference> refs = new ArrayList<MessageReference>();
-      MessageReference ref = createMock(MessageReference.class);
-      ServerMessage message = createMock(ServerMessage.class);
-      expect(message.getMessageID()).andReturn(messageID);
-      expect(ref.getMessage()).andReturn(message);
-      refs.add(ref);
-      expect(coreQueue.list(EasyMock.isA(Filter.class))).andReturn(refs);
-      expect(serverManager.removeMessage(messageID, queue)).andReturn(true);
-
-      replay(coreQueue, serverManager, ref, message);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      assertTrue(control.removeMessage(jmsMessageID));
-
-      verify(coreQueue, serverManager, ref, message);
-   }
-
-   public void testRemoveAllMessages() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      serverManager.removeAllMessages(queue);
-
-      replay(coreQueue, serverManager);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      control.removeAllMessages();
-
-      verify(coreQueue, serverManager);
-   }
-
-   public void testListMessages() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-
-      JBossQueue queue = new JBossQueue(name);
-      String filterStr = "color = 'green'";
-      List<MessageReference> refs = new ArrayList<MessageReference>();
-      MessageReference ref = createMock(MessageReference.class);
-      ServerMessage message = createMock(ServerMessage.class);
-      expect(message.getProperty(new SimpleString("JMSMessageID")))
-            .andStubReturn(randomSimpleString());
-      expect(message.getProperty(new SimpleString("JMSCorrelationID")))
-            .andStubReturn(randomSimpleString());
-      expect(message.getProperty(new SimpleString("JMSType"))).andStubReturn(
-            randomSimpleString());
-      expect(message.isDurable()).andStubReturn(randomBoolean());
-      expect(message.getPriority()).andStubReturn(randomByte());
-      expect(message.getProperty(new SimpleString("JMSReplyTo")))
-            .andStubReturn(randomSimpleString());
-      expect(message.getTimestamp()).andStubReturn(randomLong());
-      expect(message.getExpiration()).andStubReturn(randomLong());
-      expect(message.getPropertyNames()).andStubReturn(
-            new HashSet<SimpleString>());
-      expect(ref.getMessage()).andReturn(message);
-      refs.add(ref);
-      Queue coreQueue = createMock(Queue.class);
-      expect(coreQueue.list(isA(Filter.class))).andReturn(refs);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-
-      replay(coreQueue, serverManager, ref, message);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      TabularData data = control.listMessages(filterStr);
-      assertEquals(1, data.size());
-      CompositeData info = data.get(new Object[] { message.getProperty(
-            new SimpleString("JMSMessageID")).toString() });
-      assertNotNull(info);
-
-      verify(coreQueue, serverManager, ref, message);
-   }
-
-   public void testListMessagesThrowsException() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-      String invalidFilterStr = "this is not a valid filter";
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-
-      replay(coreQueue, serverManager);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      try
-      {
-         control.listMessages(invalidFilterStr);
-         fail("IllegalStateException");
-      } catch (IllegalStateException e)
-      {
-
-      }
-      verify(coreQueue, serverManager);
-   }
-
-   public void testExpireMessage() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-      String jmsMessageID = randomString();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      List<MessageReference> refs = new ArrayList<MessageReference>();
-      MessageReference ref = createMock(MessageReference.class);
-      refs.add(ref);
-      expect(coreQueue.list(EasyMock.isA(Filter.class))).andReturn(refs);
-      expect(serverManager.expireMessages(isA(Filter.class), eq(queue)))
-            .andReturn(1);
-
-      replay(coreQueue, serverManager, ref);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      assertTrue(control.expireMessage(jmsMessageID));
-
-      verify(coreQueue, serverManager, ref);
-   }
-
-   public void testExpireMessageWithNoJMSMesageID() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-      String jmsMessageID = randomString();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      expect(coreQueue.list(isA(Filter.class))).andReturn(
-            new ArrayList<MessageReference>());
-
-      replay(coreQueue, serverManager);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      try
-      {
-         control.expireMessage(jmsMessageID);
-         fail("IllegalArgumentException");
-      } catch (IllegalArgumentException e)
-      {
-      }
-
-      verify(coreQueue, serverManager);
-   }
-   
-   public void testExpireMessages() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-      int expiredMessage = randomInt();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      expect(serverManager.expireMessages(isA(Filter.class), eq(queue)))
-            .andReturn(expiredMessage);
-
-      replay(coreQueue, serverManager);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      assertEquals(expiredMessage, control.expireMessages("color = 'green'"));
-
-      verify(coreQueue, serverManager);
-   }
-
-   public void testSendMessageToDLQ() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-      String jmsMessageID = randomString();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      List<MessageReference> refs = new ArrayList<MessageReference>();
-      MessageReference ref = createMock(MessageReference.class);
-      refs.add(ref);
-      expect(coreQueue.list(isA(Filter.class))).andReturn(refs);
-      expect(serverManager.sendMessagesToDLQ(isA(Filter.class), eq(queue)))
-            .andReturn(1);
-
-      replay(coreQueue, serverManager, ref);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      assertTrue(control.sendMessageTDLQ(jmsMessageID));
-
-      verify(coreQueue, serverManager, ref);
-   }
-
-   public void testSendMessageToDLQWithNoJMSMesageID() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-      String jmsMessageID = randomString();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      expect(coreQueue.list(isA(Filter.class))).andReturn(
-            new ArrayList<MessageReference>());
-
-      replay(coreQueue, serverManager);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      try
-      {
-         control.sendMessageTDLQ(jmsMessageID);
-         fail("IllegalArgumentException");
-      } catch (IllegalArgumentException e)
-      {
-      }
-
-      verify(coreQueue, serverManager);
-   }
-   
-   public void testChangeMessagePriority() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-      byte newPriority = 5;
-      String jmsMessageID = randomString();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      List<MessageReference> refs = new ArrayList<MessageReference>();
-      MessageReference ref = createMock(MessageReference.class);
-      refs.add(ref);
-      expect(coreQueue.list(isA(Filter.class))).andReturn(refs);
-      expect(
-            serverManager.changeMessagesPriority(isA(Filter.class),
-                  eq(newPriority), eq(queue))).andReturn(1);
-
-      replay(coreQueue, serverManager, ref);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      assertTrue(control.changeMessagePriority(jmsMessageID, newPriority));
-
-      verify(coreQueue, serverManager, ref);
-   }
-
-   public void testChangeMessagePriorityWithInvalidPriorityValues()
-         throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-      String jmsMessageID = randomString();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-
-      replay(coreQueue, serverManager);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      try
-      {
-         control.changeMessagePriority(jmsMessageID, -1);
-         fail("IllegalArgumentException");
-      } catch (IllegalArgumentException e)
-      {
-      }
-
-      try
-      {
-         control.changeMessagePriority(jmsMessageID, 10);
-         fail("IllegalArgumentException");
-      } catch (IllegalArgumentException e)
-      {
-      }
-
-      verify(coreQueue, serverManager);
-   }
-
-   public void testChangeMessagePriorityWithNoJMSMesageID() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-      byte newPriority = 5;
-      String jmsMessageID = randomString();
-
-      JBossQueue queue = new JBossQueue(name);
-      Queue coreQueue = createMock(Queue.class);
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      expect(coreQueue.list(isA(Filter.class))).andReturn(
-            new ArrayList<MessageReference>());
-
-      replay(coreQueue, serverManager);
-
-      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
-            jndiBinding, serverManager);
-      try
-      {
-         control.changeMessagePriority(jmsMessageID, newPriority);
-         fail("IllegalArgumentException");
-      } catch (IllegalArgumentException e)
-      {
-      }
-
-      verify(coreQueue, serverManager);
-   }
-   
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java (from rev 4779, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,562 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.unit.jms.server.management.impl;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomByte;
+import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
+import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
+import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import junit.framework.TestCase;
+
+import org.easymock.EasyMock;
+import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.server.MessageReference;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.jms.JBossQueue;
+import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.management.impl.JMSQueueControl;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class JMSQueueControlTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testGetName() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+
+      replay(coreQueue, serverManager);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      assertEquals(name, control.getName());
+
+      verify(coreQueue, serverManager);
+   }
+
+   public void testGetAddress() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+
+      replay(coreQueue, serverManager);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      assertEquals(queue.getAddress(), control.getAddress());
+
+      verify(coreQueue, serverManager);
+   }
+
+   public void testGetJNDIBinding() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+
+      replay(coreQueue, serverManager);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      assertEquals(jndiBinding, control.getJNDIBinding());
+
+      verify(coreQueue, serverManager);
+   }
+
+   public void testIsTemporary() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+
+      replay(coreQueue, serverManager);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      assertEquals(queue.isTemporary(), control.isTemporary());
+
+      verify(coreQueue, serverManager);
+   }
+
+   public void testGetMessageCount() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+      int count = randomInt();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      expect(coreQueue.getMessageCount()).andReturn(count);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+
+      replay(coreQueue, serverManager);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      assertEquals(count, control.getMessageCount());
+
+      verify(coreQueue, serverManager);
+   }
+
+   public void testGetDLQ() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+      final String dlq = randomString();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      QueueSettings settings = new QueueSettings()
+      {
+         @Override
+         public SimpleString getDLQ()
+         {
+            return new SimpleString(JBossQueue.JMS_QUEUE_ADDRESS_PREFIX + dlq);
+         }
+      };
+      expect(serverManager.getSettings(queue)).andReturn(settings);
+
+      replay(coreQueue, serverManager);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      assertEquals(dlq, control.getDLQ());
+
+      verify(coreQueue, serverManager);
+   }
+
+   public void testGetExpiryQueue() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+      final String expiryQueue = randomString();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      QueueSettings settings = new QueueSettings()
+      {
+         @Override
+         public SimpleString getExpiryQueue()
+         {
+            return new SimpleString(JBossQueue.JMS_QUEUE_ADDRESS_PREFIX
+                  + expiryQueue);
+         }
+      };
+      expect(serverManager.getSettings(queue)).andReturn(settings);
+
+      replay(coreQueue, serverManager);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      assertEquals(expiryQueue, control.getExpiryQueue());
+
+      verify(coreQueue, serverManager);
+   }
+
+   public void testRemoveMessage() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+      String jmsMessageID = randomString();
+      long messageID = randomLong();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      List<MessageReference> refs = new ArrayList<MessageReference>();
+      MessageReference ref = createMock(MessageReference.class);
+      ServerMessage message = createMock(ServerMessage.class);
+      expect(message.getMessageID()).andReturn(messageID);
+      expect(ref.getMessage()).andReturn(message);
+      refs.add(ref);
+      expect(coreQueue.list(EasyMock.isA(Filter.class))).andReturn(refs);
+      expect(serverManager.removeMessage(messageID, queue)).andReturn(true);
+
+      replay(coreQueue, serverManager, ref, message);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      assertTrue(control.removeMessage(jmsMessageID));
+
+      verify(coreQueue, serverManager, ref, message);
+   }
+
+   public void testRemoveAllMessages() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      serverManager.removeAllMessages(queue);
+
+      replay(coreQueue, serverManager);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      control.removeAllMessages();
+
+      verify(coreQueue, serverManager);
+   }
+
+   public void testListMessages() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+
+      JBossQueue queue = new JBossQueue(name);
+      String filterStr = "color = 'green'";
+      List<MessageReference> refs = new ArrayList<MessageReference>();
+      MessageReference ref = createMock(MessageReference.class);
+      ServerMessage message = createMock(ServerMessage.class);
+      expect(message.getProperty(new SimpleString("JMSMessageID")))
+            .andStubReturn(randomSimpleString());
+      expect(message.getProperty(new SimpleString("JMSCorrelationID")))
+            .andStubReturn(randomSimpleString());
+      expect(message.getProperty(new SimpleString("JMSType"))).andStubReturn(
+            randomSimpleString());
+      expect(message.isDurable()).andStubReturn(randomBoolean());
+      expect(message.getPriority()).andStubReturn(randomByte());
+      expect(message.getProperty(new SimpleString("JMSReplyTo")))
+            .andStubReturn(randomSimpleString());
+      expect(message.getTimestamp()).andStubReturn(randomLong());
+      expect(message.getExpiration()).andStubReturn(randomLong());
+      expect(message.getPropertyNames()).andStubReturn(
+            new HashSet<SimpleString>());
+      expect(ref.getMessage()).andReturn(message);
+      refs.add(ref);
+      Queue coreQueue = createMock(Queue.class);
+      expect(coreQueue.list(isA(Filter.class))).andReturn(refs);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+
+      replay(coreQueue, serverManager, ref, message);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      TabularData data = control.listMessages(filterStr);
+      assertEquals(1, data.size());
+      CompositeData info = data.get(new Object[] { message.getProperty(
+            new SimpleString("JMSMessageID")).toString() });
+      assertNotNull(info);
+
+      verify(coreQueue, serverManager, ref, message);
+   }
+
+   public void testListMessagesThrowsException() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+      String invalidFilterStr = "this is not a valid filter";
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+
+      replay(coreQueue, serverManager);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      try
+      {
+         control.listMessages(invalidFilterStr);
+         fail("IllegalStateException");
+      } catch (IllegalStateException e)
+      {
+
+      }
+      verify(coreQueue, serverManager);
+   }
+
+   public void testExpireMessage() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+      String jmsMessageID = randomString();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      List<MessageReference> refs = new ArrayList<MessageReference>();
+      MessageReference ref = createMock(MessageReference.class);
+      refs.add(ref);
+      expect(coreQueue.list(EasyMock.isA(Filter.class))).andReturn(refs);
+      expect(serverManager.expireMessages(isA(Filter.class), eq(queue)))
+            .andReturn(1);
+
+      replay(coreQueue, serverManager, ref);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      assertTrue(control.expireMessage(jmsMessageID));
+
+      verify(coreQueue, serverManager, ref);
+   }
+
+   public void testExpireMessageWithNoJMSMesageID() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+      String jmsMessageID = randomString();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      expect(coreQueue.list(isA(Filter.class))).andReturn(
+            new ArrayList<MessageReference>());
+
+      replay(coreQueue, serverManager);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      try
+      {
+         control.expireMessage(jmsMessageID);
+         fail("IllegalArgumentException");
+      } catch (IllegalArgumentException e)
+      {
+      }
+
+      verify(coreQueue, serverManager);
+   }
+   
+   public void testExpireMessages() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+      int expiredMessage = randomInt();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      expect(serverManager.expireMessages(isA(Filter.class), eq(queue)))
+            .andReturn(expiredMessage);
+
+      replay(coreQueue, serverManager);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      assertEquals(expiredMessage, control.expireMessages("color = 'green'"));
+
+      verify(coreQueue, serverManager);
+   }
+
+   public void testSendMessageToDLQ() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+      String jmsMessageID = randomString();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      List<MessageReference> refs = new ArrayList<MessageReference>();
+      MessageReference ref = createMock(MessageReference.class);
+      refs.add(ref);
+      expect(coreQueue.list(isA(Filter.class))).andReturn(refs);
+      expect(serverManager.sendMessagesToDLQ(isA(Filter.class), eq(queue)))
+            .andReturn(1);
+
+      replay(coreQueue, serverManager, ref);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      assertTrue(control.sendMessageTDLQ(jmsMessageID));
+
+      verify(coreQueue, serverManager, ref);
+   }
+
+   public void testSendMessageToDLQWithNoJMSMesageID() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+      String jmsMessageID = randomString();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      expect(coreQueue.list(isA(Filter.class))).andReturn(
+            new ArrayList<MessageReference>());
+
+      replay(coreQueue, serverManager);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      try
+      {
+         control.sendMessageTDLQ(jmsMessageID);
+         fail("IllegalArgumentException");
+      } catch (IllegalArgumentException e)
+      {
+      }
+
+      verify(coreQueue, serverManager);
+   }
+   
+   public void testChangeMessagePriority() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+      byte newPriority = 5;
+      String jmsMessageID = randomString();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      List<MessageReference> refs = new ArrayList<MessageReference>();
+      MessageReference ref = createMock(MessageReference.class);
+      refs.add(ref);
+      expect(coreQueue.list(isA(Filter.class))).andReturn(refs);
+      expect(
+            serverManager.changeMessagesPriority(isA(Filter.class),
+                  eq(newPriority), eq(queue))).andReturn(1);
+
+      replay(coreQueue, serverManager, ref);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      assertTrue(control.changeMessagePriority(jmsMessageID, newPriority));
+
+      verify(coreQueue, serverManager, ref);
+   }
+
+   public void testChangeMessagePriorityWithInvalidPriorityValues()
+         throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+      String jmsMessageID = randomString();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+
+      replay(coreQueue, serverManager);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      try
+      {
+         control.changeMessagePriority(jmsMessageID, -1);
+         fail("IllegalArgumentException");
+      } catch (IllegalArgumentException e)
+      {
+      }
+
+      try
+      {
+         control.changeMessagePriority(jmsMessageID, 10);
+         fail("IllegalArgumentException");
+      } catch (IllegalArgumentException e)
+      {
+      }
+
+      verify(coreQueue, serverManager);
+   }
+
+   public void testChangeMessagePriorityWithNoJMSMesageID() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+      byte newPriority = 5;
+      String jmsMessageID = randomString();
+
+      JBossQueue queue = new JBossQueue(name);
+      Queue coreQueue = createMock(Queue.class);
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      expect(coreQueue.list(isA(Filter.class))).andReturn(
+            new ArrayList<MessageReference>());
+
+      replay(coreQueue, serverManager);
+
+      JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
+            jndiBinding, serverManager);
+      try
+      {
+         control.changeMessagePriority(jmsMessageID, newPriority);
+         fail("IllegalArgumentException");
+      } catch (IllegalArgumentException e)
+      {
+      }
+
+      verify(coreQueue, serverManager);
+   }
+   
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSServerControlTest.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSServerControlTest.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSServerControlTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,383 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.unit.jms.server.management.impl;
-
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
-import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
-import static org.jboss.messaging.tests.util.RandomUtil.randomString;
-
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.management.MBeanServer;
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-
-import junit.framework.TestCase;
-
-import org.jboss.messaging.jms.server.JMSServerManager;
-import org.jboss.messaging.jms.server.management.impl.JMSManagementServiceImpl;
-import org.jboss.messaging.jms.server.management.impl.JMSServerControl;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class JMSServerControlTest extends TestCase
-{
-   private MBeanServer mbeanServer;
-   private ObjectName serverON;
-
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   // Public --------------------------------------------------------
-
-   public void testIsStarted() throws Exception
-   {
-      boolean started = randomBoolean();
-
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      expect(serverManager.isStarted()).andReturn(started);
-
-      replay(serverManager);
-
-      JMSServerControl control = new JMSServerControl(serverManager);
-      assertEquals(started, control.isStarted());
-
-      verify(serverManager);
-   }
-
-   public void testCreateQueueAndReceiveNotification() throws Exception
-   {
-      String name = randomString();
-      String jndiBinding = randomString();
-      boolean created = true;
-
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      expect(serverManager.createQueue(name, jndiBinding)).andReturn(created);
-      replay(serverManager);
-
-      JMSServerControl control = new JMSServerControl(serverManager);
-      mbeanServer.registerMBean(control, serverON);
-
-      final CountDownLatch latch = new CountDownLatch(1);
-      final AtomicReference<Notification> notifRef = new AtomicReference<Notification>();
-
-      NotificationListener listener = new NotificationListener()
-      {
-         public void handleNotification(Notification notification,
-               Object handback)
-         {
-            notifRef.set(notification);
-            latch.countDown();
-         }
-      };
-
-      mbeanServer.addNotificationListener(serverON, listener, null, null);
-
-      assertEquals(created, control.createQueue(name, jndiBinding));
-
-      boolean gotNotification = latch.await(500, MILLISECONDS);
-      assertTrue(gotNotification);
-      assertNotNull(notifRef.get());
-      assertEquals(JMSServerControl.NotificationType.QUEUE_CREATED.toString(),
-            notifRef.get().getType());
-
-      verify(serverManager);
-
-      mbeanServer.removeNotificationListener(serverON, listener);
-   }
-
-   public void testDestroyQueueAndReceiveNotification() throws Exception
-   {
-      String name = randomString();
-      boolean destroyed = true;
-
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      expect(serverManager.destroyQueue(name)).andReturn(destroyed);
-      replay(serverManager);
-
-      JMSServerControl control = new JMSServerControl(serverManager);
-      mbeanServer.registerMBean(control, serverON);
-
-      final CountDownLatch latch = new CountDownLatch(1);
-      final AtomicReference<Notification> notifRef = new AtomicReference<Notification>();
-
-      NotificationListener listener = new NotificationListener()
-      {
-         public void handleNotification(Notification notification,
-               Object handback)
-         {
-            notifRef.set(notification);
-            latch.countDown();
-         }
-      };
-
-      mbeanServer.addNotificationListener(serverON, listener, null, null);
-
-      assertEquals(destroyed, control.destroyQueue(name));
-
-      boolean gotNotification = latch.await(500, MILLISECONDS);
-      assertTrue(gotNotification);
-      assertNotNull(notifRef.get());
-      assertEquals(
-            JMSServerControl.NotificationType.QUEUE_DESTROYED.toString(),
-            notifRef.get().getType());
-
-      verify(serverManager);
-
-      mbeanServer.removeNotificationListener(serverON, listener);
-   }
-
-   public void testCreateTopicAndReceiveNotification() throws Exception
-   {
-      String name = randomString();
-      String jndiBinding = randomString();
-      boolean created = true;
-
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      expect(serverManager.createTopic(name, jndiBinding)).andReturn(created);
-      replay(serverManager);
-
-      JMSServerControl control = new JMSServerControl(serverManager);
-      mbeanServer.registerMBean(control, serverON);
-
-      final CountDownLatch latch = new CountDownLatch(1);
-      final AtomicReference<Notification> notifRef = new AtomicReference<Notification>();
-
-      NotificationListener listener = new NotificationListener()
-      {
-         public void handleNotification(Notification notification,
-               Object handback)
-         {
-            notifRef.set(notification);
-            latch.countDown();
-         }
-      };
-
-      mbeanServer.addNotificationListener(serverON, listener, null, null);
-
-      assertEquals(created, control.createTopic(name, jndiBinding));
-
-      boolean gotNotification = latch.await(500, MILLISECONDS);
-      assertTrue(gotNotification);
-      assertNotNull(notifRef.get());
-      assertEquals(JMSServerControl.NotificationType.TOPIC_CREATED.toString(),
-            notifRef.get().getType());
-
-      verify(serverManager);
-
-      mbeanServer.removeNotificationListener(serverON, listener);
-   }
-
-   public void testDestroyTopicAndReceiveNotification() throws Exception
-   {
-      String name = randomString();
-      boolean destroyed = true;
-
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      expect(serverManager.destroyTopic(name)).andReturn(destroyed);
-      replay(serverManager);
-
-      JMSServerControl control = new JMSServerControl(serverManager);
-      mbeanServer.registerMBean(control, serverON);
-
-      final CountDownLatch latch = new CountDownLatch(1);
-      final AtomicReference<Notification> notifRef = new AtomicReference<Notification>();
-
-      NotificationListener listener = new NotificationListener()
-      {
-         public void handleNotification(Notification notification,
-               Object handback)
-         {
-            notifRef.set(notification);
-            latch.countDown();
-         }
-      };
-
-      mbeanServer.addNotificationListener(serverON, listener, null, null);
-
-      assertEquals(destroyed, control.destroyTopic(name));
-
-      boolean gotNotification = latch.await(500, MILLISECONDS);
-      assertTrue(gotNotification);
-      assertNotNull(notifRef.get());
-      assertEquals(
-            JMSServerControl.NotificationType.TOPIC_DESTROYED.toString(),
-            notifRef.get().getType());
-
-      verify(serverManager);
-
-      mbeanServer.removeNotificationListener(serverON, listener);
-   }
-
-   public void testCreateConnnectionFactoryAndReceiveNotification()
-         throws Exception
-   {
-      String name = randomString();
-      String clientID = randomString();
-      int dupsOKBatchSize = randomInt();
-      int consumerWindowSize = randomInt();
-      int consumerMaxRate = randomInt();
-      int producerWindowSize = randomInt();
-      int producerMaxRate = randomInt();
-      boolean blockOnAcknowledge = randomBoolean();
-      boolean defaultSendNonPersistentMessagesBlocking = randomBoolean();
-      boolean defaultSendPersistentMessagesBlocking = randomBoolean();
-      boolean created = true;
-      String jndiBinding = randomString();
-      List<String> bindings = new ArrayList<String>();
-      bindings.add(jndiBinding);
-
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      expect(
-            serverManager.createConnectionFactory(name, clientID,
-                  dupsOKBatchSize, consumerWindowSize, consumerMaxRate,
-                  producerWindowSize, producerMaxRate, blockOnAcknowledge,
-                  defaultSendNonPersistentMessagesBlocking,
-                  defaultSendPersistentMessagesBlocking, bindings)).andReturn(
-            created);
-      replay(serverManager);
-
-      JMSServerControl control = new JMSServerControl(serverManager);
-      mbeanServer.registerMBean(control, serverON);
-
-      final CountDownLatch latch = new CountDownLatch(1);
-      final AtomicReference<Notification> notifRef = new AtomicReference<Notification>();
-
-      NotificationListener listener = new NotificationListener()
-      {
-         public void handleNotification(Notification notification,
-               Object handback)
-         {
-            notifRef.set(notification);
-            latch.countDown();
-         }
-      };
-
-      mbeanServer.addNotificationListener(serverON, listener, null, null);
-      control.createConnectionFactory(name, jndiBinding, clientID,
-            dupsOKBatchSize, consumerWindowSize, consumerMaxRate,
-            producerWindowSize, producerMaxRate,
-            blockOnAcknowledge,
-            defaultSendNonPersistentMessagesBlocking, defaultSendPersistentMessagesBlocking);
-
-      boolean gotNotification = latch.await(500, MILLISECONDS);
-      assertTrue(gotNotification);
-      assertNotNull(notifRef.get());
-      assertEquals(JMSServerControl.NotificationType.CONNECTION_FACTORY_CREATED
-            .toString(), notifRef.get().getType());
-
-      verify(serverManager);
-
-      mbeanServer.removeNotificationListener(serverON, listener);
-   }
-
-   public void testDestroyConnnectionFactoryAndReceiveNotification()
-         throws Exception
-   {
-      String name = randomString();
-      boolean destroyed = true;
-
-      JMSServerManager serverManager = createMock(JMSServerManager.class);
-      expect(serverManager.destroyConnectionFactory(name)).andReturn(destroyed);
-      replay(serverManager);
-
-      JMSServerControl control = new JMSServerControl(serverManager);
-      mbeanServer.registerMBean(control, serverON);
-
-      final CountDownLatch latch = new CountDownLatch(1);
-      final AtomicReference<Notification> notifRef = new AtomicReference<Notification>();
-
-      NotificationListener listener = new NotificationListener()
-      {
-         public void handleNotification(Notification notification,
-               Object handback)
-         {
-            notifRef.set(notification);
-            latch.countDown();
-         }
-      };
-
-      mbeanServer.addNotificationListener(serverON, listener, null, null);
-      control.destroyConnectionFactory(name);
-
-      boolean gotNotification = latch.await(500, MILLISECONDS);
-      assertTrue(gotNotification);
-      assertNotNull(notifRef.get());
-      assertEquals(
-            JMSServerControl.NotificationType.CONNECTION_FACTORY_DESTROYED
-                  .toString(), notifRef.get().getType());
-
-      verify(serverManager);
-
-      mbeanServer.removeNotificationListener(serverON, listener);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   @Override
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-
-      mbeanServer = ManagementFactory.getPlatformMBeanServer();
-      serverON = JMSManagementServiceImpl.getJMSServerObjectName();
-   }
-
-   @Override
-   protected void tearDown() throws Exception
-   {
-      if (mbeanServer.isRegistered(serverON))
-      {
-         mbeanServer.unregisterMBean(serverON);
-      }
-
-      serverON = null;
-      mbeanServer = null;
-
-      super.tearDown();
-   }
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSServerControlTest.java (from rev 4779, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSServerControlTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSServerControlTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSServerControlTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,383 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.unit.jms.server.management.impl;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.management.MBeanServer;
+import javax.management.Notification;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.jms.server.JMSServerManager;
+import org.jboss.messaging.jms.server.management.impl.JMSManagementServiceImpl;
+import org.jboss.messaging.jms.server.management.impl.JMSServerControl;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class JMSServerControlTest extends TestCase
+{
+   private MBeanServer mbeanServer;
+   private ObjectName serverON;
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testIsStarted() throws Exception
+   {
+      boolean started = randomBoolean();
+
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      expect(serverManager.isStarted()).andReturn(started);
+
+      replay(serverManager);
+
+      JMSServerControl control = new JMSServerControl(serverManager);
+      assertEquals(started, control.isStarted());
+
+      verify(serverManager);
+   }
+
+   public void testCreateQueueAndReceiveNotification() throws Exception
+   {
+      String name = randomString();
+      String jndiBinding = randomString();
+      boolean created = true;
+
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      expect(serverManager.createQueue(name, jndiBinding)).andReturn(created);
+      replay(serverManager);
+
+      JMSServerControl control = new JMSServerControl(serverManager);
+      mbeanServer.registerMBean(control, serverON);
+
+      final CountDownLatch latch = new CountDownLatch(1);
+      final AtomicReference<Notification> notifRef = new AtomicReference<Notification>();
+
+      NotificationListener listener = new NotificationListener()
+      {
+         public void handleNotification(Notification notification,
+               Object handback)
+         {
+            notifRef.set(notification);
+            latch.countDown();
+         }
+      };
+
+      mbeanServer.addNotificationListener(serverON, listener, null, null);
+
+      assertEquals(created, control.createQueue(name, jndiBinding));
+
+      boolean gotNotification = latch.await(500, MILLISECONDS);
+      assertTrue(gotNotification);
+      assertNotNull(notifRef.get());
+      assertEquals(JMSServerControl.NotificationType.QUEUE_CREATED.toString(),
+            notifRef.get().getType());
+
+      verify(serverManager);
+
+      mbeanServer.removeNotificationListener(serverON, listener);
+   }
+
+   public void testDestroyQueueAndReceiveNotification() throws Exception
+   {
+      String name = randomString();
+      boolean destroyed = true;
+
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      expect(serverManager.destroyQueue(name)).andReturn(destroyed);
+      replay(serverManager);
+
+      JMSServerControl control = new JMSServerControl(serverManager);
+      mbeanServer.registerMBean(control, serverON);
+
+      final CountDownLatch latch = new CountDownLatch(1);
+      final AtomicReference<Notification> notifRef = new AtomicReference<Notification>();
+
+      NotificationListener listener = new NotificationListener()
+      {
+         public void handleNotification(Notification notification,
+               Object handback)
+         {
+            notifRef.set(notification);
+            latch.countDown();
+         }
+      };
+
+      mbeanServer.addNotificationListener(serverON, listener, null, null);
+
+      assertEquals(destroyed, control.destroyQueue(name));
+
+      boolean gotNotification = latch.await(500, MILLISECONDS);
+      assertTrue(gotNotification);
+      assertNotNull(notifRef.get());
+      assertEquals(
+            JMSServerControl.NotificationType.QUEUE_DESTROYED.toString(),
+            notifRef.get().getType());
+
+      verify(serverManager);
+
+      mbeanServer.removeNotificationListener(serverON, listener);
+   }
+
+   public void testCreateTopicAndReceiveNotification() throws Exception
+   {
+      String name = randomString();
+      String jndiBinding = randomString();
+      boolean created = true;
+
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      expect(serverManager.createTopic(name, jndiBinding)).andReturn(created);
+      replay(serverManager);
+
+      JMSServerControl control = new JMSServerControl(serverManager);
+      mbeanServer.registerMBean(control, serverON);
+
+      final CountDownLatch latch = new CountDownLatch(1);
+      final AtomicReference<Notification> notifRef = new AtomicReference<Notification>();
+
+      NotificationListener listener = new NotificationListener()
+      {
+         public void handleNotification(Notification notification,
+               Object handback)
+         {
+            notifRef.set(notification);
+            latch.countDown();
+         }
+      };
+
+      mbeanServer.addNotificationListener(serverON, listener, null, null);
+
+      assertEquals(created, control.createTopic(name, jndiBinding));
+
+      boolean gotNotification = latch.await(500, MILLISECONDS);
+      assertTrue(gotNotification);
+      assertNotNull(notifRef.get());
+      assertEquals(JMSServerControl.NotificationType.TOPIC_CREATED.toString(),
+            notifRef.get().getType());
+
+      verify(serverManager);
+
+      mbeanServer.removeNotificationListener(serverON, listener);
+   }
+
+   public void testDestroyTopicAndReceiveNotification() throws Exception
+   {
+      String name = randomString();
+      boolean destroyed = true;
+
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      expect(serverManager.destroyTopic(name)).andReturn(destroyed);
+      replay(serverManager);
+
+      JMSServerControl control = new JMSServerControl(serverManager);
+      mbeanServer.registerMBean(control, serverON);
+
+      final CountDownLatch latch = new CountDownLatch(1);
+      final AtomicReference<Notification> notifRef = new AtomicReference<Notification>();
+
+      NotificationListener listener = new NotificationListener()
+      {
+         public void handleNotification(Notification notification,
+               Object handback)
+         {
+            notifRef.set(notification);
+            latch.countDown();
+         }
+      };
+
+      mbeanServer.addNotificationListener(serverON, listener, null, null);
+
+      assertEquals(destroyed, control.destroyTopic(name));
+
+      boolean gotNotification = latch.await(500, MILLISECONDS);
+      assertTrue(gotNotification);
+      assertNotNull(notifRef.get());
+      assertEquals(
+            JMSServerControl.NotificationType.TOPIC_DESTROYED.toString(),
+            notifRef.get().getType());
+
+      verify(serverManager);
+
+      mbeanServer.removeNotificationListener(serverON, listener);
+   }
+
+   public void testCreateConnnectionFactoryAndReceiveNotification()
+         throws Exception
+   {
+      String name = randomString();
+      String clientID = randomString();
+      int dupsOKBatchSize = randomInt();
+      int consumerWindowSize = randomInt();
+      int consumerMaxRate = randomInt();
+      int producerWindowSize = randomInt();
+      int producerMaxRate = randomInt();
+      boolean blockOnAcknowledge = randomBoolean();
+      boolean defaultSendNonPersistentMessagesBlocking = randomBoolean();
+      boolean defaultSendPersistentMessagesBlocking = randomBoolean();
+      boolean created = true;
+      String jndiBinding = randomString();
+      List<String> bindings = new ArrayList<String>();
+      bindings.add(jndiBinding);
+
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      expect(
+            serverManager.createConnectionFactory(name, clientID,
+                  dupsOKBatchSize, consumerWindowSize, consumerMaxRate,
+                  producerWindowSize, producerMaxRate, blockOnAcknowledge,
+                  defaultSendNonPersistentMessagesBlocking,
+                  defaultSendPersistentMessagesBlocking, bindings)).andReturn(
+            created);
+      replay(serverManager);
+
+      JMSServerControl control = new JMSServerControl(serverManager);
+      mbeanServer.registerMBean(control, serverON);
+
+      final CountDownLatch latch = new CountDownLatch(1);
+      final AtomicReference<Notification> notifRef = new AtomicReference<Notification>();
+
+      NotificationListener listener = new NotificationListener()
+      {
+         public void handleNotification(Notification notification,
+               Object handback)
+         {
+            notifRef.set(notification);
+            latch.countDown();
+         }
+      };
+
+      mbeanServer.addNotificationListener(serverON, listener, null, null);
+      control.createConnectionFactory(name, jndiBinding, clientID,
+            dupsOKBatchSize, consumerWindowSize, consumerMaxRate,
+            producerWindowSize, producerMaxRate,
+            blockOnAcknowledge,
+            defaultSendNonPersistentMessagesBlocking, defaultSendPersistentMessagesBlocking);
+
+      boolean gotNotification = latch.await(500, MILLISECONDS);
+      assertTrue(gotNotification);
+      assertNotNull(notifRef.get());
+      assertEquals(JMSServerControl.NotificationType.CONNECTION_FACTORY_CREATED
+            .toString(), notifRef.get().getType());
+
+      verify(serverManager);
+
+      mbeanServer.removeNotificationListener(serverON, listener);
+   }
+
+   public void testDestroyConnnectionFactoryAndReceiveNotification()
+         throws Exception
+   {
+      String name = randomString();
+      boolean destroyed = true;
+
+      JMSServerManager serverManager = createMock(JMSServerManager.class);
+      expect(serverManager.destroyConnectionFactory(name)).andReturn(destroyed);
+      replay(serverManager);
+
+      JMSServerControl control = new JMSServerControl(serverManager);
+      mbeanServer.registerMBean(control, serverON);
+
+      final CountDownLatch latch = new CountDownLatch(1);
+      final AtomicReference<Notification> notifRef = new AtomicReference<Notification>();
+
+      NotificationListener listener = new NotificationListener()
+      {
+         public void handleNotification(Notification notification,
+               Object handback)
+         {
+            notifRef.set(notification);
+            latch.countDown();
+         }
+      };
+
+      mbeanServer.addNotificationListener(serverON, listener, null, null);
+      control.destroyConnectionFactory(name);
+
+      boolean gotNotification = latch.await(500, MILLISECONDS);
+      assertTrue(gotNotification);
+      assertNotNull(notifRef.get());
+      assertEquals(
+            JMSServerControl.NotificationType.CONNECTION_FACTORY_DESTROYED
+                  .toString(), notifRef.get().getType());
+
+      verify(serverManager);
+
+      mbeanServer.removeNotificationListener(serverON, listener);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      mbeanServer = ManagementFactory.getPlatformMBeanServer();
+      serverON = JMSManagementServiceImpl.getJMSServerObjectName();
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      if (mbeanServer.isRegistered(serverON))
+      {
+         mbeanServer.unregisterMBean(serverON);
+      }
+
+      serverON = null;
+      mbeanServer = null;
+
+      super.tearDown();
+   }
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}

Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/TopicControlTest.java
===================================================================
--- branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/TopicControlTest.java	2008-08-07 08:32:51 UTC (rev 4779)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/TopicControlTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -1,305 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.unit.jms.server.management.impl;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
-import static org.jboss.messaging.tests.util.RandomUtil.randomString;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularData;
-
-import junit.framework.TestCase;
-
-import org.jboss.messaging.core.management.MessagingServerManagement;
-import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.jms.JBossTopic;
-import org.jboss.messaging.jms.server.management.SubscriberInfo;
-import org.jboss.messaging.jms.server.management.impl.TopicControl;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- * 
- * @version <tt>$Revision$</tt>
- * 
- */
-public class TopicControlTest extends TestCase
-{
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   // Public --------------------------------------------------------
-
-   public void testGetName() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-
-      JBossTopic topic = new JBossTopic(name);
-      MessagingServerManagement server = createMock(MessagingServerManagement.class);
-
-      replay(server);
-
-      TopicControl control = new TopicControl(topic, server, jndiBinding);
-      assertEquals(name, control.getName());
-
-      verify(server);
-   }
-
-   public void testGetAddress() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-
-      JBossTopic topic = new JBossTopic(name);
-      MessagingServerManagement server = createMock(MessagingServerManagement.class);
-
-      replay(server);
-
-      TopicControl control = new TopicControl(topic, server, jndiBinding);
-      assertEquals(topic.getAddress(), control.getAddress());
-
-      verify(server);
-   }
-
-   public void testGetJNDIBinding() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-
-      JBossTopic topic = new JBossTopic(name);
-      MessagingServerManagement server = createMock(MessagingServerManagement.class);
-
-      replay(server);
-
-      TopicControl control = new TopicControl(topic, server, jndiBinding);
-      assertEquals(jndiBinding, control.getJNDIBinding());
-
-      verify(server);
-   }
-
-   public void testIsTemporary() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-
-      JBossTopic topic = new JBossTopic(name);
-      MessagingServerManagement server = createMock(MessagingServerManagement.class);
-
-      replay(server);
-
-      TopicControl control = new TopicControl(topic, server, jndiBinding);
-      assertEquals(topic.isTemporary(), control.isTemporary());
-
-      verify(server);
-   }
-
-   public void testGetMessageCount() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-
-      int countForNonDurableQueue = randomInt();
-      int countForDurableQueue_1 = randomInt();
-      int countForDurableQueue_2 = randomInt();
-
-      JBossTopic topic = new JBossTopic(name);
-      MessagingServerManagement server = createMock(MessagingServerManagement.class);
-      Queue nonDurableQueue = createMock(Queue.class);
-      expect(nonDurableQueue.isDurable()).andStubReturn(false);
-      expect(nonDurableQueue.getMessageCount()).andStubReturn(
-            countForNonDurableQueue);
-      Queue durableQueue_1 = createMock(Queue.class);
-      expect(durableQueue_1.isDurable()).andStubReturn(true);
-      expect(durableQueue_1.getMessageCount()).andStubReturn(
-            countForDurableQueue_1);
-      Queue durableQueue_2 = createMock(Queue.class);
-      expect(durableQueue_2.isDurable()).andStubReturn(true);
-      expect(durableQueue_2.getMessageCount()).andStubReturn(
-            countForDurableQueue_2);
-      List<Queue> queues = new ArrayList<Queue>();
-      queues.add(nonDurableQueue);
-      queues.add(durableQueue_1);
-      queues.add(durableQueue_2);
-      expect(server.getQueuesForAddress(topic.getSimpleAddress()))
-            .andStubReturn(queues);
-      replay(server, nonDurableQueue, durableQueue_1, durableQueue_2);
-
-      TopicControl control = new TopicControl(topic, server, jndiBinding);
-      assertEquals(countForNonDurableQueue + countForDurableQueue_1
-            + countForDurableQueue_2, control.getMessageCount());
-      assertEquals(countForDurableQueue_1 + countForDurableQueue_2, control
-            .getDurableMessageCount());
-      assertEquals(countForNonDurableQueue, control.getNonDurableMessageCount());
-
-      verify(server, nonDurableQueue, durableQueue_1, durableQueue_2);
-   }
-
-   public void testGetSubcribersCount() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-
-      JBossTopic topic = new JBossTopic(name);
-      MessagingServerManagement server = createMock(MessagingServerManagement.class);
-      Queue nonDurableQueue = createMock(Queue.class);
-      expect(nonDurableQueue.isDurable()).andStubReturn(false);
-      Queue durableQueue_1 = createMock(Queue.class);
-      expect(durableQueue_1.isDurable()).andStubReturn(true);
-      Queue durableQueue_2 = createMock(Queue.class);
-      expect(durableQueue_2.isDurable()).andStubReturn(true);
-      List<Queue> queues = new ArrayList<Queue>();
-      queues.add(nonDurableQueue);
-      queues.add(durableQueue_1);
-      queues.add(durableQueue_2);
-      expect(server.getQueuesForAddress(topic.getSimpleAddress()))
-            .andStubReturn(queues);
-      replay(server, nonDurableQueue, durableQueue_1, durableQueue_2);
-
-      TopicControl control = new TopicControl(topic, server, jndiBinding);
-      assertEquals(3, control.getSubcribersCount());
-      assertEquals(2, control.getDurableSubcribersCount());
-      assertEquals(1, control.getNonDurableSubcribersCount());
-
-      verify(server, nonDurableQueue, durableQueue_1, durableQueue_2);
-   }
-
-   public void testRemoveAllMessages() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-
-      JBossTopic topic = new JBossTopic(name);
-      MessagingServerManagement server = createMock(MessagingServerManagement.class);
-      server.removeAllMessagesForAddress(topic.getSimpleAddress());
-      replay(server);
-
-      TopicControl control = new TopicControl(topic, server, jndiBinding);
-      control.removeAllMessages();
-
-      verify(server);
-   }
-
-   public void testListSubscriberInfos() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-
-      JBossTopic topic = new JBossTopic(name);
-      MessagingServerManagement server = createMock(MessagingServerManagement.class);
-      Queue durableQueue = createMock(Queue.class);
-      expect(durableQueue.getName()).andStubReturn(
-            JBossTopic.createAddressFromName(randomString()));
-      expect(durableQueue.getFilter()).andStubReturn(null);
-      expect(durableQueue.isDurable()).andStubReturn(true);
-      expect(durableQueue.getMessageCount()).andStubReturn(randomInt());
-      expect(durableQueue.getMaxSizeBytes()).andStubReturn(randomInt());
-      Queue nonDurableQueue = createMock(Queue.class);
-      expect(nonDurableQueue.getName()).andStubReturn(
-            JBossTopic.createAddressFromName(randomString()));
-      expect(nonDurableQueue.getFilter()).andStubReturn(null);
-      expect(nonDurableQueue.isDurable()).andStubReturn(false);
-      expect(nonDurableQueue.getMessageCount()).andStubReturn(randomInt());
-      expect(nonDurableQueue.getMaxSizeBytes()).andStubReturn(randomInt());
-      List<Queue> queues = new ArrayList<Queue>();
-      queues.add(durableQueue);
-      queues.add(nonDurableQueue);
-      expect(server.getQueuesForAddress(topic.getSimpleAddress()))
-            .andStubReturn(queues);
-      replay(server, durableQueue, nonDurableQueue);
-
-      TopicControl control = new TopicControl(topic, server, jndiBinding);
-      SubscriberInfo[] infos = control.listAllSubscriberInfos();
-      assertEquals(2, infos.length);
-      infos = control.listDurableSubscriberInfos();
-      assertEquals(1, infos.length);
-      assertEquals(durableQueue.getName().toString(), infos[0].getID());
-      infos = control.listNonDurableSubscriberInfos();
-      assertEquals(1, infos.length);
-      assertEquals(nonDurableQueue.getName().toString(), infos[0].getID());
-
-      verify(server, durableQueue, nonDurableQueue);
-   }
-
-   public void testListSubscribers() throws Exception
-   {
-      String jndiBinding = randomString();
-      String name = randomString();
-
-      JBossTopic topic = new JBossTopic(name);
-      MessagingServerManagement server = createMock(MessagingServerManagement.class);
-      Queue durableQueue = createMock(Queue.class);
-      expect(durableQueue.getName()).andStubReturn(
-            JBossTopic.createAddressFromName(randomString()));
-      expect(durableQueue.getFilter()).andStubReturn(null);
-      expect(durableQueue.isDurable()).andStubReturn(true);
-      expect(durableQueue.getMessageCount()).andStubReturn(randomInt());
-      expect(durableQueue.getMaxSizeBytes()).andStubReturn(randomInt());
-      Queue nonDurableQueue = createMock(Queue.class);
-      expect(nonDurableQueue.getName()).andStubReturn(
-            JBossTopic.createAddressFromName(randomString()));
-      expect(nonDurableQueue.getFilter()).andStubReturn(null);
-      expect(nonDurableQueue.isDurable()).andStubReturn(false);
-      expect(nonDurableQueue.getMessageCount()).andStubReturn(randomInt());
-      expect(nonDurableQueue.getMaxSizeBytes()).andStubReturn(randomInt());
-      List<Queue> queues = new ArrayList<Queue>();
-      queues.add(durableQueue);
-      queues.add(nonDurableQueue);
-      expect(server.getQueuesForAddress(topic.getSimpleAddress()))
-            .andStubReturn(queues);
-      replay(server, durableQueue, nonDurableQueue);
-
-      TopicControl control = new TopicControl(topic, server, jndiBinding);
-      TabularData data = control.listAllSubscribers();
-      assertEquals(2, data.size());
-      data = control.listDurableSubscribers();
-      assertEquals(1, data.size());
-      CompositeData info = data.get(new String[] { durableQueue.getName().toString() });
-      assertNotNull(info);
-      data = control.listNonDurableSubscribers();
-      assertEquals(1, data.size());
-      info = data.get(new String[] { nonDurableQueue.getName().toString() });
-      assertNotNull(info);
-
-      verify(server, durableQueue, nonDurableQueue);
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-}

Copied: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/TopicControlTest.java (from rev 4779, branches/Branch_JBMESSAGING-1303/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/TopicControlTest.java)
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/TopicControlTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/TopicControlTest.java	2008-08-07 12:16:17 UTC (rev 4781)
@@ -0,0 +1,305 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.unit.jms.server.management.impl;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.jboss.messaging.tests.util.RandomUtil.randomInt;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.management.MessagingServerManagement;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.jms.JBossTopic;
+import org.jboss.messaging.jms.server.management.SubscriberInfo;
+import org.jboss.messaging.jms.server.management.impl.TopicControl;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ * 
+ * @version <tt>$Revision$</tt>
+ * 
+ */
+public class TopicControlTest extends TestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testGetName() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+
+      JBossTopic topic = new JBossTopic(name);
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+
+      replay(server);
+
+      TopicControl control = new TopicControl(topic, server, jndiBinding);
+      assertEquals(name, control.getName());
+
+      verify(server);
+   }
+
+   public void testGetAddress() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+
+      JBossTopic topic = new JBossTopic(name);
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+
+      replay(server);
+
+      TopicControl control = new TopicControl(topic, server, jndiBinding);
+      assertEquals(topic.getAddress(), control.getAddress());
+
+      verify(server);
+   }
+
+   public void testGetJNDIBinding() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+
+      JBossTopic topic = new JBossTopic(name);
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+
+      replay(server);
+
+      TopicControl control = new TopicControl(topic, server, jndiBinding);
+      assertEquals(jndiBinding, control.getJNDIBinding());
+
+      verify(server);
+   }
+
+   public void testIsTemporary() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+
+      JBossTopic topic = new JBossTopic(name);
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+
+      replay(server);
+
+      TopicControl control = new TopicControl(topic, server, jndiBinding);
+      assertEquals(topic.isTemporary(), control.isTemporary());
+
+      verify(server);
+   }
+
+   public void testGetMessageCount() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+
+      int countForNonDurableQueue = randomInt();
+      int countForDurableQueue_1 = randomInt();
+      int countForDurableQueue_2 = randomInt();
+
+      JBossTopic topic = new JBossTopic(name);
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Queue nonDurableQueue = createMock(Queue.class);
+      expect(nonDurableQueue.isDurable()).andStubReturn(false);
+      expect(nonDurableQueue.getMessageCount()).andStubReturn(
+            countForNonDurableQueue);
+      Queue durableQueue_1 = createMock(Queue.class);
+      expect(durableQueue_1.isDurable()).andStubReturn(true);
+      expect(durableQueue_1.getMessageCount()).andStubReturn(
+            countForDurableQueue_1);
+      Queue durableQueue_2 = createMock(Queue.class);
+      expect(durableQueue_2.isDurable()).andStubReturn(true);
+      expect(durableQueue_2.getMessageCount()).andStubReturn(
+            countForDurableQueue_2);
+      List<Queue> queues = new ArrayList<Queue>();
+      queues.add(nonDurableQueue);
+      queues.add(durableQueue_1);
+      queues.add(durableQueue_2);
+      expect(server.getQueuesForAddress(topic.getSimpleAddress()))
+            .andStubReturn(queues);
+      replay(server, nonDurableQueue, durableQueue_1, durableQueue_2);
+
+      TopicControl control = new TopicControl(topic, server, jndiBinding);
+      assertEquals(countForNonDurableQueue + countForDurableQueue_1
+            + countForDurableQueue_2, control.getMessageCount());
+      assertEquals(countForDurableQueue_1 + countForDurableQueue_2, control
+            .getDurableMessageCount());
+      assertEquals(countForNonDurableQueue, control.getNonDurableMessageCount());
+
+      verify(server, nonDurableQueue, durableQueue_1, durableQueue_2);
+   }
+
+   public void testGetSubcribersCount() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+
+      JBossTopic topic = new JBossTopic(name);
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Queue nonDurableQueue = createMock(Queue.class);
+      expect(nonDurableQueue.isDurable()).andStubReturn(false);
+      Queue durableQueue_1 = createMock(Queue.class);
+      expect(durableQueue_1.isDurable()).andStubReturn(true);
+      Queue durableQueue_2 = createMock(Queue.class);
+      expect(durableQueue_2.isDurable()).andStubReturn(true);
+      List<Queue> queues = new ArrayList<Queue>();
+      queues.add(nonDurableQueue);
+      queues.add(durableQueue_1);
+      queues.add(durableQueue_2);
+      expect(server.getQueuesForAddress(topic.getSimpleAddress()))
+            .andStubReturn(queues);
+      replay(server, nonDurableQueue, durableQueue_1, durableQueue_2);
+
+      TopicControl control = new TopicControl(topic, server, jndiBinding);
+      assertEquals(3, control.getSubcribersCount());
+      assertEquals(2, control.getDurableSubcribersCount());
+      assertEquals(1, control.getNonDurableSubcribersCount());
+
+      verify(server, nonDurableQueue, durableQueue_1, durableQueue_2);
+   }
+
+   public void testRemoveAllMessages() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+
+      JBossTopic topic = new JBossTopic(name);
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      server.removeAllMessagesForAddress(topic.getSimpleAddress());
+      replay(server);
+
+      TopicControl control = new TopicControl(topic, server, jndiBinding);
+      control.removeAllMessages();
+
+      verify(server);
+   }
+
+   public void testListSubscriberInfos() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+
+      JBossTopic topic = new JBossTopic(name);
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Queue durableQueue = createMock(Queue.class);
+      expect(durableQueue.getName()).andStubReturn(
+            JBossTopic.createAddressFromName(randomString()));
+      expect(durableQueue.getFilter()).andStubReturn(null);
+      expect(durableQueue.isDurable()).andStubReturn(true);
+      expect(durableQueue.getMessageCount()).andStubReturn(randomInt());
+      expect(durableQueue.getMaxSizeBytes()).andStubReturn(randomInt());
+      Queue nonDurableQueue = createMock(Queue.class);
+      expect(nonDurableQueue.getName()).andStubReturn(
+            JBossTopic.createAddressFromName(randomString()));
+      expect(nonDurableQueue.getFilter()).andStubReturn(null);
+      expect(nonDurableQueue.isDurable()).andStubReturn(false);
+      expect(nonDurableQueue.getMessageCount()).andStubReturn(randomInt());
+      expect(nonDurableQueue.getMaxSizeBytes()).andStubReturn(randomInt());
+      List<Queue> queues = new ArrayList<Queue>();
+      queues.add(durableQueue);
+      queues.add(nonDurableQueue);
+      expect(server.getQueuesForAddress(topic.getSimpleAddress()))
+            .andStubReturn(queues);
+      replay(server, durableQueue, nonDurableQueue);
+
+      TopicControl control = new TopicControl(topic, server, jndiBinding);
+      SubscriberInfo[] infos = control.listAllSubscriberInfos();
+      assertEquals(2, infos.length);
+      infos = control.listDurableSubscriberInfos();
+      assertEquals(1, infos.length);
+      assertEquals(durableQueue.getName().toString(), infos[0].getID());
+      infos = control.listNonDurableSubscriberInfos();
+      assertEquals(1, infos.length);
+      assertEquals(nonDurableQueue.getName().toString(), infos[0].getID());
+
+      verify(server, durableQueue, nonDurableQueue);
+   }
+
+   public void testListSubscribers() throws Exception
+   {
+      String jndiBinding = randomString();
+      String name = randomString();
+
+      JBossTopic topic = new JBossTopic(name);
+      MessagingServerManagement server = createMock(MessagingServerManagement.class);
+      Queue durableQueue = createMock(Queue.class);
+      expect(durableQueue.getName()).andStubReturn(
+            JBossTopic.createAddressFromName(randomString()));
+      expect(durableQueue.getFilter()).andStubReturn(null);
+      expect(durableQueue.isDurable()).andStubReturn(true);
+      expect(durableQueue.getMessageCount()).andStubReturn(randomInt());
+      expect(durableQueue.getMaxSizeBytes()).andStubReturn(randomInt());
+      Queue nonDurableQueue = createMock(Queue.class);
+      expect(nonDurableQueue.getName()).andStubReturn(
+            JBossTopic.createAddressFromName(randomString()));
+      expect(nonDurableQueue.getFilter()).andStubReturn(null);
+      expect(nonDurableQueue.isDurable()).andStubReturn(false);
+      expect(nonDurableQueue.getMessageCount()).andStubReturn(randomInt());
+      expect(nonDurableQueue.getMaxSizeBytes()).andStubReturn(randomInt());
+      List<Queue> queues = new ArrayList<Queue>();
+      queues.add(durableQueue);
+      queues.add(nonDurableQueue);
+      expect(server.getQueuesForAddress(topic.getSimpleAddress()))
+            .andStubReturn(queues);
+      replay(server, durableQueue, nonDurableQueue);
+
+      TopicControl control = new TopicControl(topic, server, jndiBinding);
+      TabularData data = control.listAllSubscribers();
+      assertEquals(2, data.size());
+      data = control.listDurableSubscribers();
+      assertEquals(1, data.size());
+      CompositeData info = data.get(new String[] { durableQueue.getName().toString() });
+      assertNotNull(info);
+      data = control.listNonDurableSubscribers();
+      assertEquals(1, data.size());
+      info = data.get(new String[] { nonDurableQueue.getName().toString() });
+      assertNotNull(info);
+
+      verify(server, durableQueue, nonDurableQueue);
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+}




More information about the jboss-cvs-commits mailing list