Repository: activemq-artemis
Updated Branches:
  refs/heads/ARTEMIS-780 [created] 58310fa85


ARTEMIS-782 Added configuration elements for new address model


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/58310fa8
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/58310fa8
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/58310fa8

Branch: refs/heads/ARTEMIS-780
Commit: 58310fa8553e9d4a6c6433cb4e99b8ea9e53537e
Parents: ffaeceb
Author: Martyn Taylor <mtay...@redhat.com>
Authored: Tue Oct 18 19:45:02 2016 +0100
Committer: Martyn Taylor <mtay...@redhat.com>
Committed: Tue Oct 18 19:45:02 2016 +0100

----------------------------------------------------------------------
 .../config/ActiveMQDefaultConfiguration.java    |  12 ++
 .../artemis/core/config/Configuration.java      |  15 ++
 .../core/config/CoreAddressConfiguration.java   | 145 +++++++++++++++++++
 .../core/config/CoreQueueConfiguration.java     |  43 ++++++
 .../core/config/impl/ConfigurationImpl.java     |  20 +++
 .../deployers/impl/FileConfigurationParser.java |  80 +++++++++-
 .../resources/schema/artemis-configuration.xsd  |  78 +++++++++-
 .../impl/DefaultsFileConfigurationTest.java     |   2 +
 .../core/config/impl/FileConfigurationTest.java |  63 ++++++++
 .../resources/ConfigurationTest-full-config.xml |  26 ++++
 10 files changed, 478 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58310fa8/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
