Author: clebert.suconic(a)jboss.com
Date: 2010-02-10 09:15:24 -0500 (Wed, 10 Feb 2010)
New Revision: 8868
Added:
trunk/src/main/org/hornetq/core/deployers/impl/FileConfigurationParser.java
Modified:
trunk/src/main/org/hornetq/core/config/Configuration.java
trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java
trunk/src/main/org/hornetq/core/config/impl/FileConfiguration.java
trunk/src/main/org/hornetq/core/deployers/impl/AddressSettingsDeployer.java
trunk/src/main/org/hornetq/core/deployers/impl/QueueDeployer.java
trunk/src/main/org/hornetq/core/deployers/impl/SecurityDeployer.java
trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
trunk/src/main/org/hornetq/core/settings/impl/AddressSettings.java
trunk/tests/config/ConfigurationTest-full-config.xml
trunk/tests/src/org/hornetq/tests/unit/core/config/impl/FileConfigurationTest.java
Log:
Improvements on configuration and parsing for better integration with AS
Modified: trunk/src/main/org/hornetq/core/config/Configuration.java
===================================================================
--- trunk/src/main/org/hornetq/core/config/Configuration.java 2010-02-08 10:28:19 UTC (rev
8867)
+++ trunk/src/main/org/hornetq/core/config/Configuration.java 2010-02-10 14:15:24 UTC (rev
8868)
@@ -21,7 +21,7 @@
import org.hornetq.api.core.Interceptor;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
+import org.hornetq.core.security.Role;
import org.hornetq.core.server.JournalType;
import org.hornetq.core.server.cluster.BridgeConfiguration;
import org.hornetq.core.server.cluster.BroadcastGroupConfiguration;
@@ -30,6 +30,7 @@
import org.hornetq.core.server.cluster.DivertConfiguration;
import org.hornetq.core.server.cluster.QueueConfiguration;
import org.hornetq.core.server.group.impl.GroupingHandlerConfiguration;
+import org.hornetq.core.settings.impl.AddressSettings;
import org.hornetq.spi.core.logging.LogDelegateFactory;
/**
@@ -804,4 +805,27 @@
*/
void setMessageExpiryThreadPriority(int messageExpiryThreadPriority);
+ /**
+ *
+ * @return A list of AddressSettings per matching to be deployed to the address
settings repository
+ */
+ Map<String, AddressSettings> getAddressesSettings();
+
+ /**
+ * @param A list of AddressSettings per matching to be deployed to the address
settings repository
+ */
+ void setAddressesSettings(Map<String, AddressSettings> addressesSettings);
+
+ /**
+ *
+ * @param roles a list of roles per matching
+ */
+ void setSecurityRoles(Map<String, Set<Role>> roles);
+
+ /**
+ *
+ * @return a list of roles per matching
+ */
+ Map<String, Set<Role>> getSecurityRoles();
+
}
Modified: trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java 2010-02-08 10:28:19
UTC (rev 8867)
+++ trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java 2010-02-10 14:15:24
UTC (rev 8868)
@@ -25,6 +25,7 @@
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.logging.impl.JULLogDelegateFactory;
+import org.hornetq.core.security.Role;
import org.hornetq.core.server.JournalType;
import org.hornetq.core.server.cluster.BridgeConfiguration;
import org.hornetq.core.server.cluster.BroadcastGroupConfiguration;
@@ -33,6 +34,7 @@
import org.hornetq.core.server.cluster.DivertConfiguration;
import org.hornetq.core.server.cluster.QueueConfiguration;
import org.hornetq.core.server.group.impl.GroupingHandlerConfiguration;
+import org.hornetq.core.settings.impl.AddressSettings;
/**
* @author <a href="mailto:ataylor@redhat.com>Andy Taylor</a>
@@ -316,6 +318,10 @@
protected GroupingHandlerConfiguration groupingHandlerConfiguration;
+ private Map<String, AddressSettings> addressesSettings = new HashMap<String,
AddressSettings>();
+
+ private Map<String, Set<Role>> securitySettings = new HashMap<String,
Set<Role>>();
+
// Public -------------------------------------------------------------------------
public boolean isClustered()
@@ -805,10 +811,10 @@
{
return messageCounterSamplePeriod;
}
-
- public void setMessageCounterSamplePeriod(long period)
+
+ public void setMessageCounterSamplePeriod(final long period)
{
- this.messageCounterSamplePeriod = period;
+ messageCounterSamplePeriod = period;
}
public int getMessageCounterMaxDayHistory()
@@ -1277,4 +1283,36 @@
return true;
}
+ /* (non-Javadoc)
+ * @see org.hornetq.core.config.Configuration#getAddressesSettings()
+ */
+ public Map<String, AddressSettings> getAddressesSettings()
+ {
+ return addressesSettings;
+ }
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.config.Configuration#setAddressesSettings(java.util.Map)
+ */
+ public void setAddressesSettings(final Map<String, AddressSettings>
addressesSettings)
+ {
+ this.addressesSettings = addressesSettings;
+ }
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.config.Configuration#getSecurityRoles()
+ */
+ public Map<String, Set<Role>> getSecurityRoles()
+ {
+ return securitySettings;
+ }
+
+ /* (non-Javadoc)
+ * @see org.hornetq.core.config.Configuration#setSecuritySettings(java.util.Map)
+ */
+ public void setSecurityRoles(final Map<String, Set<Role>>
securitySettings)
+ {
+ this.securitySettings = securitySettings;
+ }
+
}
Modified: trunk/src/main/org/hornetq/core/config/impl/FileConfiguration.java
===================================================================
--- trunk/src/main/org/hornetq/core/config/impl/FileConfiguration.java 2010-02-08 10:28:19
UTC (rev 8867)
+++ trunk/src/main/org/hornetq/core/config/impl/FileConfiguration.java 2010-02-10 14:15:24
UTC (rev 8868)
@@ -16,29 +16,11 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.hornetq.api.core.Pair;
-import org.hornetq.api.core.SimpleString;
-import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.HornetQClient;
+import org.hornetq.core.deployers.impl.FileConfigurationParser;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.server.JournalType;
-import org.hornetq.core.server.cluster.BridgeConfiguration;
-import org.hornetq.core.server.cluster.BroadcastGroupConfiguration;
-import org.hornetq.core.server.cluster.ClusterConnectionConfiguration;
-import org.hornetq.core.server.cluster.DiscoveryGroupConfiguration;
-import org.hornetq.core.server.cluster.DivertConfiguration;
-import org.hornetq.core.server.group.impl.GroupingHandlerConfiguration;
-import org.hornetq.utils.XMLConfigurationUtil;
import org.hornetq.utils.XMLUtil;
import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
* ConfigurationImpl
@@ -57,8 +39,6 @@
private static final String DEFAULT_CONFIGURATION_URL =
"hornetq-configuration.xml";
- private static final String CONFIGURATION_SCHEMA_URL =
"schema/hornetq-configuration.xsd";
-
// For a bridge confirmations must be activated or send acknowledgements won't
return
public static final int DEFAULT_CONFIRMATION_WINDOW_SIZE = 1024 * 1024;
@@ -87,359 +67,13 @@
String xml = org.hornetq.utils.XMLUtil.readerToString(reader);
xml = XMLUtil.replaceSystemProps(xml);
Element e = org.hornetq.utils.XMLUtil.stringToElement(xml);
- org.hornetq.utils.XMLUtil.validate(e, FileConfiguration.CONFIGURATION_SCHEMA_URL);
+
+ FileConfigurationParser parser = new FileConfigurationParser();
- clustered = XMLConfigurationUtil.getBoolean(e, "clustered", clustered);
+ parser.parseMainConfig(e, this);
- backup = XMLConfigurationUtil.getBoolean(e, "backup", backup);
-
- sharedStore = XMLConfigurationUtil.getBoolean(e, "shared-store",
sharedStore);
-
- // Defaults to true when using FileConfiguration
- fileDeploymentEnabled = XMLConfigurationUtil.getBoolean(e,
"file-deployment-enabled", true);
-
- persistenceEnabled = XMLConfigurationUtil.getBoolean(e,
"persistence-enabled", persistenceEnabled);
-
- persistDeliveryCountBeforeDelivery = XMLConfigurationUtil.getBoolean(e,
-
"persist-delivery-count-before-delivery",
-
persistDeliveryCountBeforeDelivery);
-
- // NOTE! All the defaults come from the super class
-
- scheduledThreadPoolMaxSize = XMLConfigurationUtil.getInteger(e,
-
"scheduled-thread-pool-max-size",
-
scheduledThreadPoolMaxSize,
- Validators.GT_ZERO);
-
- threadPoolMaxSize = XMLConfigurationUtil.getInteger(e,
-
"thread-pool-max-size",
- threadPoolMaxSize,
-
Validators.MINUS_ONE_OR_GT_ZERO);
-
- securityEnabled = XMLConfigurationUtil.getBoolean(e, "security-enabled",
securityEnabled);
-
- jmxManagementEnabled = XMLConfigurationUtil.getBoolean(e,
"jmx-management-enabled", jmxManagementEnabled);
-
- jmxDomain = XMLConfigurationUtil.getString(e, "jmx-domain", jmxDomain,
Validators.NOT_NULL_OR_EMPTY);
-
- securityInvalidationInterval = XMLConfigurationUtil.getLong(e,
-
"security-invalidation-interval",
-
securityInvalidationInterval,
- Validators.GT_ZERO);
-
- connectionTTLOverride = XMLConfigurationUtil.getLong(e,
-
"connection-ttl-override",
- connectionTTLOverride,
-
Validators.MINUS_ONE_OR_GT_ZERO);
-
- asyncConnectionExecutionEnabled = XMLConfigurationUtil.getBoolean(e,
-
"async-connection-execution-enabled",
-
asyncConnectionExecutionEnabled);
-
- transactionTimeout = XMLConfigurationUtil.getLong(e,
- "transaction-timeout",
- transactionTimeout,
- Validators.GT_ZERO);
-
- transactionTimeoutScanPeriod = XMLConfigurationUtil.getLong(e,
-
"transaction-timeout-scan-period",
-
transactionTimeoutScanPeriod,
- Validators.GT_ZERO);
-
- messageExpiryScanPeriod = XMLConfigurationUtil.getLong(e,
-
"message-expiry-scan-period",
- messageExpiryScanPeriod,
- Validators.GT_ZERO);
-
- messageExpiryThreadPriority = XMLConfigurationUtil.getInteger(e,
-
"message-expiry-thread-priority",
-
messageExpiryThreadPriority,
-
Validators.THREAD_PRIORITY_RANGE);
-
- idCacheSize = XMLConfigurationUtil.getInteger(e, "id-cache-size",
idCacheSize, Validators.GT_ZERO);
-
- persistIDCache = XMLConfigurationUtil.getBoolean(e, "persist-id-cache",
persistIDCache);
-
- managementAddress = new SimpleString(XMLConfigurationUtil.getString(e,
-
"management-address",
-
managementAddress.toString(),
-
Validators.NOT_NULL_OR_EMPTY));
-
- managementNotificationAddress = new SimpleString(XMLConfigurationUtil.getString(e,
-
"management-notification-address",
-
managementNotificationAddress.toString(),
-
Validators.NOT_NULL_OR_EMPTY));
-
- clusterPassword = XMLConfigurationUtil.getString(e,
- "cluster-password",
- clusterPassword,
- Validators.NO_CHECK);
-
- clusterUser = XMLConfigurationUtil.getString(e,
- "cluster-user",
- clusterUser,
- Validators.NO_CHECK);
-
- logDelegateFactoryClassName = XMLConfigurationUtil.getString(e,
-
"log-delegate-factory-class-name",
-
logDelegateFactoryClassName,
-
Validators.NOT_NULL_OR_EMPTY);
-
- NodeList interceptorNodes =
e.getElementsByTagName("remoting-interceptors");
-
- ArrayList<String> interceptorList = new ArrayList<String>();
-
- if (interceptorNodes.getLength() > 0)
- {
- NodeList interceptors = interceptorNodes.item(0).getChildNodes();
-
- for (int i = 0; i < interceptors.getLength(); i++)
- {
- if
("class-name".equalsIgnoreCase(interceptors.item(i).getNodeName()))
- {
- String clazz = interceptors.item(i).getTextContent();
-
- interceptorList.add(clazz);
- }
- }
- }
-
- interceptorClassNames = interceptorList;
-
- NodeList backups = e.getElementsByTagName("backup-connector-ref");
-
- // There should be only one - this will be enforced by the DTD
-
- if (backups.getLength() > 0)
- {
- Node backupNode = backups.item(0);
-
- backupConnectorName =
backupNode.getAttributes().getNamedItem("connector-name").getNodeValue();
- }
-
- NodeList connectorNodes = e.getElementsByTagName("connector");
-
- for (int i = 0; i < connectorNodes.getLength(); i++)
- {
- Element connectorNode = (Element)connectorNodes.item(i);
-
- TransportConfiguration connectorConfig =
parseTransportConfiguration(connectorNode);
-
- if (connectorConfig.getName() == null)
- {
- FileConfiguration.log.warn("Cannot deploy a connector with no name
specified.");
-
- continue;
- }
-
- if (connectorConfigs.containsKey(connectorConfig.getName()))
- {
- FileConfiguration.log.warn("There is already a connector with name
" + connectorConfig.getName() +
- " deployed. This one will not be
deployed.");
-
- continue;
- }
-
- connectorConfigs.put(connectorConfig.getName(), connectorConfig);
- }
-
- NodeList acceptorNodes = e.getElementsByTagName("acceptor");
-
- for (int i = 0; i < acceptorNodes.getLength(); i++)
- {
- Element acceptorNode = (Element)acceptorNodes.item(i);
-
- TransportConfiguration acceptorConfig =
parseTransportConfiguration(acceptorNode);
-
- acceptorConfigs.add(acceptorConfig);
- }
-
- NodeList bgNodes = e.getElementsByTagName("broadcast-group");
-
- for (int i = 0; i < bgNodes.getLength(); i++)
- {
- Element bgNode = (Element)bgNodes.item(i);
-
- parseBroadcastGroupConfiguration(bgNode);
- }
-
- NodeList dgNodes = e.getElementsByTagName("discovery-group");
-
- for (int i = 0; i < dgNodes.getLength(); i++)
- {
- Element dgNode = (Element)dgNodes.item(i);
-
- parseDiscoveryGroupConfiguration(dgNode);
- }
-
- NodeList brNodes = e.getElementsByTagName("bridge");
-
- for (int i = 0; i < brNodes.getLength(); i++)
- {
- Element mfNode = (Element)brNodes.item(i);
-
- parseBridgeConfiguration(mfNode);
- }
-
- NodeList gaNodes = e.getElementsByTagName("grouping-handler");
-
- for (int i = 0; i < gaNodes.getLength(); i++)
- {
- Element gaNode = (Element)gaNodes.item(i);
-
- parseGroupingHandlerConfiguration(gaNode);
- }
-
- NodeList ccNodes = e.getElementsByTagName("cluster-connection");
-
- for (int i = 0; i < ccNodes.getLength(); i++)
- {
- Element ccNode = (Element)ccNodes.item(i);
-
- parseClusterConnectionConfiguration(ccNode);
- }
-
- NodeList dvNodes = e.getElementsByTagName("divert");
-
- for (int i = 0; i < dvNodes.getLength(); i++)
- {
- Element dvNode = (Element)dvNodes.item(i);
-
- parseDivertConfiguration(dvNode);
- }
-
- // Persistence config
-
- largeMessagesDirectory = XMLConfigurationUtil.getString(e,
-
"large-messages-directory",
- largeMessagesDirectory,
-
Validators.NOT_NULL_OR_EMPTY);
-
- bindingsDirectory = XMLConfigurationUtil.getString(e,
- "bindings-directory",
- bindingsDirectory,
- Validators.NOT_NULL_OR_EMPTY);
-
- createBindingsDir = XMLConfigurationUtil.getBoolean(e,
"create-bindings-dir", createBindingsDir);
-
- journalDirectory = XMLConfigurationUtil.getString(e,
- "journal-directory",
- journalDirectory,
- Validators.NOT_NULL_OR_EMPTY);
-
- pagingDirectory = XMLConfigurationUtil.getString(e,
- "paging-directory",
- pagingDirectory,
- Validators.NOT_NULL_OR_EMPTY);
-
- createJournalDir = XMLConfigurationUtil.getBoolean(e,
"create-journal-dir", createJournalDir);
-
- String s = XMLConfigurationUtil.getString(e, "journal-type",
journalType.toString(), Validators.JOURNAL_TYPE);
-
- if (s.equals(JournalType.NIO.toString()))
- {
- journalType = JournalType.NIO;
- }
- else if (s.equals(JournalType.ASYNCIO.toString()))
- {
- journalType = JournalType.ASYNCIO;
- }
-
- journalSyncTransactional = XMLConfigurationUtil.getBoolean(e,
-
"journal-sync-transactional",
-
journalSyncTransactional);
-
- journalSyncNonTransactional = XMLConfigurationUtil.getBoolean(e,
-
"journal-sync-non-transactional",
-
journalSyncNonTransactional);
-
- journalFileSize = XMLConfigurationUtil.getInteger(e, "journal-file-size",
journalFileSize, Validators.GT_ZERO);
-
- int journalBufferTimeout = XMLConfigurationUtil.getInteger(e,
-
"journal-buffer-timeout",
- journalType ==
JournalType.ASYNCIO ? ConfigurationImpl.DEFAULT_JOURNAL_BUFFER_TIMEOUT_AIO
-
: ConfigurationImpl.DEFAULT_JOURNAL_BUFFER_TIMEOUT_NIO,
- Validators.GT_ZERO);
-
- int journalBufferSize = XMLConfigurationUtil.getInteger(e,
-
"journal-buffer-size",
- journalType ==
JournalType.ASYNCIO ? ConfigurationImpl.DEFAULT_JOURNAL_BUFFER_SIZE_AIO
-
: ConfigurationImpl.DEFAULT_JOURNAL_BUFFER_SIZE_NIO,
- Validators.GT_ZERO);
-
- int journalMaxIO = XMLConfigurationUtil.getInteger(e,
- "journal-max-io",
- journalType ==
JournalType.ASYNCIO ? ConfigurationImpl.DEFAULT_JOURNAL_MAX_IO_AIO
-
: ConfigurationImpl.DEFAULT_JOURNAL_MAX_IO_NIO,
- Validators.GT_ZERO);
-
- if (journalType == JournalType.ASYNCIO)
- {
- journalBufferTimeout_AIO = journalBufferTimeout;
- journalBufferSize_AIO = journalBufferSize;
- journalMaxIO_AIO = journalMaxIO;
- }
- else
- {
- journalBufferTimeout_NIO = journalBufferTimeout;
- journalBufferSize_NIO = journalBufferSize;
- journalMaxIO_NIO = journalMaxIO;
- }
-
- journalMinFiles = XMLConfigurationUtil.getInteger(e, "journal-min-files",
journalMinFiles, Validators.GT_ZERO);
-
- journalCompactMinFiles = XMLConfigurationUtil.getInteger(e,
-
"journal-compact-min-files",
- journalCompactMinFiles,
- Validators.GE_ZERO);
-
- journalCompactPercentage = XMLConfigurationUtil.getInteger(e,
-
"journal-compact-percentage",
-
journalCompactPercentage,
- Validators.PERCENTAGE);
-
- logJournalWriteRate = XMLConfigurationUtil.getBoolean(e,
-
"log-journal-write-rate",
-
ConfigurationImpl.DEFAULT_JOURNAL_LOG_WRITE_RATE);
-
- journalPerfBlastPages = XMLConfigurationUtil.getInteger(e,
-
"perf-blast-pages",
-
ConfigurationImpl.DEFAULT_JOURNAL_PERF_BLAST_PAGES,
-
Validators.MINUS_ONE_OR_GT_ZERO);
-
- runSyncSpeedTest = XMLConfigurationUtil.getBoolean(e,
"run-sync-speed-test", runSyncSpeedTest);
-
- wildcardRoutingEnabled = XMLConfigurationUtil.getBoolean(e,
"wild-card-routing-enabled", wildcardRoutingEnabled);
-
- messageCounterEnabled = XMLConfigurationUtil.getBoolean(e,
"message-counter-enabled", messageCounterEnabled);
-
- messageCounterSamplePeriod = XMLConfigurationUtil.getLong(e,
-
"message-counter-sample-period",
-
messageCounterSamplePeriod,
- Validators.GT_ZERO);
-
- messageCounterMaxDayHistory = XMLConfigurationUtil.getInteger(e,
-
"message-counter-max-day-history",
-
messageCounterMaxDayHistory,
- Validators.GT_ZERO);
-
- serverDumpInterval = XMLConfigurationUtil.getLong(e,
-
"server-dump-interval",
- serverDumpInterval,
- Validators.MINUS_ONE_OR_GT_ZERO);
// in
- // milliseconds
-
- memoryWarningThreshold = XMLConfigurationUtil.getInteger(e,
-
"memory-warning-threshold",
- memoryWarningThreshold,
- Validators.PERCENTAGE);
-
- memoryMeasureInterval = XMLConfigurationUtil.getLong(e,
-
"memory-measure-interval",
- memoryMeasureInterval,
-
Validators.MINUS_ONE_OR_GT_ZERO); // in
-
started = true;
+
}
public synchronized void stop() throws Exception
@@ -458,398 +92,4 @@
}
// Private -------------------------------------------------------------------------
-
- private TransportConfiguration parseTransportConfiguration(final Element e)
- {
- Node nameNode = e.getAttributes().getNamedItem("name");
-
- String name = nameNode != null ? nameNode.getNodeValue() : null;
-
- String clazz = XMLConfigurationUtil.getString(e, "factory-class", null,
Validators.NOT_NULL_OR_EMPTY);
-
- Map<String, Object> params = new HashMap<String, Object>();
-
- NodeList paramsNodes = e.getElementsByTagName("param");
-
- for (int i = 0; i < paramsNodes.getLength(); i++)
- {
- Node paramNode = paramsNodes.item(i);
- NamedNodeMap attributes = paramNode.getAttributes();
-
- Node nkey = attributes.getNamedItem("key");
-
- String key = nkey.getTextContent();
-
- Node nValue = attributes.getNamedItem("value");
-
- params.put(key, nValue.getTextContent());
- }
-
- return new TransportConfiguration(clazz, params, name);
- }
-
- private void parseBroadcastGroupConfiguration(final Element e)
- {
- String name = e.getAttribute("name");
-
- String localAddress = XMLConfigurationUtil.getString(e,
"local-bind-address", null, Validators.NO_CHECK);
-
- int localBindPort = XMLConfigurationUtil.getInteger(e, "local-bind-port",
-1, Validators.MINUS_ONE_OR_GT_ZERO);
-
- String groupAddress = XMLConfigurationUtil.getString(e, "group-address",
null, Validators.NOT_NULL_OR_EMPTY);
-
- int groupPort = XMLConfigurationUtil.getInteger(e, "group-port", -1,
Validators.GT_ZERO);
-
- long broadcastPeriod = XMLConfigurationUtil.getLong(e,
- "broadcast-period",
-
ConfigurationImpl.DEFAULT_BROADCAST_PERIOD,
- Validators.GT_ZERO);
-
- NodeList children = e.getChildNodes();
-
- List<Pair<String, String>> connectorNames = new
ArrayList<Pair<String, String>>();
-
- for (int j = 0; j < children.getLength(); j++)
- {
- Node child = children.item(j);
-
- if (child.getNodeName().equals("connector-ref"))
- {
- String connectorName =
child.getAttributes().getNamedItem("connector-name").getNodeValue();
-
- Node backupConnectorNode =
child.getAttributes().getNamedItem("backup-connector-name");
-
- String backupConnectorName = null;
-
- if (backupConnectorNode != null)
- {
- backupConnectorName = backupConnectorNode.getNodeValue();
- }
-
- Pair<String, String> connectorInfo = new Pair<String,
String>(connectorName, backupConnectorName);
-
- connectorNames.add(connectorInfo);
- }
- }
-
- BroadcastGroupConfiguration config = new BroadcastGroupConfiguration(name,
- localAddress,
-
localBindPort,
- groupAddress,
- groupPort,
-
broadcastPeriod,
-
connectorNames);
-
- broadcastGroupConfigurations.add(config);
- }
-
- private void parseDiscoveryGroupConfiguration(final Element e)
- {
- String name = e.getAttribute("name");
-
- String groupAddress = XMLConfigurationUtil.getString(e, "group-address",
null, Validators.NOT_NULL_OR_EMPTY);
-
- int groupPort = XMLConfigurationUtil.getInteger(e, "group-port", -1,
Validators.MINUS_ONE_OR_GT_ZERO);
-
- long refreshTimeout = XMLConfigurationUtil.getLong(e,
- "refresh-timeout",
-
ConfigurationImpl.DEFAULT_BROADCAST_REFRESH_TIMEOUT,
- Validators.GT_ZERO);
-
- DiscoveryGroupConfiguration config = new DiscoveryGroupConfiguration(name,
- groupAddress,
- groupPort,
-
refreshTimeout);
-
- if (discoveryGroupConfigurations.containsKey(name))
- {
- FileConfiguration.log.warn("There is already a discovery group with name
" + name +
- " deployed. This one will not be
deployed.");
-
- return;
- }
- else
- {
- discoveryGroupConfigurations.put(name, config);
- }
- }
-
- private void parseClusterConnectionConfiguration(final Element e)
- {
- String name = e.getAttribute("name");
-
- String address = XMLConfigurationUtil.getString(e, "address", null,
Validators.NOT_NULL_OR_EMPTY);
-
- boolean duplicateDetection = XMLConfigurationUtil.getBoolean(e,
-
"use-duplicate-detection",
-
ConfigurationImpl.DEFAULT_CLUSTER_DUPLICATE_DETECTION);
-
- boolean forwardWhenNoConsumers = XMLConfigurationUtil.getBoolean(e,
-
"forward-when-no-consumers",
-
ConfigurationImpl.DEFAULT_CLUSTER_FORWARD_WHEN_NO_CONSUMERS);
-
- int maxHops = XMLConfigurationUtil.getInteger(e,
- "max-hops",
-
ConfigurationImpl.DEFAULT_CLUSTER_MAX_HOPS,
- Validators.GE_ZERO);
-
- long retryInterval = XMLConfigurationUtil.getLong(e,
- "retry-interval",
-
ConfigurationImpl.DEFAULT_CLUSTER_RETRY_INTERVAL,
- Validators.GT_ZERO);
-
- int confirmationWindowSize = XMLConfigurationUtil.getInteger(e,
-
"confirmation-window-size",
-
FileConfiguration.DEFAULT_CONFIRMATION_WINDOW_SIZE,
- Validators.GT_ZERO);
-
- String discoveryGroupName = null;
-
- List<Pair<String, String>> connectorPairs = new
ArrayList<Pair<String, String>>();
-
- NodeList children = e.getChildNodes();
-
- for (int j = 0; j < children.getLength(); j++)
- {
- Node child = children.item(j);
-
- if (child.getNodeName().equals("discovery-group-ref"))
- {
- discoveryGroupName =
child.getAttributes().getNamedItem("discovery-group-name").getNodeValue();
- }
- else if (child.getNodeName().equals("connector-ref"))
- {
- String connectorName =
child.getAttributes().getNamedItem("connector-name").getNodeValue();
-
- Node backupNode =
child.getAttributes().getNamedItem("backup-connector-name");
-
- String backupConnectorName = null;
-
- if (backupNode != null)
- {
- backupConnectorName = backupNode.getNodeValue();
- }
-
- Pair<String, String> connectorPair = new Pair<String,
String>(connectorName, backupConnectorName);
-
- connectorPairs.add(connectorPair);
- }
- }
-
- ClusterConnectionConfiguration config;
-
- if (discoveryGroupName == null)
- {
- config = new ClusterConnectionConfiguration(name,
- address,
- retryInterval,
- duplicateDetection,
- forwardWhenNoConsumers,
- maxHops,
- confirmationWindowSize,
- connectorPairs);
- }
- else
- {
- config = new ClusterConnectionConfiguration(name,
- address,
- retryInterval,
- duplicateDetection,
- forwardWhenNoConsumers,
- maxHops,
- confirmationWindowSize,
- discoveryGroupName);
- }
-
- clusterConfigurations.add(config);
- }
-
- private void parseGroupingHandlerConfiguration(final Element node)
- {
- String name = node.getAttribute("name");
- String type = XMLConfigurationUtil.getString(node, "type", null,
Validators.NOT_NULL_OR_EMPTY);
- String address = XMLConfigurationUtil.getString(node, "address", null,
Validators.NOT_NULL_OR_EMPTY);
- Integer timeout = XMLConfigurationUtil.getInteger(node,
- "timeout",
-
GroupingHandlerConfiguration.DEFAULT_TIMEOUT,
- Validators.GT_ZERO);
- groupingHandlerConfiguration = new GroupingHandlerConfiguration(new
SimpleString(name),
-
type.equals(GroupingHandlerConfiguration.TYPE.LOCAL.getType()) ?
GroupingHandlerConfiguration.TYPE.LOCAL
-
: GroupingHandlerConfiguration.TYPE.REMOTE,
- new
SimpleString(address),
- timeout);
- }
-
- private void parseBridgeConfiguration(final Element brNode)
- {
- String name = brNode.getAttribute("name");
-
- String queueName = XMLConfigurationUtil.getString(brNode, "queue-name",
null, Validators.NOT_NULL_OR_EMPTY);
-
- String forwardingAddress = XMLConfigurationUtil.getString(brNode,
-
"forwarding-address",
- null,
-
Validators.NOT_NULL_OR_EMPTY);
-
- String transformerClassName = XMLConfigurationUtil.getString(brNode,
-
"transformer-class-name",
- null,
- Validators.NO_CHECK);
-
- long retryInterval = XMLConfigurationUtil.getLong(brNode,
- "retry-interval",
-
HornetQClient.DEFAULT_RETRY_INTERVAL,
- Validators.GT_ZERO);
-
- // Default bridge conf
- int confirmationWindowSize = XMLConfigurationUtil.getInteger(brNode,
-
"confirmation-window-size",
-
FileConfiguration.DEFAULT_CONFIRMATION_WINDOW_SIZE,
- Validators.GT_ZERO);
-
- double retryIntervalMultiplier = XMLConfigurationUtil.getDouble(brNode,
-
"retry-interval-multiplier",
-
HornetQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
-
Validators.GT_ZERO);
-
- int reconnectAttempts = XMLConfigurationUtil.getInteger(brNode,
-
"reconnect-attempts",
-
ConfigurationImpl.DEFAULT_BRIDGE_RECONNECT_ATTEMPTS,
-
Validators.MINUS_ONE_OR_GE_ZERO);
-
- boolean failoverOnServerShutdown = XMLConfigurationUtil.getBoolean(brNode,
-
"failover-on-server-shutdown",
-
HornetQClient.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN);
-
- boolean useDuplicateDetection = XMLConfigurationUtil.getBoolean(brNode,
-
"use-duplicate-detection",
-
ConfigurationImpl.DEFAULT_BRIDGE_DUPLICATE_DETECTION);
-
- String user = XMLConfigurationUtil.getString(brNode, "user",
ConfigurationImpl.DEFAULT_CLUSTER_USER, Validators.NO_CHECK);
-
- String password = XMLConfigurationUtil.getString(brNode, "password",
ConfigurationImpl.DEFAULT_CLUSTER_PASSWORD, Validators.NO_CHECK);
-
- String filterString = null;
-
- Pair<String, String> connectorPair = null;
-
- String discoveryGroupName = null;
-
- NodeList children = brNode.getChildNodes();
-
- for (int j = 0; j < children.getLength(); j++)
- {
- Node child = children.item(j);
-
- if (child.getNodeName().equals("filter"))
- {
- filterString =
child.getAttributes().getNamedItem("string").getNodeValue();
- }
- else if (child.getNodeName().equals("discovery-group-ref"))
- {
- discoveryGroupName =
child.getAttributes().getNamedItem("discovery-group-name").getNodeValue();
- }
- else if (child.getNodeName().equals("connector-ref"))
- {
- String connectorName =
child.getAttributes().getNamedItem("connector-name").getNodeValue();
-
- Node backupNode =
child.getAttributes().getNamedItem("backup-connector-name");
-
- String backupConnectorName = null;
-
- if (backupNode != null)
- {
- backupConnectorName = backupNode.getNodeValue();
- }
-
- connectorPair = new Pair<String, String>(connectorName,
backupConnectorName);
- }
- }
-
- BridgeConfiguration config;
-
- if (connectorPair != null)
- {
- config = new BridgeConfiguration(name,
- queueName,
- forwardingAddress,
- filterString,
- transformerClassName,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts,
- failoverOnServerShutdown,
- useDuplicateDetection,
- confirmationWindowSize,
-
HornetQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
- connectorPair,
- user,
- password);
- }
- else
- {
- config = new BridgeConfiguration(name,
- queueName,
- forwardingAddress,
- filterString,
- transformerClassName,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts,
- failoverOnServerShutdown,
- useDuplicateDetection,
- confirmationWindowSize,
-
HornetQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
- discoveryGroupName,
- user,
- password);
- }
-
- bridgeConfigurations.add(config);
- }
-
- private void parseDivertConfiguration(final Element e)
- {
- String name = e.getAttribute("name");
-
- String routingName = XMLConfigurationUtil.getString(e, "routing-name",
null, Validators.NO_CHECK);
-
- String address = XMLConfigurationUtil.getString(e, "address", null,
Validators.NOT_NULL_OR_EMPTY);
-
- String forwardingAddress = XMLConfigurationUtil.getString(e,
-
"forwarding-address",
- null,
-
Validators.NOT_NULL_OR_EMPTY);
-
- boolean exclusive = XMLConfigurationUtil.getBoolean(e, "exclusive",
ConfigurationImpl.DEFAULT_DIVERT_EXCLUSIVE);
-
- String transformerClassName = XMLConfigurationUtil.getString(e,
-
"transformer-class-name",
- null,
- Validators.NO_CHECK);
-
- String filterString = null;
-
- NodeList children = e.getChildNodes();
-
- for (int j = 0; j < children.getLength(); j++)
- {
- Node child = children.item(j);
-
- if (child.getNodeName().equals("filter"))
- {
- filterString =
child.getAttributes().getNamedItem("string").getNodeValue();
- }
- }
-
- DivertConfiguration config = new DivertConfiguration(name,
- routingName,
- address,
- forwardingAddress,
- exclusive,
- filterString,
- transformerClassName);
-
- divertConfigurations.add(config);
- }
}
Modified: trunk/src/main/org/hornetq/core/deployers/impl/AddressSettingsDeployer.java
===================================================================
--- trunk/src/main/org/hornetq/core/deployers/impl/AddressSettingsDeployer.java 2010-02-08
10:28:19 UTC (rev 8867)
+++ trunk/src/main/org/hornetq/core/deployers/impl/AddressSettingsDeployer.java 2010-02-10
14:15:24 UTC (rev 8868)
@@ -13,15 +13,12 @@
package org.hornetq.core.deployers.impl;
-import org.hornetq.api.core.SimpleString;
-import org.hornetq.core.config.impl.Validators;
+import org.hornetq.api.core.Pair;
import org.hornetq.core.deployers.DeploymentManager;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.settings.HierarchicalRepository;
-import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
import org.hornetq.core.settings.impl.AddressSettings;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
* A deployer for creating a set of queue settings and adding them to a repository
@@ -31,29 +28,9 @@
{
private static final Logger log = Logger.getLogger(AddressSettingsDeployer.class);
- private static final String DEAD_LETTER_ADDRESS_NODE_NAME =
"dead-letter-address";
-
- private static final String EXPIRY_ADDRESS_NODE_NAME = "expiry-address";
-
- private static final String REDELIVERY_DELAY_NODE_NAME =
"redelivery-delay";
-
- private static final String MAX_DELIVERY_ATTEMPTS =
"max-delivery-attempts";
-
- private static final String MAX_SIZE_BYTES_NODE_NAME = "max-size-bytes";
-
- private static final String ADDRESS_FULL_MESSAGE_POLICY_NODE_NAME =
"address-full-policy";
-
- private static final String PAGE_SIZE_BYTES_NODE_NAME = "page-size-bytes";
-
- private static final String MESSAGE_COUNTER_HISTORY_DAY_LIMIT_NODE_NAME =
"message-counter-history-day-limit";
-
- private static final String LVQ_NODE_NAME = "last-value-queue";
-
- private static final String REDISTRIBUTION_DELAY_NODE_NAME =
"redistribution-delay";
-
- private static final String SEND_TO_DLA_ON_NO_ROUTE =
"send-to-dla-on-no-route";
-
private final HierarchicalRepository<AddressSettings>
addressSettingsRepository;
+
+ private final FileConfigurationParser parser = new FileConfigurationParser();
public AddressSettingsDeployer(final DeploymentManager deploymentManager,
final HierarchicalRepository<AddressSettings>
addressSettingsRepository)
@@ -86,81 +63,10 @@
@Override
public void deploy(final Node node) throws Exception
{
- String match =
node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
+
+ Pair<String, AddressSettings> setting = parser.parseAddressSettings(node);
- NodeList children = node.getChildNodes();
-
- AddressSettings addressSettings = new AddressSettings();
-
- for (int i = 0; i < children.getLength(); i++)
- {
- Node child = children.item(i);
-
- if
(AddressSettingsDeployer.DEAD_LETTER_ADDRESS_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
- {
- SimpleString queueName = new SimpleString(child.getTextContent());
- addressSettings.setDeadLetterAddress(queueName);
- }
- else if
(AddressSettingsDeployer.EXPIRY_ADDRESS_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
- {
- SimpleString queueName = new SimpleString(child.getTextContent());
- addressSettings.setExpiryAddress(queueName);
- }
- else if
(AddressSettingsDeployer.REDELIVERY_DELAY_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
- {
- addressSettings.setRedeliveryDelay(Long.valueOf(child.getTextContent()));
- }
- else if
(AddressSettingsDeployer.MAX_SIZE_BYTES_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
- {
- addressSettings.setMaxSizeBytes(Integer.valueOf(child.getTextContent()));
- }
- else if
(AddressSettingsDeployer.PAGE_SIZE_BYTES_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
- {
- addressSettings.setPageSizeBytes(Integer.valueOf(child.getTextContent()));
- }
- else if
(AddressSettingsDeployer.MESSAGE_COUNTER_HISTORY_DAY_LIMIT_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
- {
-
addressSettings.setMessageCounterHistoryDayLimit(Integer.valueOf(child.getTextContent()));
- }
- else if
(AddressSettingsDeployer.ADDRESS_FULL_MESSAGE_POLICY_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
- {
- String value = child.getTextContent().trim();
-
Validators.ADDRESS_FULL_MESSAGE_POLICY_TYPE.validate(AddressSettingsDeployer.ADDRESS_FULL_MESSAGE_POLICY_NODE_NAME,
- value);
- AddressFullMessagePolicy policy = null;
- if (value.equals(AddressFullMessagePolicy.BLOCK.toString()))
- {
- policy = AddressFullMessagePolicy.BLOCK;
- }
- else if (value.equals(AddressFullMessagePolicy.DROP.toString()))
- {
- policy = AddressFullMessagePolicy.DROP;
- }
- else if (value.equals(AddressFullMessagePolicy.PAGE.toString()))
- {
- policy = AddressFullMessagePolicy.PAGE;
- }
- addressSettings.setAddressFullMessagePolicy(policy);
- }
- else if
(AddressSettingsDeployer.LVQ_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
- {
-
addressSettings.setLastValueQueue(Boolean.valueOf(child.getTextContent().trim()));
- }
- else if
(AddressSettingsDeployer.MAX_DELIVERY_ATTEMPTS.equalsIgnoreCase(child.getNodeName()))
- {
-
addressSettings.setMaxDeliveryAttempts(Integer.valueOf(child.getTextContent().trim()));
- }
- else if
(AddressSettingsDeployer.REDISTRIBUTION_DELAY_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
- {
-
addressSettings.setRedistributionDelay(Long.valueOf(child.getTextContent().trim()));
- }
- else if
(AddressSettingsDeployer.SEND_TO_DLA_ON_NO_ROUTE.equalsIgnoreCase(child.getNodeName()))
- {
-
addressSettings.setSendToDLAOnNoRoute(Boolean.valueOf(child.getTextContent().trim()));
- }
- }
-
- addressSettingsRepository.addMatch(match, addressSettings);
+ addressSettingsRepository.addMatch(setting.a, setting.b);
}
@Override
Added: trunk/src/main/org/hornetq/core/deployers/impl/FileConfigurationParser.java
===================================================================
--- trunk/src/main/org/hornetq/core/deployers/impl/FileConfigurationParser.java
(rev 0)
+++ trunk/src/main/org/hornetq/core/deployers/impl/FileConfigurationParser.java 2010-02-10
14:15:24 UTC (rev 8868)
@@ -0,0 +1,1198 @@
+/*
+ * Copyright 2010 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.core.deployers.impl;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.hornetq.api.core.Pair;
+import org.hornetq.api.core.SimpleString;
+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.ConfigurationImpl;
+import org.hornetq.core.config.impl.FileConfiguration;
+import org.hornetq.core.config.impl.Validators;
+import org.hornetq.core.logging.Logger;
+import org.hornetq.core.security.Role;
+import org.hornetq.core.server.JournalType;
+import org.hornetq.core.server.cluster.BridgeConfiguration;
+import org.hornetq.core.server.cluster.BroadcastGroupConfiguration;
+import org.hornetq.core.server.cluster.ClusterConnectionConfiguration;
+import org.hornetq.core.server.cluster.DiscoveryGroupConfiguration;
+import org.hornetq.core.server.cluster.DivertConfiguration;
+import org.hornetq.core.server.cluster.QueueConfiguration;
+import org.hornetq.core.server.group.impl.GroupingHandlerConfiguration;
+import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
+import org.hornetq.core.settings.impl.AddressSettings;
+import org.hornetq.utils.XMLConfigurationUtil;
+import org.hornetq.utils.XMLUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * This class will parse the XML associated with the File Configuration XSD
+ *
+ * @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class FileConfigurationParser
+{
+
+ // Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(FileConfigurationParser.class);
+
+ private static final String CONFIGURATION_SCHEMA_URL =
"schema/hornetq-configuration.xsd";
+
+ // Security Parsing
+ public static final String SECURITY_ELEMENT_NAME = "security-setting";
+
+ private static final String PERMISSION_ELEMENT_NAME = "permission";
+
+ private static final String TYPE_ATTR_NAME = "type";
+
+ private static final String ROLES_ATTR_NAME = "roles";
+
+ private static final String CREATEDURABLEQUEUE_NAME = "createDurableQueue";
+
+ private static final String DELETEDURABLEQUEUE_NAME = "deleteDurableQueue";
+
+ private static final String CREATETEMPQUEUE_NAME = "createTempQueue";
+
+ private static final String DELETETEMPQUEUE_NAME = "deleteTempQueue";
+
+ private static final String SEND_NAME = "send";
+
+ private static final String CONSUME_NAME = "consume";
+
+ private static final String MANAGE_NAME = "manage";
+
+ // Address parsing
+
+ private static final String DEAD_LETTER_ADDRESS_NODE_NAME =
"dead-letter-address";
+
+ private static final String EXPIRY_ADDRESS_NODE_NAME = "expiry-address";
+
+ private static final String REDELIVERY_DELAY_NODE_NAME =
"redelivery-delay";
+
+ private static final String MAX_DELIVERY_ATTEMPTS =
"max-delivery-attempts";
+
+ private static final String MAX_SIZE_BYTES_NODE_NAME = "max-size-bytes";
+
+ private static final String ADDRESS_FULL_MESSAGE_POLICY_NODE_NAME =
"address-full-policy";
+
+ private static final String PAGE_SIZE_BYTES_NODE_NAME = "page-size-bytes";
+
+ private static final String MESSAGE_COUNTER_HISTORY_DAY_LIMIT_NODE_NAME =
"message-counter-history-day-limit";
+
+ private static final String LVQ_NODE_NAME = "last-value-queue";
+
+ private static final String REDISTRIBUTION_DELAY_NODE_NAME =
"redistribution-delay";
+
+ private static final String SEND_TO_DLA_ON_NO_ROUTE =
"send-to-dla-on-no-route";
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public Configuration parseMainConfig(final InputStream input) throws Exception
+ {
+
+ Reader reader = new InputStreamReader(input);
+ String xml = org.hornetq.utils.XMLUtil.readerToString(reader);
+ xml = XMLUtil.replaceSystemProps(xml);
+ Element e = org.hornetq.utils.XMLUtil.stringToElement(xml);
+
+ Configuration config = new ConfigurationImpl();
+
+ parseMainConfig(e, config);
+
+ return config;
+ }
+
+ public void parseMainConfig(final Element e, final Configuration config) throws
Exception
+ {
+ XMLUtil.validate(e, FileConfigurationParser.CONFIGURATION_SCHEMA_URL);
+
+ config.setClustered(XMLConfigurationUtil.getBoolean(e, "clustered",
config.isClustered()));
+
+ config.setBackup(XMLConfigurationUtil.getBoolean(e, "backup",
config.isBackup()));
+
+ config.setSharedStore(XMLConfigurationUtil.getBoolean(e, "shared-store",
config.isSharedStore()));
+
+ // Defaults to true when using FileConfiguration
+ config.setFileDeploymentEnabled(XMLConfigurationUtil.getBoolean(e,
+
"file-deployment-enabled",
+ config instanceof
FileConfiguration));
+
+ config.setPersistenceEnabled(XMLConfigurationUtil.getBoolean(e,
+
"persistence-enabled",
+
config.isPersistenceEnabled()));
+
+ config.setPersistDeliveryCountBeforeDelivery(XMLConfigurationUtil.getBoolean(e,
+
"persist-delivery-count-before-delivery",
+
config.isPersistDeliveryCountBeforeDelivery()));
+
+ config.setScheduledThreadPoolMaxSize(XMLConfigurationUtil.getInteger(e,
+
"scheduled-thread-pool-max-size",
+
config.getScheduledThreadPoolMaxSize(),
+
Validators.GT_ZERO));
+
+ config.setThreadPoolMaxSize(XMLConfigurationUtil.getInteger(e,
+
"thread-pool-max-size",
+
config.getThreadPoolMaxSize(),
+
Validators.MINUS_ONE_OR_GT_ZERO));
+
+ config.setSecurityEnabled(XMLConfigurationUtil.getBoolean(e,
"security-enabled", config.isSecurityEnabled()));
+
+ config.setJMXManagementEnabled(XMLConfigurationUtil.getBoolean(e,
+
"jmx-management-enabled",
+
config.isJMXManagementEnabled()));
+
+ config.setJMXDomain(XMLConfigurationUtil.getString(e,
+ "jmx-domain",
+ config.getJMXDomain(),
+ Validators.NOT_NULL_OR_EMPTY));
+
+ config.setSecurityInvalidationInterval(XMLConfigurationUtil.getLong(e,
+
"security-invalidation-interval",
+
config.getSecurityInvalidationInterval(),
+
Validators.GT_ZERO));
+
+ config.setConnectionTTLOverride(XMLConfigurationUtil.getLong(e,
+
"connection-ttl-override",
+
config.getConnectionTTLOverride(),
+
Validators.MINUS_ONE_OR_GT_ZERO));
+
+ config.setEnabledAsyncConnectionExecution(XMLConfigurationUtil.getBoolean(e,
+
"async-connection-execution-enabled",
+
config.isAsyncConnectionExecutionEnabled()));
+
+ config.setTransactionTimeout(XMLConfigurationUtil.getLong(e,
+
"transaction-timeout",
+
config.getTransactionTimeout(),
+ Validators.GT_ZERO));
+
+ config.setTransactionTimeoutScanPeriod(XMLConfigurationUtil.getLong(e,
+
"transaction-timeout-scan-period",
+
config.getTransactionTimeoutScanPeriod(),
+
Validators.GT_ZERO));
+
+ config.setMessageExpiryScanPeriod(XMLConfigurationUtil.getLong(e,
+
"message-expiry-scan-period",
+
config.getMessageExpiryScanPeriod(),
+
Validators.GT_ZERO));
+
+ config.setMessageExpiryThreadPriority(XMLConfigurationUtil.getInteger(e,
+
"message-expiry-thread-priority",
+
config.getMessageExpiryThreadPriority(),
+
Validators.THREAD_PRIORITY_RANGE));
+
+ config.setIDCacheSize(XMLConfigurationUtil.getInteger(e,
+ "id-cache-size",
+ config.getIDCacheSize(),
+ Validators.GT_ZERO));
+
+ config.setPersistIDCache(XMLConfigurationUtil.getBoolean(e,
"persist-id-cache", config.isPersistIDCache()));
+
+ config.setManagementAddress(new SimpleString(XMLConfigurationUtil.getString(e,
+
"management-address",
+
config.getManagementAddress()
+
.toString(),
+
Validators.NOT_NULL_OR_EMPTY)));
+
+ config.setManagementNotificationAddress(new
SimpleString(XMLConfigurationUtil.getString(e,
+
"management-notification-address",
+
config.getManagementNotificationAddress()
+
.toString(),
+
Validators.NOT_NULL_OR_EMPTY)));
+
+ config.setClusterPassword(XMLConfigurationUtil.getString(e,
+
"cluster-password",
+
config.getClusterPassword(),
+ Validators.NO_CHECK));
+
+ config.setClusterUser(XMLConfigurationUtil.getString(e,
+ "cluster-user",
+ config.getClusterUser(),
+ Validators.NO_CHECK));
+
+ config.setLogDelegateFactoryClassName(XMLConfigurationUtil.getString(e,
+
"log-delegate-factory-class-name",
+
config.getLogDelegateFactoryClassName(),
+
Validators.NOT_NULL_OR_EMPTY));
+
+ NodeList interceptorNodes =
e.getElementsByTagName("remoting-interceptors");
+
+ ArrayList<String> interceptorList = new ArrayList<String>();
+
+ if (interceptorNodes.getLength() > 0)
+ {
+ NodeList interceptors = interceptorNodes.item(0).getChildNodes();
+
+ for (int i = 0; i < interceptors.getLength(); i++)
+ {
+ if
("class-name".equalsIgnoreCase(interceptors.item(i).getNodeName()))
+ {
+ String clazz = interceptors.item(i).getTextContent();
+
+ interceptorList.add(clazz);
+ }
+ }
+ }
+
+ config.setInterceptorClassNames(interceptorList);
+
+ NodeList backups = e.getElementsByTagName("backup-connector-ref");
+
+ // There should be only one - this will be enforced by the DTD
+
+ if (backups.getLength() > 0)
+ {
+ Node backupNode = backups.item(0);
+
+
config.setBackupConnectorName(backupNode.getAttributes().getNamedItem("connector-name").getNodeValue());
+ }
+
+ NodeList connectorNodes = e.getElementsByTagName("connector");
+
+ for (int i = 0; i < connectorNodes.getLength(); i++)
+ {
+ Element connectorNode = (Element)connectorNodes.item(i);
+
+ TransportConfiguration connectorConfig =
parseTransportConfiguration(connectorNode);
+
+ if (connectorConfig.getName() == null)
+ {
+ FileConfigurationParser.log.warn("Cannot deploy a connector with no name
specified.");
+
+ continue;
+ }
+
+ if (config.getConnectorConfigurations().containsKey(connectorConfig.getName()))
+ {
+ FileConfigurationParser.log.warn("There is already a connector with name
" + connectorConfig.getName() +
+ " deployed. This one will not be
deployed.");
+
+ continue;
+ }
+
+ config.getConnectorConfigurations().put(connectorConfig.getName(),
connectorConfig);
+ }
+
+ NodeList acceptorNodes = e.getElementsByTagName("acceptor");
+
+ for (int i = 0; i < acceptorNodes.getLength(); i++)
+ {
+ Element acceptorNode = (Element)acceptorNodes.item(i);
+
+ TransportConfiguration acceptorConfig =
parseTransportConfiguration(acceptorNode);
+
+ config.getAcceptorConfigurations().add(acceptorConfig);
+ }
+
+ NodeList bgNodes = e.getElementsByTagName("broadcast-group");
+
+ for (int i = 0; i < bgNodes.getLength(); i++)
+ {
+ Element bgNode = (Element)bgNodes.item(i);
+
+ parseBroadcastGroupConfiguration(bgNode, config);
+ }
+
+ NodeList dgNodes = e.getElementsByTagName("discovery-group");
+
+ for (int i = 0; i < dgNodes.getLength(); i++)
+ {
+ Element dgNode = (Element)dgNodes.item(i);
+
+ parseDiscoveryGroupConfiguration(dgNode, config);
+ }
+
+ NodeList brNodes = e.getElementsByTagName("bridge");
+
+ for (int i = 0; i < brNodes.getLength(); i++)
+ {
+ Element mfNode = (Element)brNodes.item(i);
+
+ parseBridgeConfiguration(mfNode, config);
+ }
+
+ NodeList gaNodes = e.getElementsByTagName("grouping-handler");
+
+ for (int i = 0; i < gaNodes.getLength(); i++)
+ {
+ Element gaNode = (Element)gaNodes.item(i);
+
+ parseGroupingHandlerConfiguration(gaNode, config);
+ }
+
+ NodeList ccNodes = e.getElementsByTagName("cluster-connection");
+
+ for (int i = 0; i < ccNodes.getLength(); i++)
+ {
+ Element ccNode = (Element)ccNodes.item(i);
+
+ parseClusterConnectionConfiguration(ccNode, config);
+ }
+
+ NodeList dvNodes = e.getElementsByTagName("divert");
+
+ for (int i = 0; i < dvNodes.getLength(); i++)
+ {
+ Element dvNode = (Element)dvNodes.item(i);
+
+ parseDivertConfiguration(dvNode, config);
+ }
+
+ // Persistence config
+
+ config.setLargeMessagesDirectory(XMLConfigurationUtil.getString(e,
+
"large-messages-directory",
+
config.getLargeMessagesDirectory(),
+
Validators.NOT_NULL_OR_EMPTY));
+
+ config.setBindingsDirectory(XMLConfigurationUtil.getString(e,
+
"bindings-directory",
+
config.getBindingsDirectory(),
+
Validators.NOT_NULL_OR_EMPTY));
+
+ config.setCreateBindingsDir(XMLConfigurationUtil.getBoolean(e,
+
"create-bindings-dir",
+
config.isCreateBindingsDir()));
+
+ config.setJournalDirectory(XMLConfigurationUtil.getString(e,
+
"journal-directory",
+
config.getJournalDirectory(),
+
Validators.NOT_NULL_OR_EMPTY));
+
+ config.setPagingDirectory(XMLConfigurationUtil.getString(e,
+
"paging-directory",
+
config.getPagingDirectory(),
+
Validators.NOT_NULL_OR_EMPTY));
+
+ config.setCreateJournalDir(XMLConfigurationUtil.getBoolean(e,
"create-journal-dir", config.isCreateJournalDir()));
+
+ String s = XMLConfigurationUtil.getString(e,
+ "journal-type",
+ config.getJournalType().toString(),
+ Validators.JOURNAL_TYPE);
+
+ if (s.equals(JournalType.NIO.toString()))
+ {
+ config.setJournalType(JournalType.NIO);
+ }
+ else if (s.equals(JournalType.ASYNCIO.toString()))
+ {
+ config.setJournalType(JournalType.ASYNCIO);
+ }
+
+ config.setJournalSyncTransactional(XMLConfigurationUtil.getBoolean(e,
+
"journal-sync-transactional",
+
config.isJournalSyncTransactional()));
+
+ config.setJournalSyncNonTransactional(XMLConfigurationUtil.getBoolean(e,
+
"journal-sync-non-transactional",
+
config.isJournalSyncNonTransactional()));
+
+ config.setJournalFileSize(XMLConfigurationUtil.getInteger(e,
+
"journal-file-size",
+
config.getJournalFileSize(),
+ Validators.GT_ZERO));
+
+ int journalBufferTimeout = XMLConfigurationUtil.getInteger(e,
+
"journal-buffer-timeout",
+ config.getJournalType()
== JournalType.ASYNCIO ? ConfigurationImpl.DEFAULT_JOURNAL_BUFFER_TIMEOUT_AIO
+
: ConfigurationImpl.DEFAULT_JOURNAL_BUFFER_TIMEOUT_NIO,
+ Validators.GT_ZERO);
+
+ int journalBufferSize = XMLConfigurationUtil.getInteger(e,
+
"journal-buffer-size",
+ config.getJournalType() ==
JournalType.ASYNCIO ? ConfigurationImpl.DEFAULT_JOURNAL_BUFFER_SIZE_AIO
+
: ConfigurationImpl.DEFAULT_JOURNAL_BUFFER_SIZE_NIO,
+ Validators.GT_ZERO);
+
+ int journalMaxIO = XMLConfigurationUtil.getInteger(e,
+ "journal-max-io",
+ config.getJournalType() ==
JournalType.ASYNCIO ? ConfigurationImpl.DEFAULT_JOURNAL_MAX_IO_AIO
+
: ConfigurationImpl.DEFAULT_JOURNAL_MAX_IO_NIO,
+ Validators.GT_ZERO);
+
+ if (config.getJournalType() == JournalType.ASYNCIO)
+ {
+ config.setJournalBufferTimeout_AIO(journalBufferTimeout);
+ config.setJournalBufferSize_AIO(journalBufferSize);
+ config.setJournalMaxIO_AIO(journalMaxIO);
+ }
+ else
+ {
+ config.setJournalBufferTimeout_NIO(journalBufferTimeout);
+ config.setJournalBufferSize_NIO(journalBufferSize);
+ config.setJournalMaxIO_NIO(journalMaxIO);
+ }
+
+ config.setJournalMinFiles(XMLConfigurationUtil.getInteger(e,
+
"journal-min-files",
+
config.getJournalMinFiles(),
+ Validators.GT_ZERO));
+
+ config.setJournalCompactMinFiles(XMLConfigurationUtil.getInteger(e,
+
"journal-compact-min-files",
+
config.getJournalCompactMinFiles(),
+
Validators.GE_ZERO));
+
+ config.setJournalCompactPercentage(XMLConfigurationUtil.getInteger(e,
+
"journal-compact-percentage",
+
config.getJournalCompactPercentage(),
+
Validators.PERCENTAGE));
+
+ config.setLogJournalWriteRate(XMLConfigurationUtil.getBoolean(e,
+
"log-journal-write-rate",
+
ConfigurationImpl.DEFAULT_JOURNAL_LOG_WRITE_RATE));
+
+ config.setJournalPerfBlastPages(XMLConfigurationUtil.getInteger(e,
+
"perf-blast-pages",
+
ConfigurationImpl.DEFAULT_JOURNAL_PERF_BLAST_PAGES,
+
Validators.MINUS_ONE_OR_GT_ZERO));
+
+ config.setRunSyncSpeedTest(XMLConfigurationUtil.getBoolean(e,
"run-sync-speed-test", config.isRunSyncSpeedTest()));
+
+ config.setWildcardRoutingEnabled(XMLConfigurationUtil.getBoolean(e,
+
"wild-card-routing-enabled",
+
config.isWildcardRoutingEnabled()));
+
+ config.setMessageCounterEnabled(XMLConfigurationUtil.getBoolean(e,
+
"message-counter-enabled",
+
config.isMessageCounterEnabled()));
+
+ config.setMessageCounterSamplePeriod(XMLConfigurationUtil.getLong(e,
+
"message-counter-sample-period",
+
config.getMessageCounterSamplePeriod(),
+
Validators.GT_ZERO));
+
+ config.setMessageCounterMaxDayHistory(XMLConfigurationUtil.getInteger(e,
+
"message-counter-max-day-history",
+
config.getMessageCounterMaxDayHistory(),
+
Validators.GT_ZERO));
+
+ config.setServerDumpInterval(XMLConfigurationUtil.getLong(e,
+
"server-dump-interval",
+
config.getServerDumpInterval(),
+
Validators.MINUS_ONE_OR_GT_ZERO)); // in
+ // milliseconds
+
+ config.setMemoryWarningThreshold(XMLConfigurationUtil.getInteger(e,
+
"memory-warning-threshold",
+
config.getMemoryWarningThreshold(),
+
Validators.PERCENTAGE));
+
+ config.setMemoryMeasureInterval(XMLConfigurationUtil.getLong(e,
+
"memory-measure-interval",
+
config.getMemoryMeasureInterval(),
+
Validators.MINUS_ONE_OR_GT_ZERO)); // in
+
+ parseAddressSettings(e, config);
+
+ parseQueues(e, config);
+
+ parseSecurity(e, config);
+
+
+
+ }
+
+ /**
+ * @param e
+ * @param config
+ */
+ private void parseSecurity(final Element e, final Configuration config)
+ {
+ NodeList elements = e.getElementsByTagName("security-settings");
+
+ if (elements.getLength() != 0)
+ {
+ Element node = (Element)elements.item(0);
+ NodeList list = node.getElementsByTagName("security-setting");
+ for (int i = 0 ; i < list.getLength(); i++)
+ {
+ Pair<String, Set<Role>> securityItem =
parseSecurityRoles(list.item(i));
+ config.getSecurityRoles().put(securityItem.a, securityItem.b);
+ }
+ }
+ }
+
+ /**
+ * @param e
+ * @param config
+ */
+ private void parseQueues(final Element e, final Configuration config)
+ {
+ NodeList elements = e.getElementsByTagName("queues");
+
+ if (elements.getLength() != 0)
+ {
+ Element node = (Element)elements.item(0);
+ NodeList list = node.getElementsByTagName("queue");
+ for (int i = 0 ; i < list.getLength(); i++)
+ {
+ QueueConfiguration queueConfig = parseQueueConfiguration(list.item(i));
+ config.getQueueConfigurations().add(queueConfig);
+ }
+ }
+ }
+
+ /**
+ * @param e
+ * @param config
+ */
+ private void parseAddressSettings(final Element e, final Configuration config)
+ {
+ NodeList elements = e.getElementsByTagName("address-settings");
+
+ if (elements.getLength() != 0)
+ {
+ Element node = (Element)elements.item(0);
+ NodeList list = node.getElementsByTagName("address-setting");
+ for (int i = 0 ; i < list.getLength(); i++)
+ {
+ Pair<String, AddressSettings> addressSettings =
parseAddressSettings(list.item(i));
+ config.getAddressesSettings().put(addressSettings.a, addressSettings.b);
+ }
+ }
+ }
+
+ /**
+ * @param node
+ * @return
+ */
+ public Pair<String, Set<Role>> parseSecurityRoles(final Node node)
+ {
+ String match =
node.getAttributes().getNamedItem("match").getNodeValue();
+
+ HashSet<Role> securityRoles = new HashSet<Role>();
+
+ Pair<String, Set<Role>> securityMatch = new Pair<String,
Set<Role>>(match, securityRoles);
+
+ ArrayList<String> send = new ArrayList<String>();
+ ArrayList<String> consume = new ArrayList<String>();
+ ArrayList<String> createDurableQueue = new ArrayList<String>();
+ ArrayList<String> deleteDurableQueue = new ArrayList<String>();
+ ArrayList<String> createTempQueue = new ArrayList<String>();
+ ArrayList<String> deleteTempQueue = new ArrayList<String>();
+ ArrayList<String> manageRoles = new ArrayList<String>();
+ ArrayList<String> allRoles = new ArrayList<String>();
+ NodeList children = node.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++)
+ {
+ Node child = children.item(i);
+
+ if
(FileConfigurationParser.PERMISSION_ELEMENT_NAME.equalsIgnoreCase(child.getNodeName()))
+ {
+ String type =
child.getAttributes().getNamedItem(FileConfigurationParser.TYPE_ATTR_NAME).getNodeValue();
+ String roleString = child.getAttributes()
+
.getNamedItem(FileConfigurationParser.ROLES_ATTR_NAME)
+ .getNodeValue();
+ String[] roles = roleString.split(",");
+ for (String role : roles)
+ {
+ if (FileConfigurationParser.SEND_NAME.equals(type))
+ {
+ send.add(role.trim());
+ }
+ else if (FileConfigurationParser.CONSUME_NAME.equals(type))
+ {
+ consume.add(role.trim());
+ }
+ else if (FileConfigurationParser.CREATEDURABLEQUEUE_NAME.equals(type))
+ {
+ createDurableQueue.add(role);
+ }
+ else if (FileConfigurationParser.DELETEDURABLEQUEUE_NAME.equals(type))
+ {
+ deleteDurableQueue.add(role);
+ }
+ else if (FileConfigurationParser.CREATETEMPQUEUE_NAME.equals(type))
+ {
+ createTempQueue.add(role);
+ }
+ else if (FileConfigurationParser.DELETETEMPQUEUE_NAME.equals(type))
+ {
+ deleteTempQueue.add(role);
+ }
+ else if (FileConfigurationParser.MANAGE_NAME.equals(type))
+ {
+ manageRoles.add(role);
+ }
+ if (!allRoles.contains(role.trim()))
+ {
+ allRoles.add(role.trim());
+ }
+ }
+ }
+
+ }
+
+ for (String role : allRoles)
+ {
+ securityRoles.add(new Role(role,
+ send.contains(role),
+ consume.contains(role),
+ createDurableQueue.contains(role),
+ deleteDurableQueue.contains(role),
+ createTempQueue.contains(role),
+ deleteTempQueue.contains(role),
+ manageRoles.contains(role)));
+ }
+
+ return securityMatch;
+ }
+
+ /**
+ * @param node
+ * @return
+ */
+ public Pair<String, AddressSettings> parseAddressSettings(final Node node)
+ {
+ String match =
node.getAttributes().getNamedItem("match").getNodeValue();
+
+ NodeList children = node.getChildNodes();
+
+ AddressSettings addressSettings = new AddressSettings();
+
+ Pair<String, AddressSettings> setting = new Pair<String,
AddressSettings>(match, addressSettings);
+
+ for (int i = 0; i < children.getLength(); i++)
+ {
+ Node child = children.item(i);
+
+ if
(FileConfigurationParser.DEAD_LETTER_ADDRESS_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
+ {
+ SimpleString queueName = new SimpleString(child.getTextContent());
+ addressSettings.setDeadLetterAddress(queueName);
+ }
+ else if
(FileConfigurationParser.EXPIRY_ADDRESS_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
+ {
+ SimpleString queueName = new SimpleString(child.getTextContent());
+ addressSettings.setExpiryAddress(queueName);
+ }
+ else if
(FileConfigurationParser.REDELIVERY_DELAY_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
+ {
+ addressSettings.setRedeliveryDelay(Long.valueOf(child.getTextContent()));
+ }
+ else if
(FileConfigurationParser.MAX_SIZE_BYTES_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
+ {
+ addressSettings.setMaxSizeBytes(Integer.valueOf(child.getTextContent()));
+ }
+ else if
(FileConfigurationParser.PAGE_SIZE_BYTES_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
+ {
+ addressSettings.setPageSizeBytes(Integer.valueOf(child.getTextContent()));
+ }
+ else if
(FileConfigurationParser.MESSAGE_COUNTER_HISTORY_DAY_LIMIT_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
+ {
+
addressSettings.setMessageCounterHistoryDayLimit(Integer.valueOf(child.getTextContent()));
+ }
+ else if
(FileConfigurationParser.ADDRESS_FULL_MESSAGE_POLICY_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
+ {
+ String value = child.getTextContent().trim();
+
Validators.ADDRESS_FULL_MESSAGE_POLICY_TYPE.validate(FileConfigurationParser.ADDRESS_FULL_MESSAGE_POLICY_NODE_NAME,
+ value);
+ AddressFullMessagePolicy policy = null;
+ if (value.equals(AddressFullMessagePolicy.BLOCK.toString()))
+ {
+ policy = AddressFullMessagePolicy.BLOCK;
+ }
+ else if (value.equals(AddressFullMessagePolicy.DROP.toString()))
+ {
+ policy = AddressFullMessagePolicy.DROP;
+ }
+ else if (value.equals(AddressFullMessagePolicy.PAGE.toString()))
+ {
+ policy = AddressFullMessagePolicy.PAGE;
+ }
+ addressSettings.setAddressFullMessagePolicy(policy);
+ }
+ else if
(FileConfigurationParser.LVQ_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
+ {
+
addressSettings.setLastValueQueue(Boolean.valueOf(child.getTextContent().trim()));
+ }
+ else if
(FileConfigurationParser.MAX_DELIVERY_ATTEMPTS.equalsIgnoreCase(child.getNodeName()))
+ {
+
addressSettings.setMaxDeliveryAttempts(Integer.valueOf(child.getTextContent().trim()));
+ }
+ else if
(FileConfigurationParser.REDISTRIBUTION_DELAY_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
+ {
+
addressSettings.setRedistributionDelay(Long.valueOf(child.getTextContent().trim()));
+ }
+ else if
(FileConfigurationParser.SEND_TO_DLA_ON_NO_ROUTE.equalsIgnoreCase(child.getNodeName()))
+ {
+
addressSettings.setSendToDLAOnNoRoute(Boolean.valueOf(child.getTextContent().trim()));
+ }
+ }
+ return setting;
+ }
+
+ public QueueConfiguration parseQueueConfiguration(final Node node)
+ {
+ String name = node.getAttributes().getNamedItem("name").getNodeValue();
+ String address = null;
+ String filterString = null;
+ boolean durable = true;
+
+ NodeList children = node.getChildNodes();
+
+ for (int j = 0; j < children.getLength(); j++)
+ {
+ Node child = children.item(j);
+
+ if (child.getNodeName().equals("address"))
+ {
+ address = child.getTextContent().trim();
+ }
+ else if (child.getNodeName().equals("filter"))
+ {
+ filterString =
child.getAttributes().getNamedItem("string").getNodeValue();
+ }
+ else if (child.getNodeName().equals("durable"))
+ {
+ durable = Boolean.parseBoolean(child.getTextContent().trim());
+ }
+ }
+
+ return new QueueConfiguration(address, name, filterString, durable);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ private TransportConfiguration parseTransportConfiguration(final Element e)
+ {
+ Node nameNode = e.getAttributes().getNamedItem("name");
+
+ String name = nameNode != null ? nameNode.getNodeValue() : null;
+
+ String clazz = XMLConfigurationUtil.getString(e, "factory-class", null,
Validators.NOT_NULL_OR_EMPTY);
+
+ Map<String, Object> params = new HashMap<String, Object>();
+
+ NodeList paramsNodes = e.getElementsByTagName("param");
+
+ for (int i = 0; i < paramsNodes.getLength(); i++)
+ {
+ Node paramNode = paramsNodes.item(i);
+ NamedNodeMap attributes = paramNode.getAttributes();
+
+ Node nkey = attributes.getNamedItem("key");
+
+ String key = nkey.getTextContent();
+
+ Node nValue = attributes.getNamedItem("value");
+
+ params.put(key, nValue.getTextContent());
+ }
+
+ return new TransportConfiguration(clazz, params, name);
+ }
+
+ private void parseBroadcastGroupConfiguration(final Element e, final Configuration
mainConfig)
+ {
+ String name = e.getAttribute("name");
+
+ String localAddress = XMLConfigurationUtil.getString(e,
"local-bind-address", null, Validators.NO_CHECK);
+
+ int localBindPort = XMLConfigurationUtil.getInteger(e, "local-bind-port",
-1, Validators.MINUS_ONE_OR_GT_ZERO);
+
+ String groupAddress = XMLConfigurationUtil.getString(e, "group-address",
null, Validators.NOT_NULL_OR_EMPTY);
+
+ int groupPort = XMLConfigurationUtil.getInteger(e, "group-port", -1,
Validators.GT_ZERO);
+
+ long broadcastPeriod = XMLConfigurationUtil.getLong(e,
+ "broadcast-period",
+
ConfigurationImpl.DEFAULT_BROADCAST_PERIOD,
+ Validators.GT_ZERO);
+
+ NodeList children = e.getChildNodes();
+
+ List<Pair<String, String>> connectorNames = new
ArrayList<Pair<String, String>>();
+
+ for (int j = 0; j < children.getLength(); j++)
+ {
+ Node child = children.item(j);
+
+ if (child.getNodeName().equals("connector-ref"))
+ {
+ String connectorName =
child.getAttributes().getNamedItem("connector-name").getNodeValue();
+
+ Node backupConnectorNode =
child.getAttributes().getNamedItem("backup-connector-name");
+
+ String backupConnectorName = null;
+
+ if (backupConnectorNode != null)
+ {
+ backupConnectorName = backupConnectorNode.getNodeValue();
+ }
+
+ Pair<String, String> connectorInfo = new Pair<String,
String>(connectorName, backupConnectorName);
+
+ connectorNames.add(connectorInfo);
+ }
+ }
+
+ BroadcastGroupConfiguration config = new BroadcastGroupConfiguration(name,
+ localAddress,
+
localBindPort,
+ groupAddress,
+ groupPort,
+
broadcastPeriod,
+
connectorNames);
+
+ mainConfig.getBroadcastGroupConfigurations().add(config);
+ }
+
+ private void parseDiscoveryGroupConfiguration(final Element e, final Configuration
mainConfig)
+ {
+ String name = e.getAttribute("name");
+
+ String groupAddress = XMLConfigurationUtil.getString(e, "group-address",
null, Validators.NOT_NULL_OR_EMPTY);
+
+ int groupPort = XMLConfigurationUtil.getInteger(e, "group-port", -1,
Validators.MINUS_ONE_OR_GT_ZERO);
+
+ long refreshTimeout = XMLConfigurationUtil.getLong(e,
+ "refresh-timeout",
+
ConfigurationImpl.DEFAULT_BROADCAST_REFRESH_TIMEOUT,
+ Validators.GT_ZERO);
+
+ DiscoveryGroupConfiguration config = new DiscoveryGroupConfiguration(name,
+ groupAddress,
+ groupPort,
+
refreshTimeout);
+
+ if (mainConfig.getDiscoveryGroupConfigurations().containsKey(name))
+ {
+ FileConfigurationParser.log.warn("There is already a discovery group with
name " + name +
+ " deployed. This one will not be
deployed.");
+
+ return;
+ }
+ else
+ {
+ mainConfig.getDiscoveryGroupConfigurations().put(name, config);
+ }
+ }
+
+ private void parseClusterConnectionConfiguration(final Element e, final Configuration
mainConfig)
+ {
+ String name = e.getAttribute("name");
+
+ String address = XMLConfigurationUtil.getString(e, "address", null,
Validators.NOT_NULL_OR_EMPTY);
+
+ boolean duplicateDetection = XMLConfigurationUtil.getBoolean(e,
+
"use-duplicate-detection",
+
ConfigurationImpl.DEFAULT_CLUSTER_DUPLICATE_DETECTION);
+
+ boolean forwardWhenNoConsumers = XMLConfigurationUtil.getBoolean(e,
+
"forward-when-no-consumers",
+
ConfigurationImpl.DEFAULT_CLUSTER_FORWARD_WHEN_NO_CONSUMERS);
+
+ int maxHops = XMLConfigurationUtil.getInteger(e,
+ "max-hops",
+
ConfigurationImpl.DEFAULT_CLUSTER_MAX_HOPS,
+ Validators.GE_ZERO);
+
+ long retryInterval = XMLConfigurationUtil.getLong(e,
+ "retry-interval",
+
ConfigurationImpl.DEFAULT_CLUSTER_RETRY_INTERVAL,
+ Validators.GT_ZERO);
+
+ int confirmationWindowSize = XMLConfigurationUtil.getInteger(e,
+
"confirmation-window-size",
+
FileConfiguration.DEFAULT_CONFIRMATION_WINDOW_SIZE,
+ Validators.GT_ZERO);
+
+ String discoveryGroupName = null;
+
+ List<Pair<String, String>> connectorPairs = new
ArrayList<Pair<String, String>>();
+
+ NodeList children = e.getChildNodes();
+
+ for (int j = 0; j < children.getLength(); j++)
+ {
+ Node child = children.item(j);
+
+ if (child.getNodeName().equals("discovery-group-ref"))
+ {
+ discoveryGroupName =
child.getAttributes().getNamedItem("discovery-group-name").getNodeValue();
+ }
+ else if (child.getNodeName().equals("connector-ref"))
+ {
+ String connectorName =
child.getAttributes().getNamedItem("connector-name").getNodeValue();
+
+ Node backupNode =
child.getAttributes().getNamedItem("backup-connector-name");
+
+ String backupConnectorName = null;
+
+ if (backupNode != null)
+ {
+ backupConnectorName = backupNode.getNodeValue();
+ }
+
+ Pair<String, String> connectorPair = new Pair<String,
String>(connectorName, backupConnectorName);
+
+ connectorPairs.add(connectorPair);
+ }
+ }
+
+ ClusterConnectionConfiguration config;
+
+ if (discoveryGroupName == null)
+ {
+ config = new ClusterConnectionConfiguration(name,
+ address,
+ retryInterval,
+ duplicateDetection,
+ forwardWhenNoConsumers,
+ maxHops,
+ confirmationWindowSize,
+ connectorPairs);
+ }
+ else
+ {
+ config = new ClusterConnectionConfiguration(name,
+ address,
+ retryInterval,
+ duplicateDetection,
+ forwardWhenNoConsumers,
+ maxHops,
+ confirmationWindowSize,
+ discoveryGroupName);
+ }
+
+ mainConfig.getClusterConfigurations().add(config);
+ }
+
+ private void parseGroupingHandlerConfiguration(final Element node, final Configuration
mainConfiguration)
+ {
+ String name = node.getAttribute("name");
+ String type = XMLConfigurationUtil.getString(node, "type", null,
Validators.NOT_NULL_OR_EMPTY);
+ String address = XMLConfigurationUtil.getString(node, "address", null,
Validators.NOT_NULL_OR_EMPTY);
+ Integer timeout = XMLConfigurationUtil.getInteger(node,
+ "timeout",
+
GroupingHandlerConfiguration.DEFAULT_TIMEOUT,
+ Validators.GT_ZERO);
+ mainConfiguration.setGroupingHandlerConfiguration(new
GroupingHandlerConfiguration(new SimpleString(name),
+
type.equals(GroupingHandlerConfiguration.TYPE.LOCAL.getType()) ?
GroupingHandlerConfiguration.TYPE.LOCAL
+
:
GroupingHandlerConfiguration.TYPE.REMOTE,
+
new SimpleString(address),
+
timeout));
+ }
+
+ private void parseBridgeConfiguration(final Element brNode, final Configuration
mainConfig)
+ {
+ String name = brNode.getAttribute("name");
+
+ String queueName = XMLConfigurationUtil.getString(brNode, "queue-name",
null, Validators.NOT_NULL_OR_EMPTY);
+
+ String forwardingAddress = XMLConfigurationUtil.getString(brNode,
+
"forwarding-address",
+ null,
+
Validators.NOT_NULL_OR_EMPTY);
+
+ String transformerClassName = XMLConfigurationUtil.getString(brNode,
+
"transformer-class-name",
+ null,
+ Validators.NO_CHECK);
+
+ long retryInterval = XMLConfigurationUtil.getLong(brNode,
+ "retry-interval",
+
HornetQClient.DEFAULT_RETRY_INTERVAL,
+ Validators.GT_ZERO);
+
+ // Default bridge conf
+ int confirmationWindowSize = XMLConfigurationUtil.getInteger(brNode,
+
"confirmation-window-size",
+
FileConfiguration.DEFAULT_CONFIRMATION_WINDOW_SIZE,
+ Validators.GT_ZERO);
+
+ double retryIntervalMultiplier = XMLConfigurationUtil.getDouble(brNode,
+
"retry-interval-multiplier",
+
HornetQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
+
Validators.GT_ZERO);
+
+ int reconnectAttempts = XMLConfigurationUtil.getInteger(brNode,
+
"reconnect-attempts",
+
ConfigurationImpl.DEFAULT_BRIDGE_RECONNECT_ATTEMPTS,
+
Validators.MINUS_ONE_OR_GE_ZERO);
+
+ boolean failoverOnServerShutdown = XMLConfigurationUtil.getBoolean(brNode,
+
"failover-on-server-shutdown",
+
HornetQClient.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN);
+
+ boolean useDuplicateDetection = XMLConfigurationUtil.getBoolean(brNode,
+
"use-duplicate-detection",
+
ConfigurationImpl.DEFAULT_BRIDGE_DUPLICATE_DETECTION);
+
+ String user = XMLConfigurationUtil.getString(brNode,
+ "user",
+
ConfigurationImpl.DEFAULT_CLUSTER_USER,
+ Validators.NO_CHECK);
+
+ String password = XMLConfigurationUtil.getString(brNode,
+ "password",
+
ConfigurationImpl.DEFAULT_CLUSTER_PASSWORD,
+ Validators.NO_CHECK);
+
+ String filterString = null;
+
+ Pair<String, String> connectorPair = null;
+
+ String discoveryGroupName = null;
+
+ NodeList children = brNode.getChildNodes();
+
+ for (int j = 0; j < children.getLength(); j++)
+ {
+ Node child = children.item(j);
+
+ if (child.getNodeName().equals("filter"))
+ {
+ filterString =
child.getAttributes().getNamedItem("string").getNodeValue();
+ }
+ else if (child.getNodeName().equals("discovery-group-ref"))
+ {
+ discoveryGroupName =
child.getAttributes().getNamedItem("discovery-group-name").getNodeValue();
+ }
+ else if (child.getNodeName().equals("connector-ref"))
+ {
+ String connectorName =
child.getAttributes().getNamedItem("connector-name").getNodeValue();
+
+ Node backupNode =
child.getAttributes().getNamedItem("backup-connector-name");
+
+ String backupConnectorName = null;
+
+ if (backupNode != null)
+ {
+ backupConnectorName = backupNode.getNodeValue();
+ }
+
+ connectorPair = new Pair<String, String>(connectorName,
backupConnectorName);
+ }
+ }
+
+ BridgeConfiguration config;
+
+ if (connectorPair != null)
+ {
+ config = new BridgeConfiguration(name,
+ queueName,
+ forwardingAddress,
+ filterString,
+ transformerClassName,
+ retryInterval,
+ retryIntervalMultiplier,
+ reconnectAttempts,
+ failoverOnServerShutdown,
+ useDuplicateDetection,
+ confirmationWindowSize,
+
HornetQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
+ connectorPair,
+ user,
+ password);
+ }
+ else
+ {
+ config = new BridgeConfiguration(name,
+ queueName,
+ forwardingAddress,
+ filterString,
+ transformerClassName,
+ retryInterval,
+ retryIntervalMultiplier,
+ reconnectAttempts,
+ failoverOnServerShutdown,
+ useDuplicateDetection,
+ confirmationWindowSize,
+
HornetQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
+ discoveryGroupName,
+ user,
+ password);
+ }
+
+ mainConfig.getBridgeConfigurations().add(config);
+ }
+
+ private void parseDivertConfiguration(final Element e, final Configuration
mainConfig)
+ {
+ String name = e.getAttribute("name");
+
+ String routingName = XMLConfigurationUtil.getString(e, "routing-name",
null, Validators.NO_CHECK);
+
+ String address = XMLConfigurationUtil.getString(e, "address", null,
Validators.NOT_NULL_OR_EMPTY);
+
+ String forwardingAddress = XMLConfigurationUtil.getString(e,
+
"forwarding-address",
+ null,
+
Validators.NOT_NULL_OR_EMPTY);
+
+ boolean exclusive = XMLConfigurationUtil.getBoolean(e, "exclusive",
ConfigurationImpl.DEFAULT_DIVERT_EXCLUSIVE);
+
+ String transformerClassName = XMLConfigurationUtil.getString(e,
+
"transformer-class-name",
+ null,
+ Validators.NO_CHECK);
+
+ String filterString = null;
+
+ NodeList children = e.getChildNodes();
+
+ for (int j = 0; j < children.getLength(); j++)
+ {
+ Node child = children.item(j);
+
+ if (child.getNodeName().equals("filter"))
+ {
+ filterString =
child.getAttributes().getNamedItem("string").getNodeValue();
+ }
+ }
+
+ DivertConfiguration config = new DivertConfiguration(name,
+ routingName,
+ address,
+ forwardingAddress,
+ exclusive,
+ filterString,
+ transformerClassName);
+
+ mainConfig.getDivertConfigurations().add(config);
+ }
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: trunk/src/main/org/hornetq/core/deployers/impl/QueueDeployer.java
===================================================================
--- trunk/src/main/org/hornetq/core/deployers/impl/QueueDeployer.java 2010-02-08 10:28:19
UTC (rev 8867)
+++ trunk/src/main/org/hornetq/core/deployers/impl/QueueDeployer.java 2010-02-10 14:15:24
UTC (rev 8868)
@@ -17,7 +17,6 @@
import org.hornetq.core.deployers.DeploymentManager;
import org.hornetq.core.server.cluster.QueueConfiguration;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
* A QueueDeployer
@@ -30,6 +29,8 @@
{
private final HornetQServerControl serverControl;
+ private final FileConfigurationParser parser = new FileConfigurationParser();
+
public QueueDeployer(final DeploymentManager deploymentManager, final
HornetQServerControl serverControl)
{
super(deploymentManager);
@@ -61,7 +62,7 @@
@Override
public void deploy(final Node node) throws Exception
{
- QueueConfiguration queueConfig = parseQueueConfiguration(node);
+ QueueConfiguration queueConfig = parser.parseQueueConfiguration(node);
serverControl.deployQueue(queueConfig.getAddress(),
queueConfig.getName(),
@@ -86,34 +87,4 @@
return new String[] { "hornetq-configuration.xml",
"hornetq-queues.xml" };
}
- private QueueConfiguration parseQueueConfiguration(final Node node)
- {
- String name = node.getAttributes().getNamedItem("name").getNodeValue();
- String address = null;
- String filterString = null;
- boolean durable = true;
-
- NodeList children = node.getChildNodes();
-
- for (int j = 0; j < children.getLength(); j++)
- {
- Node child = children.item(j);
-
- if (child.getNodeName().equals("address"))
- {
- address = child.getTextContent().trim();
- }
- else if (child.getNodeName().equals("filter"))
- {
- filterString =
child.getAttributes().getNamedItem("string").getNodeValue();
- }
- else if (child.getNodeName().equals("durable"))
- {
- durable = Boolean.parseBoolean(child.getTextContent().trim());
- }
- }
-
- return new QueueConfiguration(address, name, filterString, durable);
- }
-
}
Modified: trunk/src/main/org/hornetq/core/deployers/impl/SecurityDeployer.java
===================================================================
--- trunk/src/main/org/hornetq/core/deployers/impl/SecurityDeployer.java 2010-02-08
10:28:19 UTC (rev 8867)
+++ trunk/src/main/org/hornetq/core/deployers/impl/SecurityDeployer.java 2010-02-10
14:15:24 UTC (rev 8868)
@@ -13,16 +13,14 @@
package org.hornetq.core.deployers.impl;
-import java.util.ArrayList;
-import java.util.HashSet;
import java.util.Set;
+import org.hornetq.api.core.Pair;
import org.hornetq.core.deployers.DeploymentManager;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.security.Role;
import org.hornetq.core.settings.HierarchicalRepository;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
* Deploys the security settings into a security repository and adds them to the security
store.
@@ -33,32 +31,12 @@
{
private static final Logger log = Logger.getLogger(SecurityDeployer.class);
- private static final String PERMISSION_ELEMENT_NAME = "permission";
-
- private static final String TYPE_ATTR_NAME = "type";
-
- private static final String ROLES_ATTR_NAME = "roles";
-
private static final String QUEUES_XML = "hornetq-queues.xml";
private static final String MATCH = "match";
- private static final String SECURITY_ELEMENT_NAME = "security-setting";
+ private final FileConfigurationParser parser = new FileConfigurationParser();
- public static final String SEND_NAME = "send";
-
- public static final String CONSUME_NAME = "consume";
-
- public static final String CREATEDURABLEQUEUE_NAME = "createDurableQueue";
-
- public static final String DELETEDURABLEQUEUE_NAME = "deleteDurableQueue";
-
- public static final String CREATETEMPQUEUE_NAME = "createTempQueue";
-
- public static final String DELETETEMPQUEUE_NAME = "deleteTempQueue";
-
- public static final String MANAGE_NAME = "manage";
-
/**
* The repository to add to
*/
@@ -80,7 +58,7 @@
@Override
public String[] getElementTagName()
{
- return new String[] { SecurityDeployer.SECURITY_ELEMENT_NAME };
+ return new String[] { FileConfigurationParser.SECURITY_ELEMENT_NAME };
}
@Override
@@ -109,76 +87,8 @@
@Override
public void deploy(final Node node) throws Exception
{
- HashSet<Role> securityRoles = new HashSet<Role>();
- ArrayList<String> send = new ArrayList<String>();
- ArrayList<String> consume = new ArrayList<String>();
- ArrayList<String> createDurableQueue = new ArrayList<String>();
- ArrayList<String> deleteDurableQueue = new ArrayList<String>();
- ArrayList<String> createTempQueue = new ArrayList<String>();
- ArrayList<String> deleteTempQueue = new ArrayList<String>();
- ArrayList<String> manageRoles = new ArrayList<String>();
- ArrayList<String> allRoles = new ArrayList<String>();
- String match =
node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
- NodeList children = node.getChildNodes();
- for (int i = 0; i < children.getLength(); i++)
- {
- Node child = children.item(i);
-
- if
(SecurityDeployer.PERMISSION_ELEMENT_NAME.equalsIgnoreCase(child.getNodeName()))
- {
- String type =
child.getAttributes().getNamedItem(SecurityDeployer.TYPE_ATTR_NAME).getNodeValue();
- String roleString =
child.getAttributes().getNamedItem(SecurityDeployer.ROLES_ATTR_NAME).getNodeValue();
- String[] roles = roleString.split(",");
- for (String role : roles)
- {
- if (SecurityDeployer.SEND_NAME.equals(type))
- {
- send.add(role.trim());
- }
- else if (SecurityDeployer.CONSUME_NAME.equals(type))
- {
- consume.add(role.trim());
- }
- else if (SecurityDeployer.CREATEDURABLEQUEUE_NAME.equals(type))
- {
- createDurableQueue.add(role);
- }
- else if (SecurityDeployer.DELETEDURABLEQUEUE_NAME.equals(type))
- {
- deleteDurableQueue.add(role);
- }
- else if (SecurityDeployer.CREATETEMPQUEUE_NAME.equals(type))
- {
- createTempQueue.add(role);
- }
- else if (SecurityDeployer.DELETETEMPQUEUE_NAME.equals(type))
- {
- deleteTempQueue.add(role);
- }
- else if (SecurityDeployer.MANAGE_NAME.equals(type))
- {
- manageRoles.add(role);
- }
- if (!allRoles.contains(role.trim()))
- {
- allRoles.add(role.trim());
- }
- }
- }
-
- }
- for (String role : allRoles)
- {
- securityRoles.add(new Role(role,
- send.contains(role),
- consume.contains(role),
- createDurableQueue.contains(role),
- deleteDurableQueue.contains(role),
- createTempQueue.contains(role),
- deleteTempQueue.contains(role),
- manageRoles.contains(role)));
- }
- securityRepository.addMatch(match, securityRoles);
+ Pair<String, Set<Role>> securityMatch =
parser.parseSecurityRoles(node);
+ securityRepository.addMatch(securityMatch.a, securityMatch.b);
}
/**
Modified: trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2010-02-08 10:28:19
UTC (rev 8867)
+++ trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2010-02-10 14:15:24
UTC (rev 8868)
@@ -975,6 +975,8 @@
configuration.isBackup());
// Address settings need to deployed initially, since they're require on paging
manager.start()
+
+ deployAddressSettingsFromConfiguration();
if (configuration.isFileDeploymentEnabled())
{
@@ -998,6 +1000,8 @@
resourceManager.start();
+ deploySecurityFromConfiguration();
+
// Deploy all security related config
if (configuration.isFileDeploymentEnabled())
{
@@ -1088,6 +1092,14 @@
}
}
+ private void deploySecurityFromConfiguration()
+ {
+ for (Map.Entry<String, Set<Role>> entry :
configuration.getSecurityRoles().entrySet())
+ {
+ securityRepository.addMatch(entry.getKey(), entry.getValue());
+ }
+ }
+
private void deployQueuesFromConfiguration() throws Exception
{
for (QueueConfiguration config : configuration.getQueueConfigurations())
@@ -1099,6 +1111,15 @@
}
}
+ private void deployAddressSettingsFromConfiguration()
+ {
+ for (Map.Entry<String, AddressSettings> entry :
configuration.getAddressesSettings().entrySet())
+ {
+ addressSettingsRepository.addMatch(entry.getKey(), entry.getValue());
+ }
+ }
+
+
private JournalLoadInformation[] loadJournals() throws Exception
{
JournalLoadInformation[] journalInfo = new JournalLoadInformation[2];
Modified: trunk/src/main/org/hornetq/core/settings/impl/AddressSettings.java
===================================================================
--- trunk/src/main/org/hornetq/core/settings/impl/AddressSettings.java 2010-02-08 10:28:19
UTC (rev 8867)
+++ trunk/src/main/org/hornetq/core/settings/impl/AddressSettings.java 2010-02-10 14:15:24
UTC (rev 8868)
@@ -13,6 +13,8 @@
package org.hornetq.core.settings.impl;
+import java.io.Serializable;
+
import org.hornetq.api.core.SimpleString;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.settings.Mergeable;
@@ -23,8 +25,10 @@
* @author <a href="ataylor(a)redhat.com">Andy Taylor</a>
* @author <a href="tim.fox(a)jboss.com">Tim Fox</a>
*/
-public class AddressSettings implements Mergeable<AddressSettings>
+public class AddressSettings implements Mergeable<AddressSettings>, Serializable
{
+ private static final long serialVersionUID = 1607502280582336366L;
+
private static Logger log = Logger.getLogger(AddressSettings.class);
/**
Modified: trunk/tests/config/ConfigurationTest-full-config.xml
===================================================================
--- trunk/tests/config/ConfigurationTest-full-config.xml 2010-02-08 10:28:19 UTC (rev
8867)
+++ trunk/tests/config/ConfigurationTest-full-config.xml 2010-02-10 14:15:24 UTC (rev
8868)
@@ -182,4 +182,33 @@
<discovery-group-ref discovery-group-name="dg1"/>
</cluster-connection>
</cluster-connections>
+
+ <security-settings>
+ <security-setting match="a1">
+ <permission type="createTempQueue" roles="a1.1"/>
+ </security-setting>
+ <security-setting match="a2">
+ <permission type="deleteTempQueue" roles="a2.1"/>
+ </security-setting>
+ </security-settings>
+
+ <address-settings>
+ <address-setting match="a1">
+ <dead-letter-address>a1.1</dead-letter-address>
+ <expiry-address>a1.2</expiry-address>
+ <redelivery-delay>1</redelivery-delay>
+ <max-size-bytes>2</max-size-bytes>
+ <page-size-bytes>3</page-size-bytes>
+
<message-counter-history-day-limit>4</message-counter-history-day-limit>
+ </address-setting>
+ <address-setting match="a2">
+ <dead-letter-address>a2.1</dead-letter-address>
+ <expiry-address>a2.2</expiry-address>
+ <redelivery-delay>5</redelivery-delay>
+ <max-size-bytes>6</max-size-bytes>
+ <page-size-bytes>7</page-size-bytes>
+
<message-counter-history-day-limit>8</message-counter-history-day-limit>
+ </address-setting>
+ </address-settings>
+
</configuration>
Modified:
trunk/tests/src/org/hornetq/tests/unit/core/config/impl/FileConfigurationTest.java
===================================================================
---
trunk/tests/src/org/hornetq/tests/unit/core/config/impl/FileConfigurationTest.java 2010-02-08
10:28:19 UTC (rev 8867)
+++
trunk/tests/src/org/hornetq/tests/unit/core/config/impl/FileConfigurationTest.java 2010-02-10
14:15:24 UTC (rev 8868)
@@ -19,6 +19,7 @@
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.config.impl.FileConfiguration;
+import org.hornetq.core.security.Role;
import org.hornetq.core.server.JournalType;
import org.hornetq.core.server.cluster.BridgeConfiguration;
import org.hornetq.core.server.cluster.BroadcastGroupConfiguration;
@@ -258,7 +259,67 @@
Assert.assertEquals("dg1", ccc.getDiscoveryGroupName());
}
}
+
+
+ assertEquals(2, conf.getAddressesSettings().size());
+
+ assertTrue(conf.getAddressesSettings().get("a1") != null);
+ assertTrue(conf.getAddressesSettings().get("a2") != null);
+
+ assertEquals("a1.1",
conf.getAddressesSettings().get("a1").getDeadLetterAddress().toString());
+ assertEquals("a1.2",
conf.getAddressesSettings().get("a1").getExpiryAddress().toString());
+ assertEquals(1,
conf.getAddressesSettings().get("a1").getRedeliveryDelay());
+ assertEquals(2,
conf.getAddressesSettings().get("a1").getMaxSizeBytes());
+ assertEquals(3,
conf.getAddressesSettings().get("a1").getPageSizeBytes());
+ assertEquals(4,
conf.getAddressesSettings().get("a1").getMessageCounterHistoryDayLimit());
+ assertEquals("a2.1",
conf.getAddressesSettings().get("a2").getDeadLetterAddress().toString());
+ assertEquals("a2.2",
conf.getAddressesSettings().get("a2").getExpiryAddress().toString());
+ assertEquals(5,
conf.getAddressesSettings().get("a2").getRedeliveryDelay());
+ assertEquals(6,
conf.getAddressesSettings().get("a2").getMaxSizeBytes());
+ assertEquals(7,
conf.getAddressesSettings().get("a2").getPageSizeBytes());
+ assertEquals(8,
conf.getAddressesSettings().get("a2").getMessageCounterHistoryDayLimit());
+
+
+ assertEquals(2, conf.getQueueConfigurations().size());
+
+ assertEquals("queue1", conf.getQueueConfigurations().get(0).getName());
+ assertEquals("address1",
conf.getQueueConfigurations().get(0).getAddress());
+ assertEquals("color='red'",
conf.getQueueConfigurations().get(0).getFilterString());
+ assertEquals(false, conf.getQueueConfigurations().get(0).isDurable());
+
+ assertEquals("queue2", conf.getQueueConfigurations().get(1).getName());
+ assertEquals("address2",
conf.getQueueConfigurations().get(1).getAddress());
+ assertEquals("color='blue'",
conf.getQueueConfigurations().get(1).getFilterString());
+ assertEquals(false, conf.getQueueConfigurations().get(1).isDurable());
+
+ assertEquals(2, conf.getSecurityRoles().size());
+
+ assertTrue(conf.getSecurityRoles().containsKey("a1"));
+
+ assertTrue(conf.getSecurityRoles().containsKey("a2"));
+
+ Role a1Role = conf.getSecurityRoles().get("a1").toArray(new Role[1])[0];
+
+ assertFalse(a1Role.isSend());
+ assertFalse(a1Role.isConsume());
+ assertFalse(a1Role.isCreateDurableQueue());
+ assertFalse(a1Role.isDeleteDurableQueue());
+ assertTrue(a1Role.isCreateNonDurableQueue());
+ assertFalse(a1Role.isDeleteNonDurableQueue());
+ assertFalse(a1Role.isManage());
+
+ Role a2Role = conf.getSecurityRoles().get("a2").toArray(new Role[1])[0];
+
+ assertFalse(a2Role.isSend());
+ assertFalse(a2Role.isConsume());
+ assertFalse(a2Role.isCreateDurableQueue());
+ assertFalse(a2Role.isDeleteDurableQueue());
+ assertFalse(a2Role.isCreateNonDurableQueue());
+ assertTrue(a2Role.isDeleteNonDurableQueue());
+ assertFalse(a2Role.isManage());
+
+
}
public void testSetGetConfigurationURL()