Author: clebert.suconic(a)jboss.com
Date: 2010-02-05 20:13:06 -0500 (Fri, 05 Feb 2010)
New Revision: 8865
Modified:
trunk/src/main/org/hornetq/jms/server/JMSServerManager.java
trunk/src/main/org/hornetq/jms/server/config/ConnectionFactoryConfiguration.java
trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java
trunk/src/main/org/hornetq/jms/server/impl/JMSServerConfigParserImpl.java
trunk/src/main/org/hornetq/jms/server/impl/JMSServerDeployer.java
trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
trunk/tests/src/org/hornetq/tests/integration/jms/server/config/JMSServerConfigParserTest.java
Log:
Refactoring on parser for better integration with AS6
Modified: trunk/src/main/org/hornetq/jms/server/JMSServerManager.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/JMSServerManager.java 2010-02-04 22:18:08 UTC
(rev 8864)
+++ trunk/src/main/org/hornetq/jms/server/JMSServerManager.java 2010-02-06 01:13:06 UTC
(rev 8865)
@@ -21,6 +21,7 @@
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.core.server.HornetQComponent;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
/**
* The JMS Management interface.
@@ -202,6 +203,8 @@
boolean failoverOnServerShutdown,
String groupId,
List<String> jndiBindings) throws Exception;
+
+ void createConnectionFactory(ConnectionFactoryConfiguration cfConfig) throws
Exception;
/**
* destroys a connection factory.
Modified:
trunk/src/main/org/hornetq/jms/server/config/ConnectionFactoryConfiguration.java
===================================================================
---
trunk/src/main/org/hornetq/jms/server/config/ConnectionFactoryConfiguration.java 2010-02-04
22:18:08 UTC (rev 8864)
+++
trunk/src/main/org/hornetq/jms/server/config/ConnectionFactoryConfiguration.java 2010-02-06
01:13:06 UTC (rev 8865)
@@ -17,6 +17,7 @@
import org.hornetq.api.core.Pair;
import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.jms.server.JMSServerManager;
/**
* A ConnectionFactoryConfiguration
@@ -39,6 +40,34 @@
void setDiscoveryPort(int discoveryPort);
+
+ /**
+ * A Reference to the group configuration.
+ */
+ String getDiscoveryGroupName();
+
+ /**
+ * A Reference to the group configuration.
+ */
+ void setDiscoveryGroupName(String groupName);
+
+
+ /**
+ * A List of connector names that will be converted into ConnnectorConfigs.
+ * This is useful when using the method {@link
JMSServerManager#createConnectionFactory(ConnectionFactoryConfiguration)}
+ *
+ * @return
+ */
+ List<Pair<String, String>> getConnectorNames();
+
+ /**
+ * A List of connector names that will be converted into ConnnectorConfigs.
+ * This is useful when using the method {@link
JMSServerManager#createConnectionFactory(ConnectionFactoryConfiguration)}
+ *
+ * @return
+ */
+ void setConnectorNames(List<Pair<String, String>> connectors);
+
List<Pair<TransportConfiguration, TransportConfiguration>>
getConnectorConfigs();
void setConnectorConfigs(List<Pair<TransportConfiguration,
TransportConfiguration>> connectorConfigs);
Modified:
trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java
===================================================================
---
trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java 2010-02-04
22:18:08 UTC (rev 8864)
+++
trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java 2010-02-06
01:13:06 UTC (rev 8865)
@@ -37,11 +37,15 @@
private final String[] bindings;
private final String name;
+
+ private String discoveryGroupName;
private String discoveryAddress;
private int discoveryPort;
+ private List<Pair<String, String>> connectorNames;
+
private List<Pair<TransportConfiguration, TransportConfiguration>>
connectorConfigs;
private String clientID = null;
@@ -144,7 +148,7 @@
connectorConfigs.addAll(transportConfigs);
}
- private ConnectionFactoryConfigurationImpl(final String name, final String...
bindings)
+ public ConnectionFactoryConfigurationImpl(final String name, final String...
bindings)
{
this.name = name;
this.bindings = new String[bindings.length];
@@ -493,6 +497,39 @@
this.groupID = groupID;
}
+ /* (non-Javadoc)
+ * @see
org.hornetq.jms.server.config.ConnectionFactoryConfiguration#getConnectorNames()
+ */
+ public List<Pair<String, String>> getConnectorNames()
+ {
+ return connectorNames;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.hornetq.jms.server.config.ConnectionFactoryConfiguration#setConnectorNames(java.util.List)
+ */
+ public void setConnectorNames(List<Pair<String, String>> connectors)
+ {
+ this.connectorNames = connectors;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.hornetq.jms.server.config.ConnectionFactoryConfiguration#getDiscoveryGroupName()
+ */
+ public String getDiscoveryGroupName()
+ {
+ return discoveryGroupName;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.hornetq.jms.server.config.ConnectionFactoryConfiguration#setDiscoveryGroupName(java.lang.String)
+ */
+ public void setDiscoveryGroupName(String groupName)
+ {
+ this.discoveryGroupName = groupName;
+
+ }
+
// Public --------------------------------------------------------
// Package protected ---------------------------------------------
Modified: trunk/src/main/org/hornetq/jms/server/impl/JMSServerConfigParserImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/impl/JMSServerConfigParserImpl.java 2010-02-04
22:18:08 UTC (rev 8864)
+++ trunk/src/main/org/hornetq/jms/server/impl/JMSServerConfigParserImpl.java 2010-02-06
01:13:06 UTC (rev 8865)
@@ -21,12 +21,9 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.Pair;
-import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.HornetQClient;
-import org.hornetq.core.config.Configuration;
import org.hornetq.core.config.impl.Validators;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.server.cluster.DiscoveryGroupConfiguration;
import org.hornetq.jms.server.JMSServerConfigParser;
import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
import org.hornetq.jms.server.config.JMSConfiguration;
@@ -60,17 +57,10 @@
// Attributes ----------------------------------------------------
- private final Configuration configuration;
-
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
- public JMSServerConfigParserImpl(final Configuration configuration)
- {
- this.configuration = configuration;
- }
-
// Public --------------------------------------------------------
/**
@@ -317,8 +307,8 @@
Validators.GT_ZERO);
String groupid = XMLConfigurationUtil.getString(e, "group-id", null,
Validators.NO_CHECK);
List<String> jndiBindings = new ArrayList<String>();
- List<Pair<TransportConfiguration, TransportConfiguration>>
connectorConfigs = new ArrayList<Pair<TransportConfiguration,
TransportConfiguration>>();
- DiscoveryGroupConfiguration discoveryGroupConfiguration = null;
+ List<Pair<String, String>> connectorNames = new
ArrayList<Pair<String,String>>();
+ String discoveryGroupName = null;
NodeList children = node.getChildNodes();
@@ -349,53 +339,26 @@
if (JMSServerDeployer.CONNECTOR_REF_ELEMENT.equals(entry.getNodeName()))
{
String connectorName =
entry.getAttributes().getNamedItem("connector-name").getNodeValue();
- TransportConfiguration connector =
configuration.getConnectorConfigurations().get(connectorName);
- if (connector == null)
- {
- JMSServerConfigParserImpl.log.warn("There is no connector with
name '" + connectorName +
- "' deployed.");
- throw new HornetQException(HornetQException.ILLEGAL_STATE,
- "There is no connector with name
'" + connectorName + "' deployed.");
- }
+ String backupConnectorName = null;
- TransportConfiguration backupConnector = null;
Node backupNode =
entry.getAttributes().getNamedItem("backup-connector-name");
if (backupNode != null)
{
- String backupConnectorName = backupNode.getNodeValue();
- backupConnector =
configuration.getConnectorConfigurations().get(backupConnectorName);
-
- if (backupConnector == null)
- {
- JMSServerConfigParserImpl.log.warn("There is no backup
connector with name '" + backupConnectorName +
- "' deployed.");
- throw new HornetQException(HornetQException.ILLEGAL_STATE,
- "There is no backup connector
with name '" + backupConnectorName +
- "'
deployed.");
- }
+ backupConnectorName = backupNode.getNodeValue();
}
-
- connectorConfigs.add(new Pair<TransportConfiguration,
TransportConfiguration>(connector,
-
backupConnector));
+
+
+ connectorNames.add(new Pair<String, String>(connectorName,
backupConnectorName));
+
+
}
}
}
else if (JMSServerDeployer.DISCOVERY_GROUP_ELEMENT.equals(child.getNodeName()))
{
- String discoveryGroupName =
child.getAttributes().getNamedItem("discovery-group-name").getNodeValue();
+ discoveryGroupName =
child.getAttributes().getNamedItem("discovery-group-name").getNodeValue();
- discoveryGroupConfiguration =
configuration.getDiscoveryGroupConfigurations().get(discoveryGroupName);
-
- if (discoveryGroupConfiguration == null)
- {
- JMSServerConfigParserImpl.log.warn("There is no discovery group with
name '" + discoveryGroupName +
- "' deployed.");
-
- throw new HornetQException(HornetQException.ILLEGAL_STATE,
- "There is no discovery group with name
'" + discoveryGroupName +
- "' deployed.");
- }
}
}
@@ -403,13 +366,17 @@
String[] strbindings = jndiBindings.toArray(new String[jndiBindings.size()]);
- if (discoveryGroupConfiguration != null)
+ if (discoveryGroupName != null)
{
- cfConfig = newCF(name, discoveryInitialWaitTimeout, discoveryGroupConfiguration,
strbindings);
+ cfConfig = new ConnectionFactoryConfigurationImpl(name,
+ strbindings);
+ cfConfig.setInitialWaitTimeout(discoveryInitialWaitTimeout);
+ cfConfig.setDiscoveryGroupName(discoveryGroupName);
}
else
{
- cfConfig = newCF(name, connectorConfigs, strbindings);
+ cfConfig = new ConnectionFactoryConfigurationImpl(name, strbindings);
+ cfConfig.setConnectorNames(connectorNames);
}
cfConfig.setInitialWaitTimeout(discoveryInitialWaitTimeout);
@@ -444,47 +411,9 @@
return cfConfig;
}
- /**
- * hook for integration layers
- * @param name
- * @param connectorConfigs
- * @param strbindings
- * @return
- */
- protected ConnectionFactoryConfiguration newCF(final String name,
- final
List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
- final String[] strbindings)
- {
- ConnectionFactoryConfigurationImpl cfConfig;
- cfConfig = new ConnectionFactoryConfigurationImpl(name, connectorConfigs,
strbindings);
- return cfConfig;
- }
/**
* hook for integration layers
- * @param name
- * @param discoveryInitialWaitTimeout
- * @param discoveryGroupConfiguration
- * @param strbindings
- * @return
- */
- protected ConnectionFactoryConfigurationImpl newCF(final String name,
- final long
discoveryInitialWaitTimeout,
- final DiscoveryGroupConfiguration
discoveryGroupConfiguration,
- final String[] strbindings)
- {
- ConnectionFactoryConfigurationImpl cfConfig;
- cfConfig = new ConnectionFactoryConfigurationImpl(name,
-
discoveryGroupConfiguration.getGroupAddress(),
-
discoveryGroupConfiguration.getGroupPort(),
- strbindings);
-
cfConfig.setDiscoveryRefreshTimeout(discoveryGroupConfiguration.getRefreshTimeout());
- cfConfig.setInitialWaitTimeout(discoveryInitialWaitTimeout);
- return cfConfig;
- }
-
- /**
- * hook for integration layers
* @param topicName
* @param strBindings
* @return
Modified: trunk/src/main/org/hornetq/jms/server/impl/JMSServerDeployer.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/impl/JMSServerDeployer.java 2010-02-04 22:18:08
UTC (rev 8864)
+++ trunk/src/main/org/hornetq/jms/server/impl/JMSServerDeployer.java 2010-02-06 01:13:06
UTC (rev 8865)
@@ -71,7 +71,7 @@
configuration = config;
- parser = new JMSServerConfigParserImpl(configuration);
+ parser = new JMSServerConfigParserImpl();
}
/**
@@ -195,84 +195,7 @@
private void deployConnectionFactory(final Node node) throws Exception
{
ConnectionFactoryConfiguration cfConfig =
parser.parseConnectionFactoryConfiguration(node);
-
- ArrayList<String> listBindings = new ArrayList<String>();
- for (String str: cfConfig.getBindings())
- {
- listBindings.add(str);
- }
-
- if (cfConfig.getDiscoveryAddress() != null)
- {
- jmsServerControl.createConnectionFactory(cfConfig.getName(),
- cfConfig.getDiscoveryAddress(),
- cfConfig.getDiscoveryPort(),
- cfConfig.getClientID(),
- cfConfig.getDiscoveryRefreshTimeout(),
-
cfConfig.getClientFailureCheckPeriod(),
- cfConfig.getConnectionTTL(),
- cfConfig.getCallTimeout(),
- cfConfig.isCacheLargeMessagesClient(),
- cfConfig.getMinLargeMessageSize(),
- cfConfig.getConsumerWindowSize(),
- cfConfig.getConsumerMaxRate(),
- cfConfig.getConfirmationWindowSize(),
- cfConfig.getProducerWindowSize(),
- cfConfig.getProducerMaxRate(),
- cfConfig.isBlockOnAcknowledge(),
- cfConfig.isBlockOnDurableSend(),
- cfConfig.isBlockOnNonDurableSend(),
- cfConfig.isAutoGroup(),
- cfConfig.isPreAcknowledge(),
-
cfConfig.getLoadBalancingPolicyClassName(),
- cfConfig.getTransactionBatchSize(),
- cfConfig.getDupsOKBatchSize(),
- cfConfig.getInitialWaitTimeout(),
- cfConfig.isUseGlobalPools(),
-
cfConfig.getScheduledThreadPoolMaxSize(),
- cfConfig.getThreadPoolMaxSize(),
- cfConfig.getRetryInterval(),
- cfConfig.getRetryIntervalMultiplier(),
- cfConfig.getMaxRetryInterval(),
- cfConfig.getReconnectAttempts(),
- cfConfig.isFailoverOnServerShutdown(),
- cfConfig.getGroupID(),
- listBindings);
- }
- else
- {
- jmsServerControl.createConnectionFactory(cfConfig.getName(),
- cfConfig.getConnectorConfigs(),
- cfConfig.getClientID(),
-
cfConfig.getClientFailureCheckPeriod(),
- cfConfig.getConnectionTTL(),
- cfConfig.getCallTimeout(),
- cfConfig.isCacheLargeMessagesClient(),
- cfConfig.getMinLargeMessageSize(),
- cfConfig.getConsumerWindowSize(),
- cfConfig.getConsumerMaxRate(),
- cfConfig.getConfirmationWindowSize(),
- cfConfig.getProducerWindowSize(),
- cfConfig.getProducerMaxRate(),
- cfConfig.isBlockOnAcknowledge(),
- cfConfig.isBlockOnDurableSend(),
- cfConfig.isBlockOnNonDurableSend(),
- cfConfig.isAutoGroup(),
- cfConfig.isPreAcknowledge(),
-
cfConfig.getLoadBalancingPolicyClassName(),
- cfConfig.getTransactionBatchSize(),
- cfConfig.getDupsOKBatchSize(),
- cfConfig.isUseGlobalPools(),
-
cfConfig.getScheduledThreadPoolMaxSize(),
- cfConfig.getThreadPoolMaxSize(),
- cfConfig.getRetryInterval(),
- cfConfig.getRetryIntervalMultiplier(),
- cfConfig.getMaxRetryInterval(),
- cfConfig.getReconnectAttempts(),
- cfConfig.isFailoverOnServerShutdown(),
- cfConfig.getGroupID(),
- listBindings);
- }
+ jmsServerControl.createConnectionFactory(cfConfig);
}
Modified: trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2010-02-04
22:18:08 UTC (rev 8864)
+++ trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2010-02-06
01:13:06 UTC (rev 8865)
@@ -14,7 +14,6 @@
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;
@@ -26,15 +25,18 @@
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
+import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.Pair;
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.jms.HornetQJMSClient;
+import org.hornetq.core.config.Configuration;
import org.hornetq.core.deployers.DeploymentManager;
import org.hornetq.core.deployers.impl.FileDeploymentManager;
import org.hornetq.core.deployers.impl.XmlDeployer;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.server.ActivateCallback;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.core.server.cluster.DiscoveryGroupConfiguration;
import org.hornetq.jms.client.HornetQConnectionFactory;
import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.jms.client.SelectorTranslator;
@@ -357,7 +359,7 @@
HornetQConnectionFactory cf = connectionFactories.get(name);
if (cf == null)
{
- cf = (HornetQConnectionFactory)
HornetQJMSClient.createConnectionFactory(connectorConfigs);
+ cf =
(HornetQConnectionFactory)HornetQJMSClient.createConnectionFactory(connectorConfigs);
}
bindConnectionFactory(cf, name, jndiBindings);
@@ -372,7 +374,7 @@
HornetQConnectionFactory cf = connectionFactories.get(name);
if (cf == null)
{
- cf = (HornetQConnectionFactory)
HornetQJMSClient.createConnectionFactory(connectorConfigs);
+ cf =
(HornetQConnectionFactory)HornetQJMSClient.createConnectionFactory(connectorConfigs);
cf.setClientID(clientID);
}
@@ -415,7 +417,7 @@
HornetQConnectionFactory cf = connectionFactories.get(name);
if (cf == null)
{
- cf = (HornetQConnectionFactory)
HornetQJMSClient.createConnectionFactory(connectorConfigs);
+ cf =
(HornetQConnectionFactory)HornetQJMSClient.createConnectionFactory(connectorConfigs);
cf.setClientID(clientID);
cf.setClientFailureCheckPeriod(clientFailureCheckPeriod);
cf.setConnectionTTL(connectionTTL);
@@ -488,7 +490,7 @@
HornetQConnectionFactory cf = connectionFactories.get(name);
if (cf == null)
{
- cf = (HornetQConnectionFactory)
HornetQJMSClient.createConnectionFactory(discoveryAddress, discoveryPort);
+ cf =
(HornetQConnectionFactory)HornetQJMSClient.createConnectionFactory(discoveryAddress,
discoveryPort);
cf.setClientID(clientID);
cf.setDiscoveryRefreshTimeout(discoveryRefreshTimeout);
cf.setClientFailureCheckPeriod(clientFailureCheckPeriod);
@@ -532,7 +534,7 @@
HornetQConnectionFactory cf = connectionFactories.get(name);
if (cf == null)
{
- cf = (HornetQConnectionFactory)
HornetQJMSClient.createConnectionFactory(discoveryAddress, discoveryPort);
+ cf =
(HornetQConnectionFactory)HornetQJMSClient.createConnectionFactory(discoveryAddress,
discoveryPort);
}
bindConnectionFactory(cf, name, jndiBindings);
@@ -548,13 +550,100 @@
HornetQConnectionFactory cf = connectionFactories.get(name);
if (cf == null)
{
- cf = (HornetQConnectionFactory)
HornetQJMSClient.createConnectionFactory(discoveryAddress, discoveryPort);
+ cf =
(HornetQConnectionFactory)HornetQJMSClient.createConnectionFactory(discoveryAddress,
discoveryPort);
cf.setClientID(clientID);
}
bindConnectionFactory(cf, name, jndiBindings);
}
+ public synchronized void createConnectionFactory(final ConnectionFactoryConfiguration
cfConfig) throws Exception
+ {
+
+ ArrayList<String> listBindings = new ArrayList<String>();
+ for (String str : cfConfig.getBindings())
+ {
+ listBindings.add(str);
+ }
+
+ List<Pair<TransportConfiguration, TransportConfiguration>>
connectorConfigs = lookupConnectors(cfConfig);
+
+ lookupDiscovery(cfConfig);
+
+ if (cfConfig.getDiscoveryAddress() != null)
+ {
+ createConnectionFactory(cfConfig.getName(),
+ cfConfig.getDiscoveryAddress(),
+ cfConfig.getDiscoveryPort(),
+ cfConfig.getClientID(),
+ cfConfig.getDiscoveryRefreshTimeout(),
+ cfConfig.getClientFailureCheckPeriod(),
+ cfConfig.getConnectionTTL(),
+ cfConfig.getCallTimeout(),
+ cfConfig.isCacheLargeMessagesClient(),
+ cfConfig.getMinLargeMessageSize(),
+ cfConfig.getConsumerWindowSize(),
+ cfConfig.getConsumerMaxRate(),
+ cfConfig.getConfirmationWindowSize(),
+ cfConfig.getProducerWindowSize(),
+ cfConfig.getProducerMaxRate(),
+ cfConfig.isBlockOnAcknowledge(),
+ cfConfig.isBlockOnDurableSend(),
+ cfConfig.isBlockOnNonDurableSend(),
+ cfConfig.isAutoGroup(),
+ cfConfig.isPreAcknowledge(),
+ cfConfig.getLoadBalancingPolicyClassName(),
+ cfConfig.getTransactionBatchSize(),
+ cfConfig.getDupsOKBatchSize(),
+ cfConfig.getInitialWaitTimeout(),
+ cfConfig.isUseGlobalPools(),
+ cfConfig.getScheduledThreadPoolMaxSize(),
+ cfConfig.getThreadPoolMaxSize(),
+ cfConfig.getRetryInterval(),
+ cfConfig.getRetryIntervalMultiplier(),
+ cfConfig.getMaxRetryInterval(),
+ cfConfig.getReconnectAttempts(),
+ cfConfig.isFailoverOnServerShutdown(),
+ cfConfig.getGroupID(),
+ listBindings);
+ }
+ else
+ {
+ createConnectionFactory(cfConfig.getName(),
+ connectorConfigs,
+ cfConfig.getClientID(),
+ cfConfig.getClientFailureCheckPeriod(),
+ cfConfig.getConnectionTTL(),
+ cfConfig.getCallTimeout(),
+ cfConfig.isCacheLargeMessagesClient(),
+ cfConfig.getMinLargeMessageSize(),
+ cfConfig.getConsumerWindowSize(),
+ cfConfig.getConsumerMaxRate(),
+ cfConfig.getConfirmationWindowSize(),
+ cfConfig.getProducerWindowSize(),
+ cfConfig.getProducerMaxRate(),
+ cfConfig.isBlockOnAcknowledge(),
+ cfConfig.isBlockOnDurableSend(),
+ cfConfig.isBlockOnNonDurableSend(),
+ cfConfig.isAutoGroup(),
+ cfConfig.isPreAcknowledge(),
+ cfConfig.getLoadBalancingPolicyClassName(),
+ cfConfig.getTransactionBatchSize(),
+ cfConfig.getDupsOKBatchSize(),
+ cfConfig.isUseGlobalPools(),
+ cfConfig.getScheduledThreadPoolMaxSize(),
+ cfConfig.getThreadPoolMaxSize(),
+ cfConfig.getRetryInterval(),
+ cfConfig.getRetryIntervalMultiplier(),
+ cfConfig.getMaxRetryInterval(),
+ cfConfig.getReconnectAttempts(),
+ cfConfig.isFailoverOnServerShutdown(),
+ cfConfig.getGroupID(),
+ listBindings);
+ }
+
+ }
+
public synchronized void createConnectionFactory(final String name,
final TransportConfiguration liveTC,
final List<String>
jndiBindings) throws Exception
@@ -563,7 +652,7 @@
HornetQConnectionFactory cf = connectionFactories.get(name);
if (cf == null)
{
- cf = (HornetQConnectionFactory)
HornetQJMSClient.createConnectionFactory(liveTC);
+ cf =
(HornetQConnectionFactory)HornetQJMSClient.createConnectionFactory(liveTC);
}
bindConnectionFactory(cf, name, jndiBindings);
@@ -578,7 +667,7 @@
HornetQConnectionFactory cf = connectionFactories.get(name);
if (cf == null)
{
- cf = (HornetQConnectionFactory)
HornetQJMSClient.createConnectionFactory(liveTC);
+ cf =
(HornetQConnectionFactory)HornetQJMSClient.createConnectionFactory(liveTC);
cf.setClientID(clientID);
}
@@ -594,7 +683,7 @@
HornetQConnectionFactory cf = connectionFactories.get(name);
if (cf == null)
{
- cf = (HornetQConnectionFactory) HornetQJMSClient.createConnectionFactory(liveTC,
backupTC);
+ cf = (HornetQConnectionFactory)HornetQJMSClient.createConnectionFactory(liveTC,
backupTC);
}
bindConnectionFactory(cf, name, jndiBindings);
@@ -610,7 +699,7 @@
HornetQConnectionFactory cf = connectionFactories.get(name);
if (cf == null)
{
- cf = (HornetQConnectionFactory) HornetQJMSClient.createConnectionFactory(liveTC,
backupTC);
+ cf = (HornetQConnectionFactory)HornetQJMSClient.createConnectionFactory(liveTC,
backupTC);
cf.setClientID(clientID);
}
@@ -741,6 +830,36 @@
return true;
}
+ /**
+ * @param cfConfig
+ * @throws HornetQException
+ */
+ private void lookupDiscovery(final ConnectionFactoryConfiguration cfConfig) throws
HornetQException
+ {
+ if (cfConfig.getDiscoveryGroupName() != null)
+ {
+ Configuration configuration = server.getConfiguration();
+
+ DiscoveryGroupConfiguration discoveryGroupConfiguration = null;
+ discoveryGroupConfiguration = configuration.getDiscoveryGroupConfigurations()
+
.get(cfConfig.getDiscoveryGroupName());
+
+ if (discoveryGroupConfiguration == null)
+ {
+ JMSServerManagerImpl.log.warn("There is no discovery group with name
'" + cfConfig.getDiscoveryGroupName() +
+ "' deployed.");
+
+ throw new HornetQException(HornetQException.ILLEGAL_STATE,
+ "There is no discovery group with name
'" + cfConfig.getDiscoveryGroupName() +
+ "' deployed.");
+ }
+
+ cfConfig.setDiscoveryAddress(discoveryGroupConfiguration.getGroupAddress());
+ cfConfig.setDiscoveryPort(discoveryGroupConfiguration.getGroupPort());
+
+ }
+ }
+
private void addToDestinationBindings(final String destination, final String
jndiBinding)
{
if (destinations.get(destination) == null)
@@ -765,77 +884,7 @@
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.isCacheLargeMessagesClient(),
- config.getMinLargeMessageSize(),
- config.getConsumerWindowSize(),
- config.getConsumerMaxRate(),
- config.getConfirmationWindowSize(),
- config.getProducerWindowSize(),
- config.getProducerMaxRate(),
- config.isBlockOnAcknowledge(),
- config.isBlockOnDurableSend(),
- config.isBlockOnNonDurableSend(),
- 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(),
- config.getGroupID(),
- Arrays.asList(config.getBindings()));
- }
- else
- {
- createConnectionFactory(config.getName(),
- config.getConnectorConfigs(),
- config.getClientID(),
- config.getClientFailureCheckPeriod(),
- config.getConnectionTTL(),
- config.getCallTimeout(),
- config.isCacheLargeMessagesClient(),
- config.getMinLargeMessageSize(),
- config.getConsumerWindowSize(),
- config.getConsumerMaxRate(),
- config.getConfirmationWindowSize(),
- config.getProducerWindowSize(),
- config.getProducerMaxRate(),
- config.isBlockOnAcknowledge(),
- config.isBlockOnDurableSend(),
- config.isBlockOnNonDurableSend(),
- 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(),
- config.getGroupID(),
- Arrays.asList(config.getBindings()));
- }
+ createConnectionFactory(config);
}
List<QueueConfiguration> queueConfigs = config.getQueueConfigurations();
@@ -859,4 +908,57 @@
}
}
+ /**
+ * @param cfConfig
+ * @return
+ * @throws HornetQException
+ */
+ private List<Pair<TransportConfiguration, TransportConfiguration>>
lookupConnectors(final ConnectionFactoryConfiguration cfConfig) throws HornetQException
+ {
+ if (cfConfig.getConnectorConfigs() != null)
+ {
+ return cfConfig.getConnectorConfigs();
+ }
+ else
+ {
+ Configuration configuration = server.getConfiguration();
+ List<Pair<TransportConfiguration, TransportConfiguration>>
connectorConfigs = new ArrayList<Pair<TransportConfiguration,
TransportConfiguration>>();
+
+ for (Pair<String, String> configConnector : cfConfig.getConnectorNames())
+ {
+ String connectorName = configConnector.a;
+ String backupConnectorName = configConnector.b;
+
+ TransportConfiguration connector =
configuration.getConnectorConfigurations().get(connectorName);
+
+ if (connector == null)
+ {
+ JMSServerManagerImpl.log.warn("There is no connector with name
'" + connectorName + "' deployed.");
+ throw new HornetQException(HornetQException.ILLEGAL_STATE,
+ "There is no connector with name
'" + connectorName + "' deployed.");
+ }
+
+ TransportConfiguration backupConnector = null;
+
+ if (backupConnectorName != null)
+ {
+ backupConnector =
configuration.getConnectorConfigurations().get(backupConnectorName);
+
+ if (backupConnector == null)
+ {
+ JMSServerManagerImpl.log.warn("There is no backup connector with
name '" + backupConnectorName +
+ "' deployed.");
+ throw new HornetQException(HornetQException.ILLEGAL_STATE,
+ "There is no backup connector with name
'" + backupConnectorName +
+ "' deployed.");
+ }
+ }
+
+ connectorConfigs.add(new Pair<TransportConfiguration,
TransportConfiguration>(connector, backupConnector));
+ }
+ return connectorConfigs;
+
+ }
+ }
+
}
Modified:
trunk/tests/src/org/hornetq/tests/integration/jms/server/config/JMSServerConfigParserTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/integration/jms/server/config/JMSServerConfigParserTest.java 2010-02-04
22:18:08 UTC (rev 8864)
+++
trunk/tests/src/org/hornetq/tests/integration/jms/server/config/JMSServerConfigParserTest.java 2010-02-06
01:13:06 UTC (rev 8865)
@@ -54,7 +54,7 @@
// anything so the parsing will work
config.getConnectorConfigurations().put("netty", new
TransportConfiguration());
- JMSServerConfigParser parser = new JMSServerConfigParserImpl(config);
+ JMSServerConfigParser parser = new JMSServerConfigParserImpl();
String conf = "hornetq-jms-for-JMSServerDeployerTest.xml";
URL confURL = Thread.currentThread().getContextClassLoader().getResource(conf);