[jboss-cvs] JBoss Messaging SVN: r4993 - in trunk: examples/messaging and 33 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Sep 19 10:48:14 EDT 2008
Author: jmesnil
Date: 2008-09-19 10:48:13 -0400 (Fri, 19 Sep 2008)
New Revision: 4993
Added:
trunk/examples/messaging/src/org/jboss/messaging/example/ManagementClient.java
trunk/src/main/org/jboss/messaging/core/client/management/
trunk/src/main/org/jboss/messaging/core/client/management/impl/
trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendManagementMessage.java
trunk/tests/src/org/jboss/messaging/tests/integration/management/
trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/client/management/
trunk/tests/src/org/jboss/messaging/tests/unit/core/client/management/impl/
trunk/tests/src/org/jboss/messaging/tests/unit/core/client/management/impl/ManagementHelperTest.java
Modified:
trunk/build-messaging.xml
trunk/build.xml
trunk/examples/messaging/
trunk/examples/messaging/build.xml
trunk/src/config/jbm-beans.xml
trunk/src/config/jbm-standalone-beans.xml
trunk/src/main/org/jboss/messaging/core/client/ClientProducer.java
trunk/src/main/org/jboss/messaging/core/client/ClientSession.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.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/RoleInfo.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/core/persistence/impl/journal/JournalStorageManager.java
trunk/src/main/org/jboss/messaging/core/postoffice/PostOffice.java
trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java
trunk/src/main/org/jboss/messaging/core/server/Queue.java
trunk/src/main/org/jboss/messaging/core/server/QueueFactory.java
trunk/src/main/org/jboss/messaging/core/server/ServerSession.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/QueueFactoryImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java
trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementServiceImpl.java
trunk/src/main/org/jboss/messaging/util/SimpleString.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
trunk/tests/src/org/jboss/messaging/tests/concurrent/server/impl/QueueTest.java
trunk/tests/src/org/jboss/messaging/tests/performance/persistence/FakePostOffice.java
trunk/tests/src/org/jboss/messaging/tests/timing/core/server/impl/QueueImplTest.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/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/postoffice/impl/PostOfficeImplWildcardManagerTest.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/QueueFactoryImplTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/fakes/FakeQueueFactory.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/TransactionImplTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSManagementServiceImplTest.java
Log:
JBMESSAGING-1303: Revisit management interfaces
- added support to manage JBM using the core API (as opposed to JMX remoting), its use is shown in ManagementClient example
- also part of the commit, JBMESSAGING-1410: Reenable message counters
- added a temporary attribute to Queue (which introduces a lot of changes in the code dealing with queue creation). The queue's temporary behavior is handled at the session level but I added this attribute to the queue for management purpose (so that a user can look at a queue to check if it is temporary or not)
- waiting too long to commit lots of these changes was a stupid(tm) idea of mine
Modified: trunk/build-messaging.xml
===================================================================
--- trunk/build-messaging.xml 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/build-messaging.xml 2008-09-19 14:48:13 UTC (rev 4993)
@@ -975,6 +975,10 @@
<ant dir="${examples.dir}/messaging" antfile="build.xml" target="SimpleExample"/>
</target>
+ <target name="ManagementClient" depends="client-jar">
+ <ant dir="${examples.dir}/messaging" antfile="build.xml" target="ManagementClient"/>
+ </target>
+
<target name="WildCardClient" depends="jar, client-jar">
<ant dir="${examples.dir}/messaging" antfile="build.xml" target="WildCardClient"/>
</target>
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/build.xml 2008-09-19 14:48:13 UTC (rev 4993)
@@ -234,6 +234,10 @@
<ant antfile="build-messaging.xml" target="SimpleExample"/>
</target>
+ <target name="ManagementClient" depends="createthirdparty">
+ <ant antfile="build-messaging.xml" target="ManagementClient"/>
+ </target>
+
<target name="WildCardClient" depends="createthirdparty">
<ant antfile="build-messaging.xml" target="WildCardClient"/>
</target>
Property changes on: trunk/examples/messaging
___________________________________________________________________
Name: svn:ignore
+ build
Modified: trunk/examples/messaging/build.xml
===================================================================
--- trunk/examples/messaging/build.xml 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/examples/messaging/build.xml 2008-09-19 14:48:13 UTC (rev 4993)
@@ -97,6 +97,12 @@
</java>
</target>
+ <target name="ManagementClient" depends="compile">
+ <java classname="org.jboss.messaging.example.ManagementClient" fork="true">
+ <classpath refid="runtime.classpath"/>
+ </java>
+ </target>
+
<target name="WildCardClient" depends="compile">
<java classname="org.jboss.messaging.example.WildCardClient" fork="true">
<classpath refid="runtime.classpath"/>
Added: trunk/examples/messaging/src/org/jboss/messaging/example/ManagementClient.java
===================================================================
--- trunk/examples/messaging/src/org/jboss/messaging/example/ManagementClient.java (rev 0)
+++ trunk/examples/messaging/src/org/jboss/messaging/example/ManagementClient.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -0,0 +1,195 @@
+/*
+ * JBoss, Home of Professional Open SourceCopyright 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.example;
+
+import org.jboss.messaging.core.client.ClientConsumer;
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.ClientProducer;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.ClientSessionFactory;
+import org.jboss.messaging.core.client.MessageHandler;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
+import org.jboss.messaging.core.client.management.impl.ManagementHelper;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.management.impl.ManagementServiceImpl;
+import org.jboss.messaging.jms.client.JBossTextMessage;
+import org.jboss.messaging.util.SimpleString;
+
+/*
+ * Uses the core messaging API to send and receive a message to a queue.
+ *
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
+ */
+public class ManagementClient
+{
+ public static void main(final String[] args) throws Exception
+ {
+ SimpleString replytoQueue = new SimpleString("replyto.adminQueue");
+ ClientSessionFactory sessionFactory = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.netty.NettyConnectorFactory"));
+ final ClientSession clientSession = sessionFactory.createSession(false, true, true, 1, false);
+ SimpleString queue = new SimpleString("queuejms.testQueue");
+
+ sendMessages(clientSession, queue);
+
+ // add temporary destination and queue
+ clientSession.addDestination(replytoQueue, false, true);
+ clientSession.createQueue(replytoQueue, replytoQueue, null, false, true);
+
+ ClientProducer mngmntProducer = clientSession.createProducer(ManagementHelper.MANAGEMENT_DESTINATION);
+
+ // create a management message to subscribe to notifications from the
+ // server
+ ClientMessage mngmntMessage = clientSession.createClientMessage(false);
+ ManagementHelper.putNotificationSubscription(mngmntMessage, replytoQueue, true);
+ mngmntProducer.sendManagement(mngmntMessage);
+ System.out.println("send message to subscribe to notifications");
+
+ ClientConsumer mngmntConsumer = clientSession.createConsumer(replytoQueue);
+ mngmntConsumer.setMessageHandler(new MessageHandler()
+ {
+
+ public void onMessage(final ClientMessage message)
+ {
+ System.out.println("received management message");
+ if (ManagementHelper.isNotification(message))
+ {
+ System.out.println("\tnotification: " + ManagementHelper.getNotification(message));
+ }
+ else if (ManagementHelper.isOperationResult(message))
+ {
+ System.out.println("\toperation succeeded:" + ManagementHelper.hasOperationSucceeded(message));
+ if (ManagementHelper.hasOperationSucceeded(message))
+ {
+ System.out.println("\t- result=" + message.getProperty(new SimpleString("sendMessageToDLQ")));
+ }
+ else
+ {
+ System.out.println("\t- exception=" + ManagementHelper.getOperationExceptionMessage(message));
+ }
+ }
+ else if (ManagementHelper.isAttributesResult(message))
+ {
+ System.out.println("\tattributes:");
+ System.out.println("\t- MessageCount=" + message.getProperty(new SimpleString("MessageCount")));
+ System.out.println("\t- Durable=" + message.getProperty(new SimpleString("Durable")));
+ }
+ try
+ {
+ clientSession.acknowledge();
+ }
+ catch (MessagingException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ });
+ clientSession.start();
+
+ // add and remove a destination to receive two notifications from the
+ // server
+ clientSession.addDestination(new SimpleString("anotherQueue"), false, true);
+ clientSession.removeDestination(new SimpleString("anotherQueue"), false);
+
+ // to set a new value for an attribute, invoke the corresponding setter
+ // method
+ mngmntMessage = clientSession.createClientMessage(false);
+ ManagementHelper.putOperationInvocation(mngmntMessage,
+ replytoQueue,
+ ManagementServiceImpl.getMessagingServerObjectName(),
+ "setMessageCounterSamplePeriod",
+ (long)30000);
+ mngmntProducer.sendManagement(mngmntMessage);
+ System.out.println("sent management message to set an attribute");
+
+ // create a message to retrieve one or many attributes
+ mngmntMessage = clientSession.createClientMessage(false);
+ ManagementHelper.putAttributes(mngmntMessage,
+ replytoQueue,
+ ManagementServiceImpl.getQueueObjectName(queue, queue),
+ "MessageCount",
+ "Durable");
+
+ mngmntProducer.sendManagement(mngmntMessage);
+ System.out.println("sent management message to retrieve attributes");
+
+ // create a message to invoke the operation sendMessageToDLQ(long) on the
+ // queue
+ mngmntMessage = clientSession.createClientMessage(false);
+ ManagementHelper.putOperationInvocation(mngmntMessage,
+ replytoQueue,
+ ManagementServiceImpl.getQueueObjectName(queue, queue),
+ "sendMessageToDLQ",
+ (long)6161);
+ mngmntProducer.sendManagement(mngmntMessage);
+ System.out.println("sent management message to invoke operation");
+
+ // create a message to unsubscribe from the notifications sent by the
+ // server
+ mngmntMessage = clientSession.createClientMessage(false);
+ ManagementHelper.putNotificationSubscription(mngmntMessage, replytoQueue, false);
+ mngmntProducer.sendManagement(mngmntMessage);
+ System.out.println("send message to unsubscribe to notifications");
+
+ Thread.sleep(5000);
+
+ mngmntConsumer.close();
+
+ consumeMessages(clientSession, queue);
+
+ clientSession.removeDestination(replytoQueue, false);
+ clientSession.deleteQueue(replytoQueue);
+
+ clientSession.close();
+ }
+
+ private static void consumeMessages(final ClientSession clientSession, final SimpleString queue) throws MessagingException
+ {
+ ClientConsumer clientConsumer = clientSession.createConsumer(queue);
+ ClientMessage m = null;
+ do
+ {
+ m = clientConsumer.receive(5000);
+ clientSession.acknowledge();
+ }
+ while (m != null);
+ clientSession.commit();
+ System.out.println("consumed all the messages from " + queue);
+ }
+
+ private static void sendMessages(final ClientSession clientSession, final SimpleString queue) throws MessagingException
+ {
+ ClientProducer clientProducer = clientSession.createProducer(queue);
+ ClientMessage message = clientSession.createClientMessage(JBossTextMessage.TYPE,
+ false,
+ 0,
+ System.currentTimeMillis(),
+ (byte)1);
+ message.getBody().putString("Hello, World!");
+ clientProducer.send(message);
+ clientProducer.send(message);
+ clientProducer.send(message);
+ clientProducer.send(message);
+ System.out.println("sent 4 messages to " + queue);
+ }
+}
Modified: trunk/src/config/jbm-beans.xml
===================================================================
--- trunk/src/config/jbm-beans.xml 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/config/jbm-beans.xml 2008-09-19 14:48:13 UTC (rev 4993)
@@ -129,14 +129,8 @@
<bean name="JMSManagementService" class="org.jboss.messaging.jms.server.management.impl.JMSManagementServiceImpl">
<constructor>
<parameter>
- <inject bean="MBeanServer"/>
+ <inject bean="ManagementService"/>
</parameter>
- <parameter>
- <inject bean="Configuration" property="JMXManagementEnabled" />
- </parameter>
- <parameter>
- <inject bean="ManagementService" property="messageCounterManager" />
- </parameter>
</constructor>
</bean>
Modified: trunk/src/config/jbm-standalone-beans.xml
===================================================================
--- trunk/src/config/jbm-standalone-beans.xml 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/config/jbm-standalone-beans.xml 2008-09-19 14:48:13 UTC (rev 4993)
@@ -145,14 +145,8 @@
<bean name="JMSManagementService" class="org.jboss.messaging.jms.server.management.impl.JMSManagementServiceImpl">
<constructor>
<parameter>
- <inject bean="MBeanServer"/>
+ <inject bean="ManagementService"/>
</parameter>
- <parameter>
- <inject bean="Configuration" property="JMXManagementEnabled" />
- </parameter>
- <parameter>
- <inject bean="ManagementService" property="messageCounterManager" />
- </parameter>
</constructor>
</bean>
Modified: trunk/src/main/org/jboss/messaging/core/client/ClientProducer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/ClientProducer.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/client/ClientProducer.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -36,7 +36,9 @@
void send(ClientMessage message) throws MessagingException;
void send(SimpleString address, ClientMessage message) throws MessagingException;
-
+
+ void sendManagement(ClientMessage mngmntMessage) throws MessagingException;
+
void registerAcknowledgementHandler(AcknowledgementHandler handler);
void unregisterAcknowledgementHandler(AcknowledgementHandler handler);
@@ -52,4 +54,5 @@
int getMaxRate();
int getInitialWindowSize();
+
}
Modified: trunk/src/main/org/jboss/messaging/core/client/ClientSession.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/ClientSession.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/client/ClientSession.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -1,24 +1,24 @@
/*
- * 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.
- */
+ * 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.client;
@@ -30,87 +30,99 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryResponseMessage;
import org.jboss.messaging.util.SimpleString;
-/**
- *
+/*
+ *
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
* @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
* @author <a href="mailto:ataylor at redhat.com">Andy Taylor</a>
*/
public interface ClientSession extends XAResource
-{
- void createQueue(SimpleString address, SimpleString queueName, SimpleString filterString,
- boolean durable, boolean temporary) throws MessagingException;
-
+{
+ void createQueue(SimpleString address,
+ SimpleString queueName,
+ SimpleString filterString,
+ boolean durable,
+ boolean temporary) throws MessagingException;
+
void deleteQueue(SimpleString queueName) throws MessagingException;
-
+
void addDestination(SimpleString address, boolean durable, boolean temporary) throws MessagingException;
-
+
void removeDestination(SimpleString address, boolean durable) throws MessagingException;
-
+
SessionQueueQueryResponseMessage queueQuery(SimpleString queueName) throws MessagingException;
-
+
SessionBindingQueryResponseMessage bindingQuery(SimpleString address) throws MessagingException;
-
+
ClientConsumer createConsumer(SimpleString queueName) throws MessagingException;
-
- ClientConsumer createConsumer(SimpleString queueName, SimpleString filterString,
- boolean direct) throws MessagingException;
-
- ClientConsumer createConsumer(SimpleString queueName, SimpleString filterString,
+
+ ClientConsumer createConsumer(SimpleString queueName, SimpleString filterString, boolean direct) throws MessagingException;
+
+ ClientConsumer createConsumer(SimpleString queueName,
+ SimpleString filterString,
boolean direct,
- int windowSize, int maxRate) throws MessagingException;
-
+ int windowSize,
+ int maxRate) throws MessagingException;
+
ClientBrowser createBrowser(SimpleString queueName, SimpleString filterString) throws MessagingException;
-
+
ClientBrowser createBrowser(SimpleString queueName) throws MessagingException;
-
+
ClientProducer createProducer(SimpleString address) throws MessagingException;
-
- ClientProducer createProducer(SimpleString address, int windowSize, int maxRate,
- boolean blockOnNonPersistentSend, boolean blockOnPersistentSend) throws MessagingException;
-
+
+ ClientProducer createProducer(SimpleString address,
+ int windowSize,
+ int maxRate,
+ boolean blockOnNonPersistentSend,
+ boolean blockOnPersistentSend) throws MessagingException;
+
ClientProducer createRateLimitedProducer(SimpleString address, int rate) throws MessagingException;
-
+
ClientProducer createProducerWithWindowSize(SimpleString address, int windowSize) throws MessagingException;
-
+
XAResource getXAResource();
void commit() throws MessagingException;
void rollback() throws MessagingException;
-
+
void acknowledge() throws MessagingException;
-
+
void close() throws MessagingException;
-
- boolean isClosed();
-
+
+ boolean isClosed();
+
boolean isAutoCommitSends();
-
+
boolean isAutoCommitAcks();
-
+
boolean isBlockOnAcknowledge();
-
+
boolean isCacheProducers();
-
+
int getLazyAckBatchSize();
-
+
boolean isXA();
- ClientMessage createClientMessage(final byte type, final boolean durable, final long expiration,
- final long timestamp, final byte priority);
+ ClientMessage createClientMessage(final byte type,
+ final boolean durable,
+ final long expiration,
+ final long timestamp,
+ final byte priority);
ClientMessage createClientMessage(final byte type, final boolean durable);
ClientMessage createClientMessage(final boolean durable);
-
+
void start() throws MessagingException;
-
+
void stop() throws MessagingException;
-
+
void addFailureListener(FailureListener listener);
-
+
boolean removeFailureListener(FailureListener listener);
-
+
int getVersion();
}
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientProducerImpl.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -29,8 +29,9 @@
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.Channel;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionProducerCloseMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendManagementMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionProducerCloseMessage;
import org.jboss.messaging.util.SimpleString;
import org.jboss.messaging.util.TokenBucketLimiter;
@@ -135,6 +136,55 @@
doSend(address, msg);
}
+
+ // use a special wireformat packet to send management message (on the server-side they are
+ // handled by the server session differently from regular Client Message)
+ public void sendManagement(final ClientMessage msg) throws MessagingException
+ {
+ checkClosed();
+
+ if (address != null)
+ {
+ msg.setDestination(address);
+ }
+ else
+ {
+ msg.setDestination(this.address);
+ }
+
+ if (rateLimiter != null)
+ {
+ // Rate flow control
+
+ rateLimiter.limit();
+ }
+
+ boolean sendBlocking = msg.isDurable() ? blockOnPersistentSend : blockOnNonPersistentSend;
+
+ SessionSendManagementMessage message = new SessionSendManagementMessage(id, msg, false);
+
+ if (sendBlocking)
+ {
+ channel.sendBlocking(message);
+ }
+ else
+ {
+ channel.send(message);
+ }
+
+ //We only flow control with non-anonymous producers
+ if (address == null && creditFlowControl)
+ {
+ try
+ {
+ availableCredits.acquire(message.getClientMessage().getEncodeSize());
+ }
+ catch (InterruptedException e)
+ {
+ }
+ }
+ }
+
public void registerAcknowledgementHandler(final AcknowledgementHandler handler)
{
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -57,6 +57,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionBindingQueryMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionBindingQueryResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionCancelMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionConsumerFlowCreditMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateBrowserMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateConsumerMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateConsumerResponseMessage;
@@ -64,7 +65,6 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateProducerResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateQueueMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionDeleteQueueMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.SessionConsumerFlowCreditMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveDestinationMessage;
@@ -89,32 +89,38 @@
import org.jboss.messaging.util.SimpleString;
import org.jboss.messaging.util.TokenBucketLimiterImpl;
-/**
+/*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ *
* @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
* @author <a href="mailto:ataylor at redhat.com">Andy Taylor</a>
- *
+ *
* @version <tt>$Revision: 3603 $</tt>
- *
+ *
* $Id: ClientSessionImpl.java 3603 2008-01-21 18:49:20Z timfox $
*/
public class ClientSessionImpl implements ClientSessionInternal
{
// Constants
- // ------------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------
+ // --------
private static final Logger log = Logger.getLogger(ClientSessionImpl.class);
- private boolean trace = log.isTraceEnabled();
+ private final boolean trace = log.isTraceEnabled();
public static final int INITIAL_MESSAGE_BODY_SIZE = 1024;
private static final ExecutorFactory executorFactory = new OrderedExecutorFactory(Executors.newCachedThreadPool(new JBMThreadFactory("jbm-client-session-threads")));
// Attributes
- // -----------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------
+ // -------
private final ClientSessionFactoryInternal sessionFactory;
@@ -174,7 +180,8 @@
private final IDGenerator idGenerator = new IDGenerator(0);
// Constructors
- // ---------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------
+ // -----
public ClientSessionImpl(final ClientSessionFactoryInternal sessionFactory,
final String name,
@@ -204,7 +211,7 @@
this.cacheProducers = cacheProducers;
- this.executor = executorFactory.getExecutor();
+ executor = executorFactory.getExecutor();
this.xa = xa;
@@ -229,7 +236,7 @@
this.version = version;
- this.connectionRegistry = ConnectionRegistryImpl.instance;
+ connectionRegistry = ConnectionRegistryImpl.instance;
}
// ClientSession implementation
@@ -261,7 +268,7 @@
SessionQueueQueryMessage request = new SessionQueueQueryMessage(queueName);
- SessionQueueQueryResponseMessage response = (SessionQueueQueryResponseMessage) channel.sendBlocking(request);
+ SessionQueueQueryResponseMessage response = (SessionQueueQueryResponseMessage)channel.sendBlocking(request);
return response;
}
@@ -272,7 +279,7 @@
SessionBindingQueryMessage request = new SessionBindingQueryMessage(address);
- SessionBindingQueryResponseMessage response = (SessionBindingQueryResponseMessage) channel.sendBlocking(request);
+ SessionBindingQueryResponseMessage response = (SessionBindingQueryResponseMessage)channel.sendBlocking(request);
return response;
}
@@ -328,7 +335,7 @@
windowSize,
maxRate);
- SessionCreateConsumerResponseMessage response = (SessionCreateConsumerResponseMessage) channel.sendBlocking(request);
+ SessionCreateConsumerResponseMessage response = (SessionCreateConsumerResponseMessage)channel.sendBlocking(request);
// The actual windows size that gets used is determined by the user since
// could be overridden on the queue settings
@@ -404,14 +411,14 @@
return createProducer(address, connectionFactory.getProducerWindowSize(), connectionFactory.getProducerMaxRate());
}
- public ClientProducer createRateLimitedProducer(SimpleString address, int rate) throws MessagingException
+ public ClientProducer createRateLimitedProducer(final SimpleString address, final int rate) throws MessagingException
{
checkClosed();
return createProducer(address, -1, rate);
}
- public ClientProducer createProducerWithWindowSize(SimpleString address, int windowSize) throws MessagingException
+ public ClientProducer createProducerWithWindowSize(final SimpleString address, final int windowSize) throws MessagingException
{
checkClosed();
@@ -446,7 +453,7 @@
{
SessionCreateProducerMessage request = new SessionCreateProducerMessage(address, windowSize, maxRate);
- SessionCreateProducerResponseMessage response = (SessionCreateProducerResponseMessage) channel.sendBlocking(request);
+ SessionCreateProducerResponseMessage response = (SessionCreateProducerResponseMessage)channel.sendBlocking(request);
// maxRate and windowSize can be overridden by the server
@@ -567,27 +574,31 @@
}
catch (Throwable ignore)
{
- //Session close should always return without exception
+ // Session close should always return without exception
}
-
- doCleanup();
+
+ doCleanup();
}
- public ClientMessage createClientMessage(byte type, boolean durable, long expiration, long timestamp, byte priority)
+ public ClientMessage createClientMessage(final byte type,
+ final boolean durable,
+ final long expiration,
+ final long timestamp,
+ final byte priority)
{
MessagingBuffer body = remotingConnection.createBuffer(INITIAL_MESSAGE_BODY_SIZE);
return new ClientMessageImpl(type, durable, expiration, timestamp, priority, body);
}
- public ClientMessage createClientMessage(byte type, boolean durable)
+ public ClientMessage createClientMessage(final byte type, final boolean durable)
{
MessagingBuffer body = remotingConnection.createBuffer(INITIAL_MESSAGE_BODY_SIZE);
return new ClientMessageImpl(type, durable, body);
}
- public ClientMessage createClientMessage(boolean durable)
+ public ClientMessage createClientMessage(final boolean durable)
{
MessagingBuffer body = remotingConnection.createBuffer(INITIAL_MESSAGE_BODY_SIZE);
@@ -665,7 +676,7 @@
{
this.deliverID = deliverID;
- this.deliveryExpired = expired;
+ deliveryExpired = expired;
}
public void addConsumer(final ClientConsumerInternal consumer)
@@ -754,8 +765,8 @@
if (consumer != null)
{
- consumer.handleMessage(message);
- }
+ consumer.handleMessage(message);
+ }
}
public void receiveProducerCredits(final long producerID, final int credits) throws Exception
@@ -764,8 +775,8 @@
if (producer != null)
{
- producer.receiveCredits(credits);
- }
+ producer.receiveCredits(credits);
+ }
}
public void handleFailover(final RemotingConnection backupConnection)
@@ -782,7 +793,7 @@
Channel channel1 = backupConnection.getChannel(1, false, -1);
- ReattachSessionResponseMessage response = (ReattachSessionResponseMessage) channel1.sendBlocking(request);
+ ReattachSessionResponseMessage response = (ReattachSessionResponseMessage)channel1.sendBlocking(request);
channel.replayCommands(response.getLastReceivedCommandID());
}
@@ -810,7 +821,7 @@
try
{
- SessionXAResponseMessage response = (SessionXAResponseMessage) channel.sendBlocking(packet);
+ SessionXAResponseMessage response = (SessionXAResponseMessage)channel.sendBlocking(packet);
if (response.isError())
{
@@ -851,7 +862,7 @@
// Need to flush any acks to server first
acknowledgeInternal(false);
- SessionXAResponseMessage response = (SessionXAResponseMessage) channel.sendBlocking(packet);
+ SessionXAResponseMessage response = (SessionXAResponseMessage)channel.sendBlocking(packet);
if (response.isError())
{
@@ -874,7 +885,7 @@
// Need to flush any acks to server first
acknowledgeInternal(false);
- SessionXAResponseMessage response = (SessionXAResponseMessage) channel.sendBlocking(new SessionXAForgetMessage(xid));
+ SessionXAResponseMessage response = (SessionXAResponseMessage)channel.sendBlocking(new SessionXAForgetMessage(xid));
if (response.isError())
{
@@ -894,7 +905,7 @@
try
{
- SessionXAGetTimeoutResponseMessage response = (SessionXAGetTimeoutResponseMessage) channel.sendBlocking(new PacketImpl(PacketImpl.SESS_XA_GET_TIMEOUT));
+ SessionXAGetTimeoutResponseMessage response = (SessionXAGetTimeoutResponseMessage)channel.sendBlocking(new PacketImpl(PacketImpl.SESS_XA_GET_TIMEOUT));
return response.getTimeoutSeconds();
}
@@ -919,7 +930,7 @@
return false;
}
- ClientSessionImpl other = (ClientSessionImpl) xares;
+ ClientSessionImpl other = (ClientSessionImpl)xares;
return remotingConnection == other.remotingConnection;
}
@@ -935,7 +946,7 @@
try
{
- SessionXAResponseMessage response = (SessionXAResponseMessage) channel.sendBlocking(packet);
+ SessionXAResponseMessage response = (SessionXAResponseMessage)channel.sendBlocking(packet);
if (response.isError())
{
@@ -961,7 +972,7 @@
{
try
{
- SessionXAGetInDoubtXidsResponseMessage response = (SessionXAGetInDoubtXidsResponseMessage) channel.sendBlocking(new PacketImpl(PacketImpl.SESS_XA_INDOUBT_XIDS));
+ SessionXAGetInDoubtXidsResponseMessage response = (SessionXAGetInDoubtXidsResponseMessage)channel.sendBlocking(new PacketImpl(PacketImpl.SESS_XA_INDOUBT_XIDS));
List<Xid> xids = response.getXids();
@@ -992,7 +1003,7 @@
try
{
- SessionXAResponseMessage response = (SessionXAResponseMessage) channel.sendBlocking(packet);
+ SessionXAResponseMessage response = (SessionXAResponseMessage)channel.sendBlocking(packet);
if (response.isError())
{
@@ -1012,7 +1023,7 @@
try
{
- SessionXASetTimeoutResponseMessage response = (SessionXASetTimeoutResponseMessage) channel.sendBlocking(new SessionXASetTimeoutMessage(seconds));
+ SessionXASetTimeoutResponseMessage response = (SessionXASetTimeoutResponseMessage)channel.sendBlocking(new SessionXASetTimeoutMessage(seconds));
return response.isOK();
}
@@ -1054,7 +1065,7 @@
throw new XAException(XAException.XAER_INVAL);
}
- SessionXAResponseMessage response = (SessionXAResponseMessage) channel.sendBlocking(packet);
+ SessionXAResponseMessage response = (SessionXAResponseMessage)channel.sendBlocking(packet);
if (response.isError())
{
@@ -1071,16 +1082,17 @@
}
// Public
- // ---------------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------
+ // -----------
public void setForceNotSameRM(final boolean force)
{
- this.forceNotSameRM = force;
+ forceNotSameRM = force;
}
public void setConnectionRegistry(final ConnectionRegistry registry)
{
- this.connectionRegistry = registry;
+ connectionRegistry = registry;
}
public RemotingConnection getConnection()
@@ -1089,13 +1101,16 @@
}
// Protected
- // ------------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------
+ // --------
// Package Private
- // ------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------
+ // --
// Private
- // --------------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------
+ // ----------
private void checkXA() throws XAException
{
@@ -1200,6 +1215,7 @@
}
// Inner Classes
- // --------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------
+ // ----
}
Added: trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -0,0 +1,284 @@
+/*
+ * 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.client.management.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import javax.management.Notification;
+import javax.management.ObjectName;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import org.jboss.messaging.core.message.Message;
+import org.jboss.messaging.util.SimpleString;
+
+/*
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ */
+public class ManagementHelper
+{
+
+ // Constants -----------------------------------------------------
+
+ public static final SimpleString HDR_JMX_OBJECTNAME = new SimpleString("JBMJMXObjectName");
+
+ public static final SimpleString HDR_JMX_REPLYTO = new SimpleString("JBMJMXReplyTo");
+
+ public static final SimpleString HDR_JMX_ATTRIBUTE_PREFIX = new SimpleString("JBMJMXAttribute.");
+
+ public static final SimpleString HDR_JMX_OPERATION_PREFIX = new SimpleString("JBMJMXOperation.");
+
+ public static final SimpleString HDR_JMX_OPERATION_NAME = new SimpleString(HDR_JMX_OPERATION_PREFIX + "name");
+
+ public static final SimpleString HDR_JMX_OPERATION_SUCCEEDED = new SimpleString("JBMJMXOperationSucceeded");
+
+ public static final SimpleString HDR_JMX_OPERATION_EXCEPTION = new SimpleString("JBMJMXOperationException");
+
+ public static final SimpleString HDR_JMX_SUBSCRIBE_TO_NOTIFICATIONS = new SimpleString("JBMJMXSubscribeToNotification");
+
+ public static final SimpleString HDR_JMX_NOTIFICATION = new SimpleString("JBMJMXNotification");
+
+ public static final SimpleString MANAGEMENT_DESTINATION = new SimpleString("admin.AdminDestination");
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ public static void putNotificationSubscription(final Message message,
+ final SimpleString replyTo,
+ final boolean subscribeToNotifications)
+ {
+ message.putStringProperty(HDR_JMX_REPLYTO, replyTo);
+ message.putBooleanProperty(HDR_JMX_SUBSCRIBE_TO_NOTIFICATIONS, subscribeToNotifications);
+ }
+
+ public static void putAttributes(final Message message,
+ final SimpleString replyTo,
+ final ObjectName objectName,
+ final String... attributes)
+ {
+ message.putStringProperty(HDR_JMX_OBJECTNAME, new SimpleString(objectName.toString()));
+ message.putStringProperty(HDR_JMX_REPLYTO, replyTo);
+ for (int i = 0; i < attributes.length; i++)
+ {
+ message.putStringProperty(new SimpleString(HDR_JMX_ATTRIBUTE_PREFIX + Integer.toString(i)),
+ new SimpleString(attributes[i]));
+ }
+ }
+
+ public static void putOperationInvocation(final Message message,
+ final SimpleString replyTo,
+ final ObjectName objectName,
+ final String operationName,
+ final Object... parameters)
+ {
+ // store the name of the operation...
+ message.putStringProperty(HDR_JMX_OBJECTNAME, new SimpleString(objectName.toString()));
+ message.putStringProperty(HDR_JMX_REPLYTO, replyTo);
+ message.putStringProperty(HDR_JMX_OPERATION_NAME, new SimpleString(operationName));
+ // ... and all the parameters (preserving their types)
+ for (int i = 0; i < parameters.length; i++)
+ {
+ Object parameter = parameters[i];
+ SimpleString key = new SimpleString(HDR_JMX_OPERATION_PREFIX + Integer.toString(i));
+ storeTypedProperty(message, key, parameter);
+ }
+ }
+
+ public static void storeNotification(final Message message, final Notification notification)
+ {
+ message.putBooleanProperty(HDR_JMX_NOTIFICATION, true);
+ message.putStringProperty(new SimpleString("message"), new SimpleString(notification.getMessage()));
+ message.putStringProperty(new SimpleString("type"), new SimpleString(notification.getType()));
+ message.putLongProperty(new SimpleString("sequenceNumber"), notification.getSequenceNumber());
+ message.putLongProperty(new SimpleString("timestamp"), notification.getTimeStamp());
+ if (notification.getSource() instanceof ObjectName)
+ {
+ message.putStringProperty(new SimpleString("source"), new SimpleString(notification.getSource().toString()));
+ }
+ }
+
+ public static Notification getNotification(final Message message)
+ {
+ SimpleString sourceStr = (SimpleString)message.getProperty(new SimpleString("source"));
+ Object source = null;
+ if (sourceStr != null)
+ {
+ try
+ {
+ source = ObjectName.getInstance(sourceStr.toString());
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ SimpleString type = (SimpleString)message.getProperty(new SimpleString("type"));
+ long sequenceNumber = (Long)message.getProperty(new SimpleString("sequenceNumber"));
+ long timestamp = (Long)message.getProperty(new SimpleString("timestamp"));
+
+ Notification notif = new Notification(type.toString(), source, sequenceNumber, timestamp, message.toString());
+ return notif;
+ }
+
+ public static boolean isNotification(final Message message)
+ {
+ return message.containsProperty(HDR_JMX_NOTIFICATION);
+ }
+
+ public static boolean isOperationResult(final Message message)
+ {
+ return message.containsProperty(HDR_JMX_OPERATION_SUCCEEDED);
+ }
+
+ public static boolean isAttributesResult(final Message message)
+ {
+ return !(isNotification(message) && isOperationResult(message));
+ }
+
+ public static TabularData getTabularDataProperty(final Message message, final String key)
+ {
+ Object object = message.getProperty(new SimpleString(key));
+ if (object instanceof byte[])
+ {
+ return (TabularData)from((byte[])object);
+ }
+ throw new IllegalArgumentException(key + " property is not a valid TabularData");
+ }
+
+ public static boolean hasOperationSucceeded(final Message message)
+ {
+ if (!isOperationResult(message))
+ {
+ return false;
+ }
+ if (message.containsProperty(HDR_JMX_OPERATION_SUCCEEDED))
+ {
+ return (Boolean)message.getProperty(HDR_JMX_OPERATION_SUCCEEDED);
+ }
+ return false;
+ }
+
+ public static String getOperationExceptionMessage(final Message message)
+ {
+ if (message.containsProperty(HDR_JMX_OPERATION_EXCEPTION))
+ {
+ return ((SimpleString)message.getProperty(HDR_JMX_OPERATION_EXCEPTION)).toString();
+ }
+ return null;
+ }
+
+ public static void storeTypedProperty(final Message message, final SimpleString key, final Object typedProperty)
+ {
+ if (typedProperty instanceof Void)
+ {
+ // do not put the returned value if the operation was a procedure
+ }
+ else if (typedProperty instanceof Boolean)
+ {
+ message.putBooleanProperty(key, (Boolean)typedProperty);
+ }
+ else if (typedProperty instanceof Byte)
+ {
+ message.putByteProperty(key, (Byte)typedProperty);
+ }
+ else if (typedProperty instanceof Short)
+ {
+ message.putShortProperty(key, (Short)typedProperty);
+ }
+ else if (typedProperty instanceof Integer)
+ {
+ message.putIntProperty(key, (Integer)typedProperty);
+ }
+ else if (typedProperty instanceof Long)
+ {
+ message.putLongProperty(key, (Long)typedProperty);
+ }
+ else if (typedProperty instanceof Float)
+ {
+ message.putFloatProperty(key, (Float)typedProperty);
+ }
+ else if (typedProperty instanceof Double)
+ {
+ message.putDoubleProperty(key, (Character)typedProperty);
+ }
+ else if (typedProperty instanceof String)
+ {
+ message.putStringProperty(key, new SimpleString((String)typedProperty));
+ }
+ else if (typedProperty instanceof TabularData || typedProperty instanceof CompositeData)
+ {
+ storePropertyAsBytes(message, key, typedProperty);
+ }
+ // serialize as a SimpleString
+ else
+ {
+ message.putStringProperty(key, new SimpleString("" + typedProperty));
+ }
+ }
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ private static Object from(final byte[] bytes)
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ObjectInputStream ois;
+ try
+ {
+ ois = new ObjectInputStream(bais);
+ return ois.readObject();
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private static void storePropertyAsBytes(final Message message, final SimpleString key, final Object property)
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try
+ {
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(property);
+ }
+ catch (IOException e)
+ {
+ throw new IllegalStateException(property + " can not be written to a byte array");
+ }
+ message.putBytesProperty(key, baos.toByteArray());
+ }
+ // Inner classes -------------------------------------------------
+}
Modified: trunk/src/main/org/jboss/messaging/core/management/ManagementService.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/ManagementService.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/management/ManagementService.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -24,6 +24,9 @@
import java.util.Set;
+import javax.management.NotificationBroadcaster;
+import javax.management.ObjectName;
+
import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.messagecounter.MessageCounterManager;
import org.jboss.messaging.core.persistence.StorageManager;
@@ -31,6 +34,7 @@
import org.jboss.messaging.core.security.Role;
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.util.SimpleString;
@@ -41,7 +45,7 @@
* @version <tt>$Revision$</tt>
*
*/
-public interface ManagementService
+public interface ManagementService extends NotificationBroadcaster
{
MessageCounterManager getMessageCounterManager();
@@ -63,4 +67,12 @@
void unregisterQueue(SimpleString name, SimpleString address)
throws Exception;
+ void registerResource(ObjectName objectName, Object resource) throws Exception;
+
+ void unregisterResource(ObjectName objectName) throws Exception;
+
+ public Object getResource(ObjectName objectName);
+
+ void handleMessage(ServerMessage message);
+
}
Modified: trunk/src/main/org/jboss/messaging/core/management/MessageInfo.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/MessageInfo.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/management/MessageInfo.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -28,6 +28,9 @@
import static javax.management.openmbean.SimpleType.LONG;
import static javax.management.openmbean.SimpleType.STRING;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
import java.util.Map;
import javax.management.openmbean.CompositeData;
@@ -109,6 +112,30 @@
return data;
}
+ public static MessageInfo[] from(TabularData msgs)
+ {
+ Collection values = msgs.values();
+ List<MessageInfo> infos = new ArrayList<MessageInfo>();
+ for (Object object : values)
+ {
+ CompositeData compositeData = (CompositeData) object;
+ long id = (Long) compositeData.get("id");
+ String destination = (String) compositeData.get("destination");
+ boolean durable = (Boolean) compositeData.get("durable");
+ long timestamp = (Long) compositeData.get("timestamp");
+ byte type = (Byte) compositeData.get("type");
+ int size = (Integer) compositeData.get("size");
+ byte priority = (Byte) compositeData.get("priority");
+ boolean expired = (Boolean) compositeData.get("expired");
+ long expiration = (Long) compositeData.get("expiration");
+
+ infos.add(new MessageInfo(id, destination, durable, timestamp, type,
+ size, priority, expired, expiration));
+ }
+
+ return (MessageInfo[]) infos.toArray(new MessageInfo[infos.size()]);
+ }
+
// Constructors --------------------------------------------------
public MessageInfo(final long id, final String destination,
@@ -199,4 +226,13 @@
return null;
}
}
+
+ @Override
+ public String toString()
+ {
+ return "MessageInfo[id=" + id + ", destination=" + destination
+ + ", durable=" + durable + ", timestamp=" + timestamp + ", type="
+ + type + ", size=" + size + ", priority=" + priority + ", expired="
+ + expired + ", expiration=" + expiration + "]";
+ }
}
Modified: trunk/src/main/org/jboss/messaging/core/management/RoleInfo.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/RoleInfo.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/management/RoleInfo.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -25,6 +25,10 @@
import static javax.management.openmbean.SimpleType.BOOLEAN;
import static javax.management.openmbean.SimpleType.STRING;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
import javax.management.openmbean.CompositeType;
@@ -89,6 +93,23 @@
return data;
}
+ public static RoleInfo[] from(TabularData roles)
+ {
+ Collection values = roles.values();
+ List<RoleInfo> infos = new ArrayList<RoleInfo>();
+ for (Object object : values)
+ {
+ CompositeData compositeData = (CompositeData) object;
+ String name = (String) compositeData.get("name");
+ boolean create = (Boolean) compositeData.get("create");
+ boolean read = (Boolean) compositeData.get("read");
+ boolean write = (Boolean) compositeData.get("write");
+ infos.add(new RoleInfo(name, create, read, write));
+ }
+
+ return (RoleInfo[]) infos.toArray(new RoleInfo[infos.size()]);
+ }
+
// Constructors --------------------------------------------------
public RoleInfo(String name, boolean create, boolean read, boolean write)
@@ -133,6 +154,13 @@
}
}
+ @Override
+ public String toString()
+ {
+ return "RoleInfo[name=" + name + ", create=" + create + ", read=" + read
+ + ", write=" + write + "]";
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -1,39 +1,51 @@
/*
- * 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.
+ * 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 static javax.management.ObjectName.quote;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanNotificationInfo;
import javax.management.MBeanServer;
import javax.management.Notification;
import javax.management.NotificationBroadcasterSupport;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
import javax.management.ObjectName;
+import org.jboss.messaging.core.client.management.impl.ManagementHelper;
import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.management.AddressControlMBean;
@@ -49,39 +61,49 @@
import org.jboss.messaging.core.security.Role;
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.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);
+ private static final Logger log = Logger.getLogger(ManagementServiceImpl.class);
+
public static final String DOMAIN = "org.jboss.messaging";
// Attributes ----------------------------------------------------
private final MBeanServer mbeanServer;
+
private final boolean jmxManagementEnabled;
+
private final Map<ObjectName, Object> registry;
+
private final NotificationBroadcasterSupport broadcaster;
- private final AtomicLong notifSeq;
+ private AtomicLong notifSeq = new AtomicLong(0);
+
private PostOffice postOffice;
+
private HierarchicalRepository<Set<Role>> securityRepository;
+
private HierarchicalRepository<QueueSettings> queueSettingsRepository;
- private MessageCounterManager messageCounterManager = new MessageCounterManagerImpl(
- 10000);
+
private MessagingServerControlMBean managedServer;
+ private final MessageCounterManager messageCounterManager = new MessageCounterManagerImpl(10000);
+
+ // key is a Destination
+ private final Map<SimpleString, NotificationListener> notifListeners = new HashMap<SimpleString, NotificationListener>();
+
// Static --------------------------------------------------------
public static ObjectName getMessagingServerObjectName() throws Exception
@@ -89,31 +111,30 @@
return ObjectName.getInstance(DOMAIN + ":module=Core,type=Server");
}
- public static ObjectName getAddressObjectName(final SimpleString address)
- throws Exception
+ public static ObjectName getAddressObjectName(final SimpleString address) throws Exception
{
- return ObjectName.getInstance(String.format(
- "%s:module=Core,type=Address,name=%s", DOMAIN, quote(address.toString())));
+ return ObjectName.getInstance(String.format("%s:module=Core,type=Address,name=%s",
+ DOMAIN,
+ quote(address.toString())));
}
- public static ObjectName getQueueObjectName(final SimpleString address,
- final SimpleString name) throws Exception
+ 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, quote(address.toString()),
- quote(name.toString())));
+ return ObjectName.getInstance(String.format("%s:module=Core,type=Queue,address=%s,name=%s",
+ DOMAIN,
+ quote(address.toString()),
+ quote(name.toString())));
}
// Constructors --------------------------------------------------
- public ManagementServiceImpl(final MBeanServer mbeanServer,
- final boolean jmxManagementEnabled)
+ public ManagementServiceImpl(final MBeanServer mbeanServer, final boolean jmxManagementEnabled)
{
this.mbeanServer = mbeanServer;
this.jmxManagementEnabled = jmxManagementEnabled;
- this.registry = new HashMap<ObjectName, Object>();
- this.broadcaster = new NotificationBroadcasterSupport();
- this.notifSeq = new AtomicLong(0);
+ registry = new HashMap<ObjectName, Object>();
+ broadcaster = new NotificationBroadcasterSupport();
+ notifSeq = new AtomicLong(0);
}
// Public --------------------------------------------------------
@@ -125,38 +146,41 @@
return messageCounterManager;
}
- public MessagingServerControlMBean registerServer(PostOffice postOffice,
- StorageManager storageManager, Configuration configuration,
- HierarchicalRepository<Set<Role>> securityRepository,
- HierarchicalRepository<QueueSettings> queueSettingsRepository,
- MessagingServer messagingServer) throws Exception
+ public MessagingServerControlMBean registerServer(final PostOffice postOffice,
+ final StorageManager storageManager,
+ final Configuration configuration,
+ final HierarchicalRepository<Set<Role>> securityRepository,
+ final HierarchicalRepository<QueueSettings> queueSettingsRepository,
+ final MessagingServer messagingServer) throws Exception
{
this.postOffice = postOffice;
this.securityRepository = securityRepository;
this.queueSettingsRepository = queueSettingsRepository;
- managedServer = new MessagingServerControl(postOffice, storageManager,
- configuration, securityRepository, queueSettingsRepository,
- messagingServer, messageCounterManager, broadcaster);
+ managedServer = new MessagingServerControl(postOffice,
+ storageManager,
+ configuration,
+ securityRepository,
+ queueSettingsRepository,
+ messagingServer,
+ messageCounterManager,
+ broadcaster);
ObjectName objectName = getMessagingServerObjectName();
- register(objectName, managedServer);
- registerInJMX(objectName, managedServer);
+ registerResource(objectName, managedServer);
+
return managedServer;
}
public void unregisterServer() throws Exception
{
ObjectName objectName = getMessagingServerObjectName();
- unregister(objectName);
- unregisterFromJMX(objectName);
+ unregisterResource(objectName);
}
public void registerAddress(final SimpleString address) throws Exception
{
ObjectName objectName = getAddressObjectName(address);
- AddressControlMBean addressControl = new AddressControl(address,
- postOffice, securityRepository);
- register(objectName, addressControl);
- registerInJMX(objectName, addressControl);
+ AddressControlMBean addressControl = new AddressControl(address, postOffice, securityRepository);
+ registerResource(objectName, addressControl);
if (log.isDebugEnabled())
{
log.debug("registered address " + objectName);
@@ -167,63 +191,152 @@
public void unregisterAddress(final SimpleString address) throws Exception
{
ObjectName objectName = getAddressObjectName(address);
- unregister(objectName);
- unregisterFromJMX(objectName);
+ unregisterResource(objectName);
sendNotification(NotificationType.ADDRESS_REMOVED, address.toString());
}
- public void registerQueue(final Queue queue, final SimpleString address,
- final StorageManager storageManager) throws Exception
+ public void registerQueue(final Queue queue, final SimpleString address, final StorageManager storageManager) throws Exception
{
MessageCounter counter = new MessageCounter(queue.getName().toString(),
- null, queue, false, queue.isDurable(), messageCounterManager
- .getMaxDayCount());
- messageCounterManager.registerMessageCounter(queue.getName().toString(),
- counter);
+ null,
+ queue,
+ false,
+ queue.isDurable(),
+ messageCounterManager.getMaxDayCount());
+ messageCounterManager.registerMessageCounter(queue.getName().toString(), counter);
ObjectName objectName = getQueueObjectName(address, queue.getName());
- QueueControlMBean queueControl = new QueueControl(queue, storageManager,
- postOffice, queueSettingsRepository, counter);
- register(objectName, queueControl);
- registerInJMX(objectName, queueControl);
+ QueueControlMBean queueControl = new QueueControl(queue,
+ storageManager,
+ postOffice,
+ queueSettingsRepository,
+ counter);
+ registerResource(objectName, queueControl);
if (log.isDebugEnabled())
{
log.debug("registered queue " + objectName);
}
- sendNotification(NotificationType.QUEUE_CREATED, queue.getName()
- .toString());
+ sendNotification(NotificationType.QUEUE_CREATED, queue.getName().toString());
}
- public void unregisterQueue(final SimpleString name,
- final SimpleString address) throws Exception
+ public void unregisterQueue(final SimpleString name, final SimpleString address) throws Exception
{
ObjectName objectName = getQueueObjectName(address, name);
- unregister(objectName);
- unregisterFromJMX(objectName);
+ unregisterResource(objectName);
messageCounterManager.unregisterMessageCounter(name.toString());
sendNotification(NotificationType.QUEUE_DESTROYED, name.toString());
}
+ public void handleMessage(final ServerMessage message)
+ {
+ SimpleString objectName = (SimpleString)message.getProperty(ManagementHelper.HDR_JMX_OBJECTNAME);
+ if (log.isDebugEnabled())
+ {
+ log.debug("handling management message for " + objectName);
+ }
+ Set<SimpleString> propertyNames = message.getPropertyNames();
+ // use an array with all the property names to avoid a
+ // ConcurrentModificationException
+ // when invoking an operation or retrieving attributes (since they add
+ // properties to the message)
+ List<SimpleString> propNames = new ArrayList<SimpleString>(propertyNames);
+
+ if (propNames.contains(ManagementHelper.HDR_JMX_OPERATION_NAME))
+ {
+ SimpleString operation = (SimpleString)message.getProperty(ManagementHelper.HDR_JMX_OPERATION_NAME);
+ List<Object> operationParameters = retrieveOperationParameters(message);
+
+ if (operation != null)
+ {
+ try
+ {
+ Object result = invokeOperation(objectName.toString(), operation.toString(), operationParameters);
+ message.putBooleanProperty(ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED, true);
+ ManagementHelper.storeTypedProperty(message, operation, result);
+ }
+ catch (Exception e)
+ {
+ log.warn("exception while invoking " + operation + " on " + objectName, e);
+ message.putBooleanProperty(ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED, false);
+ String exceptionMessage = e.getMessage();
+ if (e instanceof InvocationTargetException)
+ {
+ exceptionMessage = ((InvocationTargetException)e).getTargetException().getMessage();
+ }
+ message.putStringProperty(ManagementHelper.HDR_JMX_OPERATION_EXCEPTION,
+ new SimpleString(exceptionMessage));
+ }
+ }
+ }
+ else
+ {
+ for (SimpleString propertyName : propNames)
+ {
+ if (propertyName.startsWith(ManagementHelper.HDR_JMX_ATTRIBUTE_PREFIX))
+ {
+ SimpleString attribute = (SimpleString)message.getProperty(propertyName);
+ Object result = getAttribute(objectName.toString(), attribute.toString());
+ ManagementHelper.storeTypedProperty(message, attribute, result);
+ }
+ }
+ }
+ }
+
+ public void registerResource(final ObjectName objectName, final Object resource) throws Exception
+ {
+ registerInRegistry(objectName, resource);
+ registerInJMX(objectName, resource);
+ }
+
+ public void unregisterResource(final ObjectName objectName) throws Exception
+ {
+ unregisterFromRegistry(objectName);
+ unregisterFromJMX(objectName);
+ }
+
+ public Object getResource(final ObjectName objectName)
+ {
+ return registry.get(objectName);
+ }
+
+ // NotificatioBroadcaster implementation -----------------------------------
+
+ public void addNotificationListener(final NotificationListener listener,
+ final NotificationFilter filter,
+ final Object handback) throws IllegalArgumentException
+ {
+ broadcaster.addNotificationListener(listener, filter, handback);
+ }
+
+ public MBeanNotificationInfo[] getNotificationInfo()
+ {
+ return broadcaster.getNotificationInfo();
+ }
+
+ public void removeNotificationListener(final NotificationListener listener) throws ListenerNotFoundException
+ {
+ broadcaster.removeNotificationListener(listener);
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
// Private -------------------------------------------------------
- private void register(ObjectName objectName, Object managedResource)
+ public void registerInRegistry(final ObjectName objectName, final Object managedResource)
{
- unregister(objectName);
+ unregisterFromRegistry(objectName);
registry.put(objectName, managedResource);
}
- private void unregister(ObjectName objectName)
+ private void unregisterFromRegistry(final ObjectName objectName)
{
registry.remove(objectName);
}
- private void registerInJMX(ObjectName objectName, Object managedResource)
- throws Exception
+ private void registerInJMX(final ObjectName objectName, final Object managedResource) throws Exception
{
if (!jmxManagementEnabled)
{
@@ -233,7 +346,7 @@
mbeanServer.registerMBean(managedResource, objectName);
}
- private void unregisterFromJMX(ObjectName objectName) throws Exception
+ private void unregisterFromJMX(final ObjectName objectName) throws Exception
{
if (!jmxManagementEnabled)
{
@@ -245,16 +358,105 @@
}
}
- private void sendNotification(MessagingServerControl.NotificationType type,
- String message)
+ private void sendNotification(final MessagingServerControl.NotificationType type, final String message) throws Exception
{
if (managedServer != null)
{
- Notification notif = new Notification(type.toString(), managedServer,
- notifSeq.incrementAndGet(), message);
+ Notification notif = new Notification(type.toString(),
+ getMessagingServerObjectName(),
+ notifSeq.incrementAndGet(),
+ message);
broadcaster.sendNotification(notif);
}
}
+ public Object getAttribute(final String objectNameStr, final String attribute)
+ {
+ try
+ {
+ ObjectName objectName = ObjectName.getInstance(objectNameStr);
+ Object resource = registry.get(objectName);
+ Method method = null;
+
+ try
+ {
+ method = resource.getClass().getMethod("get" + attribute, new Class[0]);
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ try
+ {
+ method = resource.getClass().getMethod("is" + attribute, new Class[0]);
+ }
+ catch (NoSuchMethodException nsme2)
+ {
+ throw new IllegalArgumentException("no getter method for " + attribute);
+ }
+ }
+ return method.invoke(resource, new Object[0]);
+ }
+ catch (Throwable t)
+ {
+ throw new IllegalStateException("Problem while retrieving attribute " + attribute, t);
+ }
+ }
+
+ private Object invokeOperation(final String objectNameStr, final String operation, final List<Object> params) throws Exception
+ {
+ ObjectName objectName = ObjectName.getInstance(objectNameStr);
+ Object resource = registry.get(objectName);
+ Method method = null;
+
+ Method[] methods = resource.getClass().getMethods();
+ for (Method m : methods)
+ {
+ if (m.getName().equals(operation) && m.getParameterTypes().length == params.size())
+ {
+ method = m;
+ }
+ }
+ if (method == null)
+ {
+ throw new IllegalArgumentException("no operation " + operation + "/" + params.size());
+ }
+ Object[] p = params.toArray(new Object[params.size()]);
+ Object result = method.invoke(resource, p);
+ return result;
+ }
+
+ private List<Object> retrieveOperationParameters(final ServerMessage message)
+ {
+ List<Object> params = new ArrayList<Object>();
+ Set<SimpleString> propertyNames = message.getPropertyNames();
+ // put the property names in a list to sort them and have the parameters
+ // in the correct order
+ List<SimpleString> propsNames = new ArrayList<SimpleString>(propertyNames);
+ Collections.sort(propsNames);
+ for (SimpleString propertyName : propsNames)
+ {
+ if (propertyName.startsWith(ManagementHelper.HDR_JMX_OPERATION_PREFIX))
+ {
+ String s = propertyName.toString();
+ // split by the dot
+ String[] ss = s.split("\\.");
+ try
+ {
+ int index = Integer.parseInt(ss[ss.length - 1]);
+ Object value = message.getProperty(propertyName);
+ if (value instanceof SimpleString)
+ {
+ value = value.toString();
+ }
+ params.add(index, value);
+ }
+ catch (NumberFormatException e)
+ {
+ // ignore the property (it is the operation name)
+ }
+ }
+ }
+ return params;
+ }
+
// Inner classes -------------------------------------------------
}
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -75,7 +75,6 @@
private final HierarchicalRepository<QueueSettings> queueSettingsRepository;
private final MessagingServer server;
private final MessageCounterManager messageCounterManager;
-
private final NotificationBroadcasterSupport broadcaster;
private boolean enableMessageCounters;
@@ -362,7 +361,7 @@
SimpleString sName = new SimpleString(name);
if (postOffice.getBinding(sAddress) == null)
{
- postOffice.addBinding(sAddress, sName, null, true);
+ postOffice.addBinding(sAddress, sName, null, true, false);
}
}
@@ -381,7 +380,7 @@
}
if (postOffice.getBinding(sAddress) == null)
{
- postOffice.addBinding(sAddress, sName, filter, durable);
+ postOffice.addBinding(sAddress, sName, filter, durable, false);
}
}
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/QueueControl.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -116,7 +116,7 @@
public boolean isTemporary()
{
- return queue.isDurable();
+ return queue.isTemporary();
}
public boolean isBackup()
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-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -531,7 +531,7 @@
filter = new FilterImpl(encodeBinding.filter);
}
- Queue queue = queueFactory.createQueue(id, encodeBinding.queueName, filter, true);
+ Queue queue = queueFactory.createQueue(id, encodeBinding.queueName, filter, true, false);
Binding binding = new BindingImpl(encodeBinding.address, queue);
Modified: trunk/src/main/org/jboss/messaging/core/postoffice/PostOffice.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/PostOffice.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/PostOffice.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -64,7 +64,7 @@
boolean containsDestination(SimpleString address);
Binding addBinding(SimpleString address, SimpleString queueName, Filter filter,
- boolean durable) throws Exception;
+ boolean durable, boolean temporary) throws Exception;
Binding removeBinding(SimpleString queueName) throws Exception;
Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -184,9 +184,9 @@
}
public Binding addBinding(final SimpleString address, final SimpleString queueName, final Filter filter,
- final boolean durable) throws Exception
+ final boolean durable, boolean temporary) throws Exception
{
- Binding binding = createBinding(address, queueName, filter, durable);
+ Binding binding = createBinding(address, queueName, filter, durable, temporary);
addBindingInMemory(binding);
@@ -335,9 +335,9 @@
// Private -----------------------------------------------------------------
private Binding createBinding(final SimpleString address, final SimpleString name, final Filter filter,
- final boolean durable) throws Exception
+ final boolean durable, final boolean temporary) throws Exception
{
- Queue queue = queueFactory.createQueue(-1, name, filter, durable);
+ Queue queue = queueFactory.createQueue(-1, name, filter, durable, false);
queue.setBackup(backup);
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -52,6 +52,7 @@
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_CREATEQUEUE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_DELETE_QUEUE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_FLOWTOKEN;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_MANAGEMENT_SEND;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_NULL_RESPONSE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_PACKETS_CONFIRMED;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_PRODUCER_CLOSE;
@@ -143,6 +144,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionReceiveMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveDestinationMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendManagementMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXACommitMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAEndMessage;
@@ -808,6 +810,11 @@
packet = new SessionReplicateSendMessage();
break;
}
+ case SESS_MANAGEMENT_SEND:
+ {
+ packet = new SessionSendManagementMessage();
+ break;
+ }
default:
{
throw new IllegalArgumentException("Invalid type: " + packetType);
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/PacketImpl.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -117,6 +117,7 @@
public static final byte SESS_NULL_RESPONSE = 91;
public static final byte SESS_REPLICATE_DELIVERY = 92;
public static final byte SESS_REPLICATE_SEND = 93;
+ public static final byte SESS_MANAGEMENT_SEND = 94;
// Static --------------------------------------------------------
Added: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendManagementMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendManagementMessage.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/SessionSendManagementMessage.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -0,0 +1,134 @@
+/*
+ * 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.remoting.impl.wireformat;
+
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.core.server.impl.ServerMessageImpl;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ */
+public class SessionSendManagementMessage extends PacketImpl
+{
+ // Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(SessionSendManagementMessage.class);
+
+ // Attributes ----------------------------------------------------
+
+ private long producerID;
+
+ private ClientMessage clientMessage;
+
+ private ServerMessage serverMessage;
+
+ private boolean requiresResponse;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public SessionSendManagementMessage(final long producerID, final ClientMessage message, final boolean requiresResponse)
+ {
+ super(SESS_MANAGEMENT_SEND);
+
+ this.producerID = producerID;
+
+ this.clientMessage = message;
+
+ this.requiresResponse = requiresResponse;
+ }
+
+ public SessionSendManagementMessage()
+ {
+ super(SESS_MANAGEMENT_SEND);
+ }
+
+ // Public --------------------------------------------------------
+
+ public long getProducerID()
+ {
+ return producerID;
+ }
+
+ public ClientMessage getClientMessage()
+ {
+ return clientMessage;
+ }
+
+ public ServerMessage getServerMessage()
+ {
+ return serverMessage;
+ }
+
+ public boolean isRequiresResponse()
+ {
+ return requiresResponse;
+ }
+
+ public void encodeBody(final MessagingBuffer buffer)
+ {
+ buffer.putLong(producerID);
+
+ if (clientMessage != null)
+ {
+ clientMessage.encode(buffer);
+ }
+ else
+ {
+ //If we're replicating a buffer to a backup node then we encode the serverMessage not the clientMessage
+ serverMessage.encode(buffer);
+ }
+
+ buffer.putBoolean(requiresResponse);
+ }
+
+ public void decodeBody(final MessagingBuffer buffer)
+ {
+ //TODO can be optimised
+
+ producerID = buffer.getLong();
+
+ serverMessage = new ServerMessageImpl();
+
+ serverMessage.decode(buffer);
+
+ serverMessage.getBody().flip();
+
+ requiresResponse = buffer.getBoolean();
+ }
+
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Modified: trunk/src/main/org/jboss/messaging/core/server/Queue.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/Queue.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/server/Queue.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -98,6 +98,8 @@
boolean isDurable();
+ boolean isTemporary();
+
SimpleString getName();
int getMessagesAdded();
Modified: trunk/src/main/org/jboss/messaging/core/server/QueueFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/QueueFactory.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/server/QueueFactory.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -39,7 +39,7 @@
public interface QueueFactory
{
Queue createQueue(long persistenceID, SimpleString name, Filter filter,
- boolean durable);
+ boolean durable, boolean temporary);
/**
* This is required for delete-all-reference to work correctly with paging
Modified: trunk/src/main/org/jboss/messaging/core/server/ServerSession.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/ServerSession.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/server/ServerSession.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -31,6 +31,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateConsumerResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateProducerResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryResponseMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendManagementMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAResponseMessage;
import org.jboss.messaging.core.server.impl.ServerBrowserImpl;
import org.jboss.messaging.util.SimpleString;
@@ -139,4 +140,6 @@
void transferConnection(RemotingConnection newConnection);
int replayCommands(int lastReceivedCommandID);
+
+ void handleManagementMessage(SessionSendManagementMessage message) throws Exception;
}
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessageReferenceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessageReferenceImpl.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessageReferenceImpl.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -162,7 +162,7 @@
if (dlqBinding == null)
{
- dlqBinding = postOffice.addBinding(dlq, dlq, null, true);
+ dlqBinding = postOffice.addBinding(dlq, dlq, null, true, false);
}
move(dlqBinding, persistenceManager, postOffice, false);
@@ -188,7 +188,7 @@
if (expiryBinding == null)
{
expiryBinding = postOffice.addBinding(expiryQueue, expiryQueue, null,
- true);
+ true, false);
}
move(expiryBinding, persistenceManager, postOffice, true);
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -480,6 +480,7 @@
securityStore,
executorFactory.getExecutor(),
channel,
+ managementService,
this);
if (sessions.putIfAbsent(name, session) != null)
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/QueueFactoryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/QueueFactoryImpl.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/QueueFactoryImpl.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -63,11 +63,12 @@
}
public Queue createQueue(final long persistenceID, final SimpleString name, final Filter filter,
- final boolean durable)
+ final boolean durable, final boolean temporary)
{
QueueSettings queueSettings = queueSettingsRepository.getMatch(name.toString());
- Queue queue = new QueueImpl(persistenceID, name, filter, queueSettings.isClustered(), durable, scheduledExecutor, postOffice);
+ Queue queue = new QueueImpl(persistenceID, name, filter, queueSettings.isClustered(), durable,
+ temporary, scheduledExecutor, postOffice);
queue.setDistributionPolicy(queueSettings.getDistributionPolicy());
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -66,6 +66,7 @@
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ * @author <a href="jmesnil at redhat.com">Jeff Mesnil</a>
* @author <a href="clebert.suconic at jboss.com">Clebert Suconic</a>
*
*/
@@ -87,6 +88,8 @@
private final boolean durable;
+ private final boolean temporary;
+
private final ScheduledExecutorService scheduledExecutor;
private final PostOffice postOffice;
@@ -126,6 +129,7 @@
final Filter filter,
final boolean clustered,
final boolean durable,
+ final boolean temporary,
final ScheduledExecutorService scheduledExecutor,
final PostOffice postOffice)
{
@@ -138,6 +142,8 @@
this.clustered = clustered;
this.durable = durable;
+
+ this.temporary = temporary;
this.scheduledExecutor = scheduledExecutor;
@@ -158,6 +164,11 @@
{
return durable;
}
+
+ public boolean isTemporary()
+ {
+ return temporary;
+ }
public SimpleString getName()
{
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -159,4 +159,11 @@
{
return new ServerMessageImpl(this);
}
+
+ @Override
+ public String toString()
+ {
+ return "ServerMessage[messageID=" + messageID + ", durable=" + durable
+ + ", destination=" + getDestination() + "]";
+ }
}
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -22,6 +22,7 @@
package org.jboss.messaging.core.server.impl;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
@@ -33,14 +34,18 @@
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicLong;
+import javax.management.Notification;
+import javax.management.NotificationListener;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
+import org.jboss.messaging.core.client.management.impl.ManagementHelper;
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.logging.Logger;
+import org.jboss.messaging.core.management.ManagementService;
import org.jboss.messaging.core.paging.PagingManager;
import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.Binding;
@@ -50,13 +55,14 @@
import org.jboss.messaging.core.remoting.FailureListener;
import org.jboss.messaging.core.remoting.Packet;
import org.jboss.messaging.core.remoting.RemotingConnection;
+import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionBindingQueryResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateConsumerResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionCreateProducerResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryResponseMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendManagementMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAResponseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.cluster.SessionReplicateDeliveryMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.cluster.SessionReplicateSendMessage;
import org.jboss.messaging.core.security.CheckType;
import org.jboss.messaging.core.security.SecurityStore;
import org.jboss.messaging.core.server.Delivery;
@@ -75,26 +81,31 @@
import org.jboss.messaging.util.IDGenerator;
import org.jboss.messaging.util.SimpleString;
-/**
+/*
* Session implementation
- *
+ *
* @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="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
*/
-public class ServerSessionImpl implements ServerSession, FailureListener
+public class ServerSessionImpl implements ServerSession, FailureListener, NotificationListener
{
// Constants
- // ------------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------
+ // --------
private static final Logger log = Logger.getLogger(ServerSessionImpl.class);
// Static
- // ---------------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------
+ // -----------
// Attributes
- // -----------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------
+ // -------
private final boolean trace = log.isTraceEnabled();
@@ -144,6 +155,8 @@
private final MessagingServer server;
+ private final ManagementService managementService;
+
private volatile boolean started = false;
private final List<Runnable> failureRunners = new ArrayList<Runnable>();
@@ -151,7 +164,8 @@
private final IDGenerator idGenerator = new IDGenerator(0);
// Constructors
- // ---------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------
+ // -----
public ServerSessionImpl(final String name,
final long id,
@@ -168,6 +182,7 @@
final SecurityStore securityStore,
final Executor executor,
final Channel channel,
+ final ManagementService managementService,
final MessagingServer server) throws Exception
{
this.name = name;
@@ -188,7 +203,7 @@
this.postOffice = postOffice;
- this.pager = postOffice.getPagingManager();
+ pager = postOffice.getPagingManager();
this.queueSettingsRepository = queueSettingsRepository;
@@ -208,10 +223,13 @@
// this.replicatingChannel = channel.getReplicatingChannel();
this.server = server;
+
+ this.managementService = managementService;
}
// ServerSession implementation
- // ---------------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------
+ // -----------
public String getUsername()
{
@@ -893,7 +911,7 @@
return resourceManager.getTimeoutSeconds();
}
- public boolean setXATimeout(int timeoutSeconds)
+ public boolean setXATimeout(final int timeoutSeconds)
{
return resourceManager.setTimeoutSeconds(timeoutSeconds);
}
@@ -968,7 +986,7 @@
filter = new FilterImpl(filterString);
}
- binding = postOffice.addBinding(address, queueName, filter, durable);
+ binding = postOffice.addBinding(address, queueName, filter, durable, temporary);
if (temporary)
{
@@ -1045,7 +1063,7 @@
QueueSettings qs = queueSettingsRepository.getMatch(queueName.toString());
- Integer queueWindowSize = (Integer)qs.getConsumerWindowSize();
+ Integer queueWindowSize = qs.getConsumerWindowSize();
windowSize = queueWindowSize != null ? queueWindowSize : windowSize;
@@ -1257,10 +1275,40 @@
return channel.replayCommands(lastReceivedCommandID);
}
+ public void handleManagementMessage(final SessionSendManagementMessage message) throws Exception
+ {
+ ServerMessage serverMessage = message.getServerMessage();
+ if (serverMessage.containsProperty(ManagementHelper.HDR_JMX_SUBSCRIBE_TO_NOTIFICATIONS))
+ {
+ boolean subscribe = (Boolean)serverMessage.getProperty(ManagementHelper.HDR_JMX_SUBSCRIBE_TO_NOTIFICATIONS);
+ final SimpleString replyTo = (SimpleString)serverMessage.getProperty(ManagementHelper.HDR_JMX_REPLYTO);
+ if (subscribe)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("added notification listener " + this);
+ }
+ managementService.addNotificationListener(this, null, replyTo);
+ }
+ else
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("removed notification listener " + this);
+ }
+ managementService.removeNotificationListener(this);
+ }
+ return;
+ }
+ managementService.handleMessage(message.getServerMessage());
+ serverMessage.setDestination((SimpleString)serverMessage.getProperty(ManagementHelper.HDR_JMX_REPLYTO));
+ send(serverMessage);
+ }
+
// FailureListener implementation
// --------------------------------------------------------------------
- public void connectionFailed(MessagingException me)
+ public void connectionFailed(final MessagingException me)
{
try
{
@@ -1284,8 +1332,28 @@
}
}
+ // NotificationListener implementation -------------------------------------
+
+ public void handleNotification(final Notification notification, final Object replyTo)
+ {
+ ServerMessage notificationMessage = new ServerMessageImpl(storageManager.generateID());
+ notificationMessage.setDestination((SimpleString)replyTo);
+ notificationMessage.setBody(new ByteBufferWrapper(ByteBuffer.allocate(2048)));
+ ManagementHelper.storeNotification(notificationMessage, notification);
+ try
+ {
+ send(notificationMessage);
+ }
+ catch (Exception e)
+ {
+ log.warn("problem while sending a notification message " + notification, e);
+
+ }
+ }
+
// Public
- // ---------------------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------
+ // -----------------
public Transaction getTransaction()
{
@@ -1298,7 +1366,8 @@
}
// Private
- // --------------------------------------------------------------------------------------------
+ //----------------------------------------------------------------------------
+ // ----------------
private void doAck(final MessageReference ref) throws Exception
{
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionPacketHandler.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -39,6 +39,7 @@
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_CREATEQUEUE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_DELETE_QUEUE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_FLOWTOKEN;
+import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_MANAGEMENT_SEND;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_PRODUCER_CLOSE;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_QUEUEQUERY;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_REMOVE_DESTINATION;
@@ -72,6 +73,7 @@
import org.jboss.messaging.core.remoting.ChannelHandler;
import org.jboss.messaging.core.remoting.Packet;
import org.jboss.messaging.core.remoting.impl.wireformat.MessagingExceptionMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionAcknowledgeMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionAddDestinationMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionBindingQueryMessage;
@@ -93,6 +95,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.SessionProducerCloseMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionQueueQueryMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionRemoveDestinationMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendManagementMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionSendMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXACommitMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAEndMessage;
@@ -463,6 +466,12 @@
session.handleReplicateDelivery(message.getConsumerID(), message.getMessageID());
break;
}
+ case SESS_MANAGEMENT_SEND:
+ {
+ SessionSendManagementMessage message = (SessionSendManagementMessage)packet;
+ session.handleManagementMessage(message);
+ break;
+ }
default:
{
response = new MessagingExceptionMessage(new MessagingException(MessagingException.UNSUPPORTED_PACKET,
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementServiceImpl.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementServiceImpl.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -24,13 +24,11 @@
import static javax.management.ObjectName.quote;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import javax.management.MBeanServer;
import javax.management.ObjectName;
+import org.jboss.messaging.core.management.ManagementService;
import org.jboss.messaging.core.management.impl.ManagementServiceImpl;
import org.jboss.messaging.core.messagecounter.MessageCounter;
import org.jboss.messaging.core.messagecounter.MessageCounterManager;
@@ -45,11 +43,10 @@
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
{
@@ -58,129 +55,118 @@
// Attributes ----------------------------------------------------
- public final MBeanServer mbeanServer;
- private final boolean jmxManagementEnabled;
- private final MessageCounterManager messageCounterManager;
- private Map<ObjectName, Object> registry;
+ private final ManagementService managementService;
// Static --------------------------------------------------------
public static ObjectName getJMSServerObjectName() throws Exception
{
- return ObjectName.getInstance(ManagementServiceImpl.DOMAIN
- + ":module=JMS,type=Server");
+ return ObjectName.getInstance(ManagementServiceImpl.DOMAIN + ":module=JMS,type=Server");
}
- public static ObjectName getJMSQueueObjectName(final String name)
- throws Exception
+ public static ObjectName getJMSQueueObjectName(final String name) throws Exception
{
- return ObjectName.getInstance(ManagementServiceImpl.DOMAIN
- + ":module=JMS,type=Queue,name=" + quote(name.toString()));
+ return ObjectName.getInstance(ManagementServiceImpl.DOMAIN + ":module=JMS,type=Queue,name=" +
+ quote(name.toString()));
}
- public static ObjectName getJMSTopicObjectName(final String name)
- throws Exception
+ public static ObjectName getJMSTopicObjectName(final String name) throws Exception
{
- return ObjectName.getInstance(ManagementServiceImpl.DOMAIN
- + ":module=JMS,type=Topic,name=" + quote(name.toString()));
+ return ObjectName.getInstance(ManagementServiceImpl.DOMAIN + ":module=JMS,type=Topic,name=" +
+ quote(name.toString()));
}
- public static ObjectName getConnectionFactoryObjectName(final String name)
- throws Exception
+ public static ObjectName getConnectionFactoryObjectName(final String name) throws Exception
{
- return ObjectName.getInstance(ManagementServiceImpl.DOMAIN
- + ":module=JMS,type=ConnectionFactory,name=" + quote(name));
+ return ObjectName.getInstance(ManagementServiceImpl.DOMAIN + ":module=JMS,type=ConnectionFactory,name=" +
+ quote(name));
}
// Constructors --------------------------------------------------
- public JMSManagementServiceImpl(final MBeanServer mbeanServer,
- final boolean jmxManagementEnabled, final MessageCounterManager messageCounterManager)
+ public JMSManagementServiceImpl(final ManagementService managementService)
{
- this.mbeanServer = mbeanServer;
- this.jmxManagementEnabled = jmxManagementEnabled;
- this.registry = new HashMap<ObjectName, Object>();
- this.messageCounterManager = messageCounterManager;
+ this.managementService = managementService;
}
// Public --------------------------------------------------------
// JMSManagementRegistration implementation ----------------------
- public void registerJMSServer(final JMSServerManager server)
- throws Exception
+ public void registerJMSServer(final JMSServerManager server) throws Exception
{
ObjectName objectName = getJMSServerObjectName();
JMSServerControl control = new JMSServerControl(server);
- register(objectName, control);
- registerInJMX(objectName, control);
+ managementService.registerResource(objectName, control);
}
public void unregisterJMSServer() throws Exception
{
ObjectName objectName = getJMSServerObjectName();
- unregister(objectName);
- unregisterFromJMX(objectName);
+ managementService.unregisterResource(objectName);
}
- public void registerQueue(final JBossQueue queue, final Queue coreQueue,
- final String jndiBinding, final PostOffice postOffice,
- final StorageManager storageManager,
- HierarchicalRepository<QueueSettings> queueSettingsRepository)
- throws Exception
+ public void registerQueue(final JBossQueue queue,
+ final Queue coreQueue,
+ final String jndiBinding,
+ final PostOffice postOffice,
+ final StorageManager storageManager,
+ HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
{
- MessageCounter counter = new MessageCounter(queue.getName(), null, coreQueue, false, coreQueue.isDurable(),
- messageCounterManager.getMaxDayCount());
+ MessageCounterManager messageCounterManager = managementService.getMessageCounterManager();
+ MessageCounter counter = new MessageCounter(queue.getName(),
+ null,
+ coreQueue,
+ false,
+ coreQueue.isDurable(),
+ messageCounterManager.getMaxDayCount());
messageCounterManager.registerMessageCounter(queue.getName(), counter);
ObjectName objectName = getJMSQueueObjectName(queue.getQueueName());
- JMSQueueControl control = new JMSQueueControl(queue, coreQueue,
- jndiBinding, postOffice, storageManager, queueSettingsRepository, counter);
- register(objectName, control);
- registerInJMX(objectName, control);
+ JMSQueueControl control = new JMSQueueControl(queue,
+ coreQueue,
+ jndiBinding,
+ postOffice,
+ storageManager,
+ queueSettingsRepository,
+ counter);
+ managementService.registerResource(objectName, control);
}
public void unregisterQueue(final String name) throws Exception
{
ObjectName objectName = getJMSQueueObjectName(name);
- unregister(objectName);
- unregisterFromJMX(objectName);
+ managementService.unregisterResource(objectName);
}
- public void registerTopic(final JBossTopic topic, final String jndiBinding,
- final PostOffice postOffice, final StorageManager storageManager)
- throws Exception
+ public void registerTopic(final JBossTopic topic,
+ final String jndiBinding,
+ final PostOffice postOffice,
+ final StorageManager storageManager) throws Exception
{
ObjectName objectName = getJMSTopicObjectName(topic.getTopicName());
- TopicControl control = new TopicControl(topic, jndiBinding, postOffice,
- storageManager);
- register(objectName, control);
- registerInJMX(objectName, control);
+ TopicControl control = new TopicControl(topic, jndiBinding, postOffice, storageManager);
+ managementService.registerResource(objectName, control);
}
public void unregisterTopic(final String name) throws Exception
{
ObjectName objectName = getJMSTopicObjectName(name);
- unregister(objectName);
- unregisterFromJMX(objectName);
+ managementService.unregisterResource(objectName);
}
public void registerConnectionFactory(final String name,
- final JBossConnectionFactory connectionFactory,
- final List<String> bindings) throws Exception
+ final JBossConnectionFactory connectionFactory,
+ final List<String> bindings) throws Exception
{
ObjectName objectName = getConnectionFactoryObjectName(name);
- ConnectionFactoryControl control = new ConnectionFactoryControl(
- connectionFactory, name,
- bindings);
- register(objectName, control);
- registerInJMX(objectName, control);
+ ConnectionFactoryControl control = new ConnectionFactoryControl(connectionFactory, name, bindings);
+ managementService.registerResource(objectName, control);
}
public void unregisterConnectionFactory(final String name) throws Exception
{
ObjectName objectName = getConnectionFactoryObjectName(name);
- unregister(objectName);
- unregisterFromJMX(objectName);
+ managementService.unregisterResource(objectName);
}
// Package protected ---------------------------------------------
@@ -189,39 +175,5 @@
// Private -------------------------------------------------------
- private void register(ObjectName objectName, Object managedResource)
- {
- unregister(objectName);
- registry.put(objectName, managedResource);
- }
-
- private void unregister(ObjectName objectName)
- {
- registry.remove(objectName);
- }
-
- private void registerInJMX(ObjectName objectName, Object managedResource)
- throws Exception
- {
- if (!jmxManagementEnabled)
- {
- return;
- }
- unregisterFromJMX(objectName);
- mbeanServer.registerMBean(managedResource, objectName);
- }
-
- private void unregisterFromJMX(ObjectName objectName) throws Exception
- {
- if (!jmxManagementEnabled)
- {
- return;
- }
- if (mbeanServer.isRegistered(objectName))
- {
- mbeanServer.unregisterMBean(objectName);
- }
- }
-
// Inner classes -------------------------------------------------
}
Modified: trunk/src/main/org/jboss/messaging/util/SimpleString.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/SimpleString.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/src/main/org/jboss/messaging/util/SimpleString.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -40,7 +40,7 @@
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
*
*/
-public class SimpleString implements CharSequence, Serializable
+public class SimpleString implements CharSequence, Serializable, Comparable<SimpleString>
{
private static final long serialVersionUID = 4204223851422244307L;
@@ -126,6 +126,13 @@
}
}
+ // Comparable implementation -------------------------------------
+
+ public int compareTo(SimpleString o)
+ {
+ return toString().compareTo(o.toString());
+ }
+
// Public
// ---------------------------------------------------------------------------
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-09-19 14:32:00 UTC (rev 4992)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -45,7 +45,6 @@
import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.postoffice.Binding;
-import org.jboss.messaging.core.remoting.impl.netty.NettyConnectorFactory;
import org.jboss.messaging.core.security.Role;
import org.jboss.messaging.core.server.MessagingServer;
import org.jboss.messaging.core.settings.impl.QueueSettings;
@@ -644,9 +643,14 @@
public Integer getMessageCountForQueue(String queueName) throws Exception
{
ObjectName objectName = JMSManagementServiceImpl.getJMSQueueObjectName(queueName);
- JMSQueueControlMBean queue = (JMSQueueControlMBean) MBeanServerInvocationHandler.newProxyInstance(
- ManagementFactory.getPlatformMBeanServer(), objectName, JMSQueueControlMBean.class, false);
- return queue.getMessageCount();
+ JMSQueueControlMBean queue = (JMSQueueControlMBean)getMessagingServer().getManagementService().getResource(objectName);
+ if (queue != null)
+ {
+ return queue.getMessageCount();
+ } else
+ {
+ return -1;
+ }
}
public void removeAllMessages(JBossDestination destination) throws Exception
Modified: trunk/tests/src/org/jboss/messaging/tests/concurrent/server/impl/QueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/concurrent/server/impl/QueueTest.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/tests/src/org/jboss/messaging/tests/concurrent/server/impl/QueueTest.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -57,7 +57,7 @@
*/
public void testConcurrentAddsDeliver() throws Exception
{
- Queue queue = queueFactory.createQueue(1, new SimpleString("queue1"), null, false);
+ Queue queue = queueFactory.createQueue(1, new SimpleString("queue1"), null, false, false);
FakeConsumer consumer = new FakeConsumer();
Added: trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/ManagementServiceImplTest.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -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.tests.integration.management;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.jboss.messaging.core.security.CheckType.CREATE;
+import static org.jboss.messaging.core.security.CheckType.READ;
+import static org.jboss.messaging.core.security.CheckType.WRITE;
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.lang.management.ManagementFactory;
+import java.nio.ByteBuffer;
+
+import javax.management.ObjectName;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.client.management.impl.ManagementHelper;
+import org.jboss.messaging.core.management.AddressControlMBean;
+import org.jboss.messaging.core.management.ManagementService;
+import org.jboss.messaging.core.management.impl.ManagementServiceImpl;
+import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.core.security.Role;
+import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.core.server.impl.ServerMessageImpl;
+import org.jboss.messaging.tests.util.RandomUtil;
+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 testHandleManagementMessageWithAttribute() throws Exception
+ {
+ ManagementService managementService = new ManagementServiceImpl(ManagementFactory.getPlatformMBeanServer(), true);
+ assertNotNull(managementService);
+
+ SimpleString replyTo = RandomUtil.randomSimpleString();
+ SimpleString address = RandomUtil.randomSimpleString();
+ managementService.registerAddress(address);
+
+ // invoke attribute and operation on the server
+ ServerMessage message = new ServerMessageImpl();
+ MessagingBuffer body = new ByteBufferWrapper(ByteBuffer.allocate(2048));
+ message.setBody(body);
+ ManagementHelper.putAttributes(message, replyTo, ManagementServiceImpl.getAddressObjectName(address), "Address");
+
+ managementService.handleMessage(message);
+
+ SimpleString value = (SimpleString)message.getProperty(new SimpleString("Address"));
+ assertNotNull(value);
+ assertEquals(address, value);
+
+ }
+
+ public void testHandleManagementMessageWithOperation() throws Exception
+ {
+ ManagementService managementService = new ManagementServiceImpl(ManagementFactory.getPlatformMBeanServer(), false);
+ assertNotNull(managementService);
+
+ Role role = new Role(randomString(), randomBoolean(), randomBoolean(), randomBoolean());
+
+ AddressControlMBean resource = createMock(AddressControlMBean.class);
+ resource.addRole(role.getName(), role.isCheckType(CREATE), role.isCheckType(READ), role.isCheckType(WRITE));
+ replay(resource);
+
+ SimpleString replyTo = RandomUtil.randomSimpleString();
+ SimpleString address = RandomUtil.randomSimpleString();
+ ObjectName on = ManagementServiceImpl.getAddressObjectName(address);
+ managementService.registerResource(on, resource);
+
+ // invoke attribute and operation on the server
+ ServerMessage message = new ServerMessageImpl();
+ MessagingBuffer body = new ByteBufferWrapper(ByteBuffer.allocate(2048));
+ message.setBody(body);
+ ManagementHelper.putOperationInvocation(message,
+ replyTo,
+ on,
+ "addRole",
+ role.getName(),
+ role.isCheckType(CREATE),
+ role.isCheckType(READ),
+ role.isCheckType(WRITE));
+
+ managementService.handleMessage(message);
+
+ boolean success = (Boolean)message.getProperty(ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED);
+ assertTrue(success);
+
+ verify(resource);
+ }
+
+ public void testHandleManagementMessageWithOperationWhichFails() throws Exception
+ {
+ ManagementService managementService = new ManagementServiceImpl(ManagementFactory.getPlatformMBeanServer(), false);
+ assertNotNull(managementService);
+
+ Role role = new Role(randomString(), randomBoolean(), randomBoolean(), randomBoolean());
+
+ String exceptionMessage = randomString();
+ AddressControlMBean resource = createMock(AddressControlMBean.class);
+ resource.addRole(role.getName(), role.isCheckType(CREATE), role.isCheckType(READ), role.isCheckType(WRITE));
+ expectLastCall().andThrow(new Exception(exceptionMessage));
+ replay(resource);
+
+ SimpleString replyTo = RandomUtil.randomSimpleString();
+ SimpleString address = RandomUtil.randomSimpleString();
+ ObjectName on = ManagementServiceImpl.getAddressObjectName(address);
+ managementService.registerResource(on, resource);
+
+ // invoke attribute and operation on the server
+ ServerMessage message = new ServerMessageImpl();
+ MessagingBuffer body = new ByteBufferWrapper(ByteBuffer.allocate(2048));
+ message.setBody(body);
+ ManagementHelper.putOperationInvocation(message,
+ replyTo,
+ on,
+ "addRole",
+ role.getName(),
+ role.isCheckType(CREATE),
+ role.isCheckType(READ),
+ role.isCheckType(WRITE));
+
+ managementService.handleMessage(message);
+
+ boolean success = (Boolean)message.getProperty(ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED);
+ assertFalse(success);
+ SimpleString exceptionMsg = (SimpleString)message.getProperty(ManagementHelper.HDR_JMX_OPERATION_EXCEPTION);
+ assertNotNull(exceptionMsg);
+ assertEquals(exceptionMessage, exceptionMsg.toString());
+
+ verify(resource);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Modified: trunk/tests/src/org/jboss/messaging/tests/performance/persistence/FakePostOffice.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/persistence/FakePostOffice.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/persistence/FakePostOffice.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -57,9 +57,9 @@
private volatile boolean started;
public Binding addBinding(SimpleString address, SimpleString queueName,
- Filter filter, boolean durable) throws Exception
+ Filter filter, boolean durable, boolean temporary) throws Exception
{
- Queue queue = queueFactory.createQueue(-1, queueName, filter, durable);
+ Queue queue = queueFactory.createQueue(-1, queueName, filter, durable, false);
Binding binding = new FakeBinding(address, queue);
bindings.put(address, binding);
return binding;
Modified: trunk/tests/src/org/jboss/messaging/tests/timing/core/server/impl/QueueImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/timing/core/server/impl/QueueImplTest.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/tests/src/org/jboss/messaging/tests/timing/core/server/impl/QueueImplTest.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -82,7 +82,7 @@
public void testScheduledNoConsumer() throws Exception
{
- Queue queue = new QueueImpl(1, new SimpleString("queue1"), null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, new SimpleString("queue1"), null, false, true, false, scheduledExecutor, null);
//Send one scheduled
@@ -148,7 +148,7 @@
private void testScheduled(boolean direct)
{
- Queue queue = new QueueImpl(1, new SimpleString("queue1"), null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, new SimpleString("queue1"), null, false, true, false, scheduledExecutor, null);
FakeConsumer consumer = null;
@@ -245,7 +245,7 @@
public void testDeleteAllReferences() throws Exception
{
- Queue queue = new QueueImpl(1, new SimpleString("queue1"), null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, new SimpleString("queue1"), null, false, true, false, scheduledExecutor, null);
StorageManager storageManager = EasyMock.createStrictMock(StorageManager.class);
@@ -336,7 +336,7 @@
public void testDeliveryScheduled() throws Exception
{
Consumer consumer = EasyMock.createStrictMock(Consumer.class);
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
MessageReference messageReference = generateReference(queue, 1);
final CountDownLatch countDownLatch = new CountDownLatch(1);
EasyMock.expect(consumer.handle(messageReference)).andAnswer(new IAnswer<HandleStatus>()
@@ -361,7 +361,7 @@
public void testDeliveryScheduledBusyConsumer() throws Exception
{
Consumer consumer = EasyMock.createStrictMock(Consumer.class);
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
MessageReference messageReference = generateReference(queue, 1);
final CountDownLatch countDownLatch = new CountDownLatch(1);
EasyMock.expect(consumer.handle(messageReference)).andAnswer(new IAnswer<HandleStatus>()
Added: trunk/tests/src/org/jboss/messaging/tests/unit/core/client/management/impl/ManagementHelperTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/client/management/impl/ManagementHelperTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/client/management/impl/ManagementHelperTest.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -0,0 +1,161 @@
+/*
+ * 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.client.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.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import javax.management.openmbean.TabularData;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.client.impl.ClientMessageImpl;
+import org.jboss.messaging.core.client.management.impl.ManagementHelper;
+import org.jboss.messaging.core.management.RoleInfo;
+import org.jboss.messaging.core.message.Message;
+import org.jboss.messaging.tests.util.RandomUtil;
+import org.jboss.messaging.util.SimpleString;
+
+/*
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ */
+public class ManagementHelperTest extends TestCase
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testHasOperationSucceeded() throws Exception
+ {
+ boolean result = randomBoolean();
+
+ Message msg = createMock(Message.class);
+ expect(msg.containsProperty(ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED)).andStubReturn(true);
+ expect(msg.getProperty(ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED)).andReturn(result);
+ replay(msg);
+
+ assertEquals(result, ManagementHelper.hasOperationSucceeded(msg));
+
+ verify(msg);
+ }
+
+ public void testHasOperationSucceededWithPropertyAbsent() throws Exception
+ {
+ Message msg = createMock(Message.class);
+ expect(msg.containsProperty(ManagementHelper.HDR_JMX_OPERATION_SUCCEEDED)).andReturn(false);
+
+ replay(msg);
+
+ assertFalse(ManagementHelper.hasOperationSucceeded(msg));
+
+ verify(msg);
+ }
+
+ public void testGetOperationExceptionMessage() throws Exception
+ {
+ SimpleString message = RandomUtil.randomSimpleString();
+
+ Message msg = createMock(Message.class);
+ expect(msg.containsProperty(ManagementHelper.HDR_JMX_OPERATION_EXCEPTION)).andReturn(true);
+ expect(msg.getProperty(ManagementHelper.HDR_JMX_OPERATION_EXCEPTION)).andReturn(message);
+
+ replay(msg);
+
+ assertEquals(message.toString(), ManagementHelper.getOperationExceptionMessage(msg));
+
+ verify(msg);
+ }
+
+ public void testGetOperationExceptionMessageWithNoMessage() throws Exception
+ {
+ Message msg = createMock(Message.class);
+ expect(msg.containsProperty(ManagementHelper.HDR_JMX_OPERATION_EXCEPTION)).andReturn(false);
+
+ replay(msg);
+
+ assertNull(ManagementHelper.getOperationExceptionMessage(msg));
+
+ verify(msg);
+ }
+
+ public void testGetTabularDataProperty() throws Exception
+ {
+ SimpleString key = randomSimpleString();
+ RoleInfo[] roles = new RoleInfo[] { new RoleInfo(randomString(),
+ randomBoolean(),
+ randomBoolean(),
+ randomBoolean()),
+ new RoleInfo(randomString(), randomBoolean(), randomBoolean(), randomBoolean()) };
+
+ TabularData tabularData = RoleInfo.toTabularData(roles);
+
+ Message msg = new ClientMessageImpl();
+ ManagementHelper.storeTypedProperty(msg, key, tabularData);
+
+ assertTrue(msg.containsProperty(key));
+ TabularData data = ManagementHelper.getTabularDataProperty(msg, key.toString());
+ assertNotNull(data);
+ assertEquals(2, data.size());
+ }
+
+ public void testGetTabularDataPropertyOnAnotherPropertyType() throws Exception
+ {
+ SimpleString key = randomSimpleString();
+ SimpleString value = randomSimpleString();
+
+ Message msg = createMock(Message.class);
+ expect(msg.getProperty(key)).andReturn(value);
+ replay(msg);
+
+ try
+ {
+ ManagementHelper.getTabularDataProperty(msg, key.toString());
+ fail("IllegalArgumentException");
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+
+ verify(msg);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Modified: trunk/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 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/ManagementServiceImplTest.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -159,6 +159,7 @@
expect(
mbeanServer.registerMBean(isA(AddressControlMBean.class),
eq(objectName))).andReturn(objectInstance);
+
replay(mbeanServer);
ManagementService service = new ManagementServiceImpl(mbeanServer, true);
Modified: trunk/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 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerControlTest.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -368,7 +368,7 @@
Binding newBinding = createMock(Binding.class);
expect(
postOffice.addBinding(new SimpleString(address), new SimpleString(
- name), null, true)).andReturn(newBinding);
+ name), null, true, false)).andReturn(newBinding);
replayMockedAttributes();
replay(newBinding);
@@ -385,13 +385,14 @@
String name = randomString();
String filter = "color = 'green'";
boolean durable = true;
+ boolean temporary = false;
expect(postOffice.getBinding(new SimpleString(address))).andReturn(null);
Binding newBinding = createMock(Binding.class);
expect(
postOffice.addBinding(eq(new SimpleString(address)),
eq(new SimpleString(name)), isA(Filter.class), eq(durable)
- )).andReturn(newBinding);
+ , eq(temporary))).andReturn(newBinding);
replayMockedAttributes();
replay(newBinding);
@@ -408,12 +409,13 @@
String name = randomString();
String filter = "";
boolean durable = true;
+ boolean temporary = false;
expect(postOffice.getBinding(new SimpleString(address))).andReturn(null);
Binding newBinding = createMock(Binding.class);
expect(
postOffice.addBinding(new SimpleString(address), new SimpleString(
- name), null, durable)).andReturn(newBinding);
+ name), null, durable, temporary)).andReturn(newBinding);
replay(newBinding);
replayMockedAttributes();
@@ -430,12 +432,13 @@
String name = randomString();
String filter = null;
boolean durable = true;
+ boolean temporary = false;
expect(postOffice.getBinding(new SimpleString(address))).andReturn(null);
Binding newBinding = createMock(Binding.class);
expect(
postOffice.addBinding(new SimpleString(address), new SimpleString(
- name), null, durable)).andReturn(newBinding);
+ name), null, durable, temporary)).andReturn(newBinding);
replay(newBinding);
replayMockedAttributes();
Modified: trunk/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 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/QueueControlTest.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -154,7 +154,7 @@
public void testIsTemporary() throws Exception
{
boolean temp = randomBoolean();
- expect(queue.isDurable()).andReturn(temp);
+ expect(queue.isTemporary()).andReturn(temp);
replayMockedAttributes();
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-09-19 14:32:00 UTC (rev 4992)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -702,12 +702,9 @@
Queue queue1 = EasyMock.createStrictMock(Queue.class);
Queue queue2 = EasyMock.createStrictMock(Queue.class);
Queue queue3 = EasyMock.createStrictMock(Queue.class);
- EasyMock.expect(qf.createQueue(EasyMock.eq(0L),
- EasyMock.eq(squeue1),
- EasyMock.isA(Filter.class),
- EasyMock.eq(true))).andReturn(queue1);
- EasyMock.expect(qf.createQueue(1L, squeue2, null, true)).andReturn(queue1);
- EasyMock.expect(qf.createQueue(2L, squeue3, null, true)).andReturn(queue1);
+ EasyMock.expect(qf.createQueue(EasyMock.eq(0L), EasyMock.eq(squeue1), EasyMock.isA(Filter.class), EasyMock.eq(true), EasyMock.eq(false))).andReturn(queue1);
+ EasyMock.expect(qf.createQueue(1L, squeue2, null, true, false)).andReturn(queue1);
+ EasyMock.expect(qf.createQueue(2L, squeue3, null, true, false)).andReturn(queue1);
EasyMock.replay(messageJournal, bindingsJournal, queue1, queue2, queue3, qf);
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-09-19 14:32:00 UTC (rev 4992)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -1,27 +1,32 @@
/*
- * 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.
+ * 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.tests.unit.core.postoffice.impl;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.easymock.EasyMock;
import org.easymock.IAnswer;
import org.jboss.messaging.core.exception.MessagingException;
@@ -44,35 +49,34 @@
import org.jboss.messaging.tests.util.UnitTestCase;
import org.jboss.messaging.util.SimpleString;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
+/*
* A PostOfficeTest
- *
+ *
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
* @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
*/
public class PostOfficeImplTest extends UnitTestCase
{
- private QueueFactory queueFactory = new FakeQueueFactory();
+ private final QueueFactory queueFactory = new FakeQueueFactory();
protected boolean wildCardRoutingEnabled = false;
+
public void testPostOfficeStart() throws Exception
{
StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
-
+
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, true, null, wildCardRoutingEnabled);
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.replay(pm, qf);
postOffice.start();
EasyMock.verify(pm, qf);
@@ -87,11 +91,13 @@
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, true, null, wildCardRoutingEnabled);
-
+
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.replay(pm, qf);
postOffice.start();
postOffice.stop();
@@ -118,14 +124,16 @@
EasyMock.expect(queue.getPersistenceID()).andStubReturn(1);
ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
-
+
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, true, null, wildCardRoutingEnabled);
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
+ 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(), (ResourceManager) EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.replay(pm, qf, binding, queue);
@@ -161,7 +169,6 @@
EasyMock.replay(bindings[i], queues[i]);
}
-
StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
@@ -171,9 +178,11 @@
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
+ 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(), (ResourceManager) EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.replay(pm, pgm, qf);
@@ -212,12 +221,12 @@
EasyMock.expect(queue.getPersistenceID()).andStubReturn(1);
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
-
+
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, true, null, wildCardRoutingEnabled);
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
EasyMock.expectLastCall().andAnswer(new LoadBindingsIAnswer(bindingArrayList, null));
EasyMock.replay(pm, pgm, qf, binding, binding2, queue);
@@ -258,7 +267,6 @@
EasyMock.replay(bindings[i], queues[i]);
}
-
StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
@@ -269,9 +277,11 @@
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
+ 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(), (ResourceManager) EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.replay(pm, pgm, qf);
@@ -304,7 +314,7 @@
EasyMock.expect(binding.getQueue()).andStubReturn(queue);
SimpleString queueName = new SimpleString("testQueueName1");
EasyMock.expect(queue.getName()).andStubReturn(queueName);
- queue.setFlowController((FlowController) EasyMock.anyObject());
+ queue.setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(queue.getPersistenceID()).andStubReturn(1);
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
@@ -315,10 +325,12 @@
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
+ 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);
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.replay(pm, qf, binding, queue, pgm, store);
@@ -338,11 +350,11 @@
StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
-
+
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
-
+
PagingStore pgstore = EasyMock.createNiceMock(PagingStore.class);
-
+
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, true, null, wildCardRoutingEnabled);
qf.setPostOffice(postOffice);
@@ -360,26 +372,27 @@
queues[i] = EasyMock.createStrictMock(Queue.class);
addresses[i] = new SimpleString("testAddress" + i);
queueNames[i] = new SimpleString("testQueueName" + i);
-
+
EasyMock.expect(pgm.getPageStore(addresses[i])).andReturn(pgstore);
-
+
EasyMock.expect(bindings[i].getAddress()).andStubReturn(addresses[i]);
EasyMock.expect(bindings[i].getQueue()).andStubReturn(queues[i]);
EasyMock.expect(queues[i].getName()).andStubReturn(queueNames[i]);
- queues[i].setFlowController((FlowController) EasyMock.anyObject());
+ queues[i].setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(queues[i].getPersistenceID()).andStubReturn(i + 1);
EasyMock.replay(bindings[i], queues[i]);
dests.add(addresses[i]);
}
-
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
EasyMock.expectLastCall().andAnswer(new LoadBindingsIAnswer(bindingArrayList, dests));
for (int i = 0; i < 100; i++)
{
EasyMock.expect(pm.addDestination(addresses[i])).andReturn(true);
}
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.replay(pm, qf, pgm, pgstore);
@@ -404,7 +417,6 @@
ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
PagingStore pgstore = EasyMock.createNiceMock(PagingStore.class);
-
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, true, null, wildCardRoutingEnabled);
@@ -427,20 +439,21 @@
EasyMock.expect(bindings[i].getAddress()).andStubReturn(addresses[i]);
EasyMock.expect(bindings[i].getQueue()).andStubReturn(queues[i]);
EasyMock.expect(queues[i].getName()).andStubReturn(queueNames[i]);
- queues[i].setFlowController((FlowController) EasyMock.anyObject());
+ queues[i].setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(queues[i].getPersistenceID()).andStubReturn(i + 1);
EasyMock.replay(bindings[i], queues[i]);
dests.add(addresses[i]);
}
-
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
EasyMock.expectLastCall().andAnswer(new LoadBindingsIAnswer(bindingArrayList, dests));
for (int i = 0; i < 100; i++)
{
EasyMock.expect(pm.addDestination(addresses[i])).andReturn(true);
}
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.replay(pm, qf, pgm, pgstore);
@@ -470,7 +483,6 @@
qf.setPostOffice(postOffice);
-
ArrayList<Binding> bindingArrayList = new ArrayList<Binding>();
List<SimpleString> dests = new ArrayList<SimpleString>();
Binding[] bindings = new Binding[100];
@@ -484,26 +496,27 @@
queues[i] = EasyMock.createStrictMock(Queue.class);
addresses[i] = new SimpleString("testAddress" + i);
queueNames[i] = new SimpleString("testQueueName" + i);
-
+
EasyMock.expect(pgm.getPageStore(addresses[i])).andReturn(pgstore);
-
+
EasyMock.expect(bindings[i].getAddress()).andStubReturn(addresses[i]);
EasyMock.expect(bindings[i].getQueue()).andStubReturn(queues[i]);
EasyMock.expect(queues[i].getName()).andStubReturn(queueNames[i]);
- queues[i].setFlowController((FlowController) EasyMock.anyObject());
+ queues[i].setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(queues[i].getPersistenceID()).andStubReturn(i + 1);
EasyMock.replay(bindings[i], queues[i]);
dests.add(addresses[i]);
}
-
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
EasyMock.expectLastCall().andAnswer(new LoadBindingsIAnswer(bindingArrayList, dests));
for (int i = 0; i < 100; i++)
{
EasyMock.expect(pm.addDestination(addresses[i])).andReturn(true);
}
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.replay(pm, qf, pgm, pgstore);
@@ -532,7 +545,6 @@
qf.setPostOffice(postOffice);
-
ArrayList<Binding> bindingArrayList = new ArrayList<Binding>();
List<SimpleString> dests = new ArrayList<SimpleString>();
Binding[] bindings = new Binding[100];
@@ -546,26 +558,27 @@
queues[i] = EasyMock.createStrictMock(Queue.class);
addresses[i] = new SimpleString("testAddress" + i);
queueNames[i] = new SimpleString("testQueueName" + i);
-
+
EasyMock.expect(pgm.getPageStore(addresses[i])).andReturn(pgstore);
-
+
EasyMock.expect(bindings[i].getAddress()).andStubReturn(addresses[i]);
EasyMock.expect(bindings[i].getQueue()).andStubReturn(queues[i]);
EasyMock.expect(queues[i].getName()).andStubReturn(queueNames[i]);
- queues[i].setFlowController((FlowController) EasyMock.anyObject());
+ queues[i].setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(queues[i].getPersistenceID()).andStubReturn(i + 1);
EasyMock.replay(bindings[i], queues[i]);
dests.add(addresses[i]);
}
-
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
EasyMock.expectLastCall().andAnswer(new LoadBindingsIAnswer(bindingArrayList, dests));
for (int i = 0; i < 100; i++)
{
EasyMock.expect(pm.addDestination(addresses[i])).andReturn(true);
}
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.replay(pm, qf, pgm, pgstore);
@@ -586,7 +599,7 @@
QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
-
+
PostOffice po = new PostOfficeImpl(pm, pgm, qf, ms, false, null, wildCardRoutingEnabled);
final long id = 324;
@@ -594,9 +607,9 @@
final Filter filter = EasyMock.createMock(Filter.class);
final boolean durable = true;
- Queue queue = queueFactory.createQueue(id, name, filter, durable);
+ Queue queue = queueFactory.createQueue(id, name, filter, durable, false);
- EasyMock.expect(qf.createQueue(-1, name, filter, durable)).andReturn(queue);
+ EasyMock.expect(qf.createQueue(-1, name, filter, durable, false)).andReturn(queue);
final SimpleString condition = new SimpleString("queue.wibble");
@@ -606,7 +619,7 @@
EasyMock.replay(qf, pm, filter);
- po.addBinding(condition, name, filter, durable);
+ po.addBinding(condition, name, filter, durable, false);
EasyMock.verify(qf, pm, filter);
@@ -614,9 +627,9 @@
final boolean durable2 = false;
- queue = queueFactory.createQueue(id, name, filter, durable2);
+ queue = queueFactory.createQueue(id, name, filter, durable2, false);
- EasyMock.expect(qf.createQueue(-1, name, filter, durable2)).andReturn(queue);
+ EasyMock.expect(qf.createQueue(-1, name, filter, durable2, false)).andReturn(queue);
EasyMock.replay(qf, pm, filter);
@@ -635,11 +648,11 @@
final SimpleString name = new SimpleString("wibb22");
final Filter filter = EasyMock.createMock(Filter.class);
final boolean durable = true;
-
- Queue queue = queueFactory.createQueue(id, name, filter, durable);
- EasyMock.expect(qf.createQueue(-1, name, filter, durable)).andReturn(queue);
+ Queue queue = queueFactory.createQueue(id, name, filter, durable, false);
+ EasyMock.expect(qf.createQueue(-1, name, filter, durable, false)).andReturn(queue);
+
final SimpleString condition = new SimpleString("queue.wibble");
Binding expected = new BindingImpl(condition, queue);
@@ -650,7 +663,7 @@
EasyMock.replay(qf, pm, filter);
- po.addBinding(condition, name, filter, durable);
+ po.addBinding(condition, name, filter, durable, false);
po.removeBinding(name);
@@ -660,13 +673,13 @@
final boolean durable2 = false;
- queue = queueFactory.createQueue(id, name, filter, durable2);
+ queue = queueFactory.createQueue(id, name, filter, durable2, false);
- EasyMock.expect(qf.createQueue(-1, name, filter, durable2)).andReturn(queue);
+ EasyMock.expect(qf.createQueue(-1, name, filter, durable2, false)).andReturn(queue);
EasyMock.replay(qf, pm, filter);
- po.addBinding(condition, name, filter, durable2);
+ po.addBinding(condition, name, filter, durable2, false);
po.removeBinding(name);
@@ -691,15 +704,15 @@
SimpleString squeue5 = new SimpleString("queue5");
SimpleString squeue6 = new SimpleString("queue6");
- po.addBinding(condition1, squeue1, null, false);
+ po.addBinding(condition1, squeue1, null, false, false);
Map<SimpleString, List<Binding>> mappings = po.getMappings();
assertEquals(1, mappings.size());
- po.addBinding(condition1, squeue2, null, false);
+ po.addBinding(condition1, squeue2, null, false, false);
mappings = po.getMappings();
assertEquals(1, mappings.size());
- po.addBinding(condition1, squeue3, null, false);
+ po.addBinding(condition1, squeue3, null, false, false);
mappings = po.getMappings();
assertEquals(1, mappings.size());
@@ -721,17 +734,17 @@
final SimpleString condition2 = new SimpleString("queue.wibble2");
- po.addBinding(condition2, squeue4, null, false);
+ po.addBinding(condition2, squeue4, null, false, false);
mappings = po.getMappings();
assertEquals(2, mappings.size());
- po.addBinding(condition2, squeue5, null, false);
+ po.addBinding(condition2, squeue5, null, false, false);
mappings = po.getMappings();
assertEquals(2, mappings.size());
final SimpleString condition3 = new SimpleString("topic.wibblexyz");
- po.addBinding(condition3, squeue6, null, false);
+ po.addBinding(condition3, squeue6, null, false, false);
mappings = po.getMappings();
assertEquals(3, mappings.size());
@@ -772,8 +785,10 @@
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.expect(pm.addDestination(address)).andReturn(true);
EasyMock.replay(pm, qf);
postOffice.start();
@@ -798,8 +813,10 @@
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.expect(pm.addDestination(address)).andReturn(true);
EasyMock.expect(pm.addDestination(address2)).andReturn(true);
EasyMock.expect(pm.addDestination(address3)).andReturn(true);
@@ -830,8 +847,10 @@
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.expect(pm.addDestination(address)).andReturn(true);
EasyMock.expect(pm.deleteDestination(address)).andReturn(true);
EasyMock.replay(pm, qf);
@@ -859,8 +878,10 @@
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.expect(pm.addDestination(address)).andReturn(true);
EasyMock.expect(pm.addDestination(address2)).andReturn(true);
EasyMock.expect(pm.addDestination(address3)).andReturn(true);
@@ -888,7 +909,6 @@
EasyMock.verify(pm, qf);
}
-
public void testAddDurableBinding() throws Exception
{
SimpleString queueName = new SimpleString("testQueueName");
@@ -903,17 +923,19 @@
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
- EasyMock.expect(qf.createQueue(-1, queueName, filter, true)).andReturn(queue);
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
+ EasyMock.expect(qf.createQueue(-1, queueName, filter, true, false)).andReturn(queue);
EasyMock.expect(queue.getName()).andStubReturn(queueName);
queue.setBackup(false);
- queue.setFlowController((FlowController) EasyMock.anyObject());
- pm.addBinding((Binding) EasyMock.anyObject());
+ queue.setFlowController((FlowController)EasyMock.anyObject());
+ pm.addBinding((Binding)EasyMock.anyObject());
EasyMock.replay(pm, qf, queue);
postOffice.start();
- postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, true);
+ postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, true, false);
assertNotNull(postOffice.getBinding(queueName));
EasyMock.verify(pm, qf, queue);
}
@@ -936,29 +958,31 @@
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
- EasyMock.expect(qf.createQueue(-1, queueName, filter, true)).andReturn(queue);
- EasyMock.expect(qf.createQueue(-1, queueName2, filter, true)).andReturn(queue2);
- EasyMock.expect(qf.createQueue(-1, queueName3, filter, true)).andReturn(queue3);
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
+ EasyMock.expect(qf.createQueue(-1, queueName, filter, true, false)).andReturn(queue);
+ EasyMock.expect(qf.createQueue(-1, queueName2, filter, true, false)).andReturn(queue2);
+ EasyMock.expect(qf.createQueue(-1, queueName3, filter, true, false)).andReturn(queue3);
EasyMock.expect(queue.getName()).andStubReturn(queueName);
queue.setBackup(false);
- queue.setFlowController((FlowController) EasyMock.anyObject());
+ queue.setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(queue2.getName()).andStubReturn(queueName2);
queue2.setBackup(false);
- queue2.setFlowController((FlowController) EasyMock.anyObject());
+ queue2.setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(queue3.getName()).andStubReturn(queueName3);
queue3.setBackup(false);
- queue3.setFlowController((FlowController) EasyMock.anyObject());
- pm.addBinding((Binding) EasyMock.anyObject());
- pm.addBinding((Binding) EasyMock.anyObject());
- pm.addBinding((Binding) EasyMock.anyObject());
+ queue3.setFlowController((FlowController)EasyMock.anyObject());
+ pm.addBinding((Binding)EasyMock.anyObject());
+ pm.addBinding((Binding)EasyMock.anyObject());
+ pm.addBinding((Binding)EasyMock.anyObject());
EasyMock.replay(pm, qf, queue, queue2, queue3);
postOffice.start();
- postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, true);
- postOffice.addBinding(new SimpleString("testAddress2"), queueName2, filter, true);
- postOffice.addBinding(new SimpleString("testAddress3"), queueName3, filter, true);
+ postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, true, false);
+ postOffice.addBinding(new SimpleString("testAddress2"), queueName2, filter, true, false);
+ postOffice.addBinding(new SimpleString("testAddress3"), queueName3, filter, true, false);
assertNotNull(postOffice.getBinding(queueName));
assertNotNull(postOffice.getBinding(queueName2));
assertNotNull(postOffice.getBinding(queueName3));
@@ -979,16 +1003,18 @@
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
- EasyMock.expect(qf.createQueue(-1, queueName, filter, false)).andReturn(queue);
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
+ EasyMock.expect(qf.createQueue(-1, queueName, filter, false, false)).andReturn(queue);
EasyMock.expect(queue.getName()).andStubReturn(queueName);
queue.setBackup(false);
- queue.setFlowController((FlowController) EasyMock.anyObject());
+ queue.setFlowController((FlowController)EasyMock.anyObject());
EasyMock.replay(pm, qf, queue);
postOffice.start();
- postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, false);
+ postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, false, false);
assertNotNull(postOffice.getBinding(queueName));
EasyMock.verify(pm, qf, queue);
}
@@ -1011,26 +1037,28 @@
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
- EasyMock.expect(qf.createQueue(-1, queueName, filter, false)).andReturn(queue);
- EasyMock.expect(qf.createQueue(-1, queueName2, filter, false)).andReturn(queue2);
- EasyMock.expect(qf.createQueue(-1, queueName3, filter, false)).andReturn(queue3);
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
+ EasyMock.expect(qf.createQueue(-1, queueName, filter, false, false)).andReturn(queue);
+ EasyMock.expect(qf.createQueue(-1, queueName2, filter, false, false)).andReturn(queue2);
+ EasyMock.expect(qf.createQueue(-1, queueName3, filter, false, false)).andReturn(queue3);
EasyMock.expect(queue.getName()).andStubReturn(queueName);
queue.setBackup(false);
- queue.setFlowController((FlowController) EasyMock.anyObject());
+ queue.setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(queue2.getName()).andStubReturn(queueName2);
queue2.setBackup(false);
- queue2.setFlowController((FlowController) EasyMock.anyObject());
+ queue2.setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(queue3.getName()).andStubReturn(queueName3);
queue3.setBackup(false);
- queue3.setFlowController((FlowController) EasyMock.anyObject());
+ queue3.setFlowController((FlowController)EasyMock.anyObject());
EasyMock.replay(pm, qf, queue, queue2, queue3);
postOffice.start();
- postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, false);
- postOffice.addBinding(new SimpleString("testAddress2"), queueName2, filter, false);
- postOffice.addBinding(new SimpleString("testAddress3"), queueName3, filter, false);
+ postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, false, false);
+ postOffice.addBinding(new SimpleString("testAddress2"), queueName2, filter, false, false);
+ postOffice.addBinding(new SimpleString("testAddress3"), queueName3, filter, false, false);
assertNotNull(postOffice.getBinding(queueName));
assertNotNull(postOffice.getBinding(queueName2));
assertNotNull(postOffice.getBinding(queueName3));
@@ -1051,27 +1079,29 @@
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
- EasyMock.expect(qf.createQueue(-1, queueName, filter, true)).andReturn(queue);
- EasyMock.expect(qf.createQueue(-1, queueName, filter, true)).andReturn(queue);
- EasyMock.expect(queue.getName()).andStubReturn(queueName);
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
+ EasyMock.expect(qf.createQueue(-1, queueName, filter, true, false)).andReturn(queue);
+ EasyMock.expect(qf.createQueue(-1, queueName, filter, true, false)).andReturn(queue);
+ EasyMock.expect(queue.getName()).andStubReturn(queueName);
queue.setBackup(false);
- queue.setFlowController((FlowController) EasyMock.anyObject());
- pm.addBinding((Binding) EasyMock.anyObject());
+ queue.setFlowController((FlowController)EasyMock.anyObject());
+ pm.addBinding((Binding)EasyMock.anyObject());
queue.setBackup(false);
EasyMock.replay(pm, qf, queue);
postOffice.start();
- postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, true);
+ postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, true, false);
try
{
- postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, true);
+ postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, true, false);
fail("should throw exception");
}
catch (IllegalStateException e)
{
- //pass
+ // pass
}
assertNotNull(postOffice.getBinding(queueName));
EasyMock.verify(pm, qf, queue);
@@ -1091,20 +1121,22 @@
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
- EasyMock.expect(qf.createQueue(-1, queueName, filter, true)).andReturn(queue);
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
+ EasyMock.expect(qf.createQueue(-1, queueName, filter, true, false)).andReturn(queue);
EasyMock.expect(queue.getName()).andStubReturn(queueName);
queue.setBackup(false);
- queue.setFlowController((FlowController) EasyMock.anyObject());
- pm.addBinding((Binding) EasyMock.anyObject());
+ queue.setFlowController((FlowController)EasyMock.anyObject());
+ pm.addBinding((Binding)EasyMock.anyObject());
EasyMock.expect(queue.isDurable()).andStubReturn(true);
- pm.deleteBinding((Binding) EasyMock.anyObject());
+ pm.deleteBinding((Binding)EasyMock.anyObject());
queue.setFlowController(null);
EasyMock.replay(pm, qf, queue);
postOffice.start();
- postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, true);
+ postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, true, false);
postOffice.removeBinding(queueName);
assertNull(postOffice.getBinding(queueName));
EasyMock.verify(pm, qf, queue);
@@ -1128,25 +1160,27 @@
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
- EasyMock.expect(qf.createQueue(-1, queueName, filter, true)).andReturn(queue);
- EasyMock.expect(qf.createQueue(-1, queueName2, filter, true)).andReturn(queue2);
- EasyMock.expect(qf.createQueue(-1, queueName3, filter, true)).andReturn(queue3);
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
+ EasyMock.expect(qf.createQueue(-1, queueName, filter, true, false)).andReturn(queue);
+ EasyMock.expect(qf.createQueue(-1, queueName2, filter, true, false)).andReturn(queue2);
+ EasyMock.expect(qf.createQueue(-1, queueName3, filter, true, false)).andReturn(queue3);
EasyMock.expect(queue.getName()).andStubReturn(queueName);
queue.setBackup(false);
- queue.setFlowController((FlowController) EasyMock.anyObject());
+ queue.setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(queue2.getName()).andStubReturn(queueName2);
queue2.setBackup(false);
- queue2.setFlowController((FlowController) EasyMock.anyObject());
+ queue2.setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(queue3.getName()).andStubReturn(queueName3);
queue3.setBackup(false);
- queue3.setFlowController((FlowController) EasyMock.anyObject());
- pm.addBinding((Binding) EasyMock.anyObject());
- pm.addBinding((Binding) EasyMock.anyObject());
- pm.addBinding((Binding) EasyMock.anyObject());
- pm.deleteBinding((Binding) EasyMock.anyObject());
- pm.deleteBinding((Binding) EasyMock.anyObject());
+ queue3.setFlowController((FlowController)EasyMock.anyObject());
+ pm.addBinding((Binding)EasyMock.anyObject());
+ pm.addBinding((Binding)EasyMock.anyObject());
+ pm.addBinding((Binding)EasyMock.anyObject());
+ pm.deleteBinding((Binding)EasyMock.anyObject());
+ pm.deleteBinding((Binding)EasyMock.anyObject());
EasyMock.expect(queue.isDurable()).andStubReturn(true);
queue.setFlowController(null);
EasyMock.expect(queue3.isDurable()).andStubReturn(true);
@@ -1154,9 +1188,9 @@
EasyMock.replay(pm, qf, queue, queue2, queue3);
postOffice.start();
- postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, true);
- postOffice.addBinding(new SimpleString("testAddress2"), queueName2, filter, true);
- postOffice.addBinding(new SimpleString("testAddress3"), queueName3, filter, true);
+ postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, true, false);
+ postOffice.addBinding(new SimpleString("testAddress2"), queueName2, filter, true, false);
+ postOffice.addBinding(new SimpleString("testAddress3"), queueName3, filter, true, false);
postOffice.removeBinding(queueName);
postOffice.removeBinding(queueName3);
assertNull(postOffice.getBinding(queueName));
@@ -1179,18 +1213,20 @@
qf.setPostOffice(postOffice);
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
- EasyMock.expect(qf.createQueue(-1, queueName, filter, false)).andReturn(queue);
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
+ EasyMock.expect(qf.createQueue(-1, queueName, filter, false, false)).andReturn(queue);
EasyMock.expect(queue.getName()).andStubReturn(queueName);
queue.setBackup(false);
- queue.setFlowController((FlowController) EasyMock.anyObject());
+ queue.setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(queue.isDurable()).andStubReturn(false);
queue.setFlowController(null);
EasyMock.replay(pm, qf, queue);
postOffice.start();
- postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, false);
+ postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, false, false);
postOffice.removeBinding(queueName);
assertNull(postOffice.getBinding(queueName));
EasyMock.verify(pm, qf, queue);
@@ -1211,23 +1247,25 @@
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, true, null, wildCardRoutingEnabled);
-
+
qf.setPostOffice(postOffice);
-
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
- EasyMock.expect(qf.createQueue(-1, queueName, filter, false)).andReturn(queue);
- EasyMock.expect(qf.createQueue(-1, queueName2, filter, false)).andReturn(queue2);
- EasyMock.expect(qf.createQueue(-1, queueName3, filter, false)).andReturn(queue3);
+
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
+ EasyMock.expect(qf.createQueue(-1, queueName, filter, false, false)).andReturn(queue);
+ EasyMock.expect(qf.createQueue(-1, queueName2, filter, false, false)).andReturn(queue2);
+ EasyMock.expect(qf.createQueue(-1, queueName3, filter, false, false)).andReturn(queue3);
EasyMock.expect(queue.getName()).andStubReturn(queueName);
queue.setBackup(false);
- queue.setFlowController((FlowController) EasyMock.anyObject());
+ queue.setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(queue2.getName()).andStubReturn(queueName2);
queue2.setBackup(false);
- queue2.setFlowController((FlowController) EasyMock.anyObject());
+ queue2.setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(queue3.getName()).andStubReturn(queueName3);
queue3.setBackup(false);
- queue3.setFlowController((FlowController) EasyMock.anyObject());
+ queue3.setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(queue.isDurable()).andStubReturn(false);
queue.setFlowController(null);
@@ -1236,9 +1274,9 @@
EasyMock.replay(pm, qf, queue, queue2, queue3);
postOffice.start();
- postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, false);
- postOffice.addBinding(new SimpleString("testAddress2"), queueName2, filter, false);
- postOffice.addBinding(new SimpleString("testAddress3"), queueName3, filter, false);
+ postOffice.addBinding(new SimpleString("testAddress"), queueName, filter, false, false);
+ postOffice.addBinding(new SimpleString("testAddress2"), queueName2, filter, false, false);
+ postOffice.addBinding(new SimpleString("testAddress3"), queueName3, filter, false, false);
postOffice.removeBinding(queueName);
postOffice.removeBinding(queueName3);
assertNull(postOffice.getBinding(queueName));
@@ -1257,11 +1295,13 @@
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, true, null, wildCardRoutingEnabled);
-
+
qf.setPostOffice(postOffice);
-
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.expect(queue.getName()).andStubReturn(queueName);
EasyMock.expect(queue.isDurable()).andStubReturn(false);
EasyMock.replay(pm, qf, queue);
@@ -1274,7 +1314,7 @@
}
catch (IllegalStateException e)
{
- //pass
+ // pass
}
assertNull(postOffice.getBinding(queueName));
EasyMock.verify(pm, qf, queue);
@@ -1289,11 +1329,13 @@
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, true, null, wildCardRoutingEnabled);
-
+
qf.setPostOffice(postOffice);
-
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.expect(message.getDestination()).andStubReturn(new SimpleString("testtDestination"));
EasyMock.replay(pm, qf, message);
postOffice.start();
@@ -1304,7 +1346,7 @@
}
catch (Exception e)
{
- MessagingException messagingException = (MessagingException) e;
+ MessagingException messagingException = (MessagingException)e;
assertEquals(MessagingException.ADDRESS_DOES_NOT_EXIST, messagingException.getCode());
}
EasyMock.verify(pm, qf, message);
@@ -1320,17 +1362,19 @@
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, false, null, wildCardRoutingEnabled);
-
+
qf.setPostOffice(postOffice);
-
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
EasyMock.expect(message.getDestination()).andStubReturn(new SimpleString("testtDestination"));
EasyMock.replay(pm, qf, message);
-
+
postOffice.start();
postOffice.route(message);
-
+
EasyMock.verify(pm, qf, message);
assertTrue(postOffice.isStarted());
}
@@ -1347,28 +1391,30 @@
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, false, null, wildCardRoutingEnabled);
-
+
qf.setPostOffice(postOffice);
-
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
SimpleString address = new SimpleString("testtDestination");
EasyMock.expect(message.getDestination()).andStubReturn(address);
- EasyMock.expect(qf.createQueue(-1, queueName, null, false)).andReturn(queue);
+ EasyMock.expect(qf.createQueue(-1, queueName, null, false, false)).andReturn(queue);
EasyMock.expect(queue.getName()).andStubReturn(queueName);
EasyMock.expect(queue.getFilter()).andStubReturn(null);
queue.setBackup(false);
- queue.setFlowController((FlowController) EasyMock.anyObject());
-
+ queue.setFlowController((FlowController)EasyMock.anyObject());
+
EasyMock.expect(message.createReference(queue)).andReturn(messageReference);
-
+
EasyMock.replay(pm, qf, message, queue, messageReference);
-
+
postOffice.start();
- postOffice.addBinding(address, queueName, null, false);
+ postOffice.addBinding(address, queueName, null, false, false);
List<MessageReference> references = postOffice.route(message);
-
+
EasyMock.verify(pm, qf, message, queue, messageReference);
assertTrue(postOffice.isStarted());
assertEquals(1, references.size());
@@ -1378,44 +1424,45 @@
public void testRouteAddressFull() throws Exception
{
SimpleString queueName = new SimpleString("testQueueName");
-
+
ServerMessage message = EasyMock.createStrictMock(ServerMessage.class);
-
+
Queue queue = EasyMock.createStrictMock(Queue.class);
StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-
+
ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
-
+
PagingManager pgm = EasyMock.createMock(PagingManager.class);
pgm.setPostOffice(EasyMock.isA(PostOffice.class));
pgm.start();
EasyMock.expect(pgm.addSize(EasyMock.isA(ServerMessage.class))).andReturn(-1l);
-
+
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, false, null, wildCardRoutingEnabled);
qf.setPostOffice(postOffice);
-
-
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
-
+
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
+
SimpleString address = new SimpleString("testtDestination");
EasyMock.expect(message.getDestination()).andStubReturn(address);
- EasyMock.expect(qf.createQueue(-1, queueName, null, false)).andReturn(queue);
+ EasyMock.expect(qf.createQueue(-1, queueName, null, false, false)).andReturn(queue);
EasyMock.expect(queue.getName()).andStubReturn(queueName);
EasyMock.expect(queue.getFilter()).andStubReturn(null);
queue.setBackup(false);
- queue.setFlowController((FlowController) EasyMock.anyObject());
-
+ queue.setFlowController((FlowController)EasyMock.anyObject());
+
EasyMock.replay(pm, pgm, qf, message, queue);
-
+
postOffice.start();
- postOffice.addBinding(address, queueName, null, false);
+ postOffice.addBinding(address, queueName, null, false, false);
List<MessageReference> references = postOffice.route(message);
-
+
EasyMock.verify(pm, pgm, qf, message, queue);
assertTrue(postOffice.isStarted());
assertEquals(0, references.size());
@@ -1434,23 +1481,25 @@
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, false, null, wildCardRoutingEnabled);
-
+
qf.setPostOffice(postOffice);
-
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
SimpleString address = new SimpleString("testtDestination");
EasyMock.expect(message.getDestination()).andStubReturn(address);
- EasyMock.expect(qf.createQueue(-1, queueName, filter, false)).andReturn(queue);
+ EasyMock.expect(qf.createQueue(-1, queueName, filter, false, false)).andReturn(queue);
EasyMock.expect(queue.getName()).andStubReturn(queueName);
- EasyMock.expect(queue.getFilter()).andStubReturn(filter);
+ EasyMock.expect(queue.getFilter()).andStubReturn(filter);
EasyMock.expect(filter.match(message)).andReturn(true);
queue.setBackup(false);
- queue.setFlowController((FlowController) EasyMock.anyObject());
+ queue.setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(message.createReference(queue)).andReturn(messageReference);
EasyMock.replay(pm, qf, message, queue, messageReference, filter);
postOffice.start();
- postOffice.addBinding(address, queueName, filter, false);
+ postOffice.addBinding(address, queueName, filter, false, false);
List<MessageReference> references = postOffice.route(message);
EasyMock.verify(pm, qf, message, queue, messageReference, filter);
assertTrue(postOffice.isStarted());
@@ -1471,22 +1520,24 @@
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, false, null, wildCardRoutingEnabled);
-
+
qf.setPostOffice(postOffice);
-
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
SimpleString address = new SimpleString("testtDestination");
EasyMock.expect(message.getDestination()).andStubReturn(address);
- EasyMock.expect(qf.createQueue(-1, queueName, filter, false)).andReturn(queue);
+ EasyMock.expect(qf.createQueue(-1, queueName, filter, false, false)).andReturn(queue);
EasyMock.expect(queue.getName()).andStubReturn(queueName);
EasyMock.expect(queue.getFilter()).andStubReturn(filter);
EasyMock.expect(filter.match(message)).andReturn(false);
queue.setBackup(false);
- queue.setFlowController((FlowController) EasyMock.anyObject());
+ queue.setFlowController((FlowController)EasyMock.anyObject());
EasyMock.replay(pm, qf, message, queue, messageReference, filter);
postOffice.start();
- postOffice.addBinding(address, queueName, filter, false);
+ postOffice.addBinding(address, queueName, filter, false, false);
List<MessageReference> references = postOffice.route(message);
EasyMock.verify(pm, qf, message, queue, messageReference, filter);
assertTrue(postOffice.isStarted());
@@ -1511,16 +1562,18 @@
PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, false, null, wildCardRoutingEnabled);
-
+
qf.setPostOffice(postOffice);
-
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
+
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
SimpleString address = new SimpleString("testtDestination");
EasyMock.expect(message.getDestination()).andStubReturn(address);
- EasyMock.expect(qf.createQueue(-1, queueName, null, false)).andReturn(queue);
- EasyMock.expect(qf.createQueue(-1, queueName2, null, false)).andReturn(queue2);
- EasyMock.expect(qf.createQueue(-1, queueName3, null, false)).andReturn(queue3);
+ EasyMock.expect(qf.createQueue(-1, queueName, null, false, false)).andReturn(queue);
+ EasyMock.expect(qf.createQueue(-1, queueName2, null, false, false)).andReturn(queue2);
+ EasyMock.expect(qf.createQueue(-1, queueName3, null, false, false)).andReturn(queue3);
EasyMock.expect(queue.getName()).andStubReturn(queueName);
EasyMock.expect(queue.getFilter()).andStubReturn(null);
EasyMock.expect(queue2.getName()).andStubReturn(queueName2);
@@ -1530,17 +1583,17 @@
queue.setBackup(false);
queue2.setBackup(false);
queue3.setBackup(false);
- queue.setFlowController((FlowController) EasyMock.anyObject());
- queue2.setFlowController((FlowController) EasyMock.anyObject());
- queue3.setFlowController((FlowController) EasyMock.anyObject());
+ queue.setFlowController((FlowController)EasyMock.anyObject());
+ queue2.setFlowController((FlowController)EasyMock.anyObject());
+ queue3.setFlowController((FlowController)EasyMock.anyObject());
EasyMock.expect(message.createReference(queue)).andReturn(messageReference);
EasyMock.expect(message.createReference(queue2)).andReturn(messageReference2);
EasyMock.expect(message.createReference(queue3)).andReturn(messageReference3);
EasyMock.replay(pm, qf, message, queue, queue2, queue3, messageReference);
postOffice.start();
- postOffice.addBinding(address, queueName, null, false);
- postOffice.addBinding(address, queueName2, null, false);
- postOffice.addBinding(address, queueName3, null, false);
+ postOffice.addBinding(address, queueName, null, false, false);
+ postOffice.addBinding(address, queueName2, null, false, false);
+ postOffice.addBinding(address, queueName3, null, false, false);
List<MessageReference> references = postOffice.route(message);
EasyMock.verify(pm, qf, message, queue, queue2, queue3, messageReference);
assertTrue(postOffice.isStarted());
@@ -1551,70 +1604,73 @@
}
public void testPostOfficeRouteToMultipleQueuesMixedFilters() throws Exception
- {
- SimpleString queueName = new SimpleString("testQueueName");
- SimpleString queueName2 = new SimpleString("testQueueName2");
- SimpleString queueName3 = new SimpleString("testQueueName3");
- Filter filter = EasyMock.createStrictMock(Filter.class);
- Filter filter2 = EasyMock.createStrictMock(Filter.class);
- ServerMessage message = EasyMock.createStrictMock(ServerMessage.class);
- MessageReference messageReference = EasyMock.createStrictMock(MessageReference.class);
- MessageReference messageReference2 = EasyMock.createStrictMock(MessageReference.class);
- MessageReference messageReference3 = EasyMock.createStrictMock(MessageReference.class);
- Queue queue = EasyMock.createStrictMock(Queue.class);
- Queue queue2 = EasyMock.createStrictMock(Queue.class);
- Queue queue3 = EasyMock.createStrictMock(Queue.class);
- StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
- QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
- ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
- PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
+ {
+ SimpleString queueName = new SimpleString("testQueueName");
+ SimpleString queueName2 = new SimpleString("testQueueName2");
+ SimpleString queueName3 = new SimpleString("testQueueName3");
+ Filter filter = EasyMock.createStrictMock(Filter.class);
+ Filter filter2 = EasyMock.createStrictMock(Filter.class);
+ ServerMessage message = EasyMock.createStrictMock(ServerMessage.class);
+ MessageReference messageReference = EasyMock.createStrictMock(MessageReference.class);
+ MessageReference messageReference2 = EasyMock.createStrictMock(MessageReference.class);
+ MessageReference messageReference3 = EasyMock.createStrictMock(MessageReference.class);
+ Queue queue = EasyMock.createStrictMock(Queue.class);
+ Queue queue2 = EasyMock.createStrictMock(Queue.class);
+ Queue queue3 = EasyMock.createStrictMock(Queue.class);
+ StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
+ QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+ ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
+ PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
- PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, false, null, wildCardRoutingEnabled);
-
- qf.setPostOffice(postOffice);
-
- pm.loadBindings(EasyMock.eq(qf), (List<Binding>) EasyMock.anyObject(), (List<SimpleString>) EasyMock.anyObject());
- pm.loadMessages(EasyMock.eq(postOffice), (Map<Long, Queue>) EasyMock.anyObject(), (ResourceManager) EasyMock.anyObject());
- SimpleString address = new SimpleString("testtDestination");
- EasyMock.expect(message.getDestination()).andStubReturn(address);
- EasyMock.expect(qf.createQueue(-1, queueName, null, false)).andReturn(queue);
- EasyMock.expect(qf.createQueue(-1, queueName2, null, false)).andReturn(queue2);
- EasyMock.expect(qf.createQueue(-1, queueName3, null, false)).andReturn(queue3);
- EasyMock.expect(queue.getName()).andStubReturn(queueName);
- EasyMock.expect(queue.getFilter()).andStubReturn(filter);
- EasyMock.expect(queue2.getName()).andStubReturn(queueName2);
- EasyMock.expect(queue2.getFilter()).andStubReturn(null);
- EasyMock.expect(queue3.getName()).andStubReturn(queueName3);
- EasyMock.expect(queue3.getFilter()).andStubReturn(filter2);
- EasyMock.expect(filter.match(message)).andReturn(false);
- EasyMock.expect(filter2.match(message)).andReturn(true);
- queue.setBackup(false);
- queue2.setBackup(false);
- queue3.setBackup(false);
- queue.setFlowController((FlowController) EasyMock.anyObject());
- queue2.setFlowController((FlowController) EasyMock.anyObject());
- queue3.setFlowController((FlowController) EasyMock.anyObject());
- EasyMock.expect(message.createReference(queue2)).andReturn(messageReference2);
- EasyMock.expect(message.createReference(queue3)).andReturn(messageReference3);
- EasyMock.replay(pm, qf, message, queue, queue2, queue3, messageReference, filter, filter2);
- postOffice.start();
- postOffice.addBinding(address, queueName, null, false);
- postOffice.addBinding(address, queueName2, null, false);
- postOffice.addBinding(address, queueName3, null, false);
- List<MessageReference> references = postOffice.route(message);
- EasyMock.verify(pm, qf, message, queue, queue2, queue3, messageReference, filter, filter2);
- assertTrue(postOffice.isStarted());
- assertEquals(2, references.size());
- assertEquals(messageReference2, references.get(0));
- assertEquals(messageReference3, references.get(1));
- }
+ PostOffice postOffice = new PostOfficeImpl(pm, pgm, qf, ms, false, null, wildCardRoutingEnabled);
+ qf.setPostOffice(postOffice);
+
+ pm.loadBindings(EasyMock.eq(qf), (List<Binding>)EasyMock.anyObject(), (List<SimpleString>)EasyMock.anyObject());
+ pm.loadMessages(EasyMock.eq(postOffice),
+ (Map<Long, Queue>)EasyMock.anyObject(),
+ (ResourceManager)EasyMock.anyObject());
+ SimpleString address = new SimpleString("testtDestination");
+ EasyMock.expect(message.getDestination()).andStubReturn(address);
+ EasyMock.expect(qf.createQueue(-1, queueName, null, false, false)).andReturn(queue);
+ EasyMock.expect(qf.createQueue(-1, queueName2, null, false, false)).andReturn(queue2);
+ EasyMock.expect(qf.createQueue(-1, queueName3, null, false, false)).andReturn(queue3);
+ EasyMock.expect(queue.getName()).andStubReturn(queueName);
+ EasyMock.expect(queue.getFilter()).andStubReturn(filter);
+ EasyMock.expect(queue2.getName()).andStubReturn(queueName2);
+ EasyMock.expect(queue2.getFilter()).andStubReturn(null);
+ EasyMock.expect(queue3.getName()).andStubReturn(queueName3);
+ EasyMock.expect(queue3.getFilter()).andStubReturn(filter2);
+ EasyMock.expect(filter.match(message)).andReturn(false);
+ EasyMock.expect(filter2.match(message)).andReturn(true);
+ queue.setBackup(false);
+ queue2.setBackup(false);
+ queue3.setBackup(false);
+ queue.setFlowController((FlowController)EasyMock.anyObject());
+ queue2.setFlowController((FlowController)EasyMock.anyObject());
+ queue3.setFlowController((FlowController)EasyMock.anyObject());
+ EasyMock.expect(message.createReference(queue2)).andReturn(messageReference2);
+ EasyMock.expect(message.createReference(queue3)).andReturn(messageReference3);
+ EasyMock.replay(pm, qf, message, queue, queue2, queue3, messageReference, filter, filter2);
+ postOffice.start();
+ postOffice.addBinding(address, queueName, null, false, false);
+ postOffice.addBinding(address, queueName2, null, false, false);
+ postOffice.addBinding(address, queueName3, null, false, false);
+ List<MessageReference> references = postOffice.route(message);
+ EasyMock.verify(pm, qf, message, queue, queue2, queue3, messageReference, filter, filter2);
+ assertTrue(postOffice.isStarted());
+ assertEquals(2, references.size());
+ assertEquals(messageReference2, references.get(0));
+ assertEquals(messageReference3, references.get(1));
+ }
+
class LoadBindingsIAnswer implements IAnswer
{
List<Binding> bindings;
+
List<SimpleString> dests;
- public LoadBindingsIAnswer(List<Binding> bindings, List<SimpleString> dests)
+ public LoadBindingsIAnswer(final List<Binding> bindings, final List<SimpleString> dests)
{
this.bindings = bindings;
this.dests = dests;
@@ -1622,14 +1678,14 @@
public Object answer() throws Throwable
{
- if (this.bindings != null)
+ if (bindings != null)
{
- List<Binding> bindings = (List<Binding>) EasyMock.getCurrentArguments()[1];
+ List<Binding> bindings = (List<Binding>)EasyMock.getCurrentArguments()[1];
bindings.addAll(this.bindings);
}
- if (this.dests != null)
+ if (dests != null)
{
- List<SimpleString> dests = (List<SimpleString>) EasyMock.getCurrentArguments()[2];
+ List<SimpleString> dests = (List<SimpleString>)EasyMock.getCurrentArguments()[2];
dests.addAll(this.dests);
}
return null;
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplWildcardManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplWildcardManagerTest.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplWildcardManagerTest.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -79,7 +79,7 @@
EasyMock.expect(message.getDestination()).andStubReturn(address);
EasyMock.expect(message2.getDestination()).andStubReturn(address2);
EasyMock.expect(message3.getDestination()).andStubReturn(address3);
- EasyMock.expect(qf.createQueue(-1, queueName, null, false)).andReturn(queue);
+ EasyMock.expect(qf.createQueue(-1, queueName, null, false, false)).andReturn(queue);
EasyMock.expect(queue.getName()).andStubReturn(queueName);
queue.setBackup(false);
queue.setFlowController(null);
@@ -100,7 +100,7 @@
assertTrue(postOffice.containsDestination(address));
assertTrue(postOffice.containsDestination(address2));
assertTrue(postOffice.containsDestination(address3));
- postOffice.addBinding(new SimpleString("test.*"), queueName, null, false);
+ postOffice.addBinding(new SimpleString("test.*"), queueName, null, false, false);
postOffice.route(message);
postOffice.route(message2);
postOffice.route(message3);
@@ -144,8 +144,8 @@
EasyMock.expect(message2.getDestination()).andStubReturn(address2);
EasyMock.expect(message3.getDestination()).andStubReturn(address3);
EasyMock.expect(message4.getDestination()).andStubReturn(address4);
- EasyMock.expect(qf.createQueue(-1, queueName, null, false)).andReturn(queue);
- EasyMock.expect(qf.createQueue(-1, queueName2, null, false)).andReturn(queue2);
+ EasyMock.expect(qf.createQueue(-1, queueName, null, false, false)).andReturn(queue);
+ EasyMock.expect(qf.createQueue(-1, queueName2, null, false, false)).andReturn(queue2);
EasyMock.expect(queue.getName()).andStubReturn(queueName);
EasyMock.expect(queue2.getName()).andStubReturn(queueName2);
queue.setBackup(false);
@@ -166,8 +166,8 @@
postOffice.addDestination(address2, true);
postOffice.addDestination(address3, true);
postOffice.addDestination(address4, true);
- postOffice.addBinding(new SimpleString("test.*"), queueName, null, false);
- postOffice.addBinding(new SimpleString("test2.*"), queueName2, null, false);
+ postOffice.addBinding(new SimpleString("test.*"), queueName, null, false, false);
+ postOffice.addBinding(new SimpleString("test2.*"), queueName2, null, false, false);
postOffice.route(message);
postOffice.route(message2);
postOffice.route(message3);
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-09-19 14:32:00 UTC (rev 4992)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessageReferenceImplTest.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -242,7 +242,7 @@
sm.updateDeliveryCount(messageReference);
EasyMock.expect(po.getBinding(dlqName)).andReturn(null);
- EasyMock.expect(po.addBinding(dlqName, dlqName, null, true)).andReturn(dlqBinding);
+ EasyMock.expect(po.addBinding(dlqName, dlqName, null, true, false)).andReturn(dlqBinding);
EasyMock.expect(serverMessage.copy()).andReturn(serverMessage);
@@ -402,7 +402,7 @@
EasyMock.expect(sm.generateID()).andReturn(2l);
EasyMock.expect(sm.generateTransactionID()).andReturn(1l);
EasyMock.expect(po.getBinding(expQName)).andReturn(null);
- EasyMock.expect(po.addBinding(expQName, expQName, null, true)).andReturn(expQBinding);
+ 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);
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueFactoryImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueFactoryImplTest.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueFactoryImplTest.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -51,7 +51,7 @@
EasyMock.replay(scheduledExecutor, queueSettingsRepository);
QueueFactoryImpl queueFactory = new QueueFactoryImpl(scheduledExecutor, queueSettingsRepository);
SimpleString qName = new SimpleString("testQ");
- Queue queue = queueFactory.createQueue(123, qName, filter, true);
+ Queue queue = queueFactory.createQueue(123, qName, filter, true, false);
EasyMock.verify(scheduledExecutor, queueSettingsRepository);
assertEquals(queue.getDistributionPolicy().getClass(), RoundRobinDistributionPolicy.class);
assertEquals(queue.isClustered(), true);
@@ -74,7 +74,7 @@
EasyMock.replay(scheduledExecutor, queueSettingsRepository);
QueueFactoryImpl queueFactory = new QueueFactoryImpl(scheduledExecutor, queueSettingsRepository);
SimpleString qName = new SimpleString("testQ2");
- Queue queue = queueFactory.createQueue(456, qName, null, false);
+ Queue queue = queueFactory.createQueue(456, qName, null, false, false);
EasyMock.verify(scheduledExecutor, queueSettingsRepository);
assertEquals(queue.getDistributionPolicy().getClass(), RoundRobinDistributionPolicy.class);
assertEquals(queue.isClustered(), false);
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-09-19 14:32:00 UTC (rev 4992)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -21,7 +21,7 @@
*/
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;
@@ -78,7 +78,7 @@
{
final long id = 123;
- Queue queue = new QueueImpl(id, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(id, queue1, null, false, true, false, scheduledExecutor, null);
assertEquals(id, queue.getPersistenceID());
@@ -93,29 +93,29 @@
{
final SimpleString name = new SimpleString("oobblle");
- Queue queue = new QueueImpl(1, name, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, name, null, false, true, false, scheduledExecutor, null);
assertEquals(name, queue.getName());
}
public void testClustered()
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
assertFalse(queue.isClustered());
- queue = new QueueImpl(1, queue1, null, true, true, scheduledExecutor, null);
+ queue = new QueueImpl(1, queue1, null, true, true, false, scheduledExecutor, null);
assertTrue(queue.isClustered());
}
public void testDurable()
{
- Queue queue = new QueueImpl(1, queue1, null, false, false, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, false, false, scheduledExecutor, null);
assertFalse(queue.isDurable());
- queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
assertTrue(queue.isDurable());
}
@@ -128,7 +128,7 @@
Consumer cons3 = new FakeConsumer();
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
assertEquals(0, queue.getConsumerCount());
@@ -169,7 +169,7 @@
public void testGetSetDistributionPolicy()
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
assertNotNull(queue.getDistributionPolicy());
@@ -184,14 +184,14 @@
public void testGetFilter()
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
assertNull(queue.getFilter());
Filter filter = createMock(Filter.class);
replay(filter);
- queue = new QueueImpl(1, queue1, filter, false, true, scheduledExecutor, null);
+ queue = new QueueImpl(1, queue1, filter, false, true, false, scheduledExecutor, null);
assertEquals(filter, queue.getFilter());
@@ -200,7 +200,7 @@
public void testSimpleAddLast()
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
final int numMessages = 10;
@@ -219,7 +219,7 @@
public void testSimpleDirectDelivery()
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
FakeConsumer consumer = new FakeConsumer();
@@ -247,7 +247,7 @@
public void testSimpleNonDirectDelivery()
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
final int numMessages = 10;
@@ -285,7 +285,7 @@
public void testBusyConsumer()
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
FakeConsumer consumer = new FakeConsumer();
@@ -329,7 +329,7 @@
public void testBusyConsumerThenAddMoreMessages()
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
FakeConsumer consumer = new FakeConsumer();
@@ -396,7 +396,7 @@
public void testAddFirstAddLast()
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
final int numMessages = 10;
@@ -451,7 +451,7 @@
public void testChangeConsumersAndDeliver() throws Exception
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
final int numMessages = 10;
@@ -605,7 +605,7 @@
public void testConsumerReturningNull()
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
class NullConsumer implements Consumer
{
@@ -633,7 +633,7 @@
public void testRoundRobinWithQueueing()
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
assertTrue(queue.getDistributionPolicy() instanceof RoundRobinDistributionPolicy);
@@ -678,7 +678,7 @@
public void testRoundRobinDirect()
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
assertTrue(queue.getDistributionPolicy() instanceof RoundRobinDistributionPolicy);
@@ -721,7 +721,7 @@
public void testDeleteAllReferences() throws Exception
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
StorageManager storageManager = EasyMock.createStrictMock(StorageManager.class);
@@ -805,7 +805,7 @@
public void testWithPriorities()
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
final int numMessages = 10;
@@ -872,7 +872,7 @@
public void testConsumerWithFilterAddAndRemove()
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
Filter filter = new FakeFilter("fruit", "orange");
@@ -881,7 +881,7 @@
public void testList()
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
final int numMessages = 20;
@@ -905,7 +905,7 @@
public void testListWithFilter()
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
final int numMessages = 20;
@@ -941,7 +941,7 @@
public void testConsumeWithFiltersAddAndRemoveConsumer() throws Exception
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
Filter filter = new FakeFilter("fruit", "orange");
@@ -1014,7 +1014,7 @@
private void testConsumerWithFilters(boolean direct) throws Exception
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
Filter filter = new FakeFilter("fruit", "orange");
@@ -1103,7 +1103,7 @@
public void testMessageOrder() throws Exception
{
Consumer consumer = EasyMock.createStrictMock(Consumer.class);
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1121,7 +1121,7 @@
public void testMessagesAdded() throws Exception
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1134,7 +1134,7 @@
public void testAddLastWhenLocked() throws Exception
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
MessageReference messageReference = generateReference(queue, 1);
queue.lock();
CountDownLatch countDownLatch = new CountDownLatch(1);
@@ -1150,7 +1150,7 @@
public void testAddLastWhenLockedMultiple() throws Exception
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1176,7 +1176,7 @@
public void testAddFirstWhenLocked() throws Exception
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
MessageReference messageReference = generateReference(queue, 1);
queue.lock();
CountDownLatch countDownLatch = new CountDownLatch(1);
@@ -1192,7 +1192,7 @@
public void testAddFirstWhenLockedMultiple() throws Exception
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1218,7 +1218,7 @@
public void testAddListFirst() throws Exception
{
Consumer consumer = EasyMock.createStrictMock(Consumer.class);
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1239,7 +1239,7 @@
public void testRemoveReferenceWithId() throws Exception
{
Consumer consumer = EasyMock.createStrictMock(Consumer.class);
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1260,7 +1260,7 @@
public void testGetReference() throws Exception
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1273,7 +1273,7 @@
public void testGetNonExistentReference() throws Exception
{
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1287,7 +1287,7 @@
public void testConsumerRemovedAfterException() throws Exception
{
Consumer consumer = EasyMock.createStrictMock(Consumer.class);
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1307,7 +1307,7 @@
public void testDeliveryAsync() throws Exception
{
Consumer consumer = EasyMock.createStrictMock(Consumer.class);
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
MessageReference messageReference = generateReference(queue, 1);
MessageReference messageReference2 = generateReference(queue, 2);
MessageReference messageReference3 = generateReference(queue, 3);
@@ -1336,7 +1336,7 @@
{
long messageID = randomLong();
final SimpleString expiryQueue = new SimpleString("expiryQueue");
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
MessageReference messageReference = generateReference(queue, messageID);
StorageManager storageManager = EasyMock.createMock(StorageManager.class);
EasyMock.expect(storageManager.generateTransactionID()).andReturn(randomLong());
@@ -1394,7 +1394,7 @@
{
long messageID = randomLong();
final SimpleString dlqName = new SimpleString("dlq");
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
MessageReference messageReference = generateReference(queue, messageID);
StorageManager storageManager = createMock(StorageManager.class);
expect(storageManager.generateTransactionID()).andReturn(randomLong());
@@ -1453,7 +1453,7 @@
long newMessageID = randomLong();
long tid = randomLong();
final SimpleString toQueueName = new SimpleString("toQueueName");
- Queue queue = new QueueImpl(1, queue1, null, false, true, scheduledExecutor, null);
+ Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
Queue toQueue = createMock(Queue.class);
MessageReference messageReference = generateReference(queue, messageID);
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/fakes/FakeQueueFactory.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/fakes/FakeQueueFactory.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/fakes/FakeQueueFactory.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -46,9 +46,9 @@
private PostOffice postOffice;
public Queue createQueue(long persistenceID, SimpleString name, Filter filter,
- boolean durable)
+ boolean durable, boolean temporary)
{
- return new QueueImpl(persistenceID, name, filter, false, durable, scheduledExecutor, postOffice);
+ return new QueueImpl(persistenceID, name, filter, false, durable, temporary, scheduledExecutor, postOffice);
}
public void setPostOffice(PostOffice postOffice)
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/TransactionImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/TransactionImplTest.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/TransactionImplTest.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -535,13 +535,13 @@
public void testAckCommit() throws Exception
{
//Durable queue
- Queue queue1 = new QueueImpl(12, new SimpleString("queue1"), null, false, true, scheduledExecutor, null);
+ Queue queue1 = new QueueImpl(12, new SimpleString("queue1"), null, false, true, false, scheduledExecutor, null);
//Durable queue
- Queue queue2 = new QueueImpl(34, new SimpleString("queue2"), null, false, true, scheduledExecutor, null);
+ Queue queue2 = new QueueImpl(34, new SimpleString("queue2"), null, false, true, false, scheduledExecutor, null);
//Non durable queue
- Queue queue3 = new QueueImpl(65, new SimpleString("queue3"), null, false, false, scheduledExecutor, null);
+ Queue queue3 = new QueueImpl(65, new SimpleString("queue3"), null, false, false, false, scheduledExecutor, null);
//Some refs to ack
Modified: 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/JMSManagementServiceImplTest.java 2008-09-19 14:32:00 UTC (rev 4992)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSManagementServiceImplTest.java 2008-09-19 14:48:13 UTC (rev 4993)
@@ -1,23 +1,22 @@
/*
- * 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.
+ * 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;
@@ -28,10 +27,12 @@
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.randomPositiveInt;
import static org.jboss.messaging.tests.util.RandomUtil.randomString;
import java.util.ArrayList;
import java.util.List;
+import java.util.Random;
import javax.management.MBeanServer;
import javax.management.ObjectInstance;
@@ -39,6 +40,8 @@
import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import org.jboss.messaging.core.management.ManagementService;
import org.jboss.messaging.core.messagecounter.MessageCounter;
import org.jboss.messaging.core.messagecounter.MessageCounterManager;
import org.jboss.messaging.core.persistence.StorageManager;
@@ -59,12 +62,12 @@
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;
+import org.jboss.messaging.tests.util.RandomUtil;
-/**
+/*
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
*
* @version <tt>$Revision$</tt>
- *
*/
public class JMSManagementServiceImplTest extends TestCase
{
@@ -80,63 +83,25 @@
public void testRegisterJMSServer() throws Exception
{
- ObjectName objectName = JMSManagementServiceImpl
- .getJMSServerObjectName();
- ObjectInstance objectInstance = new ObjectInstance(objectName,
- JMSServerManager.class.getName());
+ ObjectName objectName = JMSManagementServiceImpl.getJMSServerObjectName();
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);
- MessageCounterManager messageCounterManager = createMock(MessageCounterManager.class);
-
- replay(mbeanServer, server, messageCounterManager);
+ ManagementService managementService = createMock(ManagementService.class);
+ managementService.registerResource(eq(objectName), isA(JMSServerControlMBean.class));
+ replay(managementService, server);
- JMSManagementService service = new JMSManagementServiceImpl(mbeanServer,
- true, messageCounterManager);
+ JMSManagementService service = new JMSManagementServiceImpl(managementService);
service.registerJMSServer(server);
-
- verify(mbeanServer, server, messageCounterManager);
- }
- 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);
- MessageCounterManager messageCounterManager = createMock(MessageCounterManager.class);
-
- replay(mbeanServer, server, messageCounterManager);
-
- JMSManagementService service = new JMSManagementServiceImpl(mbeanServer,
- true, messageCounterManager);
- service.registerJMSServer(server);
-
- verify(mbeanServer, server, messageCounterManager);
+ verify(managementService, 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());
+ ObjectName objectName = JMSManagementServiceImpl.getJMSQueueObjectName(name);
JBossQueue queue = new JBossQueue(name);
Queue coreQueue = createMock(Queue.class);
@@ -145,117 +110,42 @@
StorageManager storageManager = createMock(StorageManager.class);
HierarchicalRepository<QueueSettings> queueSettingsRepository = createMock(HierarchicalRepository.class);
- MBeanServer mbeanServer = createMock(MBeanServer.class);
- expect(mbeanServer.isRegistered(objectName)).andReturn(false);
- expect(
- mbeanServer.registerMBean(isA(JMSQueueControlMBean.class),
- eq(objectName))).andReturn(objectInstance);
+ ManagementService managementService = createMock(ManagementService.class);
MessageCounterManager messageCounterManager = createMock(MessageCounterManager.class);
- expect(messageCounterManager.getMaxDayCount()).andReturn(10);
+ expect(managementService.getMessageCounterManager()).andReturn(messageCounterManager );
+ expect(messageCounterManager.getMaxDayCount()).andReturn(randomPositiveInt());
messageCounterManager.registerMessageCounter(eq(name), isA(MessageCounter.class));
+ managementService.registerResource(eq(objectName), isA(JMSQueueControlMBean.class));
- replay(mbeanServer, messageCounterManager, coreQueue, postOffice, storageManager, queueSettingsRepository);
+ replay(managementService, messageCounterManager, coreQueue, postOffice, storageManager, queueSettingsRepository);
- JMSManagementService service = new JMSManagementServiceImpl(mbeanServer,
- true, messageCounterManager);
+ JMSManagementService service = new JMSManagementServiceImpl(managementService);
service.registerQueue(queue, coreQueue, jndiBinding, postOffice, storageManager, queueSettingsRepository);
- verify(mbeanServer, messageCounterManager, coreQueue, postOffice, storageManager, queueSettingsRepository);
+ verify(managementService, messageCounterManager, coreQueue, postOffice, storageManager, queueSettingsRepository);
}
- 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);
- expect(coreQueue.isDurable()).andReturn(true);
- PostOffice postOffice = createMock(PostOffice.class);
- StorageManager storageManager = createMock(StorageManager.class);
- HierarchicalRepository<QueueSettings> queueSettingsRepository = createMock(HierarchicalRepository.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);
- MessageCounterManager messageCounterManager = createMock(MessageCounterManager.class);
- expect(messageCounterManager.getMaxDayCount()).andReturn(10);
- messageCounterManager.registerMessageCounter(eq(name), isA(MessageCounter.class));
- replay(mbeanServer, messageCounterManager, coreQueue, postOffice, storageManager, queueSettingsRepository);
-
- JMSManagementService service = new JMSManagementServiceImpl(mbeanServer,
- true, messageCounterManager);
- service.registerQueue(queue, coreQueue, jndiBinding, postOffice, storageManager, queueSettingsRepository);
-
- verify(mbeanServer, messageCounterManager, coreQueue, postOffice, storageManager, queueSettingsRepository);
- }
-
public void testRegisterTopic() throws Exception
{
String name = randomString();
String jndiBinding = randomString();
- ObjectName objectName = JMSManagementServiceImpl
- .getJMSTopicObjectName(name);
- ObjectInstance objectInstance = new ObjectInstance(objectName,
- TopicControl.class.getName());
+ ObjectName objectName = JMSManagementServiceImpl.getJMSTopicObjectName(name);
JBossTopic topic = new JBossTopic(name);
- PostOffice postOffice= createMock(PostOffice.class);
+ PostOffice postOffice = createMock(PostOffice.class);
StorageManager storageManager = createMock(StorageManager.class);
- MBeanServer mbeanServer = createMock(MBeanServer.class);
- expect(mbeanServer.isRegistered(objectName)).andReturn(false);
- expect(
- mbeanServer.registerMBean(isA(TopicControlMBean.class),
- eq(objectName))).andReturn(objectInstance);
- MessageCounterManager messageCounterManager = createMock(MessageCounterManager.class);
+ ManagementService managementService = createMock(ManagementService.class);
+ managementService.registerResource(eq(objectName), isA(TopicControlMBean.class));
- replay(mbeanServer, messageCounterManager, postOffice, storageManager);
+ replay(managementService, postOffice, storageManager);
- JMSManagementService service = new JMSManagementServiceImpl(mbeanServer,
- true, messageCounterManager);
+ JMSManagementService service = new JMSManagementServiceImpl(managementService);
service.registerTopic(topic, jndiBinding, postOffice, storageManager);
-
- verify(mbeanServer, postOffice, storageManager);
+
+ verify(managementService, postOffice, storageManager);
}
- 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);
- PostOffice postOffice= createMock(PostOffice.class);
- StorageManager storageManager = createMock(StorageManager.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);
- MessageCounterManager messageCounterManager = createMock(MessageCounterManager.class);
-
- replay(mbeanServer, messageCounterManager, postOffice, storageManager);
-
- JMSManagementService service = new JMSManagementServiceImpl(mbeanServer,
- true, messageCounterManager);
- service.registerTopic(topic, jndiBinding, postOffice, storageManager);
-
- verify(mbeanServer, messageCounterManager, postOffice, storageManager);
- }
-
public void testRegisterConnectionFactory() throws Exception
{
String name = randomString();
@@ -263,57 +153,20 @@
List<String> bindings = new ArrayList<String>();
bindings.add(jndiBinding);
- ObjectName objectName = JMSManagementServiceImpl
- .getConnectionFactoryObjectName(name);
- ObjectInstance objectInstance = new ObjectInstance(objectName,
- ConnectionFactoryControl.class.getName());
+ ObjectName objectName = JMSManagementServiceImpl.getConnectionFactoryObjectName(name);
- JBossConnectionFactory connectionFactory = createMock(JBossConnectionFactory.class);
- MBeanServer mbeanServer = createMock(MBeanServer.class);
- expect(mbeanServer.isRegistered(objectName)).andReturn(false);
- expect(
- mbeanServer.registerMBean(isA(ConnectionFactoryControlMBean.class),
- eq(objectName))).andReturn(objectInstance);
- MessageCounterManager messageCounterManager = createMock(MessageCounterManager.class);
+ JBossConnectionFactory connectionFactory = createMock(JBossConnectionFactory.class);
+ ManagementService managementService = createMock(ManagementService.class);
+ managementService.registerResource(eq(objectName), isA(ConnectionFactoryControlMBean.class));
- replay(mbeanServer, messageCounterManager, connectionFactory);
+ replay(managementService, connectionFactory);
- JMSManagementService service = new JMSManagementServiceImpl(mbeanServer,
- true, messageCounterManager);
+ JMSManagementService service = new JMSManagementServiceImpl(managementService);
service.registerConnectionFactory(name, connectionFactory, bindings);
- verify(mbeanServer, messageCounterManager, connectionFactory);
+ verify(managementService, connectionFactory);
}
- 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);
- MBeanServer mbeanServer = createMock(MBeanServer.class);
- expect(mbeanServer.isRegistered(objectName)).andReturn(true);
- mbeanServer.unregisterMBean(objectName);
- expect(
- mbeanServer.registerMBean(isA(ConnectionFactoryControlMBean.class),
- eq(objectName))).andReturn(objectInstance);
- MessageCounterManager messageCounterManager = createMock(MessageCounterManager.class);
-
- replay(mbeanServer, messageCounterManager, connectionFactory);
-
- JMSManagementService service = new JMSManagementServiceImpl(mbeanServer,
- true, messageCounterManager);
- service.registerConnectionFactory(name, connectionFactory, bindings);
-
- verify(mbeanServer, messageCounterManager, connectionFactory);
- }
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
More information about the jboss-cvs-commits
mailing list