----------------------------------------------------------------------
diff --git 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
index e07493f..04d06c0 100644
--- 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
+++ 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
@@ -435,6 +435,10 @@ public final class ActiveMQDefaultConfiguration {
 
    public static final int DEFAULT_DISK_SCAN = 5000;
 
+   public static final int DEFAULT_MAX_QUEUE_CONSUMERS = -1;
+
+   public static final boolean DEFAULT_DELETE_QUEUE_ON_NO_CONSUMERS = false;
+
    /**
     * If true then the ActiveMQ Artemis Server will make use of any Protocol 
Managers that are in available on the classpath. If false then only the core 
protocol will be available, unless in Embedded mode where users can inject 
their own Protocol Managers.
     */
@@ -1168,4 +1172,12 @@ public final class ActiveMQDefaultConfiguration {
    public static int getDefaultDiskScanPeriod() {
       return DEFAULT_DISK_SCAN;
    }
+
+   public static int getDefaultMaxQueueConsumers() {
+      return DEFAULT_MAX_QUEUE_CONSUMERS;
+   }
+
+   public static boolean getDefaultDeleteQueueOnNoConsumers() {
+      return DEFAULT_DELETE_QUEUE_ON_NO_CONSUMERS;
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58310fa8/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
----------------------------------------------------------------------
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
index f486a88..17a305e 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
@@ -387,6 +387,21 @@ public interface Configuration {
    Configuration addQueueConfiguration(final CoreQueueConfiguration config);
 
    /**
+    * Returns the addresses configured for this server.
+    */
+   List<CoreAddressConfiguration> getAddressConfigurations();
+
+   /**
+    * Sets the addresses configured for this server.
+    */
+   Configuration setAddressConfigurations(final List<CoreAddressConfiguration> 
configs);
+
+   /**
+    * Adds an addresses configuration
+    */
+   Configuration addAddressConfiguration(final CoreAddressConfiguration 
config);
+
+   /**
     * Returns the management address of this server. <br>
     * Clients can send management messages to this address to manage this 
server. <br>
     * Default value is {@link 
org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration#DEFAULT_MANAGEMENT_ADDRESS}.

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58310fa8/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreAddressConfiguration.java
----------------------------------------------------------------------
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreAddressConfiguration.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreAddressConfiguration.java
new file mode 100644
index 0000000..cb6d43f
--- /dev/null
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreAddressConfiguration.java
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.apache.activemq.artemis.core.config;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
+
+public class CoreAddressConfiguration implements Serializable {
+
+   public enum RoutingType {
+      MULTICAST,
+      ANYCAST
+   }
+
+   private String name = null;
+
+   private RoutingType routingType = null;
+
+   private Integer defaultMaxConsumers = 
ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers();
+
+   private Boolean defaultDeleteOnNoConsumers = 
ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers();
+
+   private List<CoreQueueConfiguration> queueConfigurations = new 
ArrayList<>();
+
+   public CoreAddressConfiguration() {
+   }
+
+   public String getName() {
+      return name;
+   }
+
+   public CoreAddressConfiguration setName(String name) {
+      this.name = name;
+      return this;
+   }
+
+   public RoutingType getRoutingType() {
+      return routingType;
+   }
+
+   public CoreAddressConfiguration setRoutingType(RoutingType routingType) {
+      this.routingType = routingType;
+      return this;
+   }
+
+   public CoreAddressConfiguration 
setQueueConfigurations(List<CoreQueueConfiguration> queueConfigurations) {
+      this.queueConfigurations = queueConfigurations;
+      return this;
+   }
+
+   public CoreAddressConfiguration 
addQueueConfiguration(CoreQueueConfiguration queueConfiguration) {
+      this.queueConfigurations.add(queueConfiguration);
+      return this;
+   }
+
+   public List<CoreQueueConfiguration> getQueueConfigurations() {
+      return queueConfigurations;
+   }
+
+   public Boolean getDefaultDeleteOnNoConsumers() {
+      return defaultDeleteOnNoConsumers;
+   }
+
+   public CoreAddressConfiguration setDefaultDeleteOnNoConsumers(Boolean 
defaultDeleteOnNoConsumers) {
+      this.defaultDeleteOnNoConsumers = defaultDeleteOnNoConsumers;
+      return this;
+   }
+
+   public Integer getDefaultMaxConsumers() {
+      return defaultMaxConsumers;
+   }
+
+   public CoreAddressConfiguration setDefaultMaxConsumers(Integer 
defaultMaxConsumers) {
+      this.defaultMaxConsumers = defaultMaxConsumers;
+      return this;
+   }
+
+   @Override
+   public int hashCode() {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((name == null) ? 0 : name.hashCode());
+      result = prime * result + ((routingType == null) ? 0 : 
routingType.hashCode());
+      result = prime * result + ((queueConfigurations == null) ? 0 : 
queueConfigurations.hashCode());
+      result = prime * result + ((defaultMaxConsumers == null) ? 0 : 
defaultMaxConsumers.hashCode());
+      result = prime * result + ((defaultDeleteOnNoConsumers == null) ? 0 : 
defaultDeleteOnNoConsumers.hashCode());
+      return result;
+   }
+
+   @Override
+   public boolean equals(Object obj) {
+      if (this == obj)
+         return true;
+      if (obj == null)
+         return false;
+      if (getClass() != obj.getClass())
+         return false;
+      CoreAddressConfiguration other = (CoreAddressConfiguration) obj;
+      if (name == null) {
+         if (other.name != null)
+            return false;
+      } else if (!name.equals(other.name))
+         return false;
+      if (routingType == null) {
+         if (other.routingType != null)
+            return false;
+      } else if (!routingType.equals(other.routingType))
+         return false;
+      if (queueConfigurations == null) {
+         if (other.queueConfigurations != null)
+            return false;
+      } else if (!queueConfigurations.equals(other.queueConfigurations))
+         return false;
+      if (defaultMaxConsumers == null) {
+         if (other.defaultMaxConsumers != null)
+            return false;
+      } else if (!defaultMaxConsumers.equals(other.defaultMaxConsumers))
+         return false;
+      if (defaultDeleteOnNoConsumers == null) {
+         if (other.defaultDeleteOnNoConsumers != null)
+            return false;
+      } else if 
(!defaultDeleteOnNoConsumers.equals(other.defaultDeleteOnNoConsumers)) {
+         return false;
+      }
+
+      return true;
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58310fa8/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java
----------------------------------------------------------------------
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java
index 2e7b9ca..79b2fd2 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java
@@ -30,6 +30,10 @@ public class CoreQueueConfiguration implements Serializable {
 
    private boolean durable = true;
 
+   private Integer maxConsumers = null;
+
+   private Boolean deleteOnNoConsumers = null;
+
    public CoreQueueConfiguration() {
    }
 
@@ -49,6 +53,8 @@ public class CoreQueueConfiguration implements Serializable {
       return durable;
    }
 
+
+
    /**
     * @param address the address to set
     */
@@ -81,6 +87,30 @@ public class CoreQueueConfiguration implements Serializable {
       return this;
    }
 
+   /**
+    * @param maxConsumers for this queue, default is -1 (unlimited)
+    */
+   public CoreQueueConfiguration setMaxConsumers(Integer maxConsumers) {
+      this.maxConsumers = maxConsumers;
+      return this;
+   }
+
+   /**
+    * @param deleteOnNoConsumers delete this queue when consumer count reaches 
0, default is false
+    */
+   public CoreQueueConfiguration setDeleteOnNoConsumers(Boolean 
deleteOnNoConsumers) {
+      this.deleteOnNoConsumers = deleteOnNoConsumers;
+      return this;
+   }
+
+   public Boolean getDeleteOnNoConsumers() {
+      return deleteOnNoConsumers;
+   }
+
+   public Integer getMaxConsumers() {
+      return maxConsumers;
+   }
+
    @Override
    public int hashCode() {
       final int prime = 31;
@@ -89,6 +119,8 @@ public class CoreQueueConfiguration implements Serializable {
       result = prime * result + (durable ? 1231 : 1237);
       result = prime * result + ((filterString == null) ? 0 : 
filterString.hashCode());
       result = prime * result + ((name == null) ? 0 : name.hashCode());
+      result = prime * result + ((maxConsumers == null) ? 0 : 
maxConsumers.hashCode());
+      result = prime * result + ((deleteOnNoConsumers == null) ? 0 : 
deleteOnNoConsumers.hashCode());
       return result;
    }
 
@@ -118,6 +150,17 @@ public class CoreQueueConfiguration implements 
Serializable {
             return false;
       } else if (!name.equals(other.name))
          return false;
+      if (maxConsumers == null) {
+         if (other.maxConsumers != null)
+            return false;
+      } else if (!maxConsumers.equals(other.maxConsumers))
+         return false;
+      if (deleteOnNoConsumers == null) {
+         if (other.deleteOnNoConsumers != null)
+            return false;
+      } else if (!deleteOnNoConsumers.equals(other.deleteOnNoConsumers)) {
+         return false;
+      }
       return true;
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58310fa8/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
----------------------------------------------------------------------
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
index 2613929..8ff1922 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
@@ -47,6 +47,7 @@ import 
org.apache.activemq.artemis.core.config.BridgeConfiguration;
 import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
 import org.apache.activemq.artemis.core.config.Configuration;
 import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration;
+import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
 import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
 import org.apache.activemq.artemis.core.config.DivertConfiguration;
 import org.apache.activemq.artemis.core.config.HAPolicyConfiguration;
@@ -127,6 +128,8 @@ public class ConfigurationImpl implements Configuration, 
Serializable {
 
    private List<CoreQueueConfiguration> queueConfigurations = new 
ArrayList<>();
 
+   private List<CoreAddressConfiguration> addressConfigurations = new 
ArrayList<>();
+
    protected transient List<BroadcastGroupConfiguration> 
broadcastGroupConfigurations = new ArrayList<>();
 
    protected transient Map<String, DiscoveryGroupConfiguration> 
discoveryGroupConfigurations = new LinkedHashMap<>();
@@ -582,6 +585,23 @@ public class ConfigurationImpl implements Configuration, 
Serializable {
    }
 
    @Override
+   public List<CoreAddressConfiguration> getAddressConfigurations() {
+      return addressConfigurations;
+   }
+
+   @Override
+   public Configuration 
setAddressConfigurations(List<CoreAddressConfiguration> configs) {
+      this.addressConfigurations = configs;
+      return this;
+   }
+
+   @Override
+   public Configuration addAddressConfiguration(CoreAddressConfiguration 
config) {
+      this.addressConfigurations.add(config);
+      return this;
+   }
+
+   @Override
    public Map<String, DiscoveryGroupConfiguration> 
getDiscoveryGroupConfigurations() {
       return discoveryGroupConfigurations;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58310fa8/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
----------------------------------------------------------------------
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
index d90c343..fc045b3 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
@@ -43,6 +43,7 @@ import 
org.apache.activemq.artemis.core.config.BridgeConfiguration;
 import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
 import org.apache.activemq.artemis.core.config.Configuration;
 import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration;
+import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
 import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
 import org.apache.activemq.artemis.core.config.DivertConfiguration;
 import org.apache.activemq.artemis.core.config.ScaleDownConfiguration;
@@ -542,6 +543,8 @@ public final class FileConfigurationParser extends 
XMLConfigurationUtil {
 
       parseQueues(e, config);
 
+      parseAddresses(e, config);
+
       parseSecurity(e, config);
 
       NodeList connectorServiceConfigs = 
e.getElementsByTagName("connector-service");
@@ -585,13 +588,35 @@ public final class FileConfigurationParser extends 
XMLConfigurationUtil {
     */
    private void parseQueues(final Element e, final Configuration config) {
       NodeList elements = e.getElementsByTagName("queues");
+      if (elements.getLength() != 0) {
+         Element node = (Element) elements.item(0);
+         config.setQueueConfigurations(parseQueueConfigurations(node));
+      }
+   }
+
+   private List<CoreQueueConfiguration> parseQueueConfigurations(final Element 
node) {
+      List<CoreQueueConfiguration> queueConfigurations = new ArrayList<>();
+      NodeList list = node.getElementsByTagName("queue");
+      for (int i = 0; i < list.getLength(); i++) {
+         CoreQueueConfiguration queueConfig = 
parseQueueConfiguration(list.item(i));
+         queueConfigurations.add(queueConfig);
+      }
+      return queueConfigurations;
+   }
+
+   /**
+    * @param e
+    * @param config
+    */
+   private void parseAddresses(final Element e, final Configuration config) {
+      NodeList elements = e.getElementsByTagName("addresses");
 
       if (elements.getLength() != 0) {
          Element node = (Element) elements.item(0);
-         NodeList list = node.getElementsByTagName("queue");
+         NodeList list = node.getElementsByTagName("address");
          for (int i = 0; i < list.getLength(); i++) {
-            CoreQueueConfiguration queueConfig = 
parseQueueConfiguration(list.item(i));
-            config.getQueueConfigurations().add(queueConfig);
+            CoreAddressConfiguration addrConfig = 
parseAddressConfiguration(list.item(i));
+            config.getAddressConfigurations().add(addrConfig);
          }
       }
    }
@@ -829,9 +854,20 @@ public final class FileConfigurationParser extends 
XMLConfigurationUtil {
       String address = null;
       String filterString = null;
       boolean durable = true;
+      Integer maxConsumers = null;
+      Boolean deleteOnNoConsumers = null;
+
+      NamedNodeMap attributes = node.getAttributes();
+      for (int i = 0; i < attributes.getLength(); i++) {
+         Node item = attributes.item(i);
+         if (item.getNodeName().equals("max-consumers")) {
+            maxConsumers = Integer.parseInt(item.getNodeValue());
+         } else if (item.getNodeName().equals("delete-on-no-consumers")) {
+            deleteOnNoConsumers = Boolean.parseBoolean(item.getNodeValue());
+         }
+      }
 
       NodeList children = node.getChildNodes();
-
       for (int j = 0; j < children.getLength(); j++) {
          Node child = children.item(j);
 
@@ -844,7 +880,41 @@ public final class FileConfigurationParser extends 
XMLConfigurationUtil {
          }
       }
 
-      return new 
CoreQueueConfiguration().setAddress(address).setName(name).setFilterString(filterString).setDurable(durable);
+      return new CoreQueueConfiguration()
+         .setAddress(address)
+         .setName(name)
+         .setFilterString(filterString)
+         .setDurable(durable)
+         .setMaxConsumers(maxConsumers)
+         .setDeleteOnNoConsumers(deleteOnNoConsumers);
+   }
+
+   protected CoreAddressConfiguration parseAddressConfiguration(final Node 
node) {
+      String name = getAttributeValue(node, "name");
+      String routingType = getAttributeValue(node, "type");
+
+      CoreAddressConfiguration addressConfiguration = new 
CoreAddressConfiguration();
+      addressConfiguration.setName(name)
+         
.setRoutingType(CoreAddressConfiguration.RoutingType.valueOf(routingType.toUpperCase()));
+
+      NodeList children = node.getChildNodes();
+      for (int j = 0; j < children.getLength(); j++) {
+         Node child = children.item(j);
+         if (child.getNodeName().equals("queues")) {
+            
addressConfiguration.setQueueConfigurations(parseQueueConfigurations((Element) 
child));
+         }
+      }
+
+      for (CoreQueueConfiguration coreQueueConfiguration : 
addressConfiguration.getQueueConfigurations()) {
+         coreQueueConfiguration.setAddress(addressConfiguration.getName());
+         if (coreQueueConfiguration.getMaxConsumers() == null) {
+            
coreQueueConfiguration.setMaxConsumers(addressConfiguration.getDefaultMaxConsumers());
+         }
+         if (coreQueueConfiguration.getDeleteOnNoConsumers() == null) {
+            
coreQueueConfiguration.setDeleteOnNoConsumers(addressConfiguration.getDefaultDeleteOnNoConsumers());
+         }
+      }
+      return addressConfiguration;
    }
 
    private TransportConfiguration parseAcceptorTransportConfiguration(final 
Element e,

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58310fa8/artemis-server/src/main/resources/schema/artemis-configuration.xsd
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/resources/schema/artemis-configuration.xsd 
b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
index 73aa20b..472f5e0 100644
--- a/artemis-server/src/main/resources/schema/artemis-configuration.xsd
+++ b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
@@ -422,7 +422,6 @@
             </xsd:complexType>
          </xsd:element>
 
-
          <!-- QUEUES -->
          <xsd:element name="queues" maxOccurs="1" minOccurs="0">
             <xsd:annotation>
@@ -855,6 +854,8 @@
                </xsd:sequence>
             </xsd:complexType>
          </xsd:element>
+
+         <xsd:element name="addresses" type="addressesType" maxOccurs="1" 
minOccurs="0" />
       </xsd:all>
    </xsd:complexType>
 
@@ -2512,4 +2513,79 @@
          </xsd:extension>
       </xsd:simpleContent>
    </xsd:complexType>
+
+
+   <!-- 2.0 Addressing configuration -->
+   <xsd:simpleType name="routingType">
+      <xsd:restriction base="xsd:string">
+         <xsd:enumeration value="multicast" />
+         <xsd:enumeration value="anycast" />
+      </xsd:restriction>
+   </xsd:simpleType>
+
+   <xsd:complexType name="queueType">
+      <xsd:all>
+         <xsd:element ref="filter" maxOccurs="1" minOccurs="0"/>
+         <xsd:element name="durable" type="xsd:boolean" default="true" 
maxOccurs="1" minOccurs="0" />
+      </xsd:all>
+      <xsd:attribute name="name" type="xsd:ID" use="required"/>
+      <xsd:attribute name="max-consumers" type="xsd:integer" use="optional"/>
+      <xsd:attribute name="delete-on-no-consumers" type="xsd:boolean" 
use="optional"/>
+   </xsd:complexType>
+
+   <xsd:complexType name="addressType">
+      <xsd:all>
+         <xsd:element name="queues" maxOccurs="1" minOccurs="0">
+            <xsd:annotation>
+               <xsd:documentation>
+                  a list of pre configured queues to create
+               </xsd:documentation>
+            </xsd:annotation>
+            <xsd:complexType>
+               <xsd:sequence>
+                  <xsd:element name="queue" type="queueType" 
maxOccurs="unbounded" minOccurs="0" />
+               </xsd:sequence>
+            </xsd:complexType>
+         </xsd:element>
+      </xsd:all>
+      <xsd:attribute name="name" type="xsd:ID" use="required">
+         <xsd:annotation>
+            <xsd:documentation>
+               The address name to matches incoming message addresses
+            </xsd:documentation>
+         </xsd:annotation>
+      </xsd:attribute>
+      <xsd:attribute name="type" type="routingType" use="required">
+         <xsd:annotation>
+            <xsd:documentation>
+               The address name to matches incoming message addresses
+            </xsd:documentation>
+         </xsd:annotation>
+      </xsd:attribute>
+      <xsd:attribute name="default-max-consumers" type="xsd:int" 
use="optional" default="-1">
+         <xsd:annotation>
+            <xsd:documentation>
+               The default value of max-consumers applied to all queues that 
are
+               auto-created under this address.  Also applies to any queues 
that do not
+               specify a value for max-consumers.
+            </xsd:documentation>
+         </xsd:annotation>
+      </xsd:attribute>
+      <xsd:attribute name="default-delete-on-no-consumers" type="xsd:boolean" 
use="optional" default="false">
+         <xsd:annotation>
+            <xsd:documentation>
+               The default value of delete-on-no-consumers applied to all 
queues that are
+               auto-created under this address.  Also applies to any queues 
that do not
+               specify a value for delete-on-no-consumers.
+            </xsd:documentation>
+         </xsd:annotation>
+      </xsd:attribute>
+   </xsd:complexType>
+
+   <xsd:complexType name="addressesType">
+      <xsd:sequence>
+         <xsd:element name="address" type="addressType" maxOccurs="unbounded" 
minOccurs="0"/>
+      </xsd:sequence>
+   </xsd:complexType>
+
 </xsd:schema>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58310fa8/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DefaultsFileConfigurationTest.java
----------------------------------------------------------------------
diff --git 
a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DefaultsFileConfigurationTest.java
 
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DefaultsFileConfigurationTest.java
index 700c290..07d5f58 100644
--- 
a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DefaultsFileConfigurationTest.java
+++ 
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DefaultsFileConfigurationTest.java
@@ -64,6 +64,8 @@ public class DefaultsFileConfigurationTest extends 
ConfigurationImplTest {
 
       Assert.assertEquals(Collections.emptyList(), 
conf.getQueueConfigurations());
 
+      Assert.assertEquals(Collections.emptyList(), 
conf.getAddressConfigurations());
+
       
Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultManagementAddress(), 
conf.getManagementAddress());
 
       
Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultManagementNotificationAddress(),
 conf.getManagementNotificationAddress());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58310fa8/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
----------------------------------------------------------------------
diff --git 
a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
 
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
index a2afd97..d004a22 100644
--- 
a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
+++ 
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
@@ -35,6 +35,8 @@ import 
org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory;
 import org.apache.activemq.artemis.core.config.BridgeConfiguration;
 import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
 import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
+import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
 import org.apache.activemq.artemis.core.config.DivertConfiguration;
 import org.apache.activemq.artemis.core.config.FileDeploymentManager;
 import org.apache.activemq.artemis.core.config.HAPolicyConfiguration;
@@ -49,6 +51,9 @@ import 
org.apache.activemq.artemis.core.settings.impl.SlowConsumerPolicy;
 import org.junit.Assert;
 import org.junit.Test;
 
+import static 
org.apache.activemq.artemis.core.config.CoreAddressConfiguration.RoutingType.ANYCAST;
+import static 
org.apache.activemq.artemis.core.config.CoreAddressConfiguration.RoutingType.MULTICAST;
+
 public class FileConfigurationTest extends ConfigurationImplTest {
 
    private final String fullConfigurationName = 
"ConfigurationTest-full-config.xml";
@@ -324,6 +329,8 @@ public class FileConfigurationTest extends 
ConfigurationImplTest {
       assertEquals("color='blue'", 
conf.getQueueConfigurations().get(1).getFilterString());
       assertEquals(false, conf.getQueueConfigurations().get(1).isDurable());
 
+      verifyAddresses();
+
       Map<String, Set<Role>> roles = conf.getSecurityRoles();
 
       assertEquals(2, roles.size());
@@ -356,6 +363,62 @@ public class FileConfigurationTest extends 
ConfigurationImplTest {
       assertEquals(123, conf.getDiskScanPeriod());
    }
 
+   private void verifyAddresses() {
+      assertEquals(2, conf.getAddressConfigurations().size());
+
+      // Addr 1
+      CoreAddressConfiguration addressConfiguration = 
conf.getAddressConfigurations().get(0);
+      assertEquals("addr1", addressConfiguration.getName());
+      assertEquals(ANYCAST, addressConfiguration.getRoutingType());
+      assertEquals(2, addressConfiguration.getQueueConfigurations().size());
+
+      // Addr 1 Queue 1
+      CoreQueueConfiguration queueConfiguration = 
addressConfiguration.getQueueConfigurations().get(0);
+
+      assertEquals("q1", queueConfiguration.getName());
+      assertFalse(queueConfiguration.isDurable());
+      assertEquals("color='blue'", queueConfiguration.getFilterString());
+      assertEquals(addressConfiguration.getDefaultDeleteOnNoConsumers(), 
queueConfiguration.getDeleteOnNoConsumers());
+      assertEquals("addr1", queueConfiguration.getAddress());
+      assertEquals(addressConfiguration.getDefaultMaxConsumers(), 
queueConfiguration.getMaxConsumers());
+
+      // Addr 1 Queue 2
+      queueConfiguration = 
addressConfiguration.getQueueConfigurations().get(1);
+
+      assertEquals("q2", queueConfiguration.getName());
+      assertTrue(queueConfiguration.isDurable());
+      assertEquals("color='green'", queueConfiguration.getFilterString());
+      assertEquals(new Integer(-1), queueConfiguration.getMaxConsumers());
+      assertFalse(queueConfiguration.getDeleteOnNoConsumers());
+      assertEquals("addr1", queueConfiguration.getAddress());
+
+      // Addr 2
+      addressConfiguration = conf.getAddressConfigurations().get(1);
+      assertEquals("addr2", addressConfiguration.getName());
+      assertEquals(MULTICAST, addressConfiguration.getRoutingType());
+      assertEquals(2, addressConfiguration.getQueueConfigurations().size());
+
+      // Addr 2 Queue 1
+      queueConfiguration = 
addressConfiguration.getQueueConfigurations().get(0);
+
+      assertEquals("q3", queueConfiguration.getName());
+      assertTrue(queueConfiguration.isDurable());
+      assertEquals("color='red'", queueConfiguration.getFilterString());
+      assertEquals(new Integer(10), queueConfiguration.getMaxConsumers());
+      assertEquals(addressConfiguration.getDefaultDeleteOnNoConsumers(), 
queueConfiguration.getDeleteOnNoConsumers());
+      assertEquals("addr2", queueConfiguration.getAddress());
+
+      // Addr 2 Queue 2
+      queueConfiguration = 
addressConfiguration.getQueueConfigurations().get(1);
+
+      assertEquals("q4", queueConfiguration.getName());
+      assertTrue(queueConfiguration.isDurable());
+      assertNull(queueConfiguration.getFilterString());
+      assertEquals(addressConfiguration.getDefaultMaxConsumers(), 
queueConfiguration.getMaxConsumers());
+      assertTrue(queueConfiguration.getDeleteOnNoConsumers());
+      assertEquals("addr2", queueConfiguration.getAddress());
+   }
+
    @Test
    public void testSecuritySettingPlugin() throws Exception {
       FileConfiguration fc = new FileConfiguration();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58310fa8/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
----------------------------------------------------------------------
diff --git 
a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml 
b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
index 8984405..3bc14bf 100644
--- a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
+++ b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
@@ -289,5 +289,31 @@
             <factory-class>org.foo</factory-class>
          </connector-service>
       </connector-services>
+
+      <addresses>
+         <address name="addr1" type="anycast">
+            <queues>
+               <queue name="q1">
+                  <durable>false</durable>
+                  <filter string="color='blue'"/>
+               </queue>
+               <queue name="q2" max-consumers="-1" 
delete-on-no-consumers="false">
+                  <durable>true</durable>
+                  <filter string="color='green'"/>
+               </queue>
+            </queues>
+         </address>
+         <address name="addr2" type="multicast">
+            <queues>
+               <queue name="q3" max-consumers="10" >
+                  <filter string="color='red'"/>
+               </queue>
+               <queue name="q4" delete-on-no-consumers="true">
+                  <durable>true</durable>
+               </queue>
+            </queues>
+         </address>
+      </addresses>
+
    </core>
 </configuration>

Reply via email to