Modified: 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java
 Sat Jul 23 19:30:45 2016
@@ -30,7 +30,6 @@ import org.apache.qpid.server.store.hand
 
 public abstract class NullMessageStore implements MessageStore, 
DurableConfigurationStore, MessageStoreProvider, MessageStore.MessageStoreReader
 {
-    private ConfiguredObjectRecord[] _initialRecords;
 
     @Override
     public MessageStore getMessageStore()
@@ -39,11 +38,8 @@ public abstract class NullMessageStore i
     }
 
     @Override
-    public void openConfigurationStore(ConfiguredObject<?> parent,
-                                       final boolean overwrite,
-                                       final ConfiguredObjectRecord... 
initialRecords)
+    public void init(ConfiguredObject<?> parent)
     {
-        _initialRecords = initialRecords;
     }
 
     @Override
@@ -129,22 +125,23 @@ public abstract class NullMessageStore i
     }
 
     @Override
-    public void visitConfiguredObjectRecords(ConfiguredObjectRecordHandler 
handler) throws StoreException
+    public boolean openConfigurationStore(ConfiguredObjectRecordHandler 
handler,
+                                          final ConfiguredObjectRecord... 
initialRecords) throws StoreException
     {
-        handler.begin();
-        if(_initialRecords != null)
+        if(initialRecords != null)
         {
-            for(ConfiguredObjectRecord record : _initialRecords)
+            for(ConfiguredObjectRecord record : initialRecords)
             {
-                if(!handler.handle(record))
-                {
-                    break;
-                }
+                handler.handle(record);
             }
         }
-        handler.end();
+        return true;
     }
 
+    @Override
+    public void reload(final ConfiguredObjectRecordHandler handler) throws 
StoreException
+    {
+    }
 
     @Override
     public void visitMessages(MessageHandler handler) throws StoreException

Modified: 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecoverer.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecoverer.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecoverer.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecoverer.java
 Sat Jul 23 19:30:45 2016
@@ -20,12 +20,14 @@
  */
 package org.apache.qpid.server.store;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.UUID;
@@ -34,6 +36,7 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import 
org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener;
 import org.apache.qpid.server.filter.FilterSupport;
+import org.apache.qpid.server.model.AbstractConfiguredObject;
 import org.apache.qpid.server.model.Binding;
 import org.apache.qpid.server.model.ConfigurationChangeListener;
 import org.apache.qpid.server.model.ConfiguredObject;
@@ -44,6 +47,7 @@ import org.apache.qpid.server.model.UUID
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.model.VirtualHostNode;
 import org.apache.qpid.server.queue.QueueArgumentsConverter;
+import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler;
 import org.apache.qpid.server.util.Action;
 
 public class VirtualHostStoreUpgraderAndRecoverer
@@ -569,15 +573,39 @@ public class VirtualHostStoreUpgraderAnd
 
     }
 
-    public void perform(final DurableConfigurationStore 
durableConfigurationStore)
+    public boolean upgradeAndRecover(final DurableConfigurationStore 
durableConfigurationStore,
+                                     final ConfiguredObjectRecord... 
initialRecords)
     {
         String virtualHostCategory = VirtualHost.class.getSimpleName();
         GenericStoreUpgrader upgraderHandler = new 
GenericStoreUpgrader(virtualHostCategory, VirtualHost.MODEL_VERSION, 
durableConfigurationStore, _upgraders);
-        upgraderHandler.upgrade();
+        boolean isNew = upgraderHandler.upgrade(initialRecords);
 
-        new 
GenericRecoverer(_virtualHostNode).recover(upgraderHandler.getRecords());
+        List<ConfiguredObjectRecord> records = upgraderHandler.getRecords();
+        recover(durableConfigurationStore, records, isNew);
+        return isNew;
+    }
 
-        final StoreConfigurationChangeListener configChangeListener = new 
StoreConfigurationChangeListener(durableConfigurationStore);
+    public void reloadAndRecover(final DurableConfigurationStore 
durableConfigurationStore)
+    {
+        final List<ConfiguredObjectRecord> records = new ArrayList<>();
+        durableConfigurationStore.reload(new ConfiguredObjectRecordHandler()
+        {
+            @Override
+            public void handle(final ConfiguredObjectRecord record)
+            {
+                records.add(record);
+            }
+        });
+        recover(durableConfigurationStore, records, false);
+    }
+
+    private void recover(final DurableConfigurationStore 
durableConfigurationStore,
+                         final List<ConfiguredObjectRecord> records, final 
boolean isNew)
+    {
+        new GenericRecoverer(_virtualHostNode).recover(records, isNew);
+
+        final StoreConfigurationChangeListener
+                configChangeListener = new 
StoreConfigurationChangeListener(durableConfigurationStore);
         if(_virtualHostNode.getVirtualHost() != null)
         {
             applyRecursively(_virtualHostNode.getVirtualHost(), new 
Action<ConfiguredObject<?>>()
@@ -648,6 +676,13 @@ public class VirtualHostStoreUpgraderAnd
 
             }
         });
+        if(isNew)
+        {
+            if(_virtualHostNode instanceof AbstractConfiguredObject)
+            {
+                
((AbstractConfiguredObject)_virtualHostNode).forceUpdateAllSecureAttributes();
+            }
+        }
     }
 
     private void applyRecursively(final ConfiguredObject<?> object, final 
Action<ConfiguredObject<?>> action)

Modified: 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/store/handler/ConfiguredObjectRecordHandler.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/store/handler/ConfiguredObjectRecordHandler.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/store/handler/ConfiguredObjectRecordHandler.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/store/handler/ConfiguredObjectRecordHandler.java
 Sat Jul 23 19:30:45 2016
@@ -24,7 +24,6 @@ import org.apache.qpid.server.store.Conf
 
 public interface ConfiguredObjectRecordHandler
 {
-    void begin();
 
     /**
      * Handles the given record.
@@ -32,7 +31,6 @@ public interface ConfiguredObjectRecordH
      * @param record
      * @return false is returned if the handler does not wish to handle other 
record, true otherwise
      */
-    boolean handle(ConfiguredObjectRecord record);
+    void handle(ConfiguredObjectRecord record);
 
-    void end();
 }

Modified: 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
 Sat Jul 23 19:30:45 2016
@@ -176,6 +176,8 @@ public abstract class AbstractVirtualHos
 
     private final AccessControl _accessControl;
 
+    private volatile boolean _createDefaultExchanges;
+
 
     private final AccessControl<SecurityToken> _systemUserAllowed = new 
AccessControl<SecurityToken>()
     {
@@ -335,6 +337,19 @@ public abstract class AbstractVirtualHos
         }
     }
 
