You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2014/08/25 17:35:12 UTC

svn commit: r1620350 [1/4] - in /qpid/branches/0.30/qpid/java: ./ bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/ bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/ bdbstore/src/test/java/org/apache/qpid/server/vi...

Author: rgodfrey
Date: Mon Aug 25 15:35:10 2014
New Revision: 1620350

URL: http://svn.apache.org/r1620350
Log:
Merging from trunk r1619093:1620329 in the Java tree

Added:
    qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/ConfiguredObjectRecordConverterTest.java
      - copied unchanged from r1619449, qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/ConfiguredObjectRecordConverterTest.java
Modified:
    qpid/branches/0.30/qpid/java/   (props changed)
    qpid/branches/0.30/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java
    qpid/branches/0.30/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java
    qpid/branches/0.30/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeTestHelper.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/BrokerOptions.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttribute.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Port.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHostNode.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPort.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPort.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortImpl.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPort.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueArgumentsConverter.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordConverter.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/util/urlstreamhandler/data/Handler.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java
    qpid/branches/0.30/qpid/java/broker-core/src/main/resources/initial-config.json
    qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java
    qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategory.java
    qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestChildCategoryImpl.java
    qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/security/auth/manager/SimpleLDAPAuthenticationManagerFactoryTest.java
    qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
    qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
    qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/util/BrokerTestHelper.java
    qpid/branches/0.30/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java
    qpid/branches/0.30/qpid/java/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/CreditCreditManager.java
    qpid/branches/0.30/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/handler/ExchangeDeclareHandler.java
    qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
    qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/FileServlet.java
    qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java
    qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
    qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/addPort.html
    qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css
    qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/metadata.js
    qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js
    qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js
    qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js
    qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js
    qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPort.js
    qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/showExchange.html
    qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/main/java/resources/showPort.html
    qpid/branches/0.30/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java
    qpid/branches/0.30/qpid/java/broker-plugins/websocket/src/main/java/org/apache/qpid/server/transport/websocket/WebSocketProvider.java
    qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java
    qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java
    qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
    qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
    qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
    qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java
    qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java
    qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_10.java
    qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_8.java
    qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer.java
    qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java
    qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java
    qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10.java
    qpid/branches/0.30/qpid/java/client/src/main/java/org/apache/qpid/client/util/BlockingWaiter.java
    qpid/branches/0.30/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java
    qpid/branches/0.30/qpid/java/pom.xml
    qpid/branches/0.30/qpid/java/qpid-systests-parent/pom.xml
    qpid/branches/0.30/qpid/java/systests/etc/config-systests.json
    qpid/branches/0.30/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java
    qpid/branches/0.30/qpid/java/systests/src/test/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java
    qpid/branches/0.30/qpid/java/test-profiles/JavaPre010Excludes   (contents, props changed)

Propchange: qpid/branches/0.30/qpid/java/
------------------------------------------------------------------------------
  Merged /qpid/trunk/qpid/java:r1619093,1619259,1619306,1619317,1619322-1619323,1619356,1619449,1619557,1619568,1619584,1619733,1619854,1619918,1620036-1620037,1620147,1620323,1620329

Modified: qpid/branches/0.30/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java (original)
+++ qpid/branches/0.30/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java Mon Aug 25 15:35:10 2014
@@ -26,6 +26,7 @@ import java.text.MessageFormat;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
@@ -63,6 +64,8 @@ import org.apache.qpid.server.model.Stat
 import org.apache.qpid.server.model.StateTransition;
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.security.SecurityManager;
+import org.apache.qpid.server.store.ConfiguredObjectRecord;
+import org.apache.qpid.server.store.ConfiguredObjectRecordImpl;
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.store.VirtualHostStoreUpgraderAndRecoverer;
 import org.apache.qpid.server.store.berkeleydb.BDBConfigurationStore;
@@ -434,41 +437,40 @@ public class BDBHAVirtualHostNodeImpl ex
                 {
                     LOGGER.debug("Creating new virtualhost with name : " + getGroupName());
                 }
-
-                boolean hasBlueprint = getContextKeys(false).contains(VIRTUALHOST_BLUEPRINT_CONTEXT_VAR);
-                boolean blueprintUtilised = getContext().containsKey(VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR)
-                                            && Boolean.parseBoolean(String.valueOf(getContext().get(
-                        VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR)));
-
-                Map<String, Object> hostAttributes = new HashMap<>();
-                if (hasBlueprint && !blueprintUtilised)
+                ConfiguredObjectRecord[] initialRecords = getInitialRecords();
+                if(initialRecords != null && initialRecords.length > 0)
                 {
-                    Map<String, Object> virtualhostBlueprint =
-                            getContextValue(Map.class, VIRTUALHOST_BLUEPRINT_CONTEXT_VAR);
-
-                    if (LOGGER.isDebugEnabled())
+                    getConfigurationStore().update(true, initialRecords);
+                    getEventLogger().message(getConfigurationStoreLogSubject(), ConfigStoreMessages.RECOVERY_START());
+                    upgraderAndRecoverer = new VirtualHostStoreUpgraderAndRecoverer(this);
+                    upgraderAndRecoverer.perform(getConfigurationStore());
+                    getEventLogger().message(getConfigurationStoreLogSubject(), ConfigStoreMessages.RECOVERY_COMPLETE());
+                    setAttribute(VIRTUALHOST_INITIAL_CONFIGURATION, getVirtualHostInitialConfiguration(), "{}" );
+                    host = getVirtualHost();
+                    if(host != null)
                     {
-                        LOGGER.debug("Using virtualhost blueprint " + virtualhostBlueprint);
+                        final VirtualHost<?,?,?> recoveredHost = host;
+                        Subject.doAs(SecurityManager.getSubjectWithAddedSystemRights(), new PrivilegedAction<Object>()
+                        {
+                            @Override
+                            public Object run()
+                            {
+                                recoveredHost.open();
+                                return null;
+                            }
+                        });
                     }
-
-                    hostAttributes.putAll(virtualhostBlueprint);
-
-
                 }
-
-                hostAttributes.put(VirtualHost.MODEL_VERSION, BrokerModel.MODEL_VERSION);
-                hostAttributes.put(VirtualHost.NAME, getGroupName());
-                hostAttributes.put(VirtualHost.TYPE, BDBHAVirtualHostImpl.VIRTUAL_HOST_TYPE);
-                host = createChild(VirtualHost.class, hostAttributes);
-
-                if (hasBlueprint && !blueprintUtilised)
+                else
                 {
-                    // Update the context with the utilised flag
-                    Map<String, String> actualContext = (Map<String, String>) getActualAttributes().get(CONTEXT);
-                    Map<String, String> context = new HashMap<>(actualContext);
-                    context.put(VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR, Boolean.TRUE.toString());
-                    setAttribute(CONTEXT, getContext(), context);
+                    Map<String, Object> hostAttributes = new HashMap<>();
+
+                    hostAttributes.put(VirtualHost.MODEL_VERSION, BrokerModel.MODEL_VERSION);
+                    hostAttributes.put(VirtualHost.NAME, getGroupName());
+                    hostAttributes.put(VirtualHost.TYPE, BDBHAVirtualHostImpl.VIRTUAL_HOST_TYPE);
+                    host = createChild(VirtualHost.class, hostAttributes);
                 }
