[jboss-cvs] JBoss Messaging SVN: r3717 - in trunk: src/main/org/jboss/jms and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 13 11:03:16 EST 2008
Author: ataylor
Date: 2008-02-13 11:03:16 -0500 (Wed, 13 Feb 2008)
New Revision: 3717
Added:
trunk/src/main/org/jboss/jms/server/JMSServerManager.java
trunk/src/main/org/jboss/jms/server/JMSServerManagerImpl.java
Removed:
trunk/src/main/org/jboss/jms/jndi/
Modified:
trunk/src/etc/server/default/deploy/jbm-beans.xml
trunk/src/main/org/jboss/messaging/core/MessagingServer.java
trunk/src/main/org/jboss/messaging/core/MessagingServerManagement.java
trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java
trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerManagementImpl.java
trunk/tests/src/org/jboss/test/messaging/JBMServerTestCase.java
trunk/tests/src/org/jboss/test/messaging/jms/AcknowledgementTest.java
trunk/tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java
trunk/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java
trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java
trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java
Log:
refactoring of management interfaces first draft
Modified: trunk/src/etc/server/default/deploy/jbm-beans.xml
===================================================================
--- trunk/src/etc/server/default/deploy/jbm-beans.xml 2008-02-13 15:48:04 UTC (rev 3716)
+++ trunk/src/etc/server/default/deploy/jbm-beans.xml 2008-02-13 16:03:16 UTC (rev 3717)
@@ -67,9 +67,9 @@
</constructor>
</bean>
- <bean name="JNDIObjectDeployer" class="org.jboss.jms.jndi.JNDIObjectDeployer">
- <property name="messagingServer">
- <inject bean="MessagingServer"/>
+ <bean name="JMSServerManager" class="org.jboss.jms.server.JMSServerManagerImpl">
+ <property name="messagingServerManagement">
+ <inject bean="MessagingServerManagement"/>
</property>
</bean>
Added: trunk/src/main/org/jboss/jms/server/JMSServerManager.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/JMSServerManager.java (rev 0)
+++ trunk/src/main/org/jboss/jms/server/JMSServerManager.java 2008-02-13 16:03:16 UTC (rev 3717)
@@ -0,0 +1,55 @@
+package org.jboss.jms.server;
+
+import org.jboss.jms.destination.JBossQueue;
+import org.jboss.jms.destination.JBossTopic;
+import org.jboss.messaging.core.impl.server.SubscriptionInfo;
+
+import java.util.List;
+
+/**
+ * A JMS Management interface.
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public interface JMSServerManager
+{
+ // management operations
+ boolean isStarted();
+
+ boolean createQueue(String queueName, String jndiBinding) throws Exception;
+
+ boolean createTopic(String topicName, String jndiBinding) throws Exception;
+
+ boolean destroyQueue(String name) throws Exception;
+
+ boolean destroyTopic(String name) throws Exception;
+
+ boolean createConnectionFactory(String name, String clientID, int dupsOKBatchSize, boolean strictTck, int prefetchSize, String jndiBinding) throws Exception;
+
+ boolean createConnectionFactory(String name, String clientID, int dupsOKBatchSize, boolean strictTck, int prefetchSize, List<String> jndiBindings) throws Exception;
+
+ boolean destroyConnectionFactory(String name) throws Exception;
+
+ public void removeAllMessagesForQueue(String queueName) throws Exception;
+
+ public void removeAllMessagesForTopic(String topicName) throws Exception;
+
+ public void removeAllMessagesForQueue(JBossQueue queueName) throws Exception;
+
+ public void removeAllMessagesForTopic(JBossTopic topicName) throws Exception;
+
+ int getMessageCountForQueue(String queue) throws Exception;
+
+ int getMessageCountForQueue(JBossQueue queue) throws Exception;
+
+ List<SubscriptionInfo> listAllSubscriptionsForTopic(String topicName) throws Exception;
+
+ List<SubscriptionInfo> listAllSubscriptionsForTopic(JBossTopic topicName) throws Exception;
+
+ List<SubscriptionInfo> listDurableSubscriptionsForTopic(String topicName) throws Exception;
+
+ List<SubscriptionInfo> listDurableSubscriptionsForTopic(JBossTopic topicName) throws Exception;
+
+ List<SubscriptionInfo> listNonDurableSubscriptionsForTopic(String topicName) throws Exception;
+
+ List<SubscriptionInfo> listNonDurableSubscriptionsForTopic(JBossTopic topicName) throws Exception;
+}
Copied: trunk/src/main/org/jboss/jms/server/JMSServerManagerImpl.java (from rev 3702, trunk/src/main/org/jboss/jms/jndi/JNDIObjectDeployer.java)
===================================================================
--- trunk/src/main/org/jboss/jms/server/JMSServerManagerImpl.java (rev 0)
+++ trunk/src/main/org/jboss/jms/server/JMSServerManagerImpl.java 2008-02-13 16:03:16 UTC (rev 3717)
@@ -0,0 +1,476 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * 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.jms.server;
+
+import org.jboss.jms.client.JBossConnectionFactory;
+import org.jboss.jms.client.api.ClientConnectionFactory;
+import org.jboss.jms.destination.JBossQueue;
+import org.jboss.jms.destination.JBossTopic;
+import org.jboss.logging.Logger;
+import org.jboss.messaging.core.MessagingServerManagement;
+import org.jboss.messaging.core.impl.server.SubscriptionInfo;
+import org.jboss.messaging.deployers.Deployer;
+import org.jboss.messaging.deployers.DeploymentManager;
+import org.jboss.messaging.util.JNDIUtil;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * A Deployer used to create and add to JNDI queues, topics and connection factories. Typically this would only be used
+ * in an app server env.
+ *
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class JMSServerManagerImpl extends Deployer implements JMSServerManager
+{
+ Logger log = Logger.getLogger(JMSServerManagerImpl.class);
+
+ /**
+ * the initial context to bind to
+ */
+ InitialContext initialContext;
+
+ HashMap<String, List<String>> destinations = new HashMap<String, List<String>>();
+ HashMap<String, JBossConnectionFactory> connectionFactories = new HashMap<String, JBossConnectionFactory>();
+
+ HashMap<String, List<String>> connectionFactoryBindings = new HashMap<String, List<String>>();
+
+
+ MessagingServerManagement messagingServerManagement;
+
+// UserManager userManager = new UserManager();
+
+ private static final String CLIENTID_ELEMENT = "client-id";
+ private static final String DUPS_OK_BATCH_SIZE_ELEMENT = "dups-ok-batch-size";
+ private static final String PREFETECH_SIZE_ELEMENT = "prefetch-size";
+ private static final String SUPPORTS_FAILOVER = "supports-failover";
+ private static final String SUPPORTS_LOAD_BALANCING = "supports-load-balancing";
+ private static final String LOAD_BALANCING_FACTORY = "load-balancing-factory";
+ private static final String STRICT_TCK = "strict-tck";
+ private static final String ENTRY_NODE_NAME = "entry";
+ private static final String CONNECTION_FACTORY_NODE_NAME = "connection-factory";
+ private static final String QUEUE_NODE_NAME = "queue";
+ private static final String TOPIC_NODE_NAME = "topic";
+
+ public void setMessagingServerManagement(MessagingServerManagement messagingServerManagement)
+ {
+ this.messagingServerManagement = messagingServerManagement;
+ }
+
+ /**
+ * lifecycle method
+ */
+ public void start()
+ {
+ try
+ {
+ initialContext = new InitialContext();
+ }
+ catch (NamingException e)
+ {
+ log.error("Unable to create Initial Context", e);
+ }
+ try
+ {
+ DeploymentManager.getInstance().registerDeployable(this);
+ }
+ catch (Exception e)
+ {
+ log.error(new StringBuilder("Unable to get Deployment Manager: ").append(e));
+ }
+ }
+
+ /**
+ * lifecycle method
+ */
+ public void stop() throws Exception
+ {
+ super.stop();
+ DeploymentManager.getInstance().unregisterDeployable(this);
+ }
+
+ /**
+ * the names of the elements to deploy
+ *
+ * @return the names of the elements todeploy
+ */
+ public String[] getElementTagName()
+ {
+ return new String[]{QUEUE_NODE_NAME, TOPIC_NODE_NAME, CONNECTION_FACTORY_NODE_NAME};
+ }
+
+ /**
+ * deploy an element
+ *
+ * @param node the element to deploy
+ * @throws Exception .
+ */
+ public void deploy(Node node) throws Exception
+ {
+ createAndBindObject(node);
+ }
+
+ private boolean bindToJndi(String jndiName, Object objectToBind)
+ throws NamingException
+ {
+ String parentContext;
+ String jndiNameInContext;
+ int sepIndex = jndiName.lastIndexOf('/');
+ if (sepIndex == -1)
+ {
+ parentContext = "";
+ }
+ else
+ {
+ parentContext = jndiName.substring(0, sepIndex);
+ }
+ jndiNameInContext = jndiName.substring(sepIndex + 1);
+ try
+ {
+ initialContext.lookup(jndiName);
+
+ log.warn("Binding for " + jndiName + " already exists");
+ return false;
+ }
+ catch (NameNotFoundException e)
+ {
+ // OK
+ }
+
+ Context c = JNDIUtil.createContext(initialContext, parentContext);
+
+ c.rebind(jndiNameInContext, objectToBind);
+ return true;
+ }
+
+ /**
+ * creates the object to bind, this will either be a JBossConnectionFActory, JBossQueue or JBossTopic
+ *
+ * @param node the config
+ * @throws Exception .
+ */
+ private void createAndBindObject(Node node) throws Exception
+ {
+ if (node.getNodeName().equals(CONNECTION_FACTORY_NODE_NAME))
+ {
+ // See http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4076040#4076040
+ NodeList attributes = node.getChildNodes();
+ boolean cfStrictTck = false;
+ int prefetchSize = 150;
+ String clientID = null;
+ int dupsOKBatchSize = 1000;
+ for (int j = 0; j < attributes.getLength(); j++)
+ {
+ if (STRICT_TCK.equalsIgnoreCase(attributes.item(j).getNodeName()))
+ {
+ cfStrictTck = Boolean.parseBoolean(attributes.item(j).getTextContent().trim());
+ }
+ else if (PREFETECH_SIZE_ELEMENT.equalsIgnoreCase(attributes.item(j).getNodeName()))
+ {
+ prefetchSize = Integer.parseInt(attributes.item(j).getTextContent().trim());
+ }
+ else if (CLIENTID_ELEMENT.equalsIgnoreCase(attributes.item(j).getNodeName()))
+ {
+ clientID = attributes.item(j).getTextContent();
+ }
+ else if (DUPS_OK_BATCH_SIZE_ELEMENT.equalsIgnoreCase(attributes.item(j).getNodeName()))
+ {
+ dupsOKBatchSize = Integer.parseInt(attributes.item(j).getTextContent().trim());
+ }
+ if (SUPPORTS_FAILOVER.equalsIgnoreCase(attributes.item(j).getNodeName()))
+ {
+ //setSupportsFailover(Boolean.parseBoolean(attributes.item(j).getTextContent().trim()));
+ }
+ if (SUPPORTS_LOAD_BALANCING.equalsIgnoreCase(attributes.item(j).getNodeName()))
+ {
+ //setSupportsLoadBalancing(Boolean.parseBoolean(attributes.item(j).getTextContent().trim()));
+ }
+ if (LOAD_BALANCING_FACTORY.equalsIgnoreCase(attributes.item(j).getNodeName()))
+ {
+ //setLoadBalancingFactory(attributes.item(j).getTextContent().trim());
+ }
+ }
+
+ NodeList children = node.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++)
+ {
+ Node child = children.item(i);
+
+ if (ENTRY_NODE_NAME.equalsIgnoreCase(children.item(i).getNodeName()))
+ {
+ String jndiName = child.getAttributes().getNamedItem("name").getNodeValue();
+ String name = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
+ createConnectionFactory(name, clientID, dupsOKBatchSize, cfStrictTck, prefetchSize, jndiName);
+ }
+ }
+ }
+ else if (node.getNodeName().equals(QUEUE_NODE_NAME))
+ {
+ String queueName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
+ NodeList children = node.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++)
+ {
+ Node child = children.item(i);
+
+ if (ENTRY_NODE_NAME.equalsIgnoreCase(children.item(i).getNodeName()))
+ {
+ String jndiName = child.getAttributes().getNamedItem("name").getNodeValue();
+ createQueue(queueName, jndiName);
+ }
+
+ }
+ }
+ else if (node.getNodeName().equals(TOPIC_NODE_NAME))
+ {
+ String topicName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
+ NodeList children = node.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++)
+ {
+ Node child = children.item(i);
+
+ if (ENTRY_NODE_NAME.equalsIgnoreCase(children.item(i).getNodeName()))
+ {
+ String jndiName = child.getAttributes().getNamedItem("name").getNodeValue();
+ createTopic(topicName, jndiName);
+ }
+ }
+ }
+ }
+
+ /**
+ * undeploys an element
+ *
+ * @param node the element to undeploy
+ * @throws Exception .
+ */
+ public void undeploy(Node node) throws Exception
+ {
+ System.out.println("JNDIObjectDeployer.undeploy");
+ }
+
+ /**
+ * The name of the configuration file name to look for for deployment
+ *
+ * @return The name of the config file
+ */
+ public String getConfigFileName()
+ {
+ return "jbm-jndi.xml";
+ }
+
+ // management operations
+
+
+ // management operations
+
+ public boolean isStarted()
+ {
+ return messagingServerManagement.isStarted();
+ }
+
+ public boolean createQueue(String queueName, String jndiBinding) throws Exception
+ {
+ JBossQueue jBossQueue = new JBossQueue(queueName);
+ messagingServerManagement.createQueue(jBossQueue.getAddress(), jBossQueue.getAddress());
+ boolean added = bindToJndi(jndiBinding, jBossQueue);
+ if (added)
+ {
+ addToDestinationBindings(queueName, jndiBinding);
+ }
+ return added;
+ }
+
+ public boolean createTopic(String topicName, String jndiBinding) throws Exception
+ {
+ JBossTopic jBossTopic = new JBossTopic(topicName);
+ messagingServerManagement.addAddress(jBossTopic.getAddress());
+ return bindToJndi(jndiBinding, jBossTopic);
+ }
+
+ public boolean destroyQueue(String name) throws Exception
+ {
+ messagingServerManagement.destroyQueue(name);
+ List<String> jndiBindings = destinations.get(name);
+ if (jndiBindings == null || jndiBindings.size() == 0)
+ {
+ return false;
+ }
+ for (String jndiBinding : jndiBindings)
+ {
+ initialContext.unbind(jndiBinding);
+ }
+ destinations.remove(name);
+ return true;
+ }
+
+ public boolean destroyTopic(String name) throws Exception
+ {
+ JBossTopic jBossTopic = new JBossTopic(name);
+ messagingServerManagement.removeAddress(jBossTopic.getAddress());
+ List<String> jndiBindings = destinations.get(name);
+ if (jndiBindings == null || jndiBindings.size() == 0)
+ {
+ return false;
+ }
+ for (String jndiBinding : jndiBindings)
+ {
+ initialContext.unbind(jndiBinding);
+ }
+ destinations.remove(name);
+ return true;
+ }
+
+ public boolean createConnectionFactory(String name, String clientID, int dupsOKBatchSize, boolean strictTck, int prefetchSize, String jndiBinding) throws Exception
+ {
+ JBossConnectionFactory cf = connectionFactories.get(name);
+ if (cf == null)
+ {
+ ClientConnectionFactory clientConnectionFactory = messagingServerManagement.createClientConnectionFactory(strictTck, prefetchSize);
+ log.debug(this + " created local connectionFactory " + clientConnectionFactory);
+ cf = new JBossConnectionFactory(clientConnectionFactory, clientID, dupsOKBatchSize);
+ }
+ if(!bindToJndi(jndiBinding, cf))
+ {
+ return false;
+ }
+ if(connectionFactoryBindings.get(name) == null)
+ {
+ connectionFactoryBindings.put(name, new ArrayList<String>());
+ }
+ connectionFactoryBindings.get(name).add(jndiBinding);
+ return true;
+ }
+
+
+ public boolean createConnectionFactory(String name, String clientID, int dupsOKBatchSize, boolean strictTck, int prefetchSize, List<String> jndiBindings) throws Exception
+ {
+ JBossConnectionFactory cf = connectionFactories.get(name);
+ if (cf == null)
+ {
+ ClientConnectionFactory clientConnectionFactory = messagingServerManagement.createClientConnectionFactory(strictTck, prefetchSize);
+ log.debug(this + " created local connectionFactory " + clientConnectionFactory);
+ cf = new JBossConnectionFactory(clientConnectionFactory, clientID, dupsOKBatchSize);
+ }
+ for (String jndiBinding : jndiBindings)
+ {
+ bindToJndi(jndiBinding, cf);
+ }
+ return true;
+ }
+
+ public boolean destroyConnectionFactory(String name) throws Exception
+ {
+ List<String> jndiBindings = connectionFactoryBindings.get(name);
+ if (jndiBindings == null || jndiBindings.size() == 0)
+ {
+ return false;
+ }
+ for (String jndiBinding : jndiBindings)
+ {
+ initialContext.unbind(jndiBinding);
+ }
+ connectionFactoryBindings.remove(name);
+ connectionFactories.remove(name);
+ return true;
+ }
+
+ public void removeAllMessagesForQueue(String queueName) throws Exception
+ {
+ JBossQueue jBossQueue = new JBossQueue(queueName);
+ removeAllMessagesForQueue(jBossQueue);
+ }
+
+ public void removeAllMessagesForTopic(String topicName) throws Exception
+ {
+ JBossTopic jBossTopic = new JBossTopic(topicName);
+ removeAllMessagesForTopic(jBossTopic);
+ }
+
+ public void removeAllMessagesForQueue(JBossQueue queue) throws Exception
+ {
+ messagingServerManagement.removeAllMessagesForAddress(queue.getAddress());
+ }
+
+ public void removeAllMessagesForTopic(JBossTopic topic) throws Exception
+ {
+ messagingServerManagement.removeAllMessagesForAddress(topic.getAddress());
+ }
+
+ public int getMessageCountForQueue(String queue) throws Exception
+ {
+ return getMessageCountForQueue(new JBossQueue(queue));
+ }
+
+ public int getMessageCountForQueue(JBossQueue queue) throws Exception
+ {
+ return messagingServerManagement.getMessageCountForQueue(queue.getAddress());
+ }
+
+ public List<SubscriptionInfo> listAllSubscriptionsForTopic(String topicName) throws Exception
+ {
+ return listAllSubscriptionsForTopic(new JBossTopic(topicName));
+ }
+
+ public List<SubscriptionInfo> listAllSubscriptionsForTopic(JBossTopic topicName) throws Exception
+ {
+ return messagingServerManagement.listAllSubscriptionsForAddress(topicName.getAddress());
+ }
+
+ public List<SubscriptionInfo> listDurableSubscriptionsForTopic(String topicName) throws Exception
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public List<SubscriptionInfo> listDurableSubscriptionsForTopic(JBossTopic topicName) throws Exception
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public List<SubscriptionInfo> listNonDurableSubscriptionsForTopic(String topicName) throws Exception
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public List<SubscriptionInfo> listNonDurableSubscriptionsForTopic(JBossTopic topicName) throws Exception
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ //private
+
+ private void addToDestinationBindings(String destination, String jndiBinding)
+ {
+ if (destinations.get(destination) == null)
+ {
+ destinations.put(destination, new ArrayList<String>());
+ }
+ destinations.get(destination).add(jndiBinding);
+ }
+}
Modified: trunk/src/main/org/jboss/messaging/core/MessagingServer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/MessagingServer.java 2008-02-13 15:48:04 UTC (rev 3716)
+++ trunk/src/main/org/jboss/messaging/core/MessagingServer.java 2008-02-13 16:03:16 UTC (rev 3717)
@@ -22,7 +22,6 @@
package org.jboss.messaging.core;
-import java.util.Collection;
import java.util.HashSet;
import org.jboss.jms.server.ConnectionManager;
@@ -81,15 +80,17 @@
HierarchicalRepository<HashSet<Role>> getSecurityRepository();
void setPostOffice(PostOffice postOffice);
+
+ void createQueue(String address, String name) throws Exception;
+
+ public boolean destroyQueue(String name) throws Exception;
+
+ public boolean destroyQueuesByAddress(String address) throws Exception;
- void createQueue(String name) throws Exception;
+ boolean addAddress(String address);
+
+ boolean removeAddress(String address);
- void createTopic(String name) throws Exception;
-
- void destroyQueue(String name) throws Exception;
-
- void destroyTopic(String name) throws Exception;
-
void enableMessageCounters();
void disableMessageCounters();
@@ -98,9 +99,7 @@
void resetAllMessageCounterHistories();
- void removeAllMessagesForQueue(String queueName) throws Exception;
+ void removeAllMessagesForAddress(String address) throws Exception;
- void removeAllMessagesForTopic(String queueName) throws Exception;
-
-
+ void removeAllMessagesForBinding(String name) throws Exception;
}
Modified: trunk/src/main/org/jboss/messaging/core/MessagingServerManagement.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/MessagingServerManagement.java 2008-02-13 15:48:04 UTC (rev 3716)
+++ trunk/src/main/org/jboss/messaging/core/MessagingServerManagement.java 2008-02-13 16:03:16 UTC (rev 3717)
@@ -22,6 +22,7 @@
package org.jboss.messaging.core;
import org.jboss.messaging.core.impl.server.SubscriptionInfo;
+import org.jboss.jms.client.api.ClientConnectionFactory;
import java.util.List;
@@ -37,23 +38,29 @@
//
// Configuration getConfiguration();
//
+ boolean isStarted();
+
+ void createQueue(String address,String name) throws Exception;
+
+ void destroyQueue(String name) throws Exception;
+
+ boolean addAddress(String address);
+
+ boolean removeAddress(String address);
+
+ ClientConnectionFactory createClientConnectionFactory(boolean strictTck,int prefetchSize);
+
+ void removeAllMessagesForAddress(String address) throws Exception;
+
+ void removeAllMessagesForBinding(String name) throws Exception;
+
int getMessageCountForQueue(String queue) throws Exception;
-//
- void removeAllMessagesForQueue(String queueName) throws Exception;
-//
- void removeAllMessagesForTopic(String topicName) throws Exception;
-//
- List<SubscriptionInfo> listAllSubscriptionsForTopic(String topicName) throws Exception;
-//
- void createQueue(String name) throws Exception;
-//
- void createTopic(String name) throws Exception;
-//
- void destroyQueue(String name) throws Exception;
-//
- void destroyTopic(String name) throws Exception;
-//
- boolean isStarted();
+
+ List<SubscriptionInfo> listAllSubscriptionsForAddress(String address) throws Exception;
+
+ List<SubscriptionInfo> listDurableSubscriptionsForAddress(String address) throws Exception;
+
+ List<SubscriptionInfo> listNonSubscriptionsForAddress(String address) throws Exception;
//
// /**
// * returns how many messagesd have been delivered from a specific queue
@@ -240,7 +247,7 @@
// * @return
// * @throws Exception
// */
-// List listAllSubscriptionsForTopic(String topic) throws Exception;
+// List listAllSubscriptionsForAddress(String topic) throws Exception;
//
// /**
// * lists all durable subscriptions for a topic
@@ -346,4 +353,6 @@
// String showPreparedTransactionsAsHTML();
//
// String listMessageCountersAsHTML() throws Exception;
+
+
}
Modified: trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java 2008-02-13 15:48:04 UTC (rev 3716)
+++ trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerImpl.java 2008-02-13 16:03:16 UTC (rev 3717)
@@ -35,10 +35,6 @@
import org.jboss.jms.server.security.NullAuthenticationManager;
import org.jboss.jms.server.security.Role;
import org.jboss.jms.server.security.SecurityMetadataStore;
-import org.jboss.jms.server.security.CheckType;
-import org.jboss.jms.destination.JBossQueue;
-import org.jboss.jms.destination.JBossTopic;
-import org.jboss.jms.destination.JBossDestination;
import org.jboss.logging.Logger;
import org.jboss.messaging.core.*;
import org.jboss.messaging.core.impl.QueueFactoryImpl;
@@ -127,6 +123,7 @@
/**
* called when the usewr wants the MessagingServer to handle the creation of the RemotingTransport
+ *
* @param remotingConfiguration the RemotingConfiguration
*/
public MessagingServerImpl(RemotingConfiguration remotingConfiguration)
@@ -174,14 +171,14 @@
{
public void propertyChange(PropertyChangeEvent evt)
{
- if(evt.getPropertyName().equals("messageCounterSamplePeriod"))
+ if (evt.getPropertyName().equals("messageCounterSamplePeriod"))
messageCounterManager.reschedule(configuration.getMessageCounterSamplePeriod());
}
});
postOffice = new PostOfficeImpl(configuration.getMessagingServerID(),
- persistenceManager, queueFactory, configuration.isStrictTck());
+ persistenceManager, queueFactory, configuration.isStrictTck());
- if(createTransport)
+ if (createTransport)
{
remotingService.start();
}
@@ -192,16 +189,16 @@
remotingService.addFailureListener(connectionManager);
memoryManager.start();
postOffice.start();
- MessagingServerPacketHandler serverPacketHandler = new MessagingServerPacketHandler(this);
+ MessagingServerPacketHandler serverPacketHandler = new MessagingServerPacketHandler(this);
getRemotingService().getDispatcher().register(serverPacketHandler);
ClassLoader loader = Thread.currentThread().getContextClassLoader();
- for (String interceptorClass: configuration.getDefaultInterceptors())
+ for (String interceptorClass : configuration.getDefaultInterceptors())
{
try
{
Class clazz = loader.loadClass(interceptorClass);
- getRemotingService().addInterceptor((Interceptor)clazz.newInstance());
+ getRemotingService().addInterceptor((Interceptor) clazz.newInstance());
}
catch (Exception e)
{
@@ -244,7 +241,7 @@
messageCounterManager = null;
postOffice.stop();
postOffice = null;
- if(createTransport)
+ if (createTransport)
{
remotingService.stop();
}
@@ -258,7 +255,6 @@
}
}
-
// MessagingServer implementation -----------------------------------------------------------
public Version getVersion()
@@ -291,7 +287,7 @@
return remotingService;
}
-
+
public void enableMessageCounters()
{
messageCounterManager.start();
@@ -306,41 +302,85 @@
messageCounterManager.resetAllCounterHistories();
}
- public void createQueue(String name) throws Exception
+ public void createQueue(String address, String name) throws Exception
{
- JBossQueue queue = new JBossQueue(name);
-
- if (getPostOffice().getBinding(queue.getAddress()) == null)
+ if (getPostOffice().getBinding(name) == null)
{
- getPostOffice().addBinding(queue.getAddress(), queue.getAddress(), null, true, false);
+ getPostOffice().addBinding(address, name, null, true, false);
}
- if (!getPostOffice().containsAllowableAddress(queue.getAddress()))
+ if (!getPostOffice().containsAllowableAddress(address))
{
- getPostOffice().addAllowableAddress(queue.getAddress());
+ getPostOffice().addAllowableAddress(address);
}
}
- public void destroyQueue(String name) throws Exception
+ public boolean destroyQueuesByAddress(String address) throws Exception
{
- destroyDestination(true, name);
+ List<Binding> bindings = getPostOffice().getBindingsForAddress(address);
+
+ boolean destroyed = false;
+
+ for (Binding binding : bindings)
+ {
+ Queue queue = binding.getQueue();
+
+ getPersistenceManager().deleteAllReferences(queue);
+
+ queue.removeAllReferences();
+
+ getPostOffice().removeBinding(queue.getName());
+
+ destroyed = true;
+ }
+
+ getPostOffice().removeAllowableAddress(address);
+
+ return destroyed;
}
- public void createTopic(String name) throws Exception
+ public boolean destroyQueue(String name) throws Exception
{
- JBossTopic topic = new JBossTopic(name);
+ Binding binding = getPostOffice().getBinding(name);
- if (!getPostOffice().containsAllowableAddress(topic.getAddress()));
+ boolean destroyed = false;
+
+ if (binding != null)
{
- getPostOffice().addAllowableAddress(topic.getAddress());
+ Queue queue = binding.getQueue();
+
+ getPersistenceManager().deleteAllReferences(queue);
+
+ queue.removeAllReferences();
+
+ getPostOffice().removeBinding(queue.getName());
+
+ destroyed = true;
}
+
+ return destroyed;
}
- public void destroyTopic(String name) throws Exception
+ public boolean addAddress(String address)
{
- destroyDestination(false, name);
+ if (!getPostOffice().containsAllowableAddress(address))
+ {
+ getPostOffice().addAllowableAddress(address);
+ return true;
+ }
+ return false;
}
+ public boolean removeAddress(String address)
+ {
+ if (getPostOffice().containsAllowableAddress(address))
+ {
+ getPostOffice().removeAllowableAddress(address);
+ return true;
+ }
+ return false;
+ }
+
public void resetAllMessageCounters()
{
this.messageCounterManager.resetAllCounters();
@@ -351,41 +391,38 @@
this.messageCounterManager.resetAllCounterHistories();
}
- public void removeAllMessagesForQueue(String queueName) throws Exception
+
+ public void removeAllMessagesForAddress(String address) throws Exception
{
- JBossQueue jbq = new JBossQueue(queueName);
+ List<Binding> bindings = postOffice.getBindingsForAddress(address);
- List<Binding> bindings = postOffice.getBindingsForAddress(jbq.getAddress());
-
- if (!bindings.isEmpty())
+ for (Binding binding : bindings)
{
- Queue queue = bindings.get(0).getQueue();
+ Queue queue = binding.getQueue();
- persistenceManager.deleteAllReferences(queue);
+ if (queue.isDurable())
+ {
+ persistenceManager.deleteAllReferences(queue);
+ }
queue.removeAllReferences();
}
}
- public void removeAllMessagesForTopic(String queueName) throws Exception
+ public void removeAllMessagesForBinding(String name) throws Exception
{
- JBossTopic jbt = new JBossTopic(queueName);
-
- List<Binding> bindings = postOffice.getBindingsForAddress(jbt.getAddress());
-
- for (Binding binding: bindings)
+ Binding binding = postOffice.getBinding(name);
+ if (binding != null)
{
Queue queue = binding.getQueue();
- if (queue.isDurable())
- {
- persistenceManager.deleteAllReferences(queue);
- }
+ persistenceManager.deleteAllReferences(queue);
queue.removeAllReferences();
}
}
+
public SecurityStore getSecurityManager()
{
return securityStore;
@@ -455,24 +492,15 @@
// Private --------------------------------------------------------------------------------------
- private boolean destroyDestination(boolean isQueue, String name) throws Exception
+ private boolean destroyDestination(String address) throws Exception
{
- JBossDestination dest;
- if (isQueue)
- {
- dest = new JBossQueue(name);
- }
- else
- {
- dest = new JBossTopic(name);
- }
- List<Binding> bindings = getPostOffice().getBindingsForAddress(dest.getAddress());
+ List<Binding> bindings = getPostOffice().getBindingsForAddress(address);
boolean destroyed = false;
- for (Binding binding: bindings)
+ for (Binding binding : bindings)
{
Queue queue = binding.getQueue();
@@ -485,7 +513,7 @@
destroyed = true;
}
- getPostOffice().removeAllowableAddress(dest.getAddress());
+ getPostOffice().removeAllowableAddress(address);
return destroyed;
}
Modified: trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerManagementImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerManagementImpl.java 2008-02-13 15:48:04 UTC (rev 3716)
+++ trunk/src/main/org/jboss/messaging/core/impl/server/MessagingServerManagementImpl.java 2008-02-13 16:03:16 UTC (rev 3717)
@@ -25,8 +25,8 @@
import java.util.List;
import org.jboss.aop.microcontainer.aspects.jmx.JMX;
-import org.jboss.jms.destination.JBossQueue;
-import org.jboss.jms.destination.JBossTopic;
+import org.jboss.jms.client.api.ClientConnectionFactory;
+import org.jboss.jms.client.impl.ClientConnectionFactoryImpl;
import org.jboss.messaging.core.Binding;
import org.jboss.messaging.core.MessagingServer;
import org.jboss.messaging.core.MessagingServerManagement;
@@ -69,45 +69,62 @@
return messagingServer.isStarted();
}
- public void createQueue(String name) throws Exception
+ public void createQueue(String address, String name) throws Exception
{
- messagingServer.createQueue(name);
+ messagingServer.createQueue(address, name);
}
-
- public void createTopic(String name) throws Exception
- {
- messagingServer.createTopic(name);
- }
-
+
public void destroyQueue(String name) throws Exception
{
messagingServer.destroyQueue(name);
}
-
- public void destroyTopic(String name) throws Exception
+
+ public boolean addAddress(String address)
{
- messagingServer.destroyTopic(name);
+ return messagingServer.addAddress(address);
}
- public void removeAllMessagesForQueue(String queueName) throws Exception
+ public boolean removeAddress(String address)
{
- messagingServer.removeAllMessagesForQueue(queueName);
+ return messagingServer.removeAddress(address);
}
- public void removeAllMessagesForTopic(String topicName) throws Exception
+ public ClientConnectionFactory createClientConnectionFactory(boolean strictTck,int prefetchSize)
{
- messagingServer.removeAllMessagesForTopic(topicName);
+ return new ClientConnectionFactoryImpl(messagingServer.getConfiguration().getMessagingServerID(),
+ messagingServer.getConfiguration().getRemotingConfiguration(), messagingServer.getVersion(), messagingServer.getConfiguration().isStrictTck() || strictTck, prefetchSize);
}
+
+ public void removeAllMessagesForAddress(String address) throws Exception
+ {
+ messagingServer.removeAllMessagesForAddress(address);
+ }
+
+ public void removeAllMessagesForBinding(String name) throws Exception
+ {
+ messagingServer.removeAllMessagesForBinding(name);
+ }
public int getMessageCountForQueue(String queue) throws Exception
{
return getQueue(queue).getMessageCount();
}
- public List<SubscriptionInfo> listAllSubscriptionsForTopic(String topicName) throws Exception
+ public List<SubscriptionInfo> listAllSubscriptionsForAddress(String address) throws Exception
{
- return listAllSubscriptions(topicName);
+ return listSubscriptions(address, ListType.ALL);
}
+
+ public List<SubscriptionInfo> listDurableSubscriptionsForAddress(String address) throws Exception
+ {
+ return listSubscriptions(address, ListType.DURABLE);
+ }
+
+ public List<SubscriptionInfo> listNonSubscriptionsForAddress(String address) throws Exception
+ {
+ return listSubscriptions(address, ListType.NON_DURABLE);
+ }
+
//
//// public int getDeliveringCountForQueue(String queue) throws Exception
//// {
@@ -519,11 +536,7 @@
// {
// return listMessages(queue, ListType.NON_DURABLE, selector);
// }
-//
- public List<SubscriptionInfo> listAllSubscriptions(String topicName) throws Exception
- {
- return listSubscriptions(topicName, ListType.ALL);
- }
+//
//
// public List<SubscriptionInfo> listDurableSubscriptions(String topicName) throws Exception
// {
@@ -608,10 +621,7 @@
//
private Queue getQueue(String queueName) throws Exception
{
- JBossQueue jbq = new JBossQueue(queueName);
-
- Binding binding = messagingServer.getPostOffice().getBinding(jbq.getAddress());
-
+ Binding binding = messagingServer.getPostOffice().getBinding(queueName);
if (binding == null)
{
throw new IllegalArgumentException("No queue with name " + queueName);
@@ -786,7 +796,7 @@
//
private enum ListType
{
- ALL, DURABLE, NON_DURABLE;
+ ALL, DURABLE, NON_DURABLE
}
//
//
@@ -836,14 +846,10 @@
// return msgs;
// }
//
- private List<SubscriptionInfo> listSubscriptions(String topicName, ListType type) throws Exception
+ private List<SubscriptionInfo> listSubscriptions(String address, ListType type) throws Exception
{
List<SubscriptionInfo> subs = new ArrayList<SubscriptionInfo>();
-
- JBossTopic topic = new JBossTopic(topicName);
- String address = topic.getAddress();
-
List<Binding> bindings = messagingServer.getPostOffice().getBindingsForAddress(address);
for (Binding binding: bindings)
Modified: trunk/tests/src/org/jboss/test/messaging/JBMServerTestCase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/JBMServerTestCase.java 2008-02-13 15:48:04 UTC (rev 3716)
+++ trunk/tests/src/org/jboss/test/messaging/JBMServerTestCase.java 2008-02-13 16:03:16 UTC (rev 3717)
@@ -322,16 +322,6 @@
return servers.get(0).getMessagingServer();
}
- protected MessagingServerManagement getJmsServerStatistics() throws Exception
- {
- return servers.get(0).getMessagingServerManagement();
- }
-
- protected MessagingServerManagement getJmsServerStatistics(int serverId) throws Exception
- {
- return servers.get(serverId).getMessagingServerManagement();
- }
-
/*protected void tearDown() throws Exception
{
super.tearDown();
@@ -738,14 +728,14 @@
}
public static void deployConnectionFactory(String clientId, String objectName,
- String[] jndiBindings)
+ List<String> jndiBindings)
throws Exception
{
servers.get(0).deployConnectionFactory(clientId, objectName, jndiBindings);
}
public static void deployConnectionFactory(String objectName,
- String[] jndiBindings,
+ List<String> jndiBindings,
int prefetchSize)
throws Exception
{
@@ -753,7 +743,7 @@
}
public static void deployConnectionFactory(String objectName,
- String[] jndiBindings)
+ List<String> jndiBindings)
throws Exception
{
servers.get(0).deployConnectionFactory(objectName, jndiBindings);
@@ -761,7 +751,7 @@
public static void deployConnectionFactory(int server,
String objectName,
- String[] jndiBindings,
+ List<String> jndiBindings,
int prefetchSize)
throws Exception
{
@@ -770,20 +760,20 @@
public static void deployConnectionFactory(int server,
String objectName,
- String[] jndiBindings)
+ List<String> jndiBindings)
throws Exception
{
servers.get(server).deployConnectionFactory(objectName, jndiBindings);
}
- public void deployConnectionFactory(String objectName, String[] jndiBindings, boolean strictTck) throws Exception
+ public void deployConnectionFactory(String objectName, List<String> jndiBindings, boolean strictTck) throws Exception
{
servers.get(0).deployConnectionFactory(objectName, jndiBindings, strictTck);
}
public void deployConnectionFactory(String clientId,
String objectName,
- String[] jndiBindings,
+ List<String> jndiBindings,
int prefetchSize,
int defaultTempQueueFullSize,
int defaultTempQueuePageSize,
@@ -798,7 +788,7 @@
}
public static void deployConnectionFactory(String objectName,
- String[] jndiBindings,
+ List<String> jndiBindings,
int prefetchSize,
int defaultTempQueueFullSize,
int defaultTempQueuePageSize,
Modified: trunk/tests/src/org/jboss/test/messaging/jms/AcknowledgementTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/AcknowledgementTest.java 2008-02-13 15:48:04 UTC (rev 3716)
+++ trunk/tests/src/org/jboss/test/messaging/jms/AcknowledgementTest.java 2008-02-13 16:03:16 UTC (rev 3717)
@@ -40,7 +40,10 @@
import EDU.oswego.cs.dl.util.concurrent.Latch;
+import java.util.List;
+import java.util.ArrayList;
+
/**
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
*
@@ -701,7 +704,9 @@
final int BATCH_SIZE = 10;
log.info("*********** DEPLOYING CF");
- deployConnectionFactory(null,"mycf", new String[]{"mycf"}, -1, -1, -1, -1, false, false, false, BATCH_SIZE);
+ ArrayList<String> bindings = new ArrayList<String>();
+ bindings.add("mycf");
+ deployConnectionFactory(null,"mycf", bindings, -1, -1, -1, -1, false, false, false, BATCH_SIZE);
log.info("************ DONE DEPLOY");
Connection conn = null;
@@ -781,8 +786,9 @@
public void testDupsOKAcknowledgeTopic() throws Exception
{
final int BATCH_SIZE = 10;
-
- deployConnectionFactory(null,"mycf", new String[]{"mycf"}, -1, -1, -1, -1, false, false, false, BATCH_SIZE);
+ ArrayList<String> bindings = new ArrayList<String>();
+ bindings.add("mycf");
+ deployConnectionFactory(null,"mycf", bindings, -1, -1, -1, -1, false, false, false, BATCH_SIZE);
Connection conn = null;
try
Modified: trunk/tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java 2008-02-13 15:48:04 UTC (rev 3716)
+++ trunk/tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java 2008-02-13 16:03:16 UTC (rev 3717)
@@ -44,6 +44,9 @@
import org.jboss.test.messaging.jms.message.SimpleJMSTextMessage;
import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
+import java.util.List;
+import java.util.ArrayList;
+
/**
* Safeguards for previously detected TCK failures.
*
@@ -77,7 +80,9 @@
{
super.setUp();
//Deploy a connection factory with load balancing but no failover on node0
- deployConnectionFactory("StrictTCKConnectionFactory", new String[]{"StrictTCKConnectionFactory"}, true);
+ List<String> bindings = new ArrayList<String>();
+ bindings.add("StrictTCKConnectionFactory");
+ deployConnectionFactory("StrictTCKConnectionFactory", bindings, true);
cf = (JBossConnectionFactory) getInitialContext().lookup("/StrictTCKConnectionFactory");
}
catch (Exception e)
Modified: trunk/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java 2008-02-13 15:48:04 UTC (rev 3716)
+++ trunk/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java 2008-02-13 16:03:16 UTC (rev 3717)
@@ -35,6 +35,7 @@
import javax.jms.Topic;
import javax.jms.TopicConnection;
import javax.jms.TopicConnectionFactory;
+import java.util.ArrayList;
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
@@ -92,9 +93,10 @@
public void testAdministrativelyConfiguredClientID() throws Exception
{
// deploy a connection factory that has an administatively configured clientID
+ ArrayList<String> bindings = new ArrayList<String>();
+ bindings.add("TestConnectionFactory");
+ deployConnectionFactory("sofiavergara", "TestConnectionFactory", bindings );
- deployConnectionFactory("sofiavergara", "TestConnectionFactory", new String[]{"TestConnectionFactory"} );
-
ConnectionFactory cf = (ConnectionFactory)ic.lookup("/TestConnectionFactory");
Connection c = cf.createConnection();
@@ -146,7 +148,9 @@
// Added for http://jira.jboss.org/jira/browse/JBMESSAGING-939
public void testDurableSubscriptionOnPreConfiguredConnectionFactory() throws Exception
{
- deployConnectionFactory("TestConnectionFactory1","cfTest", new String[]{"/TestDurableCF"});
+ ArrayList<String> bindings = new ArrayList<String>();
+ bindings.add("/TestDurableCF");
+ deployConnectionFactory("TestConnectionFactory1","cfTest", bindings);
createTopic("TestSubscriber");
@@ -199,7 +203,9 @@
public void testSlowConsumers() throws Exception
{
- deployConnectionFactory(0, "TestSlowConsumersCF", new String[]{"TestSlowConsumersCF"}, 1);
+ ArrayList<String> bindings = new ArrayList<String>();
+ bindings.add("TestSlowConsumersCF");
+ deployConnectionFactory(0, "TestSlowConsumersCF", bindings, 1);
Connection conn = null;
Modified: trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java 2008-02-13 15:48:04 UTC (rev 3716)
+++ trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java 2008-02-13 16:03:16 UTC (rev 3717)
@@ -22,6 +22,7 @@
package org.jboss.test.messaging.jms;
import java.util.HashSet;
+import java.util.ArrayList;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
@@ -180,7 +181,9 @@
Connection conn = null;
try
{
- deployConnectionFactory("dilbert-id", "preConfcf", new String[]{"preConfcf"});
+ ArrayList<String> bindings = new ArrayList<String>();
+ bindings.add("preConfcf");
+ deployConnectionFactory("dilbert-id", "preConfcf", bindings);
ConnectionFactory cf = (ConnectionFactory) getInitialContext().lookup("preConfcf");
conn = cf.createConnection("dilbert", "dogbert");
String clientID = conn.getClientID();
@@ -221,7 +224,9 @@
Connection conn = null;
try
{
- deployConnectionFactory("dilbert-id", "preConfcf", new String[]{"preConfcf"});
+ ArrayList<String> bindings = new ArrayList<String>();
+ bindings.add("preConfcf");
+ deployConnectionFactory("dilbert-id", "preConfcf", bindings);
ConnectionFactory cf = (ConnectionFactory) getInitialContext().lookup("preConfcf");
conn = cf.createConnection("dilbert", "dogbert");
conn.setClientID("myID");
@@ -448,7 +453,9 @@
Connection conn = null;
try
{
- deployConnectionFactory("dilbert-id", "preConfcf", new String[]{"preConfcf"});
+ ArrayList<String> bindings = new ArrayList<String>();
+ bindings.add("preConfcf");
+ deployConnectionFactory("dilbert-id", "preConfcf", bindings);
ConnectionFactory cf = (ConnectionFactory) getInitialContext().lookup("preConfcf");
//setSecurityConfig(oldDefaultConfig);
conn = cf.createConnection("dilbert", "dogbert");
Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2008-02-13 15:48:04 UTC (rev 3716)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2008-02-13 16:03:16 UTC (rev 3717)
@@ -25,7 +25,6 @@
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -42,21 +41,15 @@
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
-import org.jboss.jms.client.JBossConnectionFactory;
-import org.jboss.jms.client.api.ClientConnectionFactory;
-import org.jboss.jms.client.impl.ClientConnectionFactoryImpl;
-import org.jboss.jms.destination.JBossQueue;
-import org.jboss.jms.destination.JBossTopic;
import org.jboss.jms.server.security.Role;
+import org.jboss.jms.server.JMSServerManager;
import org.jboss.kernel.spi.deployment.KernelDeployment;
import org.jboss.logging.Logger;
import org.jboss.messaging.core.Binding;
import org.jboss.messaging.core.MessagingServer;
import org.jboss.messaging.core.MessagingServerManagement;
-import org.jboss.messaging.core.remoting.RemotingConfiguration;
import org.jboss.messaging.microcontainer.JBMBootstrapServer;
import org.jboss.messaging.util.JNDIUtil;
-import org.jboss.messaging.util.Version;
import org.jboss.test.messaging.tools.ConfigurationHelper;
import org.jboss.test.messaging.tools.ServerManagement;
import org.jboss.test.messaging.tools.jboss.MBeanConfigurationElement;
@@ -444,7 +437,7 @@
public boolean isServerPeerStarted() throws Exception
{
- return this.getMessagingServerManagement().isStarted();
+ return this.getJMSServerManager().isStarted();
}
public ObjectName getServerPeerObjectName()
@@ -551,40 +544,22 @@
public void destroyQueue(String name, String jndiName) throws Exception
{
- this.getMessagingServerManagement().destroyQueue(name);
- if (jndiName != null)
- {
- getInitialContext().unbind(jndiName);
- }
+ this.getJMSServerManager().destroyQueue(name);
}
public void destroyTopic(String name, String jndiName) throws Exception
{
- this.getMessagingServerManagement().destroyTopic(name);
- if (jndiName != null)
- {
- getInitialContext().unbind(jndiName);
- }
+ this.getJMSServerManager().destroyTopic(name);
}
public void createQueue(String name, String jndiName) throws Exception
{
- this.getMessagingServerManagement().createQueue(name);
- JBossQueue jBossQueue = new JBossQueue(name);
- bindObject("/queue/" + (jndiName != null ? jndiName : name), jBossQueue);
- List<String> bindings = new ArrayList<String>();
- bindings.add("/queue/" + (jndiName != null ? jndiName : name));
- allBindings.put(name, bindings);
+ this.getJMSServerManager().createQueue(name, "/queue/" + (jndiName != null ? jndiName : name));
}
public void createTopic(String name, String jndiName) throws Exception
{
- this.getMessagingServerManagement().createTopic(name);
- JBossTopic jBossTopic = new JBossTopic(name);
- bindObject("/topic/" + (jndiName != null ? jndiName : name), jBossTopic);
- List<String> bindings = new ArrayList<String>();
- bindings.add("/topic/" + (jndiName != null ? jndiName : name));
- allBindings.put(name, bindings);
+ this.getJMSServerManager().createTopic(name, "/topic/" + (jndiName != null ? jndiName : name));
}
private void bindObject(String jndiName, Object object)
@@ -618,13 +593,13 @@
}
public void deployConnectionFactory(String clientId, String objectName,
- String[] jndiBindings) throws Exception
+ List<String> jndiBindings) throws Exception
{
deployConnectionFactory(clientId, objectName, jndiBindings, -1, -1, -1, -1, false, false, false, -1);
}
public void deployConnectionFactory(String objectName,
- String[] jndiBindings,
+ List<String> jndiBindings,
int prefetchSize) throws Exception
{
deployConnectionFactory(null, objectName, jndiBindings, prefetchSize, -1, -1, -1, false, false, false, -1);
@@ -632,19 +607,19 @@
public void deployConnectionFactory(String objectName,
- String[] jndiBindings) throws Exception
+ List<String> jndiBindings) throws Exception
{
deployConnectionFactory(null, objectName, jndiBindings, -1, -1, -1, -1, false, false, false, -1);
}
- public void deployConnectionFactory(String objectName, String[] jndiBindings, boolean strictTck) throws Exception
+ public void deployConnectionFactory(String objectName, List<String> jndiBindings, boolean strictTck) throws Exception
{
deployConnectionFactory(null, objectName, jndiBindings, -1, -1, -1, -1, false, false, strictTck, -1);
}
public void deployConnectionFactory(String objectName,
- String[] jndiBindings,
+ List<String> jndiBindings,
int prefetchSize,
int defaultTempQueueFullSize,
int defaultTempQueuePageSize,
@@ -655,7 +630,7 @@
}
public void deployConnectionFactory(String objectName,
- String[] jndiBindings,
+ List<String> jndiBindings,
boolean supportsFailover, boolean supportsLoadBalancing) throws Exception
{
this.deployConnectionFactory(null, objectName, jndiBindings, -1, -1,
@@ -664,7 +639,7 @@
public void deployConnectionFactory(String clientId,
String objectName,
- String[] jndiBindings,
+ List<String> jndiBindings,
int prefetchSize,
int defaultTempQueueFullSize,
int defaultTempQueuePageSize,
@@ -675,70 +650,13 @@
int dupsOkBatchSize) throws Exception
{
log.info("deploying connection factory with name: " + objectName + " and dupsok: " + dupsOkBatchSize);
- //ConnectionFactory connectionFactory = new ConnectionFactory(clientId);
- List<String> bindings = new ArrayList<String>();
- if (jndiBindings != null)
- {
- for (String jndiBinding : jndiBindings)
- {
- bindings.add(jndiBinding);
- }
- }
- //connectionFactory.setJNDIBindings(bindings);
- //if (prefetchSize > 0)
- // connectionFactory.setPrefetchSize(prefetchSize);
- //if (defaultTempQueueFullSize > 0) if (dupsOkBatchSize > 0)
- // connectionFactory.setDupsOKBatchSize(dupsOkBatchSize);
- // connectionFactory.setSupportsFailover(supportsFailover);
- //connectionFactory.setSupportsLoadBalancing(supportsLoadBalancing);
- //connectionFactory.setStrictTck(strictTck);
- RemotingConfiguration remotingConfiguration = getMessagingServer().getRemotingService().getRemotingConfiguration();
-
- log.info("Remoting configuration is " + remotingConfiguration);
- log.info(this + " started");
- // See http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4076040#4076040
- final String id = objectName;
-
- Version version = getMessagingServer().getVersion();
-
- /*ServerConnectionFactoryEndpoint endpoint =
- new ServerConnectionFactoryEndpoint(connectionFactory.getName(), id, getMessagingServer(), connectionFactory.getClientID(),
- connectionFactory.getPrefetchSize(),
- connectionFactory.getDefaultTempQueueFullSize(),
- connectionFactory.getDefaultTempQueuePageSize(),
- connectionFactory.getDefaultTempQueueDownCacheSize(),
- connectionFactory.getDupsOKBatchSize());*/
-
- //The server peer strict setting overrides the connection factory
- boolean useStrict = getMessagingServer().getConfiguration().isStrictTck() || strictTck;
-
- ClientConnectionFactory delegate =
- new ClientConnectionFactoryImpl( getMessagingServer().getConfiguration().getMessagingServerID(),
- remotingConfiguration, version, useStrict, prefetchSize);
-
- log.debug(this + " created local connectionFactory " + delegate);
-
- // Registering with the dispatcher should always be the last thing otherwise a client could
- // use a partially initialised object
-
- //getMessagingServer().getMinaService().getDispatcher().register(endpoint.newHandler());
- JBossConnectionFactory jBossConnectionFactory = new JBossConnectionFactory(delegate, clientId, dupsOkBatchSize);
- for (String binding : bindings)
- {
- bindObject(binding, jBossConnectionFactory);
- }
- allBindings.put(objectName, bindings);
+ getJMSServerManager().createConnectionFactory(objectName, clientId, dupsOkBatchSize, strictTck, prefetchSize, jndiBindings);
}
+
public void undeployConnectionFactory(String objectName) throws Exception
{
- getMessagingServer().getRemotingService().getDispatcher().unregister(objectName);
- List<String> bindings = allBindings.get(objectName);
- for (String binding : bindings)
- {
- getInitialContext().unbind(binding);
- }
- allBindings.remove(objectName);
+ getJMSServerManager().destroyConnectionFactory(objectName);
}
public void configureSecurityForDestination(String destName, boolean isQueue, HashSet<Role> roles) throws Exception
@@ -837,9 +755,9 @@
return (MessagingServer) bootstrap.getKernel().getRegistry().getEntry("MessagingServer").getTarget();
}
- public MessagingServerManagement getMessagingServerManagement()
+ public JMSServerManager getJMSServerManager()
{
- return (MessagingServerManagement) bootstrap.getKernel().getRegistry().getEntry("MessagingServerManagement").getTarget();
+ return (JMSServerManager) bootstrap.getKernel().getRegistry().getEntry("JMSServerManager").getTarget();
}
public InitialContext getInitialContext() throws Exception
@@ -875,23 +793,23 @@
public Integer getMessageCountForQueue(String queueName) throws Exception
{
- return getMessagingServerManagement().getMessageCountForQueue(queueName);
+ return getJMSServerManager().getMessageCountForQueue(queueName);
}
public void removeAllMessagesForQueue(String destName) throws Exception
{
- getMessagingServerManagement().removeAllMessagesForQueue(destName);
+ getJMSServerManager().removeAllMessagesForQueue(destName);
}
public void removeAllMessagesForTopic(String destName) throws Exception
{
- getMessagingServerManagement().removeAllMessagesForTopic(destName);
+ getJMSServerManager().removeAllMessagesForTopic(destName);
}
public List listAllSubscriptionsForTopic(String s) throws Exception
{
- return getMessagingServerManagement().listAllSubscriptionsForTopic(s);
+ return getJMSServerManager().listAllSubscriptionsForTopic(s);
}
Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java 2008-02-13 15:48:04 UTC (rev 3716)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java 2008-02-13 16:03:16 UTC (rev 3717)
@@ -37,6 +37,7 @@
import javax.transaction.UserTransaction;
import org.jboss.jms.server.security.Role;
+import org.jboss.jms.server.JMSServerManager;
import org.jboss.kernel.spi.deployment.KernelDeployment;
import org.jboss.messaging.core.MessagingServer;
import org.jboss.messaging.core.MessagingServerManagement;
@@ -401,25 +402,25 @@
server.createTopic(name, jndiName);
}
- public void deployConnectionFactory(String objectName, String[] jndiBindings)
+ public void deployConnectionFactory(String objectName, List<String> jndiBindings)
throws Exception
{
server.deployConnectionFactory(objectName, jndiBindings);
}
- public void deployConnectionFactory(String clientID, String objectName, String[] jndiBindings) throws Exception
+ public void deployConnectionFactory(String clientID, String objectName, List<String> jndiBindings) throws Exception
{
server.deployConnectionFactory(clientID, objectName, jndiBindings);
}
- public void deployConnectionFactory(String objectName, String[] jndiBindings, int prefetchSize)
+ public void deployConnectionFactory(String objectName, List<String> jndiBindings, int prefetchSize)
throws Exception
{
server.deployConnectionFactory(objectName, jndiBindings, prefetchSize);
}
- public void deployConnectionFactory(String objectName, String[] jndiBindings, boolean strictTck) throws Exception
+ public void deployConnectionFactory(String objectName, List<String> jndiBindings, boolean strictTck) throws Exception
{
server.deployConnectionFactory(objectName, jndiBindings, strictTck);
@@ -427,7 +428,7 @@
public void deployConnectionFactory(String clientId,
String objectName,
- String[] jndiBindings,
+ List<String> jndiBindings,
int prefetchSize,
int defaultTempQueueFullSize,
int defaultTempQueuePageSize,
@@ -441,7 +442,7 @@
supportsFailover, supportsLoadBalancing, strictTck, dupsOkBatchSize);
}
public void deployConnectionFactory(String objectName,
- String[] jndiBindings,
+ List<String> jndiBindings,
int prefetchSize,
int defaultTempQueueFullSize,
int defaultTempQueuePageSize,
@@ -452,7 +453,7 @@
}
public void deployConnectionFactory(String objectName,
- String[] jndiBindings, boolean supportsFailover, boolean supportsLoadBalancing) throws Exception
+ List<String> jndiBindings, boolean supportsFailover, boolean supportsLoadBalancing) throws Exception
{
server.deployConnectionFactory(objectName, jndiBindings, supportsFailover, supportsLoadBalancing);
}
@@ -547,13 +548,11 @@
return server.getMessagingServer();
}
-
- public MessagingServerManagement getMessagingServerManagement() throws Exception
+ public JMSServerManager getJMSServerManager()
{
- return server.getMessagingServerManagement();
+ return server.getJMSServerManager();
}
-
public void removeAllMessagesForQueue(String destName) throws Exception
{
server.removeAllMessagesForQueue(destName);
@@ -567,7 +566,7 @@
public Integer getMessageCountForQueue(String queueName) throws Exception
{
- return getMessagingServerManagement().getMessageCountForQueue(queueName);
+ return getJMSServerManager().getMessageCountForQueue(queueName);
}
Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java 2008-02-13 15:48:04 UTC (rev 3716)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java 2008-02-13 16:03:16 UTC (rev 3717)
@@ -22,6 +22,7 @@
package org.jboss.test.messaging.tools.container;
import org.jboss.jms.server.security.Role;
+import org.jboss.jms.server.JMSServerManager;
import org.jboss.kernel.spi.deployment.KernelDeployment;
import org.jboss.messaging.core.MessagingServer;
import org.jboss.messaging.core.MessagingServerManagement;
@@ -188,7 +189,7 @@
public void deployConnectionFactory(String clientId,
String objectName,
- String[] jndiBindings,
+ List<String> jndiBindings,
int prefetchSize,
int defaultTempQueueFullSize,
int defaultTempQueuePageSize,
@@ -199,7 +200,7 @@
int dupsOkBatchSize) throws Exception;
void deployConnectionFactory(String objectName,
- String[] jndiBindings,
+ List<String> jndiBindings,
int prefetchSize,
int defaultTempQueueFullSize,
int defaultTempQueuePageSize,
@@ -207,21 +208,21 @@
) throws Exception;
void deployConnectionFactory(String objectName,
- String[] jndiBindings,
+ List<String> jndiBindings,
boolean supportsFailover,
boolean supportsLoadBalancing
) throws Exception;
void deployConnectionFactory(String clientID,
String objectName,
- String[] jndiBindings) throws Exception;
+ List<String> jndiBindings) throws Exception;
void deployConnectionFactory(String objectName,
- String[] jndiBindings,
+ List<String> jndiBindings,
int prefetchSize) throws Exception;
void deployConnectionFactory(String objectName,
- String[] jndiBindings) throws Exception;
+ List<String> jndiBindings) throws Exception;
void undeployConnectionFactory(String objectName) throws Exception;
@@ -275,12 +276,10 @@
void flushManagedConnectionPool() throws Exception;
- void deployConnectionFactory(String objectName, String[] jndiBindings, boolean strictTck) throws Exception;
+ void deployConnectionFactory(String objectName, List<String> jndiBindings, boolean strictTck) throws Exception;
MessagingServer getMessagingServer() throws Exception;
- MessagingServerManagement getMessagingServerManagement() throws Exception;
-
InitialContext getInitialContext() throws Exception;
void removeAllMessagesForQueue(String destName) throws Exception;
@@ -300,4 +299,5 @@
void setRedeliveryDelayOnDestination(String dest, boolean queue, long delay) throws Exception;
//void setDefaultRedeliveryDelay(long delay) throws Exception;
+ JMSServerManager getJMSServerManager() throws Exception;
}
More information about the jboss-cvs-commits
mailing list