+    @Override
+    protected void onCreate()
+    {
+        super.onCreate();
+        _createDefaultExchanges = getChildren(Exchange.class).isEmpty() && 
getChildren(Queue.class).isEmpty();
+    }
+
+    @Override
+    public void setFirstOpening(boolean firstOpening)
+    {
+        _createDefaultExchanges = firstOpening;
+    }
+
     public void onValidate()
     {
         super.onValidate();
@@ -604,15 +619,6 @@ public abstract class AbstractVirtualHos
 
     protected abstract MessageStore createMessageStore();
 
-    protected boolean isStoreEmpty()
-    {
-        final IsStoreEmptyHandler isStoreEmptyHandler = new 
IsStoreEmptyHandler();
-
-        
getDurableConfigurationStore().visitConfiguredObjectRecords(isStoreEmptyHandler);
-
-        return isStoreEmptyHandler.isEmpty();
-    }
-
     private ListenableFuture<List<Void>> createDefaultExchanges()
     {
         return Subject.doAs(getSubjectWithAddedSystemRights(), new 
PrivilegedAction<ListenableFuture<List<Void>>>()
@@ -1270,35 +1276,6 @@ public abstract class AbstractVirtualHos
         }
     }
 
-    private static class IsStoreEmptyHandler implements 
ConfiguredObjectRecordHandler
-    {
-        private boolean _empty = true;
-
-        @Override
-        public void begin()
-        {
-        }
-
-        @Override
-        public boolean handle(final ConfiguredObjectRecord record)
-        {
-            // if there is a non vhost record then the store is not empty and 
we can stop looking at the records
-            _empty = 
record.getType().equals(VirtualHost.class.getSimpleName());
-            return _empty;
-        }
-
-        @Override
-        public void end()
-        {
-
-        }
-
-        public boolean isEmpty()
-        {
-            return _empty;
-        }
-    }
-
     @Override
     public String getRedirectHost(final AmqpPort<?> port)
     {
@@ -2054,13 +2031,14 @@ public abstract class AbstractVirtualHos
 
         getBroker().assignTargetSizes();
 
-        if (isStoreEmpty())
+        if (_createDefaultExchanges)
         {
             return doAfter(createDefaultExchanges(), new Runnable()
             {
                 @Override
                 public void run()
                 {
+                    _createDefaultExchanges = false;
                     postCreateDefaultExchangeTasks();
                 }
             });
@@ -2131,32 +2109,24 @@ public abstract class AbstractVirtualHos
     {
         resetStatistics();
 
+
         final List<ConfiguredObjectRecord> records = new ArrayList<>();
 
         // Transitioning to STOPPED will have closed all our children.  Now we 
are transition
         // back to ACTIVE, we need to recover and re-open them.
 
-        getDurableConfigurationStore().visitConfiguredObjectRecords(new 
ConfiguredObjectRecordHandler()
+        getDurableConfigurationStore().reload(new 
ConfiguredObjectRecordHandler()
         {
-            @Override
-            public void begin()
-            {
-            }
 
             @Override
-            public boolean handle(final ConfiguredObjectRecord record)
+            public void handle(final ConfiguredObjectRecord record)
             {
                 records.add(record);
-                return true;
             }
 
-            @Override
-            public void end()
-            {
-            }
         });
 
-        new GenericRecoverer(this).recover(records);
+        new GenericRecoverer(this).recover(records, false);
 
         final List<ListenableFuture<Void>> childOpenFutures = new 
ArrayList<>();
 

Modified: 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java
 Sat Jul 23 19:30:45 2016
@@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.logging.messages.ConfigStoreMessages;
+import org.apache.qpid.server.model.AbstractConfiguredObject;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.RemoteReplicationNode;
@@ -77,19 +78,8 @@ public abstract class AbstractStandardVi
             LOGGER.debug("Activating virtualhost node " + this);
         }
 
-        try
-        {
-            ConfiguredObjectRecord[] initialRecords = getInitialRecords();
-            getConfigurationStore().openConfigurationStore(this, false, 
initialRecords);
-            if(initialRecords != null && initialRecords.length > 0)
-            {
-                setAttributes(Collections.<String, 
Object>singletonMap(VIRTUALHOST_INITIAL_CONFIGURATION, "{}"));
-            }
-        }
-        catch (IOException e)
-        {
-            throw new IllegalConfigurationException("Could not process initial 
configuration", e);
-        }
+        getConfigurationStore().init(this);
+
 
         getConfigurationStore().upgradeStoreStructure();
 
@@ -100,7 +90,21 @@ public abstract class AbstractStandardVi
         getEventLogger().message(getConfigurationStoreLogSubject(), 
ConfigStoreMessages.RECOVERY_START());
 
         VirtualHostStoreUpgraderAndRecoverer upgrader = new 
VirtualHostStoreUpgraderAndRecoverer(this);
-        upgrader.perform(getConfigurationStore());
+        ConfiguredObjectRecord[] initialRecords  = null;
+        try
+        {
+            initialRecords = getInitialRecords();
+        }
+        catch (IOException e)
+        {
+            throw new IllegalConfigurationException("Could not process initial 
configuration", e);
+        }
+
+        final boolean isNew = 
upgrader.upgradeAndRecover(getConfigurationStore(), initialRecords);
+        if(initialRecords.length > 0)
+        {
+            setAttributes(Collections.<String, 
Object>singletonMap(VIRTUALHOST_INITIAL_CONFIGURATION, "{}"));
+        }
 
         getEventLogger().message(getConfigurationStoreLogSubject(), 
ConfigStoreMessages.RECOVERY_COMPLETE());
 
@@ -109,16 +113,18 @@ public abstract class AbstractStandardVi
         if (host != null)
         {
             final VirtualHost<?> recoveredHost = host;
-            final ListenableFuture<Void> openFuture = 
Subject.doAs(getSubjectWithAddedSystemRights(),
-                                                                   new 
PrivilegedAction<ListenableFuture<Void>>()
-                                                                   {
-                                                                       
@Override
-                                                                       public 
ListenableFuture<Void> run()
-                                                                       {
-                                                                           
return recoveredHost.openAsync();
+            final ListenableFuture<Void> openFuture;
+            recoveredHost.setFirstOpening(isNew && initialRecords.length == 0);
+            openFuture = Subject.doAs(getSubjectWithAddedSystemRights(),
+                                      new 
PrivilegedAction<ListenableFuture<Void>>()
+                                      {
+                                          @Override
+                                          public ListenableFuture<Void> run()
+                                          {
+                                              return recoveredHost.openAsync();
 
-                                                                       }
-                                                                   });
+                                          }
+                                      });
             return openFuture;
         }
         else
@@ -188,7 +194,7 @@ public abstract class AbstractStandardVi
         {
             try
             {
-                store.openConfigurationStore(this, false);
+                store.init(this);
             }
             catch (Exception e)
             {

Modified: 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/RedirectingVirtualHostImpl.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/RedirectingVirtualHostImpl.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/RedirectingVirtualHostImpl.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/RedirectingVirtualHostImpl.java
 Sat Jul 23 19:30:45 2016
@@ -515,4 +515,9 @@ class RedirectingVirtualHostImpl
                                         + " does not permit this operation.");
     }
 
+    @Override
+    public void setFirstOpening(final boolean firstOpening)
+    {
+
+    }
 }

Modified: 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java
 Sat Jul 23 19:30:45 2016
@@ -28,6 +28,7 @@ import static org.mockito.Mockito.verify
 import static org.mockito.Mockito.when;
 
 import java.security.Principal;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -103,19 +104,17 @@ public class ManagementModeStoreHandlerT
                     public Object answer(final InvocationOnMock invocation) 
throws Throwable
                     {
                         ConfiguredObjectRecordHandler recoverer = 
recovererArgumentCaptor.getValue();
-                        if(recoverer.handle(_root))
-                        {
-                            recoverer.handle(_portEntry);
-                        }
-                        return null;
+                        recoverer.handle(_root);
+                        recoverer.handle(_portEntry);
+                        return false;
                     }
                 }
-                
).when(_store).visitConfiguredObjectRecords(recovererArgumentCaptor.capture());
+                
).when(_store).openConfigurationStore(recovererArgumentCaptor.capture());
         _options = new BrokerOptions();
 
         _handler = new ManagementModeStoreHandler(_store, _systemConfig);;
 
-        _handler.openConfigurationStore(_systemConfig, false);
+        _handler.init(_systemConfig);
     }
 
     private ManagementModeStoreHandler createManagementModeStoreHandler()
@@ -155,42 +154,87 @@ public class ManagementModeStoreHandlerT
         super.tearDown();
     }
 
-    private ConfiguredObjectRecord getRootEntry()
+    private Collection<ConfiguredObjectRecord> openAndGetRecords()
     {
-        BrokerFinder brokerFinder = new BrokerFinder();
-        _handler.visitConfiguredObjectRecords(brokerFinder);
-        return brokerFinder.getBrokerRecord();
+        final Collection<ConfiguredObjectRecord> records = new ArrayList<>();
+        _handler.openConfigurationStore(new ConfiguredObjectRecordHandler()
+        {
+
+            @Override
+            public void handle(final ConfiguredObjectRecord record)
+            {
+                records.add(record);
+            }
+
+        });
+        return records;
+    }
+
+    private ConfiguredObjectRecord 
getRootEntry(Collection<ConfiguredObjectRecord> records)
+    {
+        for(ConfiguredObjectRecord record : records)
+        {
+            if (record.getType().equals(Broker.class.getSimpleName()))
+            {
+                return record;
+            }
+        }
+        return null;
     }
 
-    private ConfiguredObjectRecord getEntry(UUID id)
+    private ConfiguredObjectRecord getEntry(Collection<ConfiguredObjectRecord> 
records, UUID id)
     {
-        RecordFinder recordFinder = new RecordFinder(id);
-        _handler.visitConfiguredObjectRecords(recordFinder);
-        return recordFinder.getFoundRecord();
+        for(ConfiguredObjectRecord record : records)
+        {
+            if (record.getId().equals(id))
+            {
+                return record;
+            }
+        }
+        return null;
     }
 
-    private Collection<UUID> getChildrenIds(ConfiguredObjectRecord record)
+    private Collection<UUID> getChildrenIds(Collection<ConfiguredObjectRecord> 
records, ConfiguredObjectRecord parent)
     {
-        ChildFinder childFinder = new ChildFinder(record);
-        _handler.visitConfiguredObjectRecords(childFinder);
-        return childFinder.getChildIds();
+        Collection<UUID> childIds = new HashSet<>();
+
+        for(ConfiguredObjectRecord record : records)
+        {
+
+            if (record.getParents() != null)
+            {
+                for (UUID parentId : record.getParents().values())
+                {
+                    if (parentId.equals(parent.getId()))
+                    {
+                        childIds.add(record.getId());
+                    }
+                }
+
+            }
+        }
+
+        return childIds;
     }
 
     public void testGetRootEntryWithEmptyOptions()
     {
-        ConfiguredObjectRecord root = getRootEntry();
+        Collection<ConfiguredObjectRecord> records = openAndGetRecords();
+        ConfiguredObjectRecord root = getRootEntry(records);
         assertEquals("Unexpected root id", _rootId, root.getId());
-        assertEquals("Unexpected children", 
Collections.singleton(_portEntryId), getChildrenIds(root));
+        assertEquals("Unexpected children", 
Collections.singleton(_portEntryId), getChildrenIds(records, root));
     }
 
     public void testGetRootEntryWithHttpPortOverriden()
     {
         _options.setManagementModeHttpPortOverride(9090);
         _handler = createManagementModeStoreHandler();
-        _handler.openConfigurationStore(_systemConfig, false);
-        ConfiguredObjectRecord root = getRootEntry();
+        _handler.init(_systemConfig);
+        Collection<ConfiguredObjectRecord> records = openAndGetRecords();
+
+        ConfiguredObjectRecord root = getRootEntry(records);
         assertEquals("Unexpected root id", _rootId, root.getId());
-        Collection<UUID> childrenIds = getChildrenIds(root);
+        Collection<UUID> childrenIds = getChildrenIds(records, root);
         assertEquals("Unexpected children size", 2, childrenIds.size());
         assertTrue("Store port entry id is not found", 
childrenIds.contains(_portEntryId));
     }