+
             }
             else
             {
@@ -706,6 +708,17 @@ public class BDBHAVirtualHostNodeImpl ex
         return _groupLogSubject;
     }
 
+    @Override
+    protected ConfiguredObjectRecord enrichInitialVirtualHostRootRecord(final ConfiguredObjectRecord vhostRecord)
+    {
+        Map<String,Object> hostAttributes = new LinkedHashMap<>(vhostRecord.getAttributes());
+        hostAttributes.put(VirtualHost.MODEL_VERSION, BrokerModel.MODEL_VERSION);
+        hostAttributes.put(VirtualHost.NAME, getGroupName());
+        hostAttributes.put(VirtualHost.TYPE, BDBHAVirtualHostImpl.VIRTUAL_HOST_TYPE);
+        return new ConfiguredObjectRecordImpl(vhostRecord.getId(), vhostRecord.getType(),
+                                              hostAttributes, vhostRecord.getParents());
+    }
+
     private class RemoteNodesDiscoverer implements ReplicationGroupListener
     {
         @Override

Modified: qpid/branches/0.30/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java (original)
+++ qpid/branches/0.30/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java Mon Aug 25 15:35:10 2014
@@ -20,7 +20,6 @@
  */
 package org.apache.qpid.server.store.berkeleydb;
 
-import static java.util.Collections.*;
 import static org.mockito.Mockito.when;
 
 import java.io.File;
@@ -29,7 +28,6 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.UUID;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
@@ -48,12 +46,10 @@ import org.apache.qpid.server.model.Virt
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.virtualhost.berkeleydb.BDBHAVirtualHost;
 import org.apache.qpid.server.virtualhost.berkeleydb.BDBHAVirtualHostImpl;
-import org.apache.qpid.server.virtualhostnode.AbstractVirtualHostNode;
 import org.apache.qpid.server.virtualhostnode.berkeleydb.BDBHARemoteReplicationNode;
 import org.apache.qpid.server.virtualhostnode.berkeleydb.BDBHARemoteReplicationNodeImpl;
 import org.apache.qpid.server.virtualhostnode.berkeleydb.BDBHAVirtualHostNode;
 import org.apache.qpid.server.virtualhostnode.berkeleydb.BDBHAVirtualHostNodeTestHelper;
-import org.apache.qpid.server.virtualhostnode.berkeleydb.BDBHAVirtualHostNodeImpl;
 import org.apache.qpid.test.utils.QpidTestCase;
 
 public class BDBHAVirtualHostNodeTest extends QpidTestCase
@@ -94,20 +90,6 @@ public class BDBHAVirtualHostNodeTest ex
         context.put(ReplicationConfig.REP_STREAM_TIMEOUT, repStreamTimeout);
         BDBHAVirtualHostNode<?> node = _helper.createHaVHN(attributes);
 
-        final CountDownLatch virtualHostAddedLatch = new CountDownLatch(1);
-        node.addChangeListener(new NoopConfigurationChangeListener()
-        {
-            @Override
-            public void childAdded(ConfiguredObject<?> object, ConfiguredObject<?> child)
-            {
-                if (child instanceof VirtualHost)
-                {
-                    child.addChangeListener(this);
-                    virtualHostAddedLatch.countDown();
-                }
-            }
-        });
-
         node.start();
         _helper.assertNodeRole(node, "MASTER", "REPLICA");
 
@@ -128,7 +110,7 @@ public class BDBHAVirtualHostNodeTest ex
         assertEquals("SYNC,NO_SYNC,SIMPLE_MAJORITY", environment.getConfig().getDurability().toString());
         assertEquals("Unexpected JE replication stream timeout", repStreamTimeout, replicationConfig.getConfigParam(ReplicationConfig.REP_STREAM_TIMEOUT));
 
-        assertTrue("Virtual host child has not been added", virtualHostAddedLatch.await(30, TimeUnit.SECONDS));
+        _helper.awaitForVirtualhost(node, 30000);
         VirtualHost<?, ?, ?> virtualHost = node.getVirtualHost();
         assertNotNull("Virtual host child was not added", virtualHost);
         assertEquals("Unexpected virtual host name", groupName, virtualHost.getName());
@@ -314,25 +296,11 @@ public class BDBHAVirtualHostNodeTest ex
         Map<String, Object> nodeAttributes = _helper.createNodeAttributes(nodeName, groupName, helperAddress, helperAddress, nodeName, node1PortNumber);
         BDBHAVirtualHostNode<?> node = _helper.createHaVHN(nodeAttributes);
 
-        final CountDownLatch virtualHostAddedLatch = new CountDownLatch(1);
-        node.addChangeListener(new NoopConfigurationChangeListener()
-        {
-            @Override
-            public void childAdded(ConfiguredObject<?> object, ConfiguredObject<?> child)
-            {
-                if (child instanceof VirtualHost)
-                {
-                    child.addChangeListener(this);
-                    virtualHostAddedLatch.countDown();
-                }
-            }
-        });
-
         node.start();
         _helper.assertNodeRole(node, "MASTER", "REPLICA");
         assertEquals("Unexpected node state", State.ACTIVE, node.getState());
 
-        assertTrue("Virtual host child has not been added", virtualHostAddedLatch.await(30, TimeUnit.SECONDS));
+        _helper.awaitForVirtualhost(node,30000);
         BDBHAVirtualHostImpl virtualHost = (BDBHAVirtualHostImpl)node.getVirtualHost();
         assertNotNull("Virtual host is not created", virtualHost);
 
@@ -500,4 +468,4 @@ public class BDBHAVirtualHostNodeTest ex
         assertTrue("Intruder protection was not triggered during expected timeout", stopLatch.await(20, TimeUnit.SECONDS));
     }
 
-}
\ No newline at end of file
+}

Modified: qpid/branches/0.30/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeTestHelper.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeTestHelper.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeTestHelper.java (original)
+++ qpid/branches/0.30/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeTestHelper.java Mon Aug 25 15:35:10 2014
@@ -38,10 +38,19 @@ import java.util.Set;
 import java.util.UUID;
 
 import com.sleepycat.je.rep.ReplicationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
 
 import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.configuration.updater.TaskExecutorImpl;
-import org.apache.qpid.server.model.*;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.BrokerModel;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.ConfiguredObjectFactory;
+import org.apache.qpid.server.model.RemoteReplicationNode;
+import org.apache.qpid.server.model.State;
+import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.VirtualHostNode;
 import org.apache.qpid.server.store.ConfiguredObjectRecordImpl;
 import org.apache.qpid.server.store.UnresolvedConfiguredObject;
 import org.apache.qpid.server.util.BrokerTestHelper;
@@ -50,8 +59,6 @@ import org.apache.qpid.server.virtualhos
 import org.apache.qpid.server.virtualhostnode.AbstractVirtualHostNode;
 import org.apache.qpid.test.utils.QpidTestCase;
 import org.apache.qpid.util.FileUtils;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.SerializationConfig;
 
 /**
  * Helper class to make the tests of BDB HA Virtual Host Nodes simpler and more concise.
@@ -281,7 +288,7 @@ public class BDBHAVirtualHostNodeTestHel
         if (ports != null)
         {
             String bluePrint = getBlueprint(ports);
-            context.put(AbstractVirtualHostNode.VIRTUALHOST_BLUEPRINT_CONTEXT_VAR, bluePrint);
+            node1Attributes.put(AbstractVirtualHostNode.VIRTUALHOST_INITIAL_CONFIGURATION, bluePrint);
         }
 
         node1Attributes.put(BDBHAVirtualHostNode.CONTEXT, context);
@@ -307,4 +314,24 @@ public class BDBHAVirtualHostNodeTestHel
         return writer.toString();
     }
 
+    public void awaitForVirtualhost(final VirtualHostNode<?> node, final int wait)
+    {
+        long endTime = System.currentTimeMillis() + wait;
+        do
+        {
+            if(node.getVirtualHost() != null)
+            {
+                return;
+            }
+            try
+            {
+                Thread.sleep(100);
+            }
+            catch (InterruptedException e)
+            {
+                // ignore
+            }
+        }
+        while(System.currentTimeMillis() < endTime);
+    }
 }

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/BrokerOptions.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/BrokerOptions.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/BrokerOptions.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/BrokerOptions.java Mon Aug 25 15:35:10 2014
@@ -85,7 +85,6 @@ public class BrokerOptions
         Map<String,Object> attributes = new HashMap<String, Object>();
 
         attributes.put("storePath", getConfigurationStoreLocation());
-        attributes.put("storeTye", getConfigurationStoreType());
         attributes.put(ConfiguredObject.CONTEXT, getConfigProperties());
         return attributes;
     }

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/binding/BindingImpl.java Mon Aug 25 15:35:10 2014
@@ -36,6 +36,7 @@ import org.apache.qpid.server.logging.Ev
 import org.apache.qpid.server.logging.messages.BindingMessages;
 import org.apache.qpid.server.logging.subjects.BindingLogSubject;
 import org.apache.qpid.server.model.AbstractConfiguredObject;
+import org.apache.qpid.server.model.Binding;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.ManagedAttributeField;
 import org.apache.qpid.server.model.Queue;
@@ -66,12 +67,31 @@ public class BindingImpl
 
     public BindingImpl(Map<String, Object> attributes, AMQQueue queue, ExchangeImpl exchange)
     {
-        super(parentsMap(queue,exchange),enhanceWithDurable(attributes,queue,exchange));
+        super(parentsMap(queue,exchange),stripEmptyArguments(enhanceWithDurable(attributes, queue, exchange)));
         _bindingKey = getName();
         _queue = queue;
         _exchange = exchange;
     }
 
+    private static Map<String, Object> stripEmptyArguments(final Map<String, Object> attributes)
+    {
+        Map<String,Object> returnVal;
+        if(attributes != null
+           && attributes.containsKey(Binding.ARGUMENTS)
+           && (attributes.get(Binding.ARGUMENTS) instanceof Map)
+           && ((Map)(attributes.get(Binding.ARGUMENTS))).isEmpty())
+        {
+            returnVal = new HashMap<>(attributes);
+            returnVal.remove(Binding.ARGUMENTS);
+        }
+        else
+        {
+            returnVal = attributes;
+        }
+
+        return returnVal;
+    }
+
     @Override
     protected void onOpen()
     {
@@ -113,7 +133,7 @@ public class BindingImpl
     {
         if(!attributes.containsKey(DURABLE))
         {
-            attributes = new HashMap<String, Object>(attributes);
+            attributes = new HashMap(attributes);
             attributes.put(DURABLE, queue.isDurable() && exchange.isDurable());
         }
         return attributes;

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java Mon Aug 25 15:35:10 2014
@@ -25,6 +25,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -111,6 +112,12 @@ public abstract class AbstractExchange<T
     public AbstractExchange(Map<String, Object> attributes, VirtualHostImpl vhost)
     {
         super(parentsMap(vhost), attributes);
+        Set<String> providedAttributeNames = new HashSet<>(attributes.keySet());
+        providedAttributeNames.removeAll(getAttributeNames());
+        if(!providedAttributeNames.isEmpty())
+        {
+            throw new IllegalArgumentException("Unknown attributes provided: " + providedAttributeNames);
+        }
         _virtualHost = vhost;
         // check ACL
         try

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java Mon Aug 25 15:35:10 2014
@@ -123,7 +123,6 @@ public class HeadersExchange extends Abs
     {
         String bindingKey = binding.getBindingKey();
         AMQQueue queue = binding.getAMQQueue();
-        Map<String,Object> args = binding.getArguments();
 
         assert queue != null;
         assert bindingKey != null;
@@ -143,7 +142,7 @@ public class HeadersExchange extends Abs
         if(_logger.isDebugEnabled())
         {
             _logger.debug("Exchange " + getName() + ": Binding " + queue.getName() +
-                          " with binding key '" +bindingKey + "' and args: " + args);
+                          " with binding key '" +bindingKey + "' and args: " + binding.getArguments());
         }
 
         _bindingHeaderMatchers.add(new HeadersBinding(binding));

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java Mon Aug 25 15:35:10 2014
@@ -469,7 +469,6 @@ public abstract class AbstractConfigured
     {
         if(_dynamicState.compareAndSet(DynamicState.UNINIT, DynamicState.OPENED))
         {
-            registerWithParents();
             final AuthenticatedPrincipal currentUser = SecurityManager.getCurrentUser();
             if(currentUser != null)
             {
@@ -487,6 +486,9 @@ public abstract class AbstractConfigured
 
             doResolution(true);
             doValidation(true);
+
+            registerWithParents();
+
             doCreation(true);
             doOpening(true);
             doAttainState();
@@ -1100,7 +1102,7 @@ public abstract class AbstractConfigured
                     @Override
                     public Map<String, Object> run()
                     {
-                        Map<String,Object> attributes = new HashMap<String, Object>();
+                        Map<String,Object> attributes = new LinkedHashMap<String, Object>();
                         Map<String,Object> actualAttributes = getActualAttributes();
                         for(ConfiguredObjectAttribute<?,?> attr : _attributeTypes.values())
                         {

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java Mon Aug 25 15:35:10 2014
@@ -89,7 +89,15 @@ abstract class AttributeValueConverter<T
             }
             else if(value instanceof String)
             {
-                return Long.valueOf(AbstractConfiguredObject.interpolate(object, (String) value));
+                String interpolated = AbstractConfiguredObject.interpolate(object, (String) value);
+                try
+                {
+                    return Long.valueOf(interpolated);
+                }
+                catch(NumberFormatException e)
+                {
+                    throw new IllegalArgumentException("Cannot convert string '" + interpolated + "'",e);
+                }
             }
             else if(value == null)
             {
@@ -117,7 +125,15 @@ abstract class AttributeValueConverter<T
             }
             else if(value instanceof String)
             {
-                return Integer.valueOf(AbstractConfiguredObject.interpolate(object, (String) value));
+                String interpolated = AbstractConfiguredObject.interpolate(object, (String) value);
+                try
+                {
+                    return Integer.valueOf(interpolated);
+                }
+                catch(NumberFormatException e)
+                {
+                    throw new IllegalArgumentException("Cannot convert string '" + interpolated + "'",e);
+                }
             }
             else if(value == null)
             {
@@ -145,7 +161,15 @@ abstract class AttributeValueConverter<T
             }
             else if(value instanceof String)
             {
-                return Short.valueOf(AbstractConfiguredObject.interpolate(object, (String) value));
+                String interpolated = AbstractConfiguredObject.interpolate(object, (String) value);
+                try
+                {
+                    return Short.valueOf(interpolated);
+                }
+                catch(NumberFormatException e)
+                {
+                    throw new IllegalArgumentException("Cannot convert string '" + interpolated + "'",e);
+                }
             }
             else if(value == null)
             {

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java Mon Aug 25 15:35:10 2014
@@ -47,8 +47,6 @@ public interface Broker<X extends Broker
     String DEFAULT_VIRTUAL_HOST = "defaultVirtualHost";
     String STATISTICS_REPORTING_PERIOD = "statisticsReportingPeriod";
     String STATISTICS_REPORTING_RESET_ENABLED = "statisticsReportingResetEnabled";
-    String STORE_TYPE = "storeType";
-    String STORE_VERSION = "storeVersion";
     String STORE_PATH = "storePath";
     String MODEL_VERSION = "modelVersion";
     String CONFIDENTIAL_CONFIGURATION_ENCRYPTION_PROVIDER = "confidentialConfigurationEncryptionProvider";

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttribute.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttribute.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttribute.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectAttribute.java Mon Aug 25 15:35:10 2014
@@ -21,11 +21,10 @@
 package org.apache.qpid.server.model;
 
 import java.lang.reflect.Method;
+import java.lang.reflect.Type;
 
 public abstract class ConfiguredObjectAttribute<C extends ConfiguredObject, T> extends ConfiguredObjectAttributeOrStatistic<C,T>
 {
-
-
     ConfiguredObjectAttribute(Class<C> clazz,
                               final Method getter)
     {
@@ -48,6 +47,20 @@ public abstract class ConfiguredObjectAt
 
     public T convert(final Object value, C object)
     {
-        return getConverter().convert(value, object);
+        final AttributeValueConverter<T> converter = getConverter();
+        try
+        {
+            return converter.convert(value, object);
+        }
+        catch (IllegalArgumentException iae)
+        {
+            Type returnType = getGetter().getGenericReturnType();
+            String simpleName = returnType instanceof Class ? ((Class) returnType).getSimpleName() : returnType.toString();
+
+            throw new IllegalArgumentException("Cannot convert '" + value
+                                               + "' into a " + simpleName
+                                               + " for attribute " + getName()
+                                               + " (" + iae.getMessage() + ")", iae);
+        }
     }
 }

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ConfiguredObjectTypeRegistry.java Mon Aug 25 15:35:10 2014
@@ -24,6 +24,7 @@ import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.AbstractCollection;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
@@ -33,6 +34,7 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.SortedSet;
+import java.util.TreeMap;
 import java.util.TreeSet;
 
 import org.apache.log4j.Logger;
@@ -45,16 +47,106 @@ public class ConfiguredObjectTypeRegistr
 {
     private static final Logger LOGGER = Logger.getLogger(ConfiguredObjectTypeRegistry.class);
 
-    private static final Comparator<ConfiguredObjectAttributeOrStatistic<?,?>> NAME_COMPARATOR = new Comparator<ConfiguredObjectAttributeOrStatistic<?, ?>>()
+    private static Map<String,Integer> STANDARD_FIRST_FIELDS_ORDER = new HashMap<>();
+    static
+    {
+        int i = 0;
+        for(String name : Arrays.asList(ConfiguredObject.ID,
+                                        ConfiguredObject.NAME,
+                                        ConfiguredObject.DESCRIPTION,
+                                        ConfiguredObject.TYPE,
+                                        ConfiguredObject.DESIRED_STATE,
+                                        ConfiguredObject.STATE,
+                                        ConfiguredObject.DURABLE,
+                                        ConfiguredObject.LIFETIME_POLICY,
+                                        ConfiguredObject.CONTEXT))
+        {
+            STANDARD_FIRST_FIELDS_ORDER.put(name, i++);
+        }
+
+    }
+
+    private static Map<String,Integer> STANDARD_LAST_FIELDS_ORDER = new HashMap<>();
+    static
+    {
+        int i = 0;
+        for(String name : Arrays.asList(ConfiguredObject.LAST_UPDATED_BY,
+                                        ConfiguredObject.LAST_UPDATED_TIME,
+                                        ConfiguredObject.CREATED_BY,
+                                        ConfiguredObject.CREATED_TIME))
+        {
+            STANDARD_LAST_FIELDS_ORDER.put(name, i++);
+        }
+
+    }
+
+
+    private static final Comparator<ConfiguredObjectAttributeOrStatistic<?,?>> OBJECT_NAME_COMPARATOR = new Comparator<ConfiguredObjectAttributeOrStatistic<?, ?>>()
     {
         @Override
         public int compare(final ConfiguredObjectAttributeOrStatistic<?, ?> left,
                            final ConfiguredObjectAttributeOrStatistic<?, ?> right)
         {
-            return left.getName().compareTo(right.getName());
+            String leftName = left.getName();
+            String rightName = right.getName();
+            return compareAttributeNames(leftName, rightName);
         }
     };
 
+    private static final Comparator<String> NAME_COMPARATOR = new Comparator<String>()
+    {
+        @Override
+        public int compare(final String left, final String right)
+        {
+            return compareAttributeNames(left, right);
+        }
+    };
+
+    private static int compareAttributeNames(final String leftName, final String rightName)
+    {
+        int result;
+        if(leftName.equals(rightName))
+        {
+            result = 0;
+        }
+        else if(STANDARD_FIRST_FIELDS_ORDER.containsKey(leftName))
+        {
+            if(STANDARD_FIRST_FIELDS_ORDER.containsKey(rightName))
+            {
+                result = STANDARD_FIRST_FIELDS_ORDER.get(leftName) - STANDARD_FIRST_FIELDS_ORDER.get(rightName);
+            }
+            else
+            {
+                result = -1;
+            }
+        }
+        else if(STANDARD_FIRST_FIELDS_ORDER.containsKey(rightName))
+        {
+            result = 1;
+        }
+        else if(STANDARD_LAST_FIELDS_ORDER.containsKey(rightName))
+        {
+            if(STANDARD_LAST_FIELDS_ORDER.containsKey(leftName))
+            {
+                result = STANDARD_LAST_FIELDS_ORDER.get(leftName) - STANDARD_LAST_FIELDS_ORDER.get(rightName);
+            }
+            else
+            {
+                result = -1;
+            }
+        }
+        else if(STANDARD_LAST_FIELDS_ORDER.containsKey(leftName))
+        {
+            result = 1;
+        }
+        else
+        {
+            result = leftName.compareTo(rightName);
+        }
+
+        return result;
+    }
+
 
     private final Map<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectAttribute<?,?>>> _allAttributes =
             Collections.synchronizedMap(new HashMap<Class<? extends ConfiguredObject>, Collection<ConfiguredObjectAttribute<?, ?>>>());
@@ -373,8 +465,8 @@ public class ConfiguredObjectTypeRegistr
                 process((Class<? extends ConfiguredObject>) superclass);
             }
 
-            final SortedSet<ConfiguredObjectAttribute<?, ?>> attributeSet = new TreeSet<>(NAME_COMPARATOR);
-            final SortedSet<ConfiguredObjectStatistic<?, ?>> statisticSet = new TreeSet<>(NAME_COMPARATOR);
+            final SortedSet<ConfiguredObjectAttribute<?, ?>> attributeSet = new TreeSet<>(OBJECT_NAME_COMPARATOR);
+            final SortedSet<ConfiguredObjectStatistic<?, ?>> statisticSet = new TreeSet<>(OBJECT_NAME_COMPARATOR);
 
             _allAttributes.put(clazz, attributeSet);
             _allStatistics.put(clazz, statisticSet);
@@ -480,7 +572,7 @@ public class ConfiguredObjectTypeRegistr
 
     private <X extends ConfiguredObject> void processAttributesTypesAndFields(final Class<X> clazz)
     {
-        Map<String,ConfiguredObjectAttribute<?,?>> attrMap = new HashMap<String, ConfiguredObjectAttribute<?, ?>>();
+        Map<String,ConfiguredObjectAttribute<?,?>> attrMap = new TreeMap<>(NAME_COMPARATOR);
         Map<String,AutomatedField> fieldMap = new HashMap<String, AutomatedField>();
 
 

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Model.java Mon Aug 25 15:35:10 2014
@@ -98,7 +98,7 @@ public abstract class Model
         return null;
     }
 
-    private Class<? extends ConfiguredObject> getAncestorClassWithGivenDescendant(
+    public Class<? extends ConfiguredObject> getAncestorClassWithGivenDescendant(
             final Class<? extends ConfiguredObject> category,
             final Class<? extends ConfiguredObject> descendantClass)
     {

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Port.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Port.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Port.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/Port.java Mon Aug 25 15:35:10 2014
@@ -45,9 +45,6 @@ public interface Port<X extends Port<X>>
 
     // Attributes
 
-    @ManagedAttribute(defaultValue = "*")
-    String getBindingAddress();
-
     @ManagedAttribute( mandatory = true )
     int getPort();
 

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHostNode.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHostNode.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHostNode.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHostNode.java Mon Aug 25 15:35:10 2014
@@ -27,6 +27,16 @@ import org.apache.qpid.server.store.Dura
 @ManagedObject(category=true, managesChildren=false)
 public interface VirtualHostNode<X extends VirtualHostNode<X>> extends ConfiguredObject<X>
 {
+    String VIRTUALHOST_INITIAL_CONFIGURATION = "virtualHostInitialConfiguration";
+
+    String VIRTUALHOST_BLUEPRINT_CONTEXT_VAR = "virtualhostBlueprint";
+
+    @ManagedContextDefault(name = VIRTUALHOST_BLUEPRINT_CONTEXT_VAR)
+    String DEFAULT_INITIAL_CONFIGURATION = "{}";
+
+    @ManagedAttribute( defaultValue = "${" + VIRTUALHOST_BLUEPRINT_CONTEXT_VAR + "}")
+    String getVirtualHostInitialConfiguration();
+
     VirtualHost<?,?,?> getVirtualHost();
 
     DurableConfigurationStore getConfigurationStore();

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java Mon Aug 25 15:35:10 2014
@@ -52,6 +52,7 @@ public class VirtualHostAliasAdapter ext
         final Map<String, Object> attributes = new HashMap<String, Object>();
         attributes.put(ID, UUID.randomUUID());
         attributes.put(NAME, virtualHost.getName());
+        attributes.put(DURABLE, false);
         return attributes;
     }
 

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java Mon Aug 25 15:35:10 2014
@@ -61,9 +61,6 @@ abstract public class AbstractPort<X ext
     private int _port;
 
     @ManagedAttributeField
-    private String _bindingAddress;
-
-    @ManagedAttributeField
     private KeyStore<?> _keyStore;
 
     @ManagedAttributeField
@@ -172,12 +169,6 @@ abstract public class AbstractPort<X ext
     }
 
     @Override
-    public String getBindingAddress()
-    {
-        return _bindingAddress;
-    }
-
-    @Override
     public int getPort()
     {
         return _port;

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPort.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPort.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPort.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPort.java Mon Aug 25 15:35:10 2014
@@ -48,6 +48,9 @@ public interface AmqpPort<X extends Amqp
     @ManagedContextDefault(name = DEFAULT_AMQP_PROTOCOLS)
     String INSTALLED_PROTOCOLS = AmqpPortImpl.getInstalledProtocolsAsString();
 
+    @ManagedAttribute(defaultValue = "*")
+    String getBindingAddress();
+
     @ManagedAttribute( defaultValue = AmqpPort.DEFAULT_AMQP_TCP_NO_DELAY )
     boolean isTcpNoDelay();
 

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java Mon Aug 25 15:35:10 2014
@@ -71,6 +71,9 @@ public class AmqpPortImpl extends Abstra
     @ManagedAttributeField
     private int _receiveBufferSize;
 
+    @ManagedAttributeField
+    private String _bindingAddress;
+
     private final Broker<?> _broker;
     private AcceptingTransport _transport;
 
@@ -81,6 +84,13 @@ public class AmqpPortImpl extends Abstra
         _broker = broker;
     }
 
+
+    @Override
+    public String getBindingAddress()
+    {
+        return _bindingAddress;
+    }
+
     @Override
     public boolean isTcpNoDelay()
     {

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPort.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPort.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPort.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPort.java Mon Aug 25 15:35:10 2014
@@ -36,6 +36,8 @@ public interface HttpPort<X extends Http
     String DEFAULT_AMQP_NEED_CLIENT_AUTH = "false";
     String DEFAULT_AMQP_WANT_CLIENT_AUTH = "false";
 
+    @ManagedAttribute(defaultValue = "*")
+    String getBindingAddress();
 
     @ManagedAttribute( defaultValue = DEFAULT_AMQP_NEED_CLIENT_AUTH )
     boolean getNeedClientAuth();

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortImpl.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortImpl.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortImpl.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortImpl.java Mon Aug 25 15:35:10 2014
@@ -25,6 +25,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ManagedAttributeField;
 import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
 import org.apache.qpid.server.model.Protocol;
 import org.apache.qpid.server.model.State;
@@ -33,6 +34,9 @@ public class HttpPortImpl extends Abstra
 {
     private PortManager _portManager;
 
+    @ManagedAttributeField
+    private String _bindingAddress;
+
     @ManagedObjectFactoryConstructor
     public HttpPortImpl(final Map<String, Object> attributes,
                         final Broker<?> broker)
@@ -45,6 +49,13 @@ public class HttpPortImpl extends Abstra
         _portManager = manager;
     }
 
+
+    @Override
+    public String getBindingAddress()
+    {
+        return _bindingAddress;
+    }
+
     @Override
     protected State onActivate()
     {

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPort.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPort.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPort.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPort.java Mon Aug 25 15:35:10 2014
@@ -32,21 +32,9 @@ import org.apache.qpid.server.model.Tran
 @ManagedObject( category = false, type = "JMX")
 public interface JmxPort<X extends JmxPort<X>> extends Port<X>
 {
-
-    String DEFAULT_AMQP_NEED_CLIENT_AUTH = "false";
-    String DEFAULT_AMQP_WANT_CLIENT_AUTH = "false";
-
-
-    @ManagedAttribute( defaultValue = DEFAULT_AMQP_NEED_CLIENT_AUTH )
-    boolean getNeedClientAuth();
-
-    @ManagedAttribute( defaultValue = DEFAULT_AMQP_WANT_CLIENT_AUTH )
-    boolean getWantClientAuth();
-
     @ManagedAttribute( mandatory = true )
     AuthenticationProvider getAuthenticationProvider();
 
-
     @ManagedAttribute( defaultValue = "TCP",
                        validValues = {"[ \"TCP\" ]", "[ \"SSL\" ]"})
     Set<Transport> getTransports();

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueArgumentsConverter.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueArgumentsConverter.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueArgumentsConverter.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueArgumentsConverter.java Mon Aug 25 15:35:10 2014
@@ -23,6 +23,8 @@ package org.apache.qpid.server.queue;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
+
+import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.virtualhost.AbstractVirtualHost;
 
@@ -87,6 +89,8 @@ public class QueueArgumentsConverter
         ATTRIBUTE_MAPPINGS.put(X_QPID_PRIORITIES, PriorityQueue.PRIORITIES);
 
         ATTRIBUTE_MAPPINGS.put(X_QPID_DESCRIPTION, Queue.DESCRIPTION);
+        ATTRIBUTE_MAPPINGS.put(Queue.ALTERNATE_EXCHANGE, Queue.ALTERNATE_EXCHANGE);
+
 
         ATTRIBUTE_MAPPINGS.put(X_QPID_DLQ_ENABLED, AbstractVirtualHost.CREATE_DLQ_ON_CREATION);
         ATTRIBUTE_MAPPINGS.put(QPID_GROUP_HEADER_KEY, Queue.MESSAGE_GROUP_KEY);
@@ -147,6 +151,10 @@ public class QueueArgumentsConverter
                 {
                     value = ((Enum) value).name();
                 }
+                else if(value instanceof ConfiguredObject)
+                {
+                    value = ((ConfiguredObject)value).getName();
+                }
                 wireArguments.put(entry.getKey(), value);
             }
         }

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordConverter.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordConverter.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordConverter.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordConverter.java Mon Aug 25 15:35:10 2014
@@ -22,8 +22,11 @@ package org.apache.qpid.server.store;
 
 import java.io.IOException;
 import java.io.Reader;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
@@ -37,6 +40,11 @@ public class ConfiguredObjectRecordConve
 {
     private final Model _model;
 
+    private static interface NameToIdResolver
+    {
+        public boolean resolve(Map<UUID, ConfiguredObjectRecord> objectsById);
+    }
+
     public ConfiguredObjectRecordConverter(final Model model)
     {
         _model = model;
@@ -52,16 +60,32 @@ public class ConfiguredObjectRecordConve
         Map data = objectMapper.readValue(reader, Map.class);
         if(!data.isEmpty())
         {
-            loadChild(rootClass, data, parent.getCategoryClass(), parent.getId(), objectsById);
+            Collection<NameToIdResolver> unresolved =
+                    loadChild(rootClass, data, parent.getCategoryClass(), parent.getId(), objectsById);
+
+            Iterator<NameToIdResolver> iterator = unresolved.iterator();
+            while(iterator.hasNext())
+            {
+                if(iterator.next().resolve(objectsById))
+                {
+                    iterator.remove();
+                }
+            }
+
+            if(!unresolved.isEmpty())
+            {
+                throw new IllegalArgumentException("Initial configuration has unresolved references");
+            }
         }
         return objectsById.values();
     }
 
 
-    private void loadChild(final Class<? extends ConfiguredObject> clazz,
-                           final Map<String, Object> data,
-                           final Class<? extends ConfiguredObject> parentClass,
-                           final UUID parentId, final Map<UUID, ConfiguredObjectRecord> records)
+    private Collection<NameToIdResolver> loadChild(final Class<? extends ConfiguredObject> clazz,
+                                                   final Map<String, Object> data,
+                                                   final Class<? extends ConfiguredObject> parentClass,
+                                                   final UUID parentId,
+                                                   final Map<UUID, ConfiguredObjectRecord> records)
     {
         String idStr = (String) data.remove("id");
 
@@ -70,6 +94,7 @@ public class ConfiguredObjectRecordConve
         Map<String,UUID> parentMap = new HashMap<>();
 
         Collection<Class<? extends ConfiguredObject>> childClasses = _model.getChildTypes(clazz);
+        List<NameToIdResolver> requiringResolution = new ArrayList<>();
         for(Class<? extends ConfiguredObject> childClass : childClasses)
         {
             final String childType = childClass.getSimpleName();
@@ -83,13 +108,14 @@ public class ConfiguredObjectRecordConve
                     {
                         if(child instanceof Map)
                         {
-                            loadChild(childClass, (Map)child, clazz, id, records);
+                            requiringResolution.addAll(loadChild(childClass, (Map) child, clazz, id, records));
                         }
                     }
                 }
             }
 
         }
+
         if(parentId != null)
         {
             parentMap.put(parentClass.getSimpleName(),parentId);
@@ -107,7 +133,15 @@ public class ConfiguredObjectRecordConve
                         }
                         catch(IllegalArgumentException e)
                         {
-                            // TODO
+                            final String ancestorClassName =
+                                    _model.getAncestorClassWithGivenDescendant(clazz, otherParent).getSimpleName();
+                            final String parentName = (String) otherParentId;
+                            final String parentType = otherParent.getSimpleName();
+
+                            requiringResolution.add(new AncestorFindingResolver(id,
+                                                                                parentType,
+                                                                                parentName,
+                                                                                ancestorClassName));
                         }
                     }
                 }
@@ -117,7 +151,79 @@ public class ConfiguredObjectRecordConve
 
         records.put(id, new ConfiguredObjectRecordImpl(id, type, data, parentMap));
 
+        return requiringResolution;
     }
 
 
+    private static class AncestorFindingResolver implements NameToIdResolver
+    {
+        private final String _parentType;
+        private final String _parentName;
+        private final String _commonAncestorType;
+        private final UUID _id;
+
+        public AncestorFindingResolver(final UUID id,
+                                       final String parentType,
+                                       final String parentName,
+                                       final String commonAncestorType)
+        {
+            _id = id;
+            _parentType = parentType;
+            _parentName = parentName;
+            _commonAncestorType = commonAncestorType;
+        }
+
+        @Override
+        public boolean resolve(final Map<UUID, ConfiguredObjectRecord> objectsById)
+        {
+
+            ConfiguredObjectRecord record = objectsById.get(_id);
+            Collection<ConfiguredObjectRecord> recordsWithMatchingName = new ArrayList<>();
+            for(ConfiguredObjectRecord possibleParentRecord : objectsById.values())
+            {
+                if(possibleParentRecord.getType().equals(_parentType)
+                   && _parentName.equals(possibleParentRecord.getAttributes().get(ConfiguredObject.NAME)))
+                {
+                    recordsWithMatchingName.add(possibleParentRecord);
+                }
+            }
+            for(ConfiguredObjectRecord candidate : recordsWithMatchingName)
+            {
+                UUID candidateAncestor = findAncestor(candidate, _commonAncestorType, objectsById);
+                UUID recordAncestor = findAncestor(record, _commonAncestorType, objectsById);
+                if(recordAncestor.equals(candidateAncestor))
+                {
+                    HashMap<String, UUID> parents = new HashMap<>(record.getParents());
+                    parents.put(_parentType, candidate.getId());
+                    objectsById.put(_id, new ConfiguredObjectRecordImpl(_id, record.getType(), record.getAttributes(), parents));
+
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        private UUID findAncestor(final ConfiguredObjectRecord record,
+                                  final String commonAncestorType,
+                                  final Map<UUID, ConfiguredObjectRecord> objectsById)
+        {
+            UUID id = record.getParents().get(commonAncestorType);
+            if(id == null)
+            {
+                for(UUID parentId : record.getParents().values())
+                {
+                    ConfiguredObjectRecord parent = objectsById.get(parentId);
+                    if(parent != null)
+                    {
+                        id = findAncestor(parent, commonAncestorType, objectsById);
+                    }
+                    if(id != null)
+                    {
+                        break;
+                    }
+                }
+            }
+            return id;
+        }
+    }
 }

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java Mon Aug 25 15:35:10 2014
@@ -31,6 +31,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
@@ -57,6 +58,28 @@ public class JsonFileConfigStore impleme
 {
     private static final Logger _logger = Logger.getLogger(JsonFileConfigStore.class);
 
+    private static final Comparator<Class<? extends ConfiguredObject>> CATEGORY_CLASS_COMPARATOR =
+            new Comparator<Class<? extends ConfiguredObject>>()
+            {
+                @Override
+                public int compare(final Class<? extends ConfiguredObject> left,
+                                   final Class<? extends ConfiguredObject> right)
+                {
+                    return left.getSimpleName().compareTo(right.getSimpleName());
+                }
+            };
+    private static final Comparator<ConfiguredObjectRecord> CONFIGURED_OBJECT_RECORD_COMPARATOR =
+            new Comparator<ConfiguredObjectRecord>()
+            {
+                @Override
+                public int compare(final ConfiguredObjectRecord left, final ConfiguredObjectRecord right)
+                {
+                    String leftName = (String) left.getAttributes().get(ConfiguredObject.NAME);
+                    String rightName = (String) right.getAttributes().get(ConfiguredObject.NAME);
+                    return leftName.compareTo(rightName);
+                }
+            };
+
     private final Map<UUID, ConfiguredObjectRecord> _objectsById = new HashMap<UUID, ConfiguredObjectRecord>();
     private final Map<String, List<UUID>> _idsByType = new HashMap<String, List<UUID>>();
     private final ObjectMapper _objectMapper = new ObjectMapper();
@@ -313,6 +336,14 @@ public class JsonFileConfigStore impleme
         {
             throw new StoreException("Cannot create object of unknown type " + record.getType());
         }
+        else if(record.getAttributes() == null || !(record.getAttributes().get(ConfiguredObject.NAME) instanceof String))
+        {
+            throw new StoreException("The record " + record.getId()
+                                     + " of type " + record.getType()
+                                     + " does not have an attribute '"
+                                     + ConfiguredObject.NAME
+                                     + "' of type String");
+        }
         else
         {
             record = new ConfiguredObjectRecordImpl(record);
@@ -385,8 +416,6 @@ public class JsonFileConfigStore impleme
     {
         ConfiguredObjectRecord record = _objectsById.get(id);
         Map<String,Object> map = new LinkedHashMap<String, Object>();
-        map.put("id", id);
-        map.putAll(record.getAttributes());
 
         Collection<Class<? extends ConfiguredObject>> parentTypes = _parent.getModel().getParentTypes(type);
         if(parentTypes.size() > 1)
@@ -403,9 +432,14 @@ public class JsonFileConfigStore impleme
             }
         }
 
-        Collection<Class<? extends ConfiguredObject>> childClasses =
+        map.put("id", id);
+        map.putAll(record.getAttributes());
+
+        List<Class<? extends ConfiguredObject>> childClasses =
                 new ArrayList<Class<? extends ConfiguredObject>>(_parent.getModel().getChildTypes(type));
 
+        Collections.sort(childClasses, CATEGORY_CLASS_COMPARATOR);
+
         for(Class<? extends ConfiguredObject> childClass : childClasses)
         {
             // only add if this is the "first" parent
@@ -416,6 +450,7 @@ public class JsonFileConfigStore impleme
                 if(childIds != null)
                 {
                     List<Map<String,Object>> entities = new ArrayList<Map<String, Object>>();
+                    List<ConfiguredObjectRecord> sortedChildren = new ArrayList<>();
                     for(UUID childId : childIds)
                     {
                         ConfiguredObjectRecord childRecord = _objectsById.get(childId);
@@ -424,9 +459,17 @@ public class JsonFileConfigStore impleme
                         String parentId = parent.toString();
                         if(id.toString().equals(parentId))
                         {
-                            entities.add(build(childClass,childId));
+                            sortedChildren.add(childRecord);
                         }
                     }
+
+                    Collections.sort(sortedChildren, CONFIGURED_OBJECT_RECORD_COMPARATOR);
+
+                    for(ConfiguredObjectRecord childRecord : sortedChildren)
+                    {
+                        entities.add(build(childClass, childRecord.getId()));
+                    }
+
                     if(!entities.isEmpty())
                     {
                         map.put(attrName,entities);
@@ -475,6 +518,13 @@ public class JsonFileConfigStore impleme
             final UUID id = record.getId();
             final String type = record.getType();
 
+            if(record.getAttributes() == null || !(record.getAttributes().get(ConfiguredObject.NAME) instanceof String))
+            {
+                throw new StoreException("The record " + id + " of type " + type + " does not have an attribute '"
+                                         + ConfiguredObject.NAME
+                                         + "' of type String");
+            }
+
             if(_objectsById.containsKey(id))
             {
                 final ConfiguredObjectRecord existingRecord = _objectsById.get(id);

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java Mon Aug 25 15:35:10 2014
@@ -29,6 +29,8 @@ import org.apache.qpid.server.store.hand
 
 public abstract class NullMessageStore implements MessageStore, DurableConfigurationStore, MessageStoreProvider
 {
+    private ConfiguredObjectRecord[] _initialRecords;
+
     @Override
     public MessageStore getMessageStore()
     {
@@ -40,6 +42,7 @@ public abstract class NullMessageStore i
                                        final boolean overwrite,
                                        final ConfiguredObjectRecord... initialRecords)
     {
+        _initialRecords = initialRecords;
     }
 
     @Override
@@ -121,6 +124,18 @@ public abstract class NullMessageStore i
     @Override
     public void visitConfiguredObjectRecords(ConfiguredObjectRecordHandler handler) throws StoreException
     {
+        handler.begin();
+        if(_initialRecords != null)
+        {
+            for(ConfiguredObjectRecord record : _initialRecords)
+            {
+                if(!handler.handle(record))
+                {
+                    break;
+                }
+            }
+        }
+        handler.end();
     }
 
     @Override

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/util/urlstreamhandler/data/Handler.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/util/urlstreamhandler/data/Handler.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/util/urlstreamhandler/data/Handler.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/util/urlstreamhandler/data/Handler.java Mon Aug 25 15:35:10 2014
@@ -136,13 +136,4 @@ public class Handler extends URLStreamHa
             return new ByteArrayInputStream(_content);
         }
     }
-
-    public static void main(String[] args) throws IOException
-    {
-        register();
-        URL url = new URL("data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7");
-        InputStream is = url.openStream();
-        url = new URL("data:,A%20brief%20note");
-        is = url.openStream();
-    }
 }

Modified: qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java?rev=1620350&r1=1620349&r2=1620350&view=diff
==============================================================================
--- qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java (original)
+++ qpid/branches/0.30/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java Mon Aug 25 15:35:10 2014
@@ -20,24 +20,27 @@
  */
 package org.apache.qpid.server.virtualhostnode;
 
+import java.io.IOException;
 import java.security.PrivilegedAction;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 import javax.security.auth.Subject;
 
 import org.apache.log4j.Logger;
 
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.logging.messages.ConfigStoreMessages;
 import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.BrokerModel;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.RemoteReplicationNode;
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.model.VirtualHostNode;
 import org.apache.qpid.server.security.SecurityManager;
+import org.apache.qpid.server.store.ConfiguredObjectRecord;
+import org.apache.qpid.server.store.ConfiguredObjectRecordImpl;
 import org.apache.qpid.server.store.VirtualHostStoreUpgraderAndRecoverer;
 
 public abstract class AbstractStandardVirtualHostNode<X extends AbstractStandardVirtualHostNode<X>> extends AbstractVirtualHostNode<X>
@@ -71,7 +74,20 @@ public abstract class AbstractStandardVi
             LOGGER.debug("Activating virtualhost node " + this);
         }
 
-        getConfigurationStore().openConfigurationStore(this, false);
+        try
+        {
+            ConfiguredObjectRecord[] initialRecords = getInitialRecords();
+            getConfigurationStore().openConfigurationStore(this, false, initialRecords);
+            if(initialRecords != null && initialRecords.length > 0)
+            {
+                setAttribute(VIRTUALHOST_INITIAL_CONFIGURATION, getVirtualHostInitialConfiguration(), "{}");
+            }
+        }
+        catch (IOException e)
+        {
+            throw new IllegalConfigurationException("Could not process initial configuration", e);
+        }
+
         getConfigurationStore().upgradeStoreStructure();
 
         getEventLogger().message(getConfigurationStoreLogSubject(), ConfigStoreMessages.CREATED());
@@ -87,47 +103,7 @@ public abstract class AbstractStandardVi
 
         VirtualHost<?,?,?>  host = getVirtualHost();
 
-        if (host == null)
-        {
-
-            boolean hasBlueprint = getContextKeys(false).contains(VIRTUALHOST_BLUEPRINT_CONTEXT_VAR);
-            boolean blueprintUtilised = getContext().containsKey(VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR)
-                    && Boolean.parseBoolean(String.valueOf(getContext().get(VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR)));
-
-            if (hasBlueprint && !blueprintUtilised)
-            {
-                Map<String, Object> virtualhostBlueprint = getContextValue(Map.class, VIRTUALHOST_BLUEPRINT_CONTEXT_VAR);
-
-                if (LOGGER.isDebugEnabled())
-                {
-                    LOGGER.debug("Using virtualhost blueprint " + virtualhostBlueprint);
-                }
-
-                Map<String, Object> virtualhostAttributes = new HashMap<>();
-                virtualhostAttributes.put(VirtualHost.MODEL_VERSION, BrokerModel.MODEL_VERSION);
-                virtualhostAttributes.put(VirtualHost.NAME, getName());
-                virtualhostAttributes.putAll(virtualhostBlueprint);
-
-                if (LOGGER.isDebugEnabled())
-                {
-                    LOGGER.debug("Creating new virtualhost named " + virtualhostAttributes.get(VirtualHost.NAME));
-                }
-
-                host = createChild(VirtualHost.class, virtualhostAttributes);
-
-                if (LOGGER.isDebugEnabled())
-                {
-                    LOGGER.debug("Created new virtualhost: " + host);
-                }
-
-                // Update the context with the utilised flag
-                Map<String, String> actualContext = (Map<String, String>) getActualAttributes().get(CONTEXT);
-                Map<String, String> context = new HashMap<>(actualContext);
-                context.put(VIRTUALHOST_BLUEPRINT_UTILISED_CONTEXT_VAR, Boolean.TRUE.toString());
-                setAttribute(CONTEXT, getContext(), context);
-            }
-        }
-        else
+        if (host != null)
         {
             final VirtualHost<?,?,?> recoveredHost = host;
             Subject.doAs(SecurityManager.getSubjectWithAddedSystemRights(), new PrivilegedAction<Object>()
@@ -142,6 +118,44 @@ public abstract class AbstractStandardVi
         }
     }
 
+
+    @Override
+    protected ConfiguredObjectRecord enrichInitialVirtualHostRootRecord(final ConfiguredObjectRecord vhostRecord)
+    {
+        ConfiguredObjectRecord replacementRecord;
+        if (vhostRecord.getAttributes().get(ConfiguredObject.NAME) == null)
+        {
+            Map<String, Object> updatedAttributes = new LinkedHashMap<>(vhostRecord.getAttributes());
+            updatedAttributes.put(ConfiguredObject.NAME, getName());
+            if (!updatedAttributes.containsKey(VirtualHost.MODEL_VERSION))
+            {
+                updatedAttributes.put(VirtualHost.MODEL_VERSION, getBroker().getModelVersion());
+            }
+            replacementRecord = new ConfiguredObjectRecordImpl(vhostRecord.getId(),
+                                                               vhostRecord.getType(),
+                                                               updatedAttributes,
+                                                               vhostRecord.getParents());
+        }
+        else if (vhostRecord.getAttributes().get(VirtualHost.MODEL_VERSION) == null)
+        {
+            Map<String, Object> updatedAttributes = new LinkedHashMap<>(vhostRecord.getAttributes());
+
+            updatedAttributes.put(VirtualHost.MODEL_VERSION, getBroker().getModelVersion());
+
+            replacementRecord = new ConfiguredObjectRecordImpl(vhostRecord.getId(),
+                                                               vhostRecord.getType(),
+                                                               updatedAttributes,
+                                                               vhostRecord.getParents());
+        }
+        else
+        {
+            replacementRecord = vhostRecord;
+        }
+
+        return replacementRecord;
+    }
+
+
     protected abstract void writeLocationEventLog();
 
     @Override



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org