[hornetq-commits] JBoss hornetq SVN: r8033 - in trunk: src/main/org/hornetq/jms/server/config and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Oct 2 08:41:40 EDT 2009


Author: jmesnil
Date: 2009-10-02 08:41:40 -0400 (Fri, 02 Oct 2009)
New Revision: 8033

Added:
   trunk/src/main/org/hornetq/jms/server/config/
   trunk/src/main/org/hornetq/jms/server/config/ConnectionFactoryConfiguration.java
   trunk/src/main/org/hornetq/jms/server/config/JMSConfiguration.java
   trunk/src/main/org/hornetq/jms/server/config/QueueConfiguration.java
   trunk/src/main/org/hornetq/jms/server/config/TopicConfiguration.java
   trunk/src/main/org/hornetq/jms/server/config/impl/
   trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java
   trunk/src/main/org/hornetq/jms/server/config/impl/JMSConfigurationImpl.java
   trunk/src/main/org/hornetq/jms/server/config/impl/QueueConfigurationImpl.java
   trunk/src/main/org/hornetq/jms/server/config/impl/TopicConfigurationImpl.java
   trunk/tests/src/org/hornetq/tests/integration/jms/server/config/
   trunk/tests/src/org/hornetq/tests/integration/jms/server/config/JMSConfigurationTest.java
Modified:
   trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
Log:
HORNETQ-161: Allow creation of JMS destinations via IoC

* added org.hornetq.server.jms.config package to configure a JMSServerManager using POJOs
  (similar to Configuration API for core HornetQServer)

Added: trunk/src/main/org/hornetq/jms/server/config/ConnectionFactoryConfiguration.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/config/ConnectionFactoryConfiguration.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/jms/server/config/ConnectionFactoryConfiguration.java	2009-10-02 12:41:40 UTC (rev 8033)
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.server.config;
+
+import java.util.List;
+
+import org.hornetq.core.config.TransportConfiguration;
+import org.hornetq.utils.Pair;
+
+/**
+ * A ConnectionFactoryConfiguration
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public interface ConnectionFactoryConfiguration
+{
+   String getName();
+
+   String[] getBindings();
+
+   String getDiscoveryAddress();
+
+   void setDiscoveryAddress(String discoveryAddress);
+
+   int getDiscoveryPort();
+
+   void setDiscoveryPort(int discoveryPort);
+
+   List<Pair<TransportConfiguration, TransportConfiguration>> getConnectorConfigs();
+
+   void setConnectorConfigs(List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs);
+
+   String getClientID();
+
+   void setClientID(String clientID);
+
+   long getDiscoveryRefreshTimeout();
+
+   void setDiscoveryRefreshTimeout(long discoveryRefreshTimeout);
+
+   long getClientFailureCheckPeriod();
+
+   void setClientFailureCheckPeriod(long clientFailureCheckPeriod);
+
+   long getConnectionTTL();
+
+   void setConnectionTTL(long connectionTTL);
+
+   long getCallTimeout();
+
+   void setCallTimeout(long callTimeout);
+
+   int getMaxConnections();
+
+   void setMaxConnections(int maxConnections);
+
+   boolean isCacheLargeMessagesClient();
+
+   void setCacheLargeMessagesClient(boolean cacheLargeMessagesClient);
+
+   int getMinLargeMessageSize();
+
+   void setMinLargeMessageSize(int minLargeMessageSize);
+
+   int getConsumerWindowSize();
+
+   void setConsumerWindowSize(int consumerWindowSize);
+
+   int getConsumerMaxRate();
+
+   void setConsumerMaxRate(int consumerMaxRate);
+
+   int getProducerWindowSize();
+
+   void setProducerWindowSize(int producerWindowSize);
+
+   int getProducerMaxRate();
+
+   void setProducerMaxRate(int producerMaxRate);
+
+   boolean isBlockOnAcknowledge();
+
+   void setBlockOnAcknowledge(boolean blockOnAcknowledge);
+
+   boolean isBlockOnPersistentSend();
+
+   void setBlockOnPersistentSend(boolean blockOnPersistentSend);
+
+   boolean isBlockOnNonPersistentSend();
+
+   void setBlockOnNonPersistentSend(boolean blockOnNonPersistentSend);
+
+   boolean isAutoGroup();
+
+   void setAutoGroup(boolean autoGroup);
+
+   boolean isPreAcknowledge();
+
+   void setPreAcknowledge(boolean preAcknowledge);
+
+   String getLoadBalancingPolicyClassName();
+
+   void setLoadBalancingPolicyClassName(String loadBalancingPolicyClassName);
+
+   int getTransactionBatchSize();
+
+   void setTransactionBatchSize(int transactionBatchSize);
+
+   int getDupsOKBatchSize();
+
+   void setDupsOKBatchSize(int dupsOKBatchSize);
+
+   long getInitialWaitTimeout();
+
+   void setInitialWaitTimeout(long initialWaitTimeout);
+
+   boolean isUseGlobalPools();
+
+   void setUseGlobalPools(boolean useGlobalPools);
+
+   int getScheduledThreadPoolMaxSize();
+
+   void setScheduledThreadPoolMaxSize(int scheduledThreadPoolMaxSize);
+
+   int getThreadPoolMaxSize();
+
+   void setThreadPoolMaxSize(int threadPoolMaxSize);
+
+   long getRetryInterval();
+
+   void setRetryInterval(long retryInterval);
+
+   double getRetryIntervalMultiplier();
+
+   void setRetryIntervalMultiplier(double retryIntervalMultiplier);
+
+   long getMaxRetryInterval();
+
+   void setMaxRetryInterval(long maxRetryInterval);
+
+   int getReconnectAttempts();
+
+   void setReconnectAttempts(int reconnectAttempts);
+
+   boolean isFailoverOnServerShutdown();
+
+   void setFailoverOnServerShutdown(boolean failoverOnServerShutdown);
+
+}

Added: trunk/src/main/org/hornetq/jms/server/config/JMSConfiguration.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/config/JMSConfiguration.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/jms/server/config/JMSConfiguration.java	2009-10-02 12:41:40 UTC (rev 8033)
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.server.config;
+
+import java.util.List;
+
+import javax.naming.Context;
+
+/**
+ * A JMSConfiguration
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public interface JMSConfiguration
+{
+   void setContext(Context context);
+   Context getContext();
+   
+   List<QueueConfiguration> getQueueConfigurations();
+   List<TopicConfiguration> getTopicConfigurations();
+   List<ConnectionFactoryConfiguration> getConnectionFactoryConfigurations();
+}

Added: trunk/src/main/org/hornetq/jms/server/config/QueueConfiguration.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/config/QueueConfiguration.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/jms/server/config/QueueConfiguration.java	2009-10-02 12:41:40 UTC (rev 8033)
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.server.config;
+
+/**
+ * A QeueConfiguration
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public interface QueueConfiguration
+{
+   String getName();
+   String getSelector();
+   boolean isDurable();
+   String[] getBindings();
+}

Added: trunk/src/main/org/hornetq/jms/server/config/TopicConfiguration.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/config/TopicConfiguration.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/jms/server/config/TopicConfiguration.java	2009-10-02 12:41:40 UTC (rev 8033)
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.server.config;
+
+/**
+ * A TopicConfiguration
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ */
+public interface TopicConfiguration
+{
+   String getName();
+   String[] getBindings();
+}

Added: trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java	2009-10-02 12:41:40 UTC (rev 8033)
@@ -0,0 +1,485 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.server.config.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
+import org.hornetq.core.config.TransportConfiguration;
+import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
+import org.hornetq.utils.Pair;
+
+/**
+ * A ConnectionFactoryConfigurationImpl
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public class ConnectionFactoryConfigurationImpl implements ConnectionFactoryConfiguration
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   public final String[] bindings;
+
+   public final String name;
+
+   public String discoveryAddress;
+
+   public int discoveryPort;
+
+   public List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs;
+
+   public String clientID = null;
+
+   public long discoveryRefreshTimeout = ClientSessionFactoryImpl.DEFAULT_DISCOVERY_REFRESH_TIMEOUT;
+
+   public long clientFailureCheckPeriod = ClientSessionFactoryImpl.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD;
+
+   public long connectionTTL = ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
+
+   public long callTimeout = ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT;
+
+   public int maxConnections = ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
+
+   public boolean cacheLargeMessagesClient = ClientSessionFactoryImpl.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT;
+
+   public int minLargeMessageSize = ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
+
+   public int consumerWindowSize = ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+
+   public int consumerMaxRate = ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
+
+   public int producerWindowSize = ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE;
+
+   public int producerMaxRate = ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+
+   public boolean blockOnAcknowledge = ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
+
+   public boolean blockOnPersistentSend = ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND;
+
+   public boolean blockOnNonPersistentSend = ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
+
+   public boolean autoGroup = ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
+
+   public boolean preAcknowledge = ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
+
+   public String loadBalancingPolicyClassName = ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
+
+   public int transactionBatchSize = ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
+
+   public int dupsOKBatchSize = ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
+
+   public long initialWaitTimeout = ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT;
+
+   public boolean useGlobalPools = ClientSessionFactoryImpl.DEFAULT_USE_GLOBAL_POOLS;
+
+   public int scheduledThreadPoolMaxSize = ClientSessionFactoryImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE;
+
+   public int threadPoolMaxSize = ClientSessionFactoryImpl.DEFAULT_THREAD_POOL_MAX_SIZE;
+
+   public long retryInterval = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
+
+   public double retryIntervalMultiplier = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
+
+   public long maxRetryInterval = ClientSessionFactoryImpl.DEFAULT_MAX_RETRY_INTERVAL;
+
+   public int reconnectAttempts = ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
+
+   public boolean failoverOnServerShutdown = ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public ConnectionFactoryConfigurationImpl(String name, String discoveryAddress, int discoveryPort, String... bindings)
+   {
+      this(name, bindings);
+      this.discoveryAddress = discoveryAddress;
+      this.discoveryPort = discoveryPort;
+   }
+
+   public ConnectionFactoryConfigurationImpl(String name, TransportConfiguration liveConfig, String... bindings)
+   {
+      this(name, liveConfig, null, bindings);
+   }
+
+   public ConnectionFactoryConfigurationImpl(String name, TransportConfiguration liveConfig, TransportConfiguration backupConfig, String... bindings)
+   {
+      this(name, bindings);
+      connectorConfigs = new ArrayList<Pair<TransportConfiguration,TransportConfiguration>>();
+      connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(liveConfig, backupConfig));
+   }
+
+   public ConnectionFactoryConfigurationImpl(String name, List<Pair<TransportConfiguration,TransportConfiguration>> transportConfigs, TransportConfiguration backupConfig, String... bindings)
+   {
+      this(name, bindings);
+      connectorConfigs = new ArrayList<Pair<TransportConfiguration,TransportConfiguration>>();
+      connectorConfigs.addAll(transportConfigs);
+   }
+
+   private ConnectionFactoryConfigurationImpl(String name, String... bindings)
+   {
+      this.name = name;
+      this.bindings = new String[bindings.length];
+      System.arraycopy(bindings, 0, this.bindings, 0, bindings.length);
+   }
+
+   // ConnectionFactoryConfiguration implementation -----------------
+
+   public String[] getBindings()
+   {
+      return bindings;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public String getDiscoveryAddress()
+   {
+      return discoveryAddress;
+   }
+
+   public void setDiscoveryAddress(String discoveryAddress)
+   {
+      this.discoveryAddress = discoveryAddress;
+   }
+
+   public int getDiscoveryPort()
+   {
+      return discoveryPort;
+   }
+
+   public void setDiscoveryPort(int discoveryPort)
+   {
+      this.discoveryPort = discoveryPort;
+   }
+
+   public List<Pair<TransportConfiguration, TransportConfiguration>> getConnectorConfigs()
+   {
+      return connectorConfigs;
+   }
+
+   public void setConnectorConfigs(List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs)
+   {
+      this.connectorConfigs = connectorConfigs;
+   }
+
+   public String getClientID()
+   {
+      return clientID;
+   }
+
+   public void setClientID(String clientID)
+   {
+      this.clientID = clientID;
+   }
+
+   public long getDiscoveryRefreshTimeout()
+   {
+      return discoveryRefreshTimeout;
+   }
+
+   public void setDiscoveryRefreshTimeout(long discoveryRefreshTimeout)
+   {
+      this.discoveryRefreshTimeout = discoveryRefreshTimeout;
+   }
+
+   public long getClientFailureCheckPeriod()
+   {
+      return clientFailureCheckPeriod;
+   }
+
+   public void setClientFailureCheckPeriod(long clientFailureCheckPeriod)
+   {
+      this.clientFailureCheckPeriod = clientFailureCheckPeriod;
+   }
+
+   public long getConnectionTTL()
+   {
+      return connectionTTL;
+   }
+
+   public void setConnectionTTL(long connectionTTL)
+   {
+      this.connectionTTL = connectionTTL;
+   }
+
+   public long getCallTimeout()
+   {
+      return callTimeout;
+   }
+
+   public void setCallTimeout(long callTimeout)
+   {
+      this.callTimeout = callTimeout;
+   }
+
+   public int getMaxConnections()
+   {
+      return maxConnections;
+   }
+
+   public void setMaxConnections(int maxConnections)
+   {
+      this.maxConnections = maxConnections;
+   }
+
+   public boolean isCacheLargeMessagesClient()
+   {
+      return cacheLargeMessagesClient;
+   }
+
+   public void setCacheLargeMessagesClient(boolean cacheLargeMessagesClient)
+   {
+      this.cacheLargeMessagesClient = cacheLargeMessagesClient;
+   }
+
+   public int getMinLargeMessageSize()
+   {
+      return minLargeMessageSize;
+   }
+
+   public void setMinLargeMessageSize(int minLargeMessageSize)
+   {
+      this.minLargeMessageSize = minLargeMessageSize;
+   }
+
+   public int getConsumerWindowSize()
+   {
+      return consumerWindowSize;
+   }
+
+   public void setConsumerWindowSize(int consumerWindowSize)
+   {
+      this.consumerWindowSize = consumerWindowSize;
+   }
+
+   public int getConsumerMaxRate()
+   {
+      return consumerMaxRate;
+   }
+
+   public void setConsumerMaxRate(int consumerMaxRate)
+   {
+      this.consumerMaxRate = consumerMaxRate;
+   }
+
+   public int getProducerWindowSize()
+   {
+      return producerWindowSize;
+   }
+
+   public void setProducerWindowSize(int producerWindowSize)
+   {
+      this.producerWindowSize = producerWindowSize;
+   }
+
+   public int getProducerMaxRate()
+   {
+      return producerMaxRate;
+   }
+
+   public void setProducerMaxRate(int producerMaxRate)
+   {
+      this.producerMaxRate = producerMaxRate;
+   }
+
+   public boolean isBlockOnAcknowledge()
+   {
+      return blockOnAcknowledge;
+   }
+
+   public void setBlockOnAcknowledge(boolean blockOnAcknowledge)
+   {
+      this.blockOnAcknowledge = blockOnAcknowledge;
+   }
+
+   public boolean isBlockOnPersistentSend()
+   {
+      return blockOnPersistentSend;
+   }
+
+   public void setBlockOnPersistentSend(boolean blockOnPersistentSend)
+   {
+      this.blockOnPersistentSend = blockOnPersistentSend;
+   }
+
+   public boolean isBlockOnNonPersistentSend()
+   {
+      return blockOnNonPersistentSend;
+   }
+
+   public void setBlockOnNonPersistentSend(boolean blockOnNonPersistentSend)
+   {
+      this.blockOnNonPersistentSend = blockOnNonPersistentSend;
+   }
+
+   public boolean isAutoGroup()
+   {
+      return autoGroup;
+   }
+
+   public void setAutoGroup(boolean autoGroup)
+   {
+      this.autoGroup = autoGroup;
+   }
+
+   public boolean isPreAcknowledge()
+   {
+      return preAcknowledge;
+   }
+
+   public void setPreAcknowledge(boolean preAcknowledge)
+   {
+      this.preAcknowledge = preAcknowledge;
+   }
+
+   public String getLoadBalancingPolicyClassName()
+   {
+      return loadBalancingPolicyClassName;
+   }
+
+   public void setLoadBalancingPolicyClassName(String loadBalancingPolicyClassName)
+   {
+      this.loadBalancingPolicyClassName = loadBalancingPolicyClassName;
+   }
+
+   public int getTransactionBatchSize()
+   {
+      return transactionBatchSize;
+   }
+
+   public void setTransactionBatchSize(int transactionBatchSize)
+   {
+      this.transactionBatchSize = transactionBatchSize;
+   }
+
+   public int getDupsOKBatchSize()
+   {
+      return dupsOKBatchSize;
+   }
+
+   public void setDupsOKBatchSize(int dupsOKBatchSize)
+   {
+      this.dupsOKBatchSize = dupsOKBatchSize;
+   }
+
+   public long getInitialWaitTimeout()
+   {
+      return initialWaitTimeout;
+   }
+
+   public void setInitialWaitTimeout(long initialWaitTimeout)
+   {
+      this.initialWaitTimeout = initialWaitTimeout;
+   }
+
+   public boolean isUseGlobalPools()
+   {
+      return useGlobalPools;
+   }
+
+   public void setUseGlobalPools(boolean useGlobalPools)
+   {
+      this.useGlobalPools = useGlobalPools;
+   }
+
+   public int getScheduledThreadPoolMaxSize()
+   {
+      return scheduledThreadPoolMaxSize;
+   }
+
+   public void setScheduledThreadPoolMaxSize(int scheduledThreadPoolMaxSize)
+   {
+      this.scheduledThreadPoolMaxSize = scheduledThreadPoolMaxSize;
+   }
+
+   public int getThreadPoolMaxSize()
+   {
+      return threadPoolMaxSize;
+   }
+
+   public void setThreadPoolMaxSize(int threadPoolMaxSize)
+   {
+      this.threadPoolMaxSize = threadPoolMaxSize;
+   }
+
+   public long getRetryInterval()
+   {
+      return retryInterval;
+   }
+
+   public void setRetryInterval(long retryInterval)
+   {
+      this.retryInterval = retryInterval;
+   }
+
+   public double getRetryIntervalMultiplier()
+   {
+      return retryIntervalMultiplier;
+   }
+
+   public void setRetryIntervalMultiplier(double retryIntervalMultiplier)
+   {
+      this.retryIntervalMultiplier = retryIntervalMultiplier;
+   }
+
+   public long getMaxRetryInterval()
+   {
+      return maxRetryInterval;
+   }
+
+   public void setMaxRetryInterval(long maxRetryInterval)
+   {
+      this.maxRetryInterval = maxRetryInterval;
+   }
+
+   public int getReconnectAttempts()
+   {
+      return reconnectAttempts;
+   }
+
+   public void setReconnectAttempts(int reconnectAttempts)
+   {
+      this.reconnectAttempts = reconnectAttempts;
+   }
+
+   public boolean isFailoverOnServerShutdown()
+   {
+      return failoverOnServerShutdown;
+   }
+
+   public void setFailoverOnServerShutdown(boolean failoverOnServerShutdown)
+   {
+      this.failoverOnServerShutdown = failoverOnServerShutdown;
+   }
+
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Added: trunk/src/main/org/hornetq/jms/server/config/impl/JMSConfigurationImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/config/impl/JMSConfigurationImpl.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/jms/server/config/impl/JMSConfigurationImpl.java	2009-10-02 12:41:40 UTC (rev 8033)
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.server.config.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.Context;
+
+import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
+import org.hornetq.jms.server.config.JMSConfiguration;
+import org.hornetq.jms.server.config.QueueConfiguration;
+import org.hornetq.jms.server.config.TopicConfiguration;
+
+/**
+ * A JMSConfigurationImpl
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public class JMSConfigurationImpl implements JMSConfiguration
+{
+
+   private final List<ConnectionFactoryConfiguration> connectionFactoryConfigurations = new ArrayList<ConnectionFactoryConfiguration>();
+
+   private final List<QueueConfiguration> queueConfigurations = new ArrayList<QueueConfiguration>();
+
+   private final List<TopicConfiguration> topicConfigurations = new ArrayList<TopicConfiguration>();
+
+   private Context context = null;
+   
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public JMSConfigurationImpl()
+   {
+   }
+
+   public JMSConfigurationImpl(final List<ConnectionFactoryConfiguration> connectionFactoryConfigurations,
+                               final List<QueueConfiguration> queueConfigurations,
+                               final List<TopicConfiguration> topicConfigurations)
+   {
+      this.connectionFactoryConfigurations.addAll(connectionFactoryConfigurations);
+      this.queueConfigurations.addAll(queueConfigurations);
+      this.topicConfigurations.addAll(topicConfigurations);
+   }
+
+   // JMSConfiguration implementation -------------------------------
+
+   public List<ConnectionFactoryConfiguration> getConnectionFactoryConfigurations()
+   {
+      return connectionFactoryConfigurations;
+   }
+
+   public List<QueueConfiguration> getQueueConfigurations()
+   {
+      return queueConfigurations;
+   }
+
+   public List<TopicConfiguration> getTopicConfigurations()
+   {
+      return topicConfigurations;
+   }
+
+   public Context getContext()
+   {
+      return context;
+   }
+   
+   public void setContext(Context context)
+   {
+      this.context = context;
+   }
+   
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Added: trunk/src/main/org/hornetq/jms/server/config/impl/QueueConfigurationImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/config/impl/QueueConfigurationImpl.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/jms/server/config/impl/QueueConfigurationImpl.java	2009-10-02 12:41:40 UTC (rev 8033)
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.server.config.impl;
+
+import org.hornetq.jms.server.config.QueueConfiguration;
+
+/**
+ * A QueueConfigurationImpl
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public class QueueConfigurationImpl implements QueueConfiguration
+{
+   
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final String name;
+   private final String selector;
+   private final boolean durable;
+   private final String[] bindings;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public QueueConfigurationImpl(String name, String selector, boolean durable, String... bindings)
+   {
+      this.name = name;
+      this.selector = selector;
+      this.durable = durable;
+      this.bindings = new String[bindings.length];
+      System.arraycopy(bindings, 0, this.bindings, 0, bindings.length);
+   }
+   
+   // QueueConfiguration implementation -----------------------------
+   
+   public String[] getBindings()
+   {
+      return bindings;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public String getSelector()
+   {
+      return selector;
+   }
+
+   public boolean isDurable()
+   {
+      return durable;
+   }
+   
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Added: trunk/src/main/org/hornetq/jms/server/config/impl/TopicConfigurationImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/config/impl/TopicConfigurationImpl.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/jms/server/config/impl/TopicConfigurationImpl.java	2009-10-02 12:41:40 UTC (rev 8033)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.server.config.impl;
+
+import org.hornetq.jms.server.config.TopicConfiguration;
+
+/**
+ * A TopicConfigurationImpl
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public class TopicConfigurationImpl implements TopicConfiguration
+{
+   
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private final String name;
+   private final String[] bindings;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public TopicConfigurationImpl(String name, String... bindings)
+   {
+      this.name = name;
+      this.bindings = new String[bindings.length];
+      System.arraycopy(bindings, 0, this.bindings, 0, bindings.length);
+   }
+   
+   // TopicConfiguration implementation -----------------------------
+   
+   public String[] getBindings()
+   {
+      return bindings;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+   
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Modified: trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java	2009-10-02 12:36:05 UTC (rev 8032)
+++ trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java	2009-10-02 12:41:40 UTC (rev 8033)
@@ -14,6 +14,7 @@
 package org.hornetq.jms.server.impl;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -37,6 +38,10 @@
 import org.hornetq.jms.client.HornetQConnectionFactory;
 import org.hornetq.jms.client.SelectorTranslator;
 import org.hornetq.jms.server.JMSServerManager;
+import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
+import org.hornetq.jms.server.config.JMSConfiguration;
+import org.hornetq.jms.server.config.QueueConfiguration;
+import org.hornetq.jms.server.config.TopicConfiguration;
 import org.hornetq.jms.server.management.JMSManagementService;
 import org.hornetq.jms.server.management.impl.JMSManagementServiceImpl;
 import org.hornetq.utils.Pair;
@@ -79,9 +84,11 @@
    private DeploymentManager deploymentManager;
 
    private final String configFileName;
-   
+
    private boolean contextSet;
-   
+
+   private JMSConfiguration config;
+
    public JMSServerManagerImpl(final HornetQServer server) throws Exception
    {
       this.server = server;
@@ -96,6 +103,15 @@
       this.configFileName = configFileName;
    }
 
+   public JMSServerManagerImpl(final HornetQServer server, final JMSConfiguration configuration) throws Exception
+   {
+      this.server = server;
+
+      this.configFileName = null;
+
+      this.config = configuration;
+   }
+
    // ActivateCallback implementation -------------------------------------
 
    public synchronized void activated()
@@ -118,6 +134,8 @@
          jmsDeployer.start();
 
          deploymentManager.start();
+
+         deploy();
       }
       catch (Exception e)
       {
@@ -709,4 +727,112 @@
       }
       destinations.get(destination).add(jndiBinding);
    }
+
+   private void deploy() throws Exception
+   {
+      if (config == null)
+      {
+         return;
+      }
+      
+      if (config.getContext() != null)
+      {
+         setContext(config.getContext());
+      }
+
+      List<ConnectionFactoryConfiguration> connectionFactoryConfigurations = config.getConnectionFactoryConfigurations();
+      for (ConnectionFactoryConfiguration config : connectionFactoryConfigurations)
+      {
+         if (config.getDiscoveryAddress() != null)
+         {
+            createConnectionFactory(config.getName(),
+                                    config.getDiscoveryAddress(),
+                                    config.getDiscoveryPort(),
+                                    config.getClientID(),
+                                    config.getDiscoveryRefreshTimeout(),
+                                    config.getClientFailureCheckPeriod(),
+                                    config.getConnectionTTL(),
+                                    config.getCallTimeout(),
+                                    config.getMaxConnections(),
+                                    config.isCacheLargeMessagesClient(),
+                                    config.getMinLargeMessageSize(),
+                                    config.getConsumerWindowSize(),
+                                    config.getConsumerMaxRate(),
+                                    config.getProducerWindowSize(),
+                                    config.getProducerMaxRate(),
+                                    config.isBlockOnAcknowledge(),
+                                    config.isBlockOnPersistentSend(),
+                                    config.isBlockOnNonPersistentSend(),
+                                    config.isAutoGroup(),
+                                    config.isPreAcknowledge(),
+                                    config.getLoadBalancingPolicyClassName(),
+                                    config.getTransactionBatchSize(),
+                                    config.getDupsOKBatchSize(),
+                                    config.getInitialWaitTimeout(),
+                                    config.isUseGlobalPools(),
+                                    config.getScheduledThreadPoolMaxSize(),
+                                    config.getThreadPoolMaxSize(),
+                                    config.getRetryInterval(),
+                                    config.getRetryIntervalMultiplier(),
+                                    config.getMaxRetryInterval(),
+                                    config.getReconnectAttempts(),
+                                    config.isFailoverOnServerShutdown(),
+                                    Arrays.asList(config.getBindings()));
+         }
+         else
+         {
+            createConnectionFactory(config.getName(),
+                                    config.getConnectorConfigs(),
+                                    config.getClientID(),
+                                    config.getClientFailureCheckPeriod(),
+                                    config.getConnectionTTL(),
+                                    config.getCallTimeout(),
+                                    config.getMaxConnections(),
+                                    config.isCacheLargeMessagesClient(),
+                                    config.getMinLargeMessageSize(),
+                                    config.getConsumerWindowSize(),
+                                    config.getConsumerMaxRate(),
+                                    config.getProducerWindowSize(),
+                                    config.getProducerMaxRate(),
+                                    config.isBlockOnAcknowledge(),
+                                    config.isBlockOnPersistentSend(),
+                                    config.isBlockOnNonPersistentSend(),
+                                    config.isAutoGroup(),
+                                    config.isPreAcknowledge(),
+                                    config.getLoadBalancingPolicyClassName(),
+                                    config.getTransactionBatchSize(),
+                                    config.getDupsOKBatchSize(),
+                                    config.isUseGlobalPools(),
+                                    config.getScheduledThreadPoolMaxSize(),
+                                    config.getThreadPoolMaxSize(),
+                                    config.getRetryInterval(),
+                                    config.getRetryIntervalMultiplier(),
+                                    config.getMaxRetryInterval(),
+                                    config.getReconnectAttempts(),
+                                    config.isFailoverOnServerShutdown(),
+                                    Arrays.asList(config.getBindings()));
+         }
+      }
+
+      List<QueueConfiguration> queueConfigs = config.getQueueConfigurations();
+      for (QueueConfiguration config : queueConfigs)
+      {
+         String[] bindings = config.getBindings();
+         for (String binding : bindings)
+         {
+            createQueue(config.getName(), binding, config.getSelector(), config.isDurable());
+         }
+      }
+
+      List<TopicConfiguration> topicConfigs = config.getTopicConfigurations();
+      for (TopicConfiguration config : topicConfigs)
+      {
+         String[] bindings = config.getBindings();
+         for (String binding : bindings)
+         {
+            createTopic(config.getName(), binding);
+         }
+      }
+   }
+
 }

Added: trunk/tests/src/org/hornetq/tests/integration/jms/server/config/JMSConfigurationTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/server/config/JMSConfigurationTest.java	                        (rev 0)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/server/config/JMSConfigurationTest.java	2009-10-02 12:41:40 UTC (rev 8033)
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.jms.server.config;
+
+import static org.hornetq.tests.util.RandomUtil.randomString;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Queue;
+import javax.jms.Topic;
+import javax.naming.Context;
+
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.config.TransportConfiguration;
+import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.core.server.impl.HornetQServerImpl;
+import org.hornetq.jms.server.JMSServerManager;
+import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
+import org.hornetq.jms.server.config.JMSConfiguration;
+import org.hornetq.jms.server.config.TopicConfiguration;
+import org.hornetq.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
+import org.hornetq.jms.server.config.impl.JMSConfigurationImpl;
+import org.hornetq.jms.server.config.impl.QueueConfigurationImpl;
+import org.hornetq.jms.server.config.impl.TopicConfigurationImpl;
+import org.hornetq.jms.server.impl.JMSServerManagerImpl;
+import org.hornetq.tests.unit.util.InVMContext;
+import org.hornetq.tests.util.ServiceTestBase;
+
+/**
+ * A JMSConfigurationTest
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public class JMSConfigurationTest extends ServiceTestBase
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public void testSetupJMSConfiguration() throws Exception
+   {
+      Context context = new InVMContext();
+
+      Configuration coreConfiguration = createDefaultConfig(false);
+      HornetQServer coreServer = new HornetQServerImpl(coreConfiguration);
+
+      JMSConfiguration jmsConfiguration = new JMSConfigurationImpl();
+      jmsConfiguration.setContext(context);
+      TransportConfiguration connectorConfig = new TransportConfiguration(InVMConnectorFactory.class.getName());
+      ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl(randomString(),
+                                                                                       connectorConfig,
+                                                                                       "/cf/binding1",
+                                                                                       "/cf/binding2");
+      jmsConfiguration.getConnectionFactoryConfigurations().add(cfConfig);
+      QueueConfigurationImpl queueConfig = new QueueConfigurationImpl(randomString(),
+                                                                      null,
+                                                                      false,
+                                                                      "/queue/binding1",
+                                                                      "/queue/binding2");
+      jmsConfiguration.getQueueConfigurations().add(queueConfig);
+      TopicConfiguration topicConfig = new TopicConfigurationImpl(randomString(), "/topic/binding1", "/topic/binding2");
+      jmsConfiguration.getTopicConfigurations().add(topicConfig);
+
+      JMSServerManager server = new JMSServerManagerImpl(coreServer, jmsConfiguration);
+      server.start();
+
+      for (String binding : cfConfig.getBindings())
+      {
+         Object o = context.lookup(binding);
+         assertNotNull(o);
+         assertTrue(o instanceof ConnectionFactory);
+         ConnectionFactory cf = (ConnectionFactory)o;
+         Connection connection = cf.createConnection();
+         connection.close();
+      }
+
+      for (String binding : queueConfig.getBindings())
+      {
+         Object o = context.lookup(binding);
+         assertNotNull(o);
+         assertTrue(o instanceof Queue);
+         Queue queue = (Queue)o;
+         assertEquals(queueConfig.getName(), queue.getQueueName());
+      }
+
+      for (String binding : topicConfig.getBindings())
+      {
+         Object o = context.lookup(binding);
+         assertNotNull(o);
+         assertTrue(o instanceof Topic);
+         Topic topic = (Topic)o;
+         assertEquals(topicConfig.getName(), topic.getTopicName());
+      }
+
+      server.stop();
+   }
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}



More information about the hornetq-commits mailing list