@@ -199,27 +243,32 @@ public class ManagementModeStoreHandlerT
     {
         _options.setManagementModeHttpPortOverride(1000);
         _handler = createManagementModeStoreHandler();
-        _handler.openConfigurationStore(_systemConfig, false);
+        _handler.init(_systemConfig);
+        Collection<ConfiguredObjectRecord> records = openAndGetRecords();
 
-        ConfiguredObjectRecord root = getRootEntry();
+        ConfiguredObjectRecord root = getRootEntry(records);
         assertEquals("Unexpected root id", _rootId, root.getId());
-        Collection<UUID> childrenIds = getChildrenIds(root);
+        Collection<UUID> childrenIds = getChildrenIds(records, root);
         assertEquals("Unexpected children size", 2, childrenIds.size());
         assertTrue("Store port entry id is not found", 
childrenIds.contains(_portEntryId));
     }
 
     public void testGetEntryByRootId()
     {
-        ConfiguredObjectRecord root = getEntry(_rootId);
+        Collection<ConfiguredObjectRecord> records = openAndGetRecords();
+
+        ConfiguredObjectRecord root = getEntry(records, _rootId);
         assertEquals("Unexpected root id", _rootId, root.getId());
-        assertEquals("Unexpected children", 
Collections.singleton(_portEntryId), getChildrenIds(root));
+        assertEquals("Unexpected children", 
Collections.singleton(_portEntryId), getChildrenIds(records, root));
     }
 
     public void testGetEntryByPortId()
     {
-        ConfiguredObjectRecord portEntry = getEntry(_portEntryId);
+        Collection<ConfiguredObjectRecord> records = openAndGetRecords();
+
+        ConfiguredObjectRecord portEntry = getEntry(records, _portEntryId);
         assertEquals("Unexpected entry id", _portEntryId, portEntry.getId());
-        assertTrue("Unexpected children", getChildrenIds(portEntry).isEmpty());
+        assertTrue("Unexpected children", getChildrenIds(records, 
portEntry).isEmpty());
         assertEquals("Unexpected state", State.QUIESCED, 
portEntry.getAttributes().get(Port.STATE));
     }
 
@@ -227,12 +276,13 @@ public class ManagementModeStoreHandlerT
     {
         _options.setManagementModeHttpPortOverride(9090);
         _handler = createManagementModeStoreHandler();
-        _handler.openConfigurationStore(_systemConfig, false);
+        _handler.init(_systemConfig);
 
+        Collection<ConfiguredObjectRecord> records = openAndGetRecords();
 
-        UUID optionsPort = getOptionsPortId();
-        ConfiguredObjectRecord portEntry = getEntry(optionsPort);
-        assertCLIPortEntry(portEntry, optionsPort, Protocol.HTTP);
+        UUID optionsPort = getOptionsPortId(records);
+        ConfiguredObjectRecord portEntry = getEntry(records, optionsPort);
+        assertCLIPortEntry(records, portEntry, optionsPort, Protocol.HTTP);
     }
 
     public void testHttpPortEntryIsQuiesced()
@@ -242,10 +292,11 @@ public class ManagementModeStoreHandlerT
         when(_portEntry.getAttributes()).thenReturn(attributes);
         _options.setManagementModeHttpPortOverride(9090);
         _handler = createManagementModeStoreHandler();
-        _handler.openConfigurationStore(_systemConfig, false);
+        _handler.init(_systemConfig);
 
+        Collection<ConfiguredObjectRecord> records = openAndGetRecords();
 
-        ConfiguredObjectRecord portEntry = getEntry(_portEntryId);
+        ConfiguredObjectRecord portEntry = getEntry(records, _portEntryId);
         assertEquals("Unexpected state", State.QUIESCED, 
portEntry.getAttributes().get(Port.STATE));
     }
 
@@ -274,17 +325,13 @@ public class ManagementModeStoreHandlerT
                     public Object answer(final InvocationOnMock invocation) 
throws Throwable
                     {
                         ConfiguredObjectRecordHandler recoverer = 
recovererArgumentCaptor.getValue();
-                        if(recoverer.handle(_root))
-                        {
-                            if(recoverer.handle(_portEntry))
-                            {
-                                recoverer.handle(virtualHost);
-                            }
-                        }
-                        return null;
+                        recoverer.handle(_root);
+                        recoverer.handle(_portEntry);
+                        recoverer.handle(virtualHost);
+                        return false;
                     }
                 }
-                
).when(_store).visitConfiguredObjectRecords(recovererArgumentCaptor.capture());
+                
).when(_store).openConfigurationStore(recovererArgumentCaptor.capture());
 
         State expectedState = mmQuiesceVhosts ? State.QUIESCED : null;
         if(mmQuiesceVhosts)
@@ -293,9 +340,10 @@ public class ManagementModeStoreHandlerT
         }
 
         _handler = createManagementModeStoreHandler();
-        _handler.openConfigurationStore(_systemConfig, false);
+        _handler.init(_systemConfig);
+        Collection<ConfiguredObjectRecord> records = openAndGetRecords();
 
-        ConfiguredObjectRecord hostEntry = getEntry(virtualHostId);
+        ConfiguredObjectRecord hostEntry = getEntry(records, virtualHostId);
         Map<String, Object> hostAttributes = new HashMap<String, 
Object>(hostEntry.getAttributes());
         assertEquals("Unexpected state", expectedState, 
hostAttributes.get(VirtualHost.STATE));
         hostAttributes.remove(VirtualHost.STATE);
@@ -303,10 +351,13 @@ public class ManagementModeStoreHandlerT
     }
 
     @SuppressWarnings("unchecked")
-    private void assertCLIPortEntry(ConfiguredObjectRecord portEntry, UUID 
optionsPort, Protocol protocol)
+    private void assertCLIPortEntry(final Collection<ConfiguredObjectRecord> 
records,
+                                    ConfiguredObjectRecord portEntry,
+                                    UUID optionsPort,
+                                    Protocol protocol)
     {
         assertEquals("Unexpected entry id", optionsPort, portEntry.getId());
-        assertTrue("Unexpected children", getChildrenIds(portEntry).isEmpty());
+        assertTrue("Unexpected children", getChildrenIds(records, 
portEntry).isEmpty());
         Map<String, Object> attributes = portEntry.getAttributes();
         assertEquals("Unexpected name", "MANAGEMENT-MODE-PORT-" + 
protocol.name(), attributes.get(Port.NAME));
         assertEquals("Unexpected protocol", Collections.singleton(protocol), 
new HashSet<Protocol>(
@@ -317,13 +368,14 @@ public class ManagementModeStoreHandlerT
     {
         _options.setManagementModeHttpPortOverride(1000);
         _handler = createManagementModeStoreHandler();
-        _handler.openConfigurationStore(_systemConfig, false);
+        _handler.init(_systemConfig);
+        Collection<ConfiguredObjectRecord> records = openAndGetRecords();
 
         Map<String, Object> attributes = new HashMap<String, Object>();
         attributes.put(Port.NAME, "TEST");
         ConfiguredObjectRecord
                 configurationEntry = new 
ConfiguredObjectRecordImpl(_portEntryId, Port.class.getSimpleName(), attributes,
-                Collections.singletonMap(Broker.class.getSimpleName(), 
getRootEntry().getId()));
+                Collections.singletonMap(Broker.class.getSimpleName(), 
getRootEntry(records).getId()));
         _handler.create(configurationEntry);
         verify(_store).create(any(ConfiguredObjectRecord.class));
     }
@@ -332,9 +384,10 @@ public class ManagementModeStoreHandlerT
     {
         _options.setManagementModeHttpPortOverride(1000);
         _handler = createManagementModeStoreHandler();
-        _handler.openConfigurationStore(_systemConfig, false);
+        _handler.init(_systemConfig);
+        Collection<ConfiguredObjectRecord> records = openAndGetRecords();
 
-        ConfiguredObjectRecord root = getRootEntry();
+        ConfiguredObjectRecord root = getRootEntry(records);
         Map<String, Object> attributes = new HashMap<String, Object>();
         attributes.put(Broker.NAME, "TEST");
         ConfiguredObjectRecord
@@ -347,15 +400,16 @@ public class ManagementModeStoreHandlerT
     {
         _options.setManagementModeHttpPortOverride(1000);
         _handler = createManagementModeStoreHandler();
-        _handler.openConfigurationStore(_systemConfig, false);
+        _handler.init(_systemConfig);
+        Collection<ConfiguredObjectRecord> records = openAndGetRecords();
 
-        UUID portId = getOptionsPortId();
+        UUID portId = getOptionsPortId(records);
         Map<String, Object> attributes = new HashMap<String, Object>();
         attributes.put(Port.NAME, "TEST");
         ConfiguredObjectRecord
                 configurationEntry = new ConfiguredObjectRecordImpl(portId, 
Port.class.getSimpleName(), attributes,
                                                                     
Collections.singletonMap(Broker.class.getSimpleName(),
-                                                                               
              getRootEntry().getId()));
+                                                                               
              getRootEntry(records).getId()));
         try
         {
             _handler.update(false, configurationEntry);
@@ -371,7 +425,8 @@ public class ManagementModeStoreHandlerT
     {
         _options.setManagementModeHttpPortOverride(1000);
         _handler = createManagementModeStoreHandler();
-        _handler.openConfigurationStore(_systemConfig, false);
+        _handler.init(_systemConfig);
+        Collection<ConfiguredObjectRecord> records = openAndGetRecords();
 
         ConfiguredObjectRecord record = new ConfiguredObjectRecord()
         {
@@ -407,9 +462,10 @@ public class ManagementModeStoreHandlerT
     {
         _options.setManagementModeHttpPortOverride(1000);
         _handler = createManagementModeStoreHandler();
-        _handler.openConfigurationStore(_systemConfig, false);
+        _handler.init(_systemConfig);
+        Collection<ConfiguredObjectRecord> records = openAndGetRecords();
 
-        UUID portId = getOptionsPortId();
+        UUID portId = getOptionsPortId(records);
         ConfiguredObjectRecord record = mock(ConfiguredObjectRecord.class);
         when(record.getId()).thenReturn(portId);
         try
@@ -423,11 +479,12 @@ public class ManagementModeStoreHandlerT
         }
     }
 
-    private UUID getOptionsPortId()
+    private UUID getOptionsPortId(Collection<ConfiguredObjectRecord> records)
     {
-        ConfiguredObjectRecord root = getRootEntry();
+
+        ConfiguredObjectRecord root = getRootEntry(records);
         assertEquals("Unexpected root id", _rootId, root.getId());
-        Collection<UUID> childrenIds = getChildrenIds(root);
+        Collection<UUID> childrenIds = getChildrenIds(records, root);
 
         childrenIds.remove(_portEntryId);
         UUID optionsPort = childrenIds.iterator().next();
@@ -435,116 +492,4 @@ public class ManagementModeStoreHandlerT
     }
 
 
-    private class BrokerFinder implements ConfiguredObjectRecordHandler
-    {
-        private ConfiguredObjectRecord _brokerRecord;
-        private int _version;
-
-        @Override
-        public void begin()
-        {
-        }
-
-        @Override
-        public boolean handle(final ConfiguredObjectRecord object)
-        {
-            if(object.getType().equals(Broker.class.getSimpleName()))
-            {
-                _brokerRecord = object;
-                return false;
-            }
-            return true;
-        }
-
-        @Override
-        public void end()
-        {
-        }
-
-        public ConfiguredObjectRecord getBrokerRecord()
-        {
-            return _brokerRecord;
-        }
-    }
-
-    private class RecordFinder implements ConfiguredObjectRecordHandler
-    {
-        private final UUID _id;
-        private ConfiguredObjectRecord _foundRecord;
-
-        private RecordFinder(final UUID id)
-        {
-            _id = id;
-        }
-
-        @Override
-        public void begin()
-        {
-        }
-
-        @Override
-        public boolean handle(final ConfiguredObjectRecord object)
-        {
-            if(object.getId().equals(_id))
-            {
-                _foundRecord = object;
-                return false;
-            }
-            return true;
-        }
-
-        @Override
-        public void end()
-        {
-        }
-
-        public ConfiguredObjectRecord getFoundRecord()
-        {
-            return _foundRecord;
-        }
-    }
-
-    private class ChildFinder implements ConfiguredObjectRecordHandler
-    {
-        private final Collection<UUID> _childIds = new HashSet<UUID>();
-        private final ConfiguredObjectRecord _parent;
-
-        private ChildFinder(final ConfiguredObjectRecord parent)
-        {
-            _parent = parent;
-        }
-
-        @Override
-        public void begin()
-        {
-        }
-
-        @Override
-        public boolean handle(final ConfiguredObjectRecord object)
-        {
-
-            if(object.getParents() != null)
-            {
-                for(UUID parent : object.getParents().values())
-                {
-                    if(parent.equals(_parent.getId()))
-                    {
-                        _childIds.add(object.getId());
-                    }
-                }
-
-            }
-            return true;
-        }
-
-        @Override
-        public void end()
-        {
-        }
-
-        public Collection<UUID> getChildIds()
-        {
-            return _childIds;
-        }
-    }
 }

Modified: 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/logging/BrokerMemoryLoggerTest.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/logging/BrokerMemoryLoggerTest.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/logging/BrokerMemoryLoggerTest.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/logging/BrokerMemoryLoggerTest.java
 Sat Jul 23 19:30:45 2016
@@ -71,7 +71,7 @@ public class BrokerMemoryLoggerTest exte
         when(_brokerEntry.getAttributes()).thenReturn(attributesMap);
         
when(_brokerEntry.getParents()).thenReturn(Collections.singletonMap(SystemConfig.class.getSimpleName(),
 _systemConfig.getId()));
         GenericRecoverer recoverer = new GenericRecoverer(_systemConfig);
-        recoverer.recover(Arrays.asList(_brokerEntry));
+        recoverer.recover(Arrays.asList(_brokerEntry), false);
     }
 
     public void testCreateDeleteBrokerMemoryLogger()

Modified: 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/VirtualHostTest.java
 Sat Jul 23 19:30:45 2016
@@ -208,29 +208,39 @@ public class VirtualHostTest extends Qpi
         assertEquals("Unexpected number of queues before stop", 1, 
virtualHost.getChildren(Queue.class).size());
         assertEquals("Unexpected number of exchanges before stop", 5, 
virtualHost.getChildren(Exchange.class).size());
 
+        final List<ConfiguredObjectRecord> allObjects = new ArrayList<>();
+        allObjects.add(virtualHostCor);
+        allObjects.add(queueCor);
+        for(Exchange e : virtualHost.getChildren(Exchange.class))
+        {
+            allObjects.add(e.asObjectRecord());
+        }
+
+
         virtualHost.stop();
         assertEquals("Unexpected state", State.STOPPED, 
virtualHost.getState());
         assertEquals("Unexpected number of queues after stop", 0, 
virtualHost.getChildren(Queue.class).size());
         assertEquals("Unexpected number of exchanges after stop", 0, 
virtualHost.getChildren(Exchange.class).size());
 
+
         // Setup an answer that will return the configured object records
         doAnswer(new Answer()
         {
-            final Iterator<ConfiguredObjectRecord> corIterator = 
asList(queueCor, exchangeCor, virtualHostCor).iterator();
+            final Iterator<ConfiguredObjectRecord> corIterator = 
allObjects.iterator();
 
             @Override
             public Object answer(final InvocationOnMock invocation) throws 
Throwable
             {
                 ConfiguredObjectRecordHandler handler = 
(ConfiguredObjectRecordHandler) invocation.getArguments()[0];
                 boolean handlerContinue = true;
-                while(corIterator.hasNext() && handlerContinue)
+                while(corIterator.hasNext())
                 {
-                    handlerContinue = handler.handle(corIterator.next());
+                    handler.handle(corIterator.next());
                 }
 
                 return null;
             }
-        
}).when(_configStore).visitConfiguredObjectRecords(any(ConfiguredObjectRecordHandler.class));
+        }).when(_configStore).reload(any(ConfiguredObjectRecordHandler.class));
 
         virtualHost.start();
         assertEquals("Unexpected state", State.ACTIVE, virtualHost.getState());

Modified: 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
 Sat Jul 23 19:30:45 2016
@@ -103,7 +103,6 @@ public abstract class AbstractDurableCon
         FileUtils.delete(new File(_storePath), true);
 
         _handler = mock(ConfiguredObjectRecordHandler.class);
-        
when(_handler.handle(any(ConfiguredObjectRecord.class))).thenReturn(true);
 
         _bindingArgs = new HashMap<String, Object>();
         String argKey = AMQPFilterTypes.JMS_SELECTOR.toString();
@@ -113,7 +112,16 @@ public abstract class AbstractDurableCon
         _parent = createVirtualHostNode(_storePath, _factory);
 
         _configStore = createConfigStore();
-        _configStore.openConfigurationStore(_parent, false);
+        _configStore.init(_parent);
+        _configStore.openConfigurationStore(new ConfiguredObjectRecordHandler()
+        {
+
+            @Override
+            public void handle(final ConfiguredObjectRecord record)
+            {
+            }
+
+        });
         _rootRecord = new ConfiguredObjectRecordImpl(UUID.randomUUID(), 
VirtualHost.class.getSimpleName(), Collections.<String, 
Object>singletonMap(ConfiguredObject.NAME, "vhost"));
         _configStore.create(_rootRecord);
     }
@@ -146,7 +154,7 @@ public abstract class AbstractDurableCon
         _configStore.create(exchange.asObjectRecord());
 
         reopenStore();
-        _configStore.visitConfiguredObjectRecords(_handler);
+        _configStore.openConfigurationStore(_handler);
 
         verify(_handler).handle(matchesRecord(_exchangeId, EXCHANGE,
                 map( org.apache.qpid.server.model.Exchange.NAME, getName(),
@@ -196,7 +204,7 @@ public abstract class AbstractDurableCon
         _configStore.create(binding.asObjectRecord());
 
         reopenStore();
-        _configStore.visitConfiguredObjectRecords(_handler);
+        _configStore.openConfigurationStore(_handler);
 
         Map<String,Object> map = new HashMap<String, Object>();
         map.put(Binding.NAME, ROUTING_KEY);
@@ -302,7 +310,7 @@ public abstract class AbstractDurableCon
         _configStore.create(queue.asObjectRecord());
 
         reopenStore();
-        _configStore.visitConfiguredObjectRecords(_handler);
+        _configStore.openConfigurationStore(_handler);
 
         Map<String, Object> queueAttributes = new HashMap<String, Object>();
         queueAttributes.put(Queue.NAME, getName());
@@ -323,7 +331,7 @@ public abstract class AbstractDurableCon
         _configStore.create(queue.asObjectRecord());
 
         reopenStore();
-        _configStore.visitConfiguredObjectRecords(_handler);
+        _configStore.openConfigurationStore(_handler);
 
         Map<String,Object> queueAttributes = new HashMap<String, Object>();
 
@@ -343,7 +351,7 @@ public abstract class AbstractDurableCon
         _configStore.create(queue.asObjectRecord());
 
         reopenStore();
-        _configStore.visitConfiguredObjectRecords(_handler);
+        _configStore.openConfigurationStore(_handler);
 
         Map<String, Object> queueAttributes = new HashMap<String, Object>();
         queueAttributes.put(Queue.NAME, getName());
@@ -379,7 +387,7 @@ public abstract class AbstractDurableCon
         _configStore.update(false, queue.asObjectRecord());
 
         reopenStore();
-        _configStore.visitConfiguredObjectRecords(_handler);
+        _configStore.openConfigurationStore(_handler);
 
         Map<String,Object> queueAttributes = new HashMap<String, Object>();
 
@@ -406,7 +414,7 @@ public abstract class AbstractDurableCon
         _configStore.update(false, queue.asObjectRecord());
 
         reopenStore();
-        _configStore.visitConfiguredObjectRecords(_handler);
+        _configStore.openConfigurationStore(_handler);
 
         Map<String,Object> queueAttributes = new HashMap<String, Object>();
 
@@ -534,7 +542,7 @@ public abstract class AbstractDurableCon
     {
         closeConfigStore();
         _configStore = createConfigStore();
-        _configStore.openConfigurationStore(_parent, false);
+        _configStore.init(_parent);
     }
 
     protected abstract DurableConfigurationStore createConfigStore() throws 
Exception;

Modified: 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java
 Sat Jul 23 19:30:45 2016
@@ -301,7 +301,7 @@ public class BrokerRecovererTest extends
     private void resolveObjects(ConfiguredObjectRecord... records)
     {
         GenericRecoverer recoverer = new GenericRecoverer(_systemConfig);
-        recoverer.recover(Arrays.asList(records));
+        recoverer.recover(Arrays.asList(records), false);
     }
 
 }

Modified: 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecovererTest.java
 Sat Jul 23 19:30:45 2016
@@ -663,9 +663,7 @@ public class BrokerStoreUpgraderAndRecov
         }
 
         @Override
-        public void openConfigurationStore(ConfiguredObject<?> parent,
-                                           final boolean overwrite,
-                                           final ConfiguredObjectRecord... 
initialRecords) throws StoreException
+        public void init(ConfiguredObject<?> parent) throws StoreException
         {
         }
 
@@ -702,14 +700,24 @@ public class BrokerStoreUpgraderAndRecov
         }
 
         @Override
-        public void visitConfiguredObjectRecords(ConfiguredObjectRecordHandler 
handler) throws StoreException
+        public boolean openConfigurationStore(ConfiguredObjectRecordHandler 
handler,
+                                              final ConfiguredObjectRecord... 
initialRecords) throws StoreException
+        {
+            for (ConfiguredObjectRecord record : records)
+            {
+                handler.handle(record);
+            }
+            return false;
+        }
+
+
+        @Override
+        public void reload(ConfiguredObjectRecordHandler handler) throws 
StoreException
         {
-            handler.begin();
             for (ConfiguredObjectRecord record : records)
             {
                 handler.handle(record);
             }
-            handler.end();
         }
     }
 }

Modified: 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/JsonFileConfigStoreTest.java
 Sat Jul 23 19:30:45 2016
@@ -80,7 +80,6 @@ public class JsonFileConfigStoreTest ext
         _store = new JsonFileConfigStore(VirtualHost.class);
 
         _handler = mock(ConfiguredObjectRecordHandler.class);
-        
when(_handler.handle(any(ConfiguredObjectRecord.class))).thenReturn(true);
     }
 
     @Override
@@ -102,7 +101,7 @@ public class JsonFileConfigStoreTest ext
 
         try
         {
-            _store.openConfigurationStore(_parent, false);
+            _store.init(_parent);
             fail("Store should not successfully configure if there is no path 
set");
         }
         catch (ServerScopedRuntimeException e)
@@ -117,7 +116,7 @@ public class JsonFileConfigStoreTest ext
         
when(_parent.getStorePath()).thenReturn(System.getProperty("file.separator"));
         try
         {
-            _store.openConfigurationStore(_parent, false);
+            _store.init(_parent);
             fail("Store should not successfully configure if there is an 
invalid path set");
         }
         catch (ServerScopedRuntimeException e)
@@ -128,32 +127,40 @@ public class JsonFileConfigStoreTest ext
 
     public void testVisitEmptyStore()
     {
-        _store.openConfigurationStore(_parent, false);
-        _store.visitConfiguredObjectRecords(_handler);
+        _store.init(_parent);
+        _store.openConfigurationStore(_handler);
 
         InOrder inorder = inOrder(_handler);
-        inorder.verify(_handler).begin();
         
inorder.verify(_handler,times(0)).handle(any(ConfiguredObjectRecord.class));
-        inorder.verify(_handler).end();
 
         _store.closeConfigurationStore();
     }
 
     public void testInsertAndUpdateTopLevelObject() throws Exception
     {
-        _store.openConfigurationStore(_parent, false);
+        _store.init(_parent);
+        
_store.openConfigurationStore(mock(ConfiguredObjectRecordHandler.class));
         createRootRecord();
         _store.closeConfigurationStore();
 
-        _store.openConfigurationStore(_parent, false);
+        _store.init(_parent);
+        _store.openConfigurationStore(new ConfiguredObjectRecordHandler()
+        {
+
+            @Override
+            public void handle(final ConfiguredObjectRecord record)
+            {
+            }
+
+        });
         Map<String, Object> newAttributes = new HashMap<String, 
Object>(_rootRecord.getAttributes());
         newAttributes.put("attributeName", "attributeValue");
         _store.update(false, new 
ConfiguredObjectRecordImpl(_rootRecord.getId(), _rootRecord.getType(), 
newAttributes));
         _store.closeConfigurationStore();
 
-        _store.openConfigurationStore(_parent, false);
+        _store.init(_parent);
 
-        _store.visitConfiguredObjectRecords(_handler);
+        _store.openConfigurationStore(_handler);
 
         Map<String, Object> expectedAttributes = new HashMap<String, 
Object>(newAttributes);
         verify(_handler, times(1)).handle(matchesRecord(_rootRecord.getId(), 
_rootRecord.getType(), expectedAttributes));
@@ -162,7 +169,8 @@ public class JsonFileConfigStoreTest ext
 
     public void testCreateObject() throws Exception
     {
-        _store.openConfigurationStore(_parent, false);
+        _store.init(_parent);
+        
_store.openConfigurationStore(mock(ConfiguredObjectRecordHandler.class));
         createRootRecord();
 
         final UUID queueId = new UUID(0, 1);
@@ -172,9 +180,9 @@ public class JsonFileConfigStoreTest ext
         _store.create(new ConfiguredObjectRecordImpl(queueId, queueType, 
queueAttr, getRootAsParentMap()));
         _store.closeConfigurationStore();
 
-        _store.openConfigurationStore(_parent, false);
+        _store.init(_parent);
 
-        _store.visitConfiguredObjectRecords(_handler);
+        _store.openConfigurationStore(_handler);
         verify(_handler).handle(matchesRecord(queueId, queueType, queueAttr));
         verify(_handler).handle(matchesRecord(ANY_UUID, VIRTUAL_HOST_TYPE, 
ANY_MAP));
         _store.closeConfigurationStore();
@@ -182,7 +190,8 @@ public class JsonFileConfigStoreTest ext
 
     public void testCreateAndUpdateObject() throws Exception
     {
-        _store.openConfigurationStore(_parent, false);
+        _store.init(_parent);
+        
_store.openConfigurationStore(mock(ConfiguredObjectRecordHandler.class));
         createRootRecord();
 
         final UUID queueId = new UUID(0, 1);
@@ -197,8 +206,8 @@ public class JsonFileConfigStoreTest ext
 
         _store.closeConfigurationStore();
 
-        _store.openConfigurationStore(_parent, false);
-        _store.visitConfiguredObjectRecords(_handler);
+        _store.init(_parent);
+        _store.openConfigurationStore(_handler);
         verify(_handler, times(1)).handle(matchesRecord(queueId, queueType, 
queueAttr));
         _store.closeConfigurationStore();
     }
@@ -206,7 +215,8 @@ public class JsonFileConfigStoreTest ext
 
     public void testCreateAndRemoveObject() throws Exception
     {
-        _store.openConfigurationStore(_parent, false);
+        _store.init(_parent);
+        
_store.openConfigurationStore(mock(ConfiguredObjectRecordHandler.class));
         createRootRecord();
 
         final UUID queueId = new UUID(0, 1);
@@ -221,15 +231,16 @@ public class JsonFileConfigStoreTest ext
 
         _store.closeConfigurationStore();
 
-        _store.openConfigurationStore(_parent, false);
-        _store.visitConfiguredObjectRecords(_handler);
+        _store.init(_parent);
+        _store.openConfigurationStore(_handler);
         verify(_handler, times(1)).handle(matchesRecord(ANY_UUID, 
VIRTUAL_HOST_TYPE, ANY_MAP));
         _store.closeConfigurationStore();
     }
 
     public void testCreateUnknownObjectType() throws Exception
     {
-        _store.openConfigurationStore(_parent, false);
+        _store.init(_parent);
+        
_store.openConfigurationStore(mock(ConfiguredObjectRecordHandler.class));
         createRootRecord();
 
         try
@@ -245,7 +256,8 @@ public class JsonFileConfigStoreTest ext
 
     public void testTwoObjectsWithSameId() throws Exception
     {
-        _store.openConfigurationStore(_parent, false);
+        _store.init(_parent);
+        
_store.openConfigurationStore(mock(ConfiguredObjectRecordHandler.class));
         createRootRecord();
 
         final UUID id = UUID.randomUUID();
@@ -268,7 +280,8 @@ public class JsonFileConfigStoreTest ext
 
     public void testObjectWithoutName() throws Exception
     {
-        _store.openConfigurationStore(_parent, false);
+        _store.init(_parent);
+        
_store.openConfigurationStore(mock(ConfiguredObjectRecordHandler.class));
         createRootRecord();
 
         final UUID id = UUID.randomUUID();
@@ -287,7 +300,8 @@ public class JsonFileConfigStoreTest ext
 
     public void testObjectWithNonStringName() throws Exception
     {
-        _store.openConfigurationStore(_parent, false);
+        _store.init(_parent);
+        
_store.openConfigurationStore(mock(ConfiguredObjectRecordHandler.class));
         createRootRecord();
 
         final UUID id = UUID.randomUUID();
@@ -306,7 +320,8 @@ public class JsonFileConfigStoreTest ext
 
     public void testChangeTypeOfObject() throws Exception
     {
-        _store.openConfigurationStore(_parent, false);
+        _store.init(_parent);
+        
_store.openConfigurationStore(mock(ConfiguredObjectRecordHandler.class));
         createRootRecord();
 
         final UUID id = UUID.randomUUID();
@@ -314,7 +329,8 @@ public class JsonFileConfigStoreTest ext
                                                      Collections.<String, 
Object>singletonMap(ConfiguredObject.NAME, "queue"),
                                                      getRootAsParentMap()));
         _store.closeConfigurationStore();
-        _store.openConfigurationStore(_parent, false);
+        _store.init(_parent);
+        
_store.openConfigurationStore(mock(ConfiguredObjectRecordHandler.class));
 
         try
         {
@@ -331,13 +347,13 @@ public class JsonFileConfigStoreTest ext
 
     public void testLockFileGuaranteesExclusiveAccess() throws Exception
     {
-        _store.openConfigurationStore(_parent, false);
+        _store.init(_parent);
 
         JsonFileConfigStore secondStore = new 
JsonFileConfigStore(VirtualHost.class);
 
         try
         {
-            secondStore.openConfigurationStore(_parent, false);
+            secondStore.init(_parent);
             fail("Should not be able to open a second store with the same 
path");
         }
         catch(ServerScopedRuntimeException e)
@@ -345,7 +361,7 @@ public class JsonFileConfigStoreTest ext
             // pass
         }
         _store.closeConfigurationStore();
-        secondStore.openConfigurationStore(_parent, false);
+        secondStore.init(_parent);
     }
 
     public void testStoreFileLifecycle()
@@ -358,7 +374,7 @@ public class JsonFileConfigStoreTest ext
         assertFalse("JSON backup should not exist", 
expectedJsonFileBak.exists());
         assertFalse("JSON lock should not exist", 
expectedJsonFileLck.exists());
 
-        _store.openConfigurationStore(_parent, false);
+        _store.init(_parent);
         assertTrue("JSON store should exist after open", 
expectedJsonFile.exists());
         assertFalse("JSON backup should not exist after open", 
expectedJsonFileBak.exists());
         assertTrue("JSON lock should exist", expectedJsonFileLck.exists());
@@ -374,7 +390,8 @@ public class JsonFileConfigStoreTest ext
 
     public void testCreatedNestedObjects() throws Exception
     {
-        _store.openConfigurationStore(_parent, false);
+        _store.init(_parent);
+        
_store.openConfigurationStore(mock(ConfiguredObjectRecordHandler.class));
         createRootRecord();
 
         final UUID queueId = new UUID(0, 1);
@@ -424,8 +441,8 @@ public class JsonFileConfigStoreTest ext
                                                binding2Parents);
         _store.update(true, bindingRecord, binding2Record);
         _store.closeConfigurationStore();
-        _store.openConfigurationStore(_parent, false);
-        _store.visitConfiguredObjectRecords(_handler);
+        _store.init(_parent);
+        _store.openConfigurationStore(_handler);
         verify(_handler).handle(matchesRecord(queueId, "Queue", queueAttr));
         verify(_handler).handle(matchesRecord(queue2Id, "Queue", queue2Attr));
         verify(_handler).handle(matchesRecord(exchangeId, "Exchange", 
exchangeAttr));

Modified: 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecovererTest.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecovererTest.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecovererTest.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecovererTest.java
 Sat Jul 23 19:30:45 2016
@@ -137,7 +137,7 @@ public class VirtualHostStoreUpgraderAnd
         setUpVisit(_hostRecord, queue, dlq, dle, queueBinding, dlqBinding);
 
         VirtualHostStoreUpgraderAndRecoverer upgraderAndRecoverer = new 
VirtualHostStoreUpgraderAndRecoverer(_virtualHostNode);
-        upgraderAndRecoverer.perform(_durableConfigurationStore);
+        upgraderAndRecoverer.upgradeAndRecover(_durableConfigurationStore);
 
         final VirtualHost<?>  host = _virtualHostNode.getVirtualHost();
         Subject.doAs(_systemSubject, new PrivilegedAction<Void>()
@@ -180,7 +180,7 @@ public class VirtualHostStoreUpgraderAnd
         setUpVisit(_hostRecord, queue, exchange, queueBinding1, queueBinding2);
 
         VirtualHostStoreUpgraderAndRecoverer upgraderAndRecoverer = new 
VirtualHostStoreUpgraderAndRecoverer(_virtualHostNode);
-        upgraderAndRecoverer.perform(_durableConfigurationStore);
+        upgraderAndRecoverer.upgradeAndRecover(_durableConfigurationStore);
 
         final VirtualHost<?>  host = _virtualHostNode.getVirtualHost();
         Subject.doAs(_systemSubject, new PrivilegedAction<Void>()
@@ -281,15 +281,13 @@ public class VirtualHostStoreUpgraderAnd
             {
                 Iterator<ConfiguredObjectRecord> iterator = 
asList(records).iterator();
                 ConfiguredObjectRecordHandler handler = 
(ConfiguredObjectRecordHandler) invocation.getArguments()[0];
-                handler.begin();
                 boolean handlerContinue = true;
-                while(iterator.hasNext() && handlerContinue)
+                while(iterator.hasNext())
                 {
-                    handlerContinue = handler.handle(iterator.next());
+                    handler.handle(iterator.next());
                 }
-                handler.end();
                 return null;
             }
-        
}).when(_durableConfigurationStore).visitConfiguredObjectRecords(any(ConfiguredObjectRecordHandler.class));
+        
}).when(_durableConfigurationStore).openConfigurationStore(any(ConfiguredObjectRecordHandler.class));
     }
 }

Modified: 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java
 (original)
+++ 
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java
 Sat Jul 23 19:30:45 2016
@@ -372,7 +372,7 @@ public class AbstractStandardVirtualHost
         Map<String, Object> attributes = Collections.<String, 
Object>singletonMap(TestVirtualHostNode.NAME, nodeName);
 
         final DurableConfigurationStore store = 
mock(DurableConfigurationStore.class);
-        doThrow(new RuntimeException("Cannot open 
store")).when(store).openConfigurationStore(any(ConfiguredObject.class), 
any(boolean.class));
+        doThrow(new RuntimeException("Cannot open 
store")).when(store).init(any(ConfiguredObject.class));
         AbstractStandardVirtualHostNode node = 
createTestStandardVirtualHostNode(attributes, store);
 
         try
@@ -421,7 +421,7 @@ public class AbstractStandardVirtualHost
         AbstractStandardVirtualHostNode node = 
createTestStandardVirtualHostNode(attributes, store);
 
         node.create();
-        verify(store, times(2)).openConfigurationStore(node, false); // once 
of validation, once for real
+        verify(store, times(2)).init(node); // once of validation, once for 
real
         verify(store, times(1)).closeConfigurationStore();
         node.close();
     }
@@ -480,7 +480,7 @@ public class AbstractStandardVirtualHost
         Map<String, Object> attributes = Collections.<String, 
Object>singletonMap(TestVirtualHostNode.NAME, nodeName);
 
         final DurableConfigurationStore store = 
mock(DurableConfigurationStore.class);
-        doThrow(new RuntimeException("Cannot open 
store")).when(store).openConfigurationStore(any(ConfiguredObject.class), 
any(boolean.class));
+        doThrow(new RuntimeException("Cannot open 
store")).when(store).init(any(ConfiguredObject.class));
         AbstractStandardVirtualHostNode node = 
createTestStandardVirtualHostNode(attributes, store);
         node.open();
         assertEquals("Unexpected node state", State.ERRORED, node.getState());
@@ -495,11 +495,11 @@ public class AbstractStandardVirtualHost
         Map<String, Object> attributes = Collections.<String, 
Object>singletonMap(TestVirtualHostNode.NAME, nodeName);
 
         DurableConfigurationStore store = 
mock(DurableConfigurationStore.class);
-        doThrow(new RuntimeException("Cannot open 
store")).when(store).openConfigurationStore(any(ConfiguredObject.class), 
any(boolean.class));
+        doThrow(new RuntimeException("Cannot open 
store")).when(store).init(any(ConfiguredObject.class));
         AbstractVirtualHostNode node = 
createTestStandardVirtualHostNode(attributes, store);
         node.open();
         assertEquals("Unexpected node state", State.ERRORED, node.getState());
-        
doNothing().when(store).openConfigurationStore(any(ConfiguredObject.class), 
any(boolean.class));
+        doNothing().when(store).init(any(ConfiguredObject.class));
 
         node.setAttributes(Collections.<String, 
Object>singletonMap(VirtualHostNode.DESIRED_STATE, State.ACTIVE));
         assertEquals("Unexpected state", State.ACTIVE, node.getState());
@@ -512,11 +512,11 @@ public class AbstractStandardVirtualHost
         Map<String, Object> attributes = Collections.<String, 
Object>singletonMap(TestVirtualHostNode.NAME, nodeName);
 
         DurableConfigurationStore store = 
mock(DurableConfigurationStore.class);
-        doThrow(new RuntimeException("Cannot open 
store")).when(store).openConfigurationStore(any(ConfiguredObject.class), 
any(boolean.class));
+        doThrow(new RuntimeException("Cannot open 
store")).when(store).init(any(ConfiguredObject.class));
         AbstractVirtualHostNode node = 
createTestStandardVirtualHostNode(attributes, store);
         node.open();
         assertEquals("Unexpected node state", State.ERRORED, node.getState());
-        
doNothing().when(store).openConfigurationStore(any(ConfiguredObject.class), 
any(boolean.class));
+        doNothing().when(store).init(any(ConfiguredObject.class));
 
         node.start();
         assertEquals("Unexpected state", State.ACTIVE, node.getState());
@@ -542,14 +542,14 @@ public class AbstractStandardVirtualHost
         return new NullMessageStore(){
 
             @Override
-            public void 
visitConfiguredObjectRecords(ConfiguredObjectRecordHandler handler) throws 
StoreException
+            public boolean 
openConfigurationStore(ConfiguredObjectRecordHandler handler,
+                                                  final 
ConfiguredObjectRecord... initialRecords) throws StoreException
             {
-                handler.begin();
                 if (record != null)
                 {
                     handler.handle(record);
                 }
-                handler.end();
+                return false;
             }
         };
     }

Modified: 
qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java
 (original)
+++ 
qpid/java/trunk/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyConfigurationStore.java
 Sat Jul 23 19:30:45 2016
@@ -21,19 +21,20 @@
 package org.apache.qpid.server.store.derby;
 
 
+
+import static 
org.apache.qpid.server.store.AbstractJDBCConfigurationStore.State.*;
+
 import java.io.File;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.store.AbstractJDBCConfigurationStore;
-import org.apache.qpid.server.store.ConfiguredObjectRecord;
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.store.FileBasedSettings;
 import org.apache.qpid.server.store.MessageStore;
@@ -52,7 +53,7 @@ public class DerbyConfigurationStore ext
 {
     private static final Logger LOGGER = 
LoggerFactory.getLogger(DerbyConfigurationStore.class);
 
-    private final AtomicBoolean _configurationStoreOpen = new AtomicBoolean();
+
     private final ProvidedMessageStore _providedMessageStore = new 
ProvidedMessageStore();
     private final ProvidedPreferenceStore _providedPreferenceStore = new 
ProvidedPreferenceStore();
 
@@ -67,38 +68,30 @@ public class DerbyConfigurationStore ext
     }
 
     @Override
-    public void openConfigurationStore(ConfiguredObject<?> parent,
-                                       final boolean overwrite,
-                                       final ConfiguredObjectRecord... 
initialRecords)
+    public void init(ConfiguredObject<?> parent)
             throws StoreException
     {
-        if (_configurationStoreOpen.compareAndSet(false,  true))
+        changeState(CLOSED, CONFIGURED);
         {
             _parent = parent;
             DerbyUtils.loadDerbyDriver();
 
             _connectionURL = DerbyUtils.createConnectionUrl(parent.getName(), 
((FileBasedSettings)_parent).getStorePath());
 
-            createOrOpenConfigurationStoreDatabase(overwrite);
+            createOrOpenConfigurationStoreDatabase();
 
-            if(hasNoConfigurationEntries())
-            {
-                update(true, initialRecords);
-            }
         }
     }
 
     @Override
     public void upgradeStoreStructure() throws StoreException
     {
-        checkConfigurationStoreOpen();
         upgradeIfNecessary(_parent);
     }
 
     @Override
     protected Connection getConnection() throws SQLException
     {
-        checkConfigurationStoreOpen();
         return DriverManager.getConnection(_connectionURL);
     }
 
@@ -110,17 +103,8 @@ public class DerbyConfigurationStore ext
             throw new IllegalStateException("Cannot close the store as the 
provided message store is still open");
         }
 
-        if (_configurationStoreOpen.compareAndSet(true,  false))
-        {
-            try
-            {
-                DerbyUtils.shutdownDatabase(_connectionURL);
-            }
-            catch (SQLException e)
-            {
-                throw new StoreException("Error closing configuration store", 
e);
-            }
-        }
+        setState(CLOSED);
+
     }
 
     @Override
@@ -192,15 +176,6 @@ public class DerbyConfigurationStore ext
     }
 
     @Override
-    protected void checkConfigurationStoreOpen()
-    {
-        if (!_configurationStoreOpen.get())
-        {
-            throw new IllegalStateException("Configuration store is not open");
-        }
-    }
-
-    @Override
     protected Logger getLogger()
     {
         return LOGGER;

Modified: 
qpid/java/trunk/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java
 (original)
+++ 
qpid/java/trunk/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java
 Sat Jul 23 19:30:45 2016
@@ -19,6 +19,10 @@
 package org.apache.qpid.server.store.jdbc;
 
 
+import static 
org.apache.qpid.server.store.AbstractJDBCConfigurationStore.State.CLOSED;
+import static 
org.apache.qpid.server.store.AbstractJDBCConfigurationStore.State.CONFIGURED;
+import static 
org.apache.qpid.server.store.AbstractJDBCConfigurationStore.State.OPEN;
+
 import java.io.File;
 import java.nio.charset.Charset;
 import java.sql.Blob;
@@ -37,7 +41,6 @@ import org.slf4j.LoggerFactory;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.plugin.JDBCConnectionProviderFactory;
 import org.apache.qpid.server.store.AbstractJDBCConfigurationStore;
-import org.apache.qpid.server.store.ConfiguredObjectRecord;
 import org.apache.qpid.server.store.MessageStore;
 import org.apache.qpid.server.store.MessageStoreProvider;
 import org.apache.qpid.server.store.StoreException;
@@ -54,10 +57,8 @@ public class GenericJDBCConfigurationSto
 
     private static final Logger LOGGER = 
LoggerFactory.getLogger(GenericJDBCConfigurationStore.class);
 
-    private final AtomicBoolean _configurationStoreOpen = new AtomicBoolean();
     private final MessageStore _providedMessageStore = new 
ProvidedMessageStore();
     private final PreferenceStore _providedPreferenceStore = new 
ProvidedPreferenceStore();
-
     private String _connectionURL;
     private ConnectionProvider _connectionProvider;
 
@@ -75,80 +76,76 @@ public class GenericJDBCConfigurationSto
     }
 
     @Override
-    public void openConfigurationStore(ConfiguredObject<?> parent,
-                                       final boolean overwrite,
-                                       final ConfiguredObjectRecord... 
initialRecords)
+    public void init(ConfiguredObject<?> parent)
             throws StoreException
     {
-        if (_configurationStoreOpen.compareAndSet(false,  true))
-        {
-            _parent = parent;
+        changeState(CONFIGURED, OPEN);
 
-            JDBCSettings settings = (JDBCSettings)parent;
-            _connectionURL = settings.getConnectionUrl();
+        _parent = parent;
 
-            JDBCDetails details = 
JDBCDetails.getDetailsForJdbcUrl(_connectionURL, parent);
+        JDBCSettings settings = (JDBCSettings) parent;
+        _connectionURL = settings.getConnectionUrl();
 
-            if (!details.isKnownVendor() && getLogger().isInfoEnabled())
-            {
-                getLogger().info("Do not recognize vendor from connection URL: 
" + _connectionURL
-                                + " Using fallback settings " + details);
-            }
-            if (details.isOverridden() && getLogger().isInfoEnabled())
-            {
-                getLogger().info("One or more JDBC details were overridden 
from context. "
-                               +  " Using settings : " + details);
-            }
+        JDBCDetails details = JDBCDetails.getDetailsForJdbcUrl(_connectionURL, 
parent);
 
-            String connectionPoolType = settings.getConnectionPoolType() == 
null ? DefaultConnectionProviderFactory.TYPE : settings.getConnectionPoolType();
+        if (!details.isKnownVendor() && getLogger().isInfoEnabled())
+        {
+            getLogger().info("Do not recognize vendor from connection URL: " + 
_connectionURL
+                             + " Using fallback settings " + details);
+        }
+        if (details.isOverridden() && getLogger().isInfoEnabled())
+        {
+            getLogger().info("One or more JDBC details were overridden from 
context. "
+                             + " Using settings : " + details);
+        }
 
-            JDBCConnectionProviderFactory connectionProviderFactory =
-                    
JDBCConnectionProviderFactory.FACTORIES.get(connectionPoolType);
-            if(connectionProviderFactory == null)
-            {
-                LOGGER.warn("Unknown connection pool type: "
-                             + connectionPoolType
-                             + ".  no connection pooling will be used");
-                connectionProviderFactory = new 
DefaultConnectionProviderFactory();
-            }
+        String connectionPoolType = settings.getConnectionPoolType() == null
+                ? DefaultConnectionProviderFactory.TYPE
+                : settings.getConnectionPoolType();
 
-            try
-            {
-                Map<String, String> providerAttributes = new HashMap<>();
-                Set<String> providerAttributeNames = new 
HashSet<String>(connectionProviderFactory.getProviderAttributeNames());
-                providerAttributeNames.retainAll(parent.getContextKeys(false));
-                for(String attr : providerAttributeNames)
-                {
-                    providerAttributes.put(attr, 
parent.getContextValue(String.class, attr));
-                }
-
-                _connectionProvider = 
connectionProviderFactory.getConnectionProvider(_connectionURL,
-                                                                               
       settings.getUsername(),
-                                                                               
       settings.getPassword(),
-                                                                               
       providerAttributes);
-            }
-            catch (SQLException e)
-            {
-                throw new StoreException("Failed to create connection provider 
for connectionUrl: " + _connectionURL +
-                                            " and username: " + 
settings.getUsername(), e);
-            }
-            _blobType = details.getBlobType();
-            _varBinaryType = details.getVarBinaryType();
-            _useBytesMethodsForBlob = details.isUseBytesMethodsForBlob();
-            _bigIntType = details.getBigintType();
+        JDBCConnectionProviderFactory connectionProviderFactory =
+                
JDBCConnectionProviderFactory.FACTORIES.get(connectionPoolType);
+        if (connectionProviderFactory == null)
+        {
+            LOGGER.warn("Unknown connection pool type: "
+                        + connectionPoolType
+                        + ".  no connection pooling will be used");
+            connectionProviderFactory = new DefaultConnectionProviderFactory();
+        }
 
-            createOrOpenConfigurationStoreDatabase(overwrite);
-            if(hasNoConfigurationEntries())
+        try
+        {
+            Map<String, String> providerAttributes = new HashMap<>();
+            Set<String> providerAttributeNames =
+                    new 
HashSet<String>(connectionProviderFactory.getProviderAttributeNames());
+            providerAttributeNames.retainAll(parent.getContextKeys(false));
+            for (String attr : providerAttributeNames)
             {
-                update(true, initialRecords);
+                providerAttributes.put(attr, 
parent.getContextValue(String.class, attr));
             }
+
+            _connectionProvider = 
connectionProviderFactory.getConnectionProvider(_connectionURL,
+                                                                               
   settings.getUsername(),
+                                                                               
   settings.getPassword(),
+                                                                               
   providerAttributes);
+        }
+        catch (SQLException e)
+        {
+            throw new StoreException("Failed to create connection provider for 
connectionUrl: " + _connectionURL +
+                                     " and username: " + 
settings.getUsername(), e);
         }
+        _blobType = details.getBlobType();
+        _varBinaryType = details.getVarBinaryType();
+        _useBytesMethodsForBlob = details.isUseBytesMethodsForBlob();
+        _bigIntType = details.getBigintType();
+
+        createOrOpenConfigurationStoreDatabase();
+
     }
 
     @Override
     public void upgradeStoreStructure() throws StoreException
     {
-        checkConfigurationStoreOpen();
         upgradeIfNecessary(_parent);
     }
 
@@ -161,17 +158,15 @@ public class GenericJDBCConfigurationSto
     @Override
     public void closeConfigurationStore() throws StoreException
     {
-        if (_configurationStoreOpen.compareAndSet(true, false))
+        try
         {
-            try
-            {
-                _connectionProvider.close();
-            }
-            catch (SQLException e)
-            {
-                throw new StoreException("Unable to close connection provider 
", e);
-            }
+            _connectionProvider.close();
         }
+        catch (SQLException e)
+        {
+            throw new StoreException("Unable to close connection provider ", 
e);
+        }
+        setState(State.CLOSED);
     }
 
     @Override
@@ -229,15 +224,6 @@ public class GenericJDBCConfigurationSto
     }
 
     @Override
-    protected void checkConfigurationStoreOpen()
-    {
-        if (!_configurationStoreOpen.get())
-        {
-            throw new IllegalStateException("Configuration store is not open");
-        }
-    }
-
-    @Override
     protected Logger getLogger()
     {
         return LOGGER;
@@ -364,4 +350,6 @@ public class GenericJDBCConfigurationSto
             // noop
         }
     }
+
+
 }

Modified: 
qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/filter/ExceptionHandlingFilter.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/filter/ExceptionHandlingFilter.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/filter/ExceptionHandlingFilter.java
 (original)
+++ 
qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/filter/ExceptionHandlingFilter.java
 Sat Jul 23 19:30:45 2016
@@ -83,6 +83,7 @@ public class ExceptionHandlingFilter imp
         catch (RuntimeException e)
         {
             LOGGER.error("Unexpected exception in servlet '{}': ", requestURI, 
e);
+            LOGGER.error("Stack trace: ", e);
             throw e;
         }
     }

Modified: 
qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/AbstractBrokerHolder.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/AbstractBrokerHolder.java?rev=1753882&r1=1753881&r2=1753882&view=diff
==============================================================================
--- 
qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/AbstractBrokerHolder.java
 (original)
+++ 
qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/AbstractBrokerHolder.java
 Sat Jul 23 19:30:45 2016
@@ -169,19 +169,19 @@ public abstract class AbstractBrokerHold
         start(options);
         if (_amqpPort <= 0)
         {
-            _amqpPort = scrubPortFromLog(_logFile, _amqpTcpPortRegExp);
+            _amqpPort = scrapePortFromLog(_logFile, _amqpTcpPortRegExp);
         }
         if (_amqpTlsPort <= 0)
         {
-            _amqpTlsPort = scrubPortFromLog(_logFile, _amqpTlsPortRegExp);
+            _amqpTlsPort = scrapePortFromLog(_logFile, _amqpTlsPortRegExp);
         }
         if (_httpPort <= 0)
         {
-            _httpPort = scrubPortFromLog(_logFile, _httpTcpPortRegExp);
+            _httpPort = scrapePortFromLog(_logFile, _httpTcpPortRegExp);
         }
         if (_httpsPort <= 0)
         {
-            _httpsPort = scrubPortFromLog(_logFile, _httpTlsPortRegExp);
+            _httpsPort = scrapePortFromLog(_logFile, _httpTlsPortRegExp);
         }
     }
 
@@ -246,7 +246,7 @@ public abstract class AbstractBrokerHold
         return options;
     }
 
-    private int scrubPortFromLog(final File logFile, final String portRegEx) 
throws IOException
+    private int scrapePortFromLog(final File logFile, final String portRegEx) 
throws IOException
     {
         final String logPrefix = getLogPrefix();
         Pattern portPattern = Pattern.compile(portRegEx);



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to