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/07/27 00:57:13 UTC

svn commit: r1613739 [2/3] - in /qpid/trunk/qpid/java: bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/ bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ bdbstore/src/main/java/org/apache/qpid/server/virtualhost...

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCConfigurationStore.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCConfigurationStore.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCConfigurationStore.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCConfigurationStore.java Sat Jul 26 22:57:11 2014
@@ -311,8 +311,7 @@ public abstract class AbstractJDBCConfig
             PreparedStatement stmt = connection.prepareStatement(SELECT_FROM_CONFIGURED_OBJECTS);
             try
             {
-                ResultSet rs = stmt.executeQuery();
-                try
+                try (ResultSet rs = stmt.executeQuery())
                 {
                     while (rs.next())
                     {
@@ -322,38 +321,26 @@ public abstract class AbstractJDBCConfig
                         {
                             continue;
                         }
-                        Map<String,Object> attributes = objectMapper.readValue(getBlobAsString(rs, 3),Map.class);
+                        Map<String, Object> attributes = objectMapper.readValue(getBlobAsString(rs, 3), Map.class);
 
-                        if(objectType.endsWith("Binding"))
+                        if (objectType.endsWith("Binding"))
                         {
-                            bindingsToUpdate.put(id,attributes);
+                            bindingsToUpdate.put(id, attributes);
                         }
                         else
                         {
                             if (objectType.equals("Exchange"))
                             {
-                                defaultExchanges.remove((String)attributes.get("name"));
+                                defaultExchanges.remove((String) attributes.get("name"));
                             }
                             others.add(id);
                         }
                     }
                 }
-                catch (JsonMappingException e)
-                {
-                    throw new StoreException("Error recovering persistent state: " + e.getMessage(), e);
-                }
-                catch (JsonParseException e)
-                {
-                    throw new StoreException("Error recovering persistent state: " + e.getMessage(), e);
-                }
                 catch (IOException e)
                 {
                     throw new StoreException("Error recovering persistent state: " + e.getMessage(), e);
                 }
-                finally
-                {
-                    rs.close();
-                }
             }
             finally
             {
@@ -395,7 +382,7 @@ public abstract class AbstractJDBCConfig
                 exchangeAttributes.put("name", defaultExchangeEntry.getKey());
                 exchangeAttributes.put("type", defaultExchangeEntry.getValue());
                 exchangeAttributes.put("lifetimePolicy", "PERMANENT");
-                Map<String, ConfiguredObjectRecord> parents = Collections.singletonMap("VirtualHost", virtualHostRecord);
+                Map<String, UUID> parents = Collections.singletonMap("VirtualHost", virtualHostRecord.getId());
                 ConfiguredObjectRecord exchangeRecord = new org.apache.qpid.server.store.ConfiguredObjectRecordImpl(id, "Exchange", exchangeAttributes, parents);
                 insertConfiguredObject(exchangeRecord, connection);
             }
@@ -414,14 +401,6 @@ public abstract class AbstractJDBCConfig
                     stmt.execute();
                 }
             }
-            catch (JsonMappingException e)
-            {
-                throw new StoreException("Error recovering persistent state: " + e.getMessage(), e);
-            }
-            catch (JsonGenerationException e)
-            {
-                throw new StoreException("Error recovering persistent state: " + e.getMessage(), e);
-            }
             catch (IOException e)
             {
                 throw new StoreException("Error recovering persistent state: " + e.getMessage(), e);
@@ -464,15 +443,15 @@ public abstract class AbstractJDBCConfig
     protected abstract String getSqlBigIntType();
 
 
-    protected void createOrOpenConfigurationStoreDatabase() throws StoreException
+    protected void createOrOpenConfigurationStoreDatabase(final boolean clear) throws StoreException
     {
         Connection conn = null;
         try
         {
             conn = newAutoCommitConnection();
 
-            createConfiguredObjectsTable(conn);
-            createConfiguredObjectHierarchyTable(conn);
+            createConfiguredObjectsTable(conn, clear);
+            createConfiguredObjectHierarchyTable(conn, clear);
         }
         catch (SQLException e)
         {
@@ -500,36 +479,43 @@ public abstract class AbstractJDBCConfig
         }
     }
 
-    private void createConfiguredObjectsTable(final Connection conn) throws SQLException
+    private void createConfiguredObjectsTable(final Connection conn, final boolean clear) throws SQLException
     {
         if(!tableExists(CONFIGURED_OBJECTS_TABLE_NAME, conn))
         {
-            Statement stmt = conn.createStatement();
-            try
+            try (Statement stmt = conn.createStatement())
             {
-                stmt.execute("CREATE TABLE " + CONFIGURED_OBJECTS_TABLE_NAME
-                        + " ( id VARCHAR(36) not null, object_type varchar(255), attributes "+getSqlBlobType()+",  PRIMARY KEY (id))");
+                stmt.execute("CREATE TABLE "
+                             + CONFIGURED_OBJECTS_TABLE_NAME
+                             + " ( id VARCHAR(36) not null, object_type varchar(255), attributes "
+                             + getSqlBlobType()
+                             + ",  PRIMARY KEY (id))");
             }
-            finally
+        }
+        else if(clear)
+        {
+            try (Statement stmt = conn.createStatement())
             {
-                stmt.close();
+                stmt.execute("DELETE FROM " + CONFIGURED_OBJECTS_TABLE_NAME);
             }
         }
     }
 
-    private void createConfiguredObjectHierarchyTable(final Connection conn) throws SQLException
+    private void createConfiguredObjectHierarchyTable(final Connection conn, final boolean clear) throws SQLException
     {
         if(!tableExists(CONFIGURED_OBJECT_HIERARCHY_TABLE_NAME, conn))
         {
-            Statement stmt = conn.createStatement();
-            try
+            try (Statement stmt = conn.createStatement())
             {
                 stmt.execute("CREATE TABLE " + CONFIGURED_OBJECT_HIERARCHY_TABLE_NAME
                              + " ( child_id VARCHAR(36) not null, parent_type varchar(255), parent_id VARCHAR(36),  PRIMARY KEY (child_id, parent_type))");
             }
-            finally
+        }
+        else if(clear)
+        {
+            try (Statement stmt = conn.createStatement())
             {
-                stmt.close();
+                stmt.execute("DELETE FROM " + CONFIGURED_OBJECT_HIERARCHY_TABLE_NAME);
             }
         }
     }
@@ -643,6 +629,14 @@ public abstract class AbstractJDBCConfig
         return connection;
     }
 
+    protected boolean hasNoConfigurationEntries()
+    {
+        ConfiguredObjectRecordPresenceDetector recordPresenceDetector = new ConfiguredObjectRecordPresenceDetector();
+        visitConfiguredObjectRecords(recordPresenceDetector);
+
+        return !recordPresenceDetector.isRecordsPresent();
+    }
+
     protected abstract Connection getConnection() throws SQLException;
 
     private void insertConfiguredObject(ConfiguredObjectRecord configuredObject, final Connection conn) throws StoreException
@@ -900,11 +894,11 @@ public abstract class AbstractJDBCConfig
         PreparedStatement insertStmt = conn.prepareStatement(INSERT_INTO_CONFIGURED_OBJECT_HIERARCHY);
         try
         {
-            for(Map.Entry<String,ConfiguredObjectRecord> parentEntry : configuredObject.getParents().entrySet())
+            for(Map.Entry<String,UUID> parentEntry : configuredObject.getParents().entrySet())
             {
                 insertStmt.setString(1, configuredObject.getId().toString());
                 insertStmt.setString(2, parentEntry.getKey());
-                insertStmt.setString(3, parentEntry.getValue().getId().toString());
+                insertStmt.setString(3, parentEntry.getValue().toString());
 
                 insertStmt.execute();
             }
@@ -963,7 +957,7 @@ public abstract class AbstractJDBCConfig
         private final UUID _id;
         private final String _type;
         private final Map<String, Object> _attributes;
-        private final Map<String, ConfiguredObjectRecord> _parents = new HashMap<String, ConfiguredObjectRecord>();
+        private final Map<String, UUID> _parents = new HashMap<>();
 
         private ConfiguredObjectRecordImpl(final UUID id,
                                            final String type,
@@ -988,7 +982,7 @@ public abstract class AbstractJDBCConfig
 
         private void addParent(String parentType, ConfiguredObjectRecord parent)
         {
-            _parents.put(parentType, parent);
+            _parents.put(parentType, parent.getId());
         }
 
         @Override
@@ -998,7 +992,7 @@ public abstract class AbstractJDBCConfig
         }
 
         @Override
-        public Map<String, ConfiguredObjectRecord> getParents()
+        public Map<String, UUID> getParents()
         {
             return Collections.unmodifiableMap(_parents);
         }
@@ -1010,4 +1004,33 @@ public abstract class AbstractJDBCConfig
                     + _parents + "]";
         }
     }
+
+    private static class ConfiguredObjectRecordPresenceDetector implements ConfiguredObjectRecordHandler
+    {
+        private boolean _recordsPresent;
+
+        @Override
+        public void begin()
+        {
+
+        }
+
+        @Override
+        public boolean handle(final ConfiguredObjectRecord record)
+        {
+            _recordsPresent = true;
+            return false;
+        }
+
+        @Override
+        public void end()
+        {
+
+        }
+
+        public boolean isRecordsPresent()
+        {
+            return _recordsPresent;
+        }
+    }
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryStore.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryStore.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryStore.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryStore.java Sat Jul 26 22:57:11 2014
@@ -28,13 +28,19 @@ import java.util.concurrent.ConcurrentHa
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler;
 
-abstract class AbstractMemoryStore implements DurableConfigurationStore, MessageStoreProvider
+public abstract class AbstractMemoryStore implements DurableConfigurationStore, MessageStoreProvider
 {
     private final MessageStore _messageStore = new MemoryMessageStore();
+    private final Class<? extends ConfiguredObject> _rootClass;
 
 
     private final ConcurrentHashMap<UUID, ConfiguredObjectRecord> _configuredObjectRecords = new ConcurrentHashMap<UUID, ConfiguredObjectRecord>();
 
+    protected AbstractMemoryStore(final Class<? extends ConfiguredObject> rootClass)
+    {
+        _rootClass = rootClass;
+    }
+
     @Override
     public void create(ConfiguredObjectRecord record)
     {
@@ -49,10 +55,17 @@ abstract class AbstractMemoryStore imple
     {
         for (ConfiguredObjectRecord record : records)
         {
-            ConfiguredObjectRecord previousValue = _configuredObjectRecords.replace(record.getId(), record);
-            if (previousValue == null && !createIfNecessary)
+            if(createIfNecessary)
             {
-                throw new StoreException("Record with id " + record.getId() + " does not exist");
+                _configuredObjectRecords.put(record.getId(), record);
+            }
+            else
+            {
+                ConfiguredObjectRecord previousValue = _configuredObjectRecords.replace(record.getId(), record);
+                if (previousValue == null)
+                {
+                    throw new StoreException("Record with id " + record.getId() + " does not exist");
+                }
             }
         }
     }
@@ -72,8 +85,14 @@ abstract class AbstractMemoryStore imple
     }
 
     @Override
-    public void openConfigurationStore(ConfiguredObject<?> parent)
+    public void openConfigurationStore(ConfiguredObject<?> parent,
+                                       final boolean overwrite,
+                                       final ConfiguredObjectRecord... initialRecords)
     {
+        for(ConfiguredObjectRecord record : initialRecords)
+        {
+            _configuredObjectRecords.put(record.getId(), record);
+        }
     }
 
     @Override

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/BrokerStoreUpgraderAndRecoverer.java Sat Jul 26 22:57:11 2014
@@ -31,19 +31,19 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.SystemContext;
+import org.apache.qpid.server.model.SystemConfig;
 import org.apache.qpid.server.util.Action;
 
 public class BrokerStoreUpgraderAndRecoverer
 {
-    private final SystemContext<?> _systemContext;
+    private final SystemConfig<?> _systemConfig;
     private final Map<String, StoreUpgraderPhase> _upgraders = new HashMap<String, StoreUpgraderPhase>();
 
     // Note: don't use externally defined constants in upgraders in case they change, the values here MUST stay the same
     // no matter what changes are made to the code in the future
-    public BrokerStoreUpgraderAndRecoverer(SystemContext<?> systemContext)
+    public BrokerStoreUpgraderAndRecoverer(SystemConfig<?> systemConfig)
     {
-        _systemContext = systemContext;
+        _systemConfig = systemConfig;
 
         register(new Upgrader_1_0_to_1_1());
         register(new Upgrader_1_1_to_1_2());
@@ -477,10 +477,10 @@ public class BrokerStoreUpgraderAndRecov
     public Broker<?> perform(final DurableConfigurationStore store)
     {
         List<ConfiguredObjectRecord> upgradedRecords = upgrade(store);
-        new GenericRecoverer(_systemContext, Broker.class.getSimpleName()).recover(upgradedRecords);
+        new GenericRecoverer(_systemConfig, Broker.class.getSimpleName()).recover(upgradedRecords);
 
         final StoreConfigurationChangeListener configChangeListener = new StoreConfigurationChangeListener(store);
-        applyRecursively(_systemContext.getBroker(), new Action<ConfiguredObject<?>>()
+        applyRecursively(_systemConfig.getBroker(), new Action<ConfiguredObject<?>>()
         {
             @Override
             public void performAction(final ConfiguredObject<?> object)
@@ -489,7 +489,7 @@ public class BrokerStoreUpgraderAndRecov
             }
         });
 
-        return _systemContext.getBroker();
+        return _systemConfig.getBroker();
     }
 
     List<ConfiguredObjectRecord> upgrade(final DurableConfigurationStore store)

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecord.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecord.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecord.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecord.java Sat Jul 26 22:57:11 2014
@@ -31,5 +31,5 @@ public interface ConfiguredObjectRecord
 
     Map<String,Object> getAttributes();
 
-    Map<String, ConfiguredObjectRecord> getParents();
+    Map<String, UUID> getParents();
 }

Added: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordConverter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordConverter.java?rev=1613739&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordConverter.java (added)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordConverter.java Sat Jul 26 22:57:11 2014
@@ -0,0 +1,123 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.store;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.map.ObjectMapper;
+
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.Model;
+
+public class ConfiguredObjectRecordConverter
+{
+    private final Model _model;
+
+    public ConfiguredObjectRecordConverter(final Model model)
+    {
+        _model = model;
+    }
+
+    public Collection<ConfiguredObjectRecord> readFromJson(final Class<? extends ConfiguredObject> rootClass,
+                                                           final ConfiguredObject<?> parent, final Reader reader) throws IOException
+    {
+        Map<UUID, ConfiguredObjectRecord> objectsById = new HashMap<>();
+
+        ObjectMapper objectMapper = new ObjectMapper();
+        objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
+        Map data = objectMapper.readValue(reader, Map.class);
+        if(!data.isEmpty())
+        {
+            loadChild(rootClass, data, parent.getCategoryClass(), parent.getId(), objectsById);
+        }
+        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)
+    {
+        String idStr = (String) data.remove("id");
+
+        final UUID id = idStr == null ? UUID.randomUUID() : UUID.fromString(idStr);
+        final String type = clazz.getSimpleName();
+        Map<String,UUID> parentMap = new HashMap<>();
+
+        Collection<Class<? extends ConfiguredObject>> childClasses = _model.getChildTypes(clazz);
+        for(Class<? extends ConfiguredObject> childClass : childClasses)
+        {
+            final String childType = childClass.getSimpleName();
+            String attrName = childType.toLowerCase() + "s";
+            Object children = data.remove(attrName);
+            if(children != null)
+            {
+                if(children instanceof Collection)
+                {
+                    for(Object child : (Collection)children)
+                    {
+                        if(child instanceof Map)
+                        {
+                            loadChild(childClass, (Map)child, clazz, id, records);
+                        }
+                    }
+                }
+            }
+
+        }
+        if(parentId != null)
+        {
+            parentMap.put(parentClass.getSimpleName(),parentId);
+            for(Class<? extends ConfiguredObject> otherParent : _model.getParentTypes(clazz))
+            {
+                if(otherParent != parentClass)
+                {
+                    final String otherParentAttr = otherParent.getSimpleName().toLowerCase();
+                    Object otherParentId = data.remove(otherParentAttr);
+                    if(otherParentId instanceof String)
+                    {
+                        try
+                        {
+                            parentMap.put(otherParent.getSimpleName(), UUID.fromString((String) otherParentId));
+                        }
+                        catch(IllegalArgumentException e)
+                        {
+                            // TODO
+                        }
+                    }
+                }
+
+            }
+        }
+
+        records.put(id, new ConfiguredObjectRecordImpl(id, type, data, parentMap));
+
+    }
+
+
+}

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordImpl.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordImpl.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/ConfiguredObjectRecordImpl.java Sat Jul 26 22:57:11 2014
@@ -30,20 +30,26 @@ public class ConfiguredObjectRecordImpl 
     private UUID _id;
     private String _type;
     private final Map<String,Object> _attributes;
-    private final Map<String,ConfiguredObjectRecord> _parents;
+    private final Map<String,UUID> _parents;
+
+
+    public ConfiguredObjectRecordImpl(ConfiguredObjectRecord record)
+    {
+        this(record.getId(), record.getType(), record.getAttributes(), record.getParents());
+    }
 
     public ConfiguredObjectRecordImpl(UUID id, String type, Map<String, Object> attributes)
     {
-        this(id,type,attributes,Collections.<String,ConfiguredObjectRecord>emptyMap());
+        this(id,type,attributes,Collections.<String,UUID>emptyMap());
     }
 
-    public ConfiguredObjectRecordImpl(UUID id, String type, Map<String, Object> attributes, Map<String,ConfiguredObjectRecord> parents)
+    public ConfiguredObjectRecordImpl(UUID id, String type, Map<String, Object> attributes, Map<String,UUID> parents)
     {
         super();
         _id = id;
         _type = type;
-        _attributes = Collections.unmodifiableMap(new LinkedHashMap<String,Object>(attributes));
-        _parents = Collections.unmodifiableMap(new LinkedHashMap<String, ConfiguredObjectRecord>(parents));
+        _attributes = Collections.unmodifiableMap(new LinkedHashMap<>(attributes));
+        _parents = Collections.unmodifiableMap(new LinkedHashMap<>(parents));
     }
 
     @Override
@@ -65,7 +71,7 @@ public class ConfiguredObjectRecordImpl 
     }
 
     @Override
-    public Map<String, ConfiguredObjectRecord> getParents()
+    public Map<String, UUID> getParents()
     {
         return _parents;
     }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStore.java Sat Jul 26 22:57:11 2014
@@ -20,7 +20,6 @@
  */
 package org.apache.qpid.server.store;
 
-import java.util.Map;
 import java.util.UUID;
 
 import org.apache.qpid.server.model.ConfiguredObject;
@@ -30,10 +29,14 @@ public interface DurableConfigurationSto
 {
     /**
      * Initializes and opens the configuration store.
-     *  @param parent
+     * @param parent
+     * @param overwrite
+     * @param initialRecords
      *
      */
-    void openConfigurationStore(ConfiguredObject<?> parent) throws StoreException;
+    void openConfigurationStore(ConfiguredObject<?> parent,
+                                final boolean overwrite,
+                                final ConfiguredObjectRecord... initialRecords) throws StoreException;
 
     /**
      * Requests that the store performs any upgrade work on the store's structure. If there is no

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/GenericRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/GenericRecoverer.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/GenericRecoverer.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/GenericRecoverer.java Sat Jul 26 22:57:11 2014
@@ -93,8 +93,7 @@ public class GenericRecoverer
                 records = new ArrayList<ConfiguredObjectRecord>(records);
 
                 String parentOfRootCategory = _parentOfRoot.getCategoryClass().getSimpleName();
-                ConfiguredObjectRecord parentRecord = new ConfiguredObjectRecordImpl(_parentOfRoot.getId(), parentOfRootCategory, Collections.<String, Object>emptyMap());
-                Map<String, ConfiguredObjectRecord> rootParents = Collections.<String, ConfiguredObjectRecord>singletonMap(parentOfRootCategory, parentRecord);
+                Map<String, UUID> rootParents = Collections.singletonMap(parentOfRootCategory, _parentOfRoot.getId());
                 records.remove(rootRecord);
                 records.add(new ConfiguredObjectRecordImpl(rootRecord.getId(), _rootCategory, rootRecord.getAttributes(), rootParents));
             }
@@ -124,16 +123,16 @@ public class GenericRecoverer
                 ConfiguredObjectRecord record = iter.next();
                 Collection<ConfiguredObject<?>> parents = new ArrayList<ConfiguredObject<?>>();
                 boolean foundParents = true;
-                for (ConfiguredObjectRecord parent : record.getParents().values())
+                for (UUID parentId : record.getParents().values())
                 {
-                    if (!resolvedObjects.containsKey(parent.getId()))
+                    if (!resolvedObjects.containsKey(parentId))
                     {
                         foundParents = false;
                         break;
                     }
                     else
                     {
-                        parents.add(resolvedObjects.get(parent.getId()));
+                        parents.add(resolvedObjects.get(parentId));
                     }
                 }
                 if (foundParents)

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java Sat Jul 26 22:57:11 2014
@@ -22,11 +22,13 @@ package org.apache.qpid.server.store;
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.FileReader;
 import java.io.IOException;
 import java.nio.channels.FileChannel;
 import java.nio.channels.FileLock;
 import java.nio.channels.OverlappingFileLockException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -36,11 +38,10 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
+import org.apache.log4j.Logger;
 import org.codehaus.jackson.JsonGenerator;
-import org.codehaus.jackson.JsonParseException;
 import org.codehaus.jackson.JsonProcessingException;
 import org.codehaus.jackson.Version;
-import org.codehaus.jackson.map.JsonMappingException;
 import org.codehaus.jackson.map.JsonSerializer;
 import org.codehaus.jackson.map.Module;
 import org.codehaus.jackson.map.ObjectMapper;
@@ -50,11 +51,12 @@ import org.codehaus.jackson.map.module.S
 
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.Model;
-import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler;
 
 public class JsonFileConfigStore implements DurableConfigurationStore
 {
+    private static final Logger _logger = Logger.getLogger(JsonFileConfigStore.class);
+
     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();
@@ -66,6 +68,7 @@ public class JsonFileConfigStore impleme
     private FileLock _fileLock;
     private String _configFileName;
     private String _backupFileName;
+    private String _lockFileName;
 
     private static final Module _module;
     static
@@ -90,11 +93,6 @@ public class JsonFileConfigStore impleme
 
     private ConfiguredObject<?> _parent;
 
-    public JsonFileConfigStore()
-    {
-        this(VirtualHost.class);
-    }
-
     public JsonFileConfigStore(Class<? extends ConfiguredObject> rootClass)
     {
         _objectMapper.registerModule(_module);
@@ -109,14 +107,16 @@ public class JsonFileConfigStore impleme
     }
 
     @Override
-    public void openConfigurationStore(ConfiguredObject<?> parent)
+    public void openConfigurationStore(ConfiguredObject<?> parent,
+                                       final boolean overwrite,
+                                       final ConfiguredObjectRecord... initialRecords)
     {
         _parent = parent;
         _name = parent.getName();
         _classNameMapping = generateClassNameMap(_parent.getModel(), _rootClass);
         FileBasedSettings fileBasedSettings = (FileBasedSettings)_parent;
         setup(fileBasedSettings);
-        load();
+        load(overwrite, initialRecords);
     }
 
     @Override
@@ -142,9 +142,23 @@ public class JsonFileConfigStore impleme
         {
             throw new StoreException("Cannot determine path for configuration storage");
         }
-        _directoryName = configurationStoreSettings.getStorePath();
-        _configFileName = _name + ".json";
-        _backupFileName = _name + ".bak";
+        File fileFromSettings = new File(configurationStoreSettings.getStorePath());
+        if(fileFromSettings.isFile() || (!fileFromSettings.exists() && (new File(fileFromSettings.getParent())).isDirectory()))
+        {
+            _directoryName = fileFromSettings.getParent();
+            _configFileName = fileFromSettings.getName();
+            _backupFileName = fileFromSettings.getName() + ".bak";
+            _lockFileName = fileFromSettings.getName() + ".lck";
+        }
+        else
+        {
+            _directoryName = configurationStoreSettings.getStorePath();
+            _configFileName = _name + ".json";
+            _backupFileName = _name + ".bak";
+            _lockFileName = _name + ".lck";
+        }
+
+
         checkDirectoryIsWritable(_directoryName);
         getFileLock();
 
@@ -195,7 +209,7 @@ public class JsonFileConfigStore impleme
 
     private void getFileLock()
     {
-        File lockFile = new File(_directoryName, _name + ".lck");
+        File lockFile = new File(_directoryName, _lockFileName);
         try
         {
             lockFile.createNewFile();
@@ -245,102 +259,47 @@ public class JsonFileConfigStore impleme
         }
     }
 
-    protected void load()
+    protected void load(final boolean overwrite, final ConfiguredObjectRecord[] initialRecords)
     {
         final File configFile = new File(_directoryName, _configFileName);
         try
         {
-            Map data = _objectMapper.readValue(configFile,Map.class);
-            loadFromMap(data);
-        }
-        catch (JsonMappingException e)
-        {
-            throw new StoreException("Cannot parse the configuration file " + configFile, e);
-        }
-        catch (JsonParseException e)
-        {
-            throw new StoreException("Cannot parse the configuration file " + configFile, e);
-        }
-        catch (IOException e)
-        {
-            throw new StoreException("Could not load the configuration file " + configFile, e);
-        }
-
-    }
-
-    protected void loadFromMap(final Map<String,Object> data)
-    {
-        if (!data.isEmpty())
-        {
-            loadChild(_rootClass, data, null, null);
-        }
-    }
-
+            boolean updated = false;
+            Collection<ConfiguredObjectRecord> records = Collections.emptyList();
+            if(!overwrite)
+            {
+                ConfiguredObjectRecordConverter configuredObjectRecordConverter =
+                        new ConfiguredObjectRecordConverter(_parent.getModel());
 
-    private void loadChild(final Class<? extends ConfiguredObject> clazz,
-                           final Map<String,Object> data,
-                           final Class<? extends ConfiguredObject> parentClass,
-                           final UUID parentId)
-    {
-        String idStr = (String) data.remove("id");
-        final UUID id = UUID.fromString(idStr);
-        final String type = clazz.getSimpleName();
-        Map<String,UUID> parentMap = new HashMap<String, UUID>();
+                records = configuredObjectRecordConverter.readFromJson(_rootClass, _parent, new FileReader(configFile));
+            }
 
-        Collection<Class<? extends ConfiguredObject>> childClasses = _parent.getModel().getChildTypes(clazz);
-        for(Class<? extends ConfiguredObject> childClass : childClasses)
-        {
-            final String childType = childClass.getSimpleName();
-            String attrName = childType.toLowerCase() + "s";
-            Object children = data.remove(attrName);
-            if(children != null)
+            if(records.isEmpty())
             {
-                if(children instanceof Collection)
-                {
-                    for(Object child : (Collection)children)
-                    {
-                        if(child instanceof Map)
-                        {
-                            loadChild(childClass, (Map)child, clazz, id);
-                        }
-                    }
-                }
+                records = Arrays.asList(initialRecords);
+                updated = true;
             }
 
-        }
-        if(parentId != null)
-        {
-            parentMap.put(parentClass.getSimpleName(),parentId);
-            for(Class<? extends ConfiguredObject> otherParent : _parent.getModel().getParentTypes(clazz))
+            for(ConfiguredObjectRecord record : records)
             {
-                if(otherParent != parentClass)
+                _objectsById.put(record.getId(), record);
+                List<UUID> idsForType = _idsByType.get(record.getType());
+                if (idsForType == null)
                 {
-                    final String otherParentAttr = otherParent.getSimpleName().toLowerCase();
-                    Object otherParentId = data.remove(otherParentAttr);
-                    if(otherParentId instanceof String)
-                    {
-                        try
-                        {
-                            parentMap.put(otherParent.getSimpleName(), UUID.fromString((String) otherParentId));
-                        }
-                        catch(IllegalArgumentException e)
-                        {
-                            //
-                        }
-                    }
+                    idsForType = new ArrayList<>();
+                    _idsByType.put(record.getType(), idsForType);
                 }
-
+                idsForType.add(record.getId());
+            }
+            if(updated)
+            {
+                save();
             }
         }
-
-        _objectsById.put(id, new ConfiguredObjectRecordImpl(id, type, data, parentMap));
-        List<UUID> idsForType = _idsByType.get(type);
-        if(idsForType == null)
+        catch (IOException e)
         {
-            idsForType = new ArrayList<UUID>();
-            _idsByType.put(type, idsForType);
+            throw new StoreException("Cannot construct configuration from the configuration file " + configFile, e);
         }
-        idsForType.add(id);
     }
 
     @Override
@@ -440,7 +399,7 @@ public class JsonFileConfigStore impleme
             while(iter.hasNext())
             {
                 String parentType = iter.next().getSimpleName();
-                map.put(parentType.toLowerCase(), record.getParents().get(parentType).getId());
+                map.put(parentType.toLowerCase(), record.getParents().get(parentType));
             }
         }
 
@@ -461,8 +420,8 @@ public class JsonFileConfigStore impleme
                     {
                         ConfiguredObjectRecord childRecord = _objectsById.get(childId);
 
-                        final ConfiguredObjectRecord parent = childRecord.getParents().get(type.getSimpleName());
-                        String parentId = parent.getId().toString();
+                        final UUID parent = childRecord.getParents().get(type.getSimpleName());
+                        String parentId = parent.toString();
                         if(id.toString().equals(parentId))
                         {
                             entities.add(build(childClass,childId));
@@ -558,6 +517,7 @@ public class JsonFileConfigStore impleme
     @Override
     public void closeConfigurationStore()
     {
+        _logger.info("Close Config Store called", new Exception());
         try
         {
             releaseFileLock();
@@ -616,87 +576,4 @@ public class JsonFileConfigStore impleme
         return map;
     }
 
-    private class ConfiguredObjectRecordImpl implements ConfiguredObjectRecord
-    {
-
-        private final UUID _id;
-        private final String _type;
-        private final Map<String, Object> _attributes;
-        private final Map<String, UUID> _parents;
-
-        private ConfiguredObjectRecordImpl(ConfiguredObjectRecord record)
-        {
-            this(record.getId(), record.getType(), record.getAttributes(), convertParents(record.getParents()));
-        }
-
-        private ConfiguredObjectRecordImpl(final UUID id, final String type, final Map<String, Object> attributes,
-                                           final Map<String, UUID> parents)
-        {
-            _id = id;
-            _type = type;
-            _attributes = attributes;
-            _parents = parents;
-        }
-
-        @Override
-        public UUID getId()
-        {
-            return _id;
-        }
-
-        @Override
-        public String getType()
-        {
-            return _type;
-        }
-
-        @Override
-        public Map<String, Object> getAttributes()
-        {
-            return _attributes;
-        }
-
-        @Override
-        public Map<String, ConfiguredObjectRecord> getParents()
-        {
-            Map<String,ConfiguredObjectRecord> parents = new HashMap<String, ConfiguredObjectRecord>();
-            for(Map.Entry<String,UUID> entry : _parents.entrySet())
-            {
-                ConfiguredObjectRecord value = _objectsById.get(entry.getValue());
-
-                if(value == null && entry.getKey().equals("Exchange"))
-                {
-                    // TODO - remove this hack for the defined exchanges
-                    value = new ConfiguredObjectRecordImpl(entry.getValue(),entry.getKey(),Collections.<String,Object>emptyMap(), Collections.<String,UUID>emptyMap());
-                }
-
-                parents.put(entry.getKey(), value);
-            }
-            return parents;
-        }
-
-        @Override
-        public String toString()
-        {
-            return "ConfiguredObjectRecordImpl [_id=" + _id + ", _type=" + _type + ", _attributes=" + _attributes + ", _parents="
-                    + _parents + "]";
-        }
-
-    }
-
-    private static Map<String, UUID> convertParents(final Map<String, ConfiguredObjectRecord> parents)
-    {
-        if(parents == null || parents.isEmpty())
-        {
-            return Collections.emptyMap();
-        }
-        Map<String,UUID> parentMap = new HashMap<>();
-        for(Map.Entry<String,ConfiguredObjectRecord> entry : parents.entrySet())
-        {
-            parentMap.put(entry.getKey(), entry.getValue().getId());
-        }
-        return parentMap;
-    }
-
-
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/NullMessageStore.java Sat Jul 26 22:57:11 2014
@@ -36,7 +36,9 @@ public abstract class NullMessageStore i
     }
 
     @Override
-    public void openConfigurationStore(ConfiguredObject<?> parent)
+    public void openConfigurationStore(ConfiguredObject<?> parent,
+                                       final boolean overwrite,
+                                       final ConfiguredObjectRecord... initialRecords)
     {
     }
 

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecoverer.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecoverer.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/VirtualHostStoreUpgraderAndRecoverer.java Sat Jul 26 22:57:11 2014
@@ -107,12 +107,11 @@ public class VirtualHostStoreUpgraderAnd
 
         private boolean isTopicExchange(ConfiguredObjectRecord entry)
         {
-            ConfiguredObjectRecord exchangeRecord = entry.getParents().get("Exchange");
-            if (exchangeRecord == null)
+            UUID exchangeId = entry.getParents().get("Exchange");
+            if (exchangeId == null)
             {
                 return false;
             }
-            UUID exchangeId = exchangeRecord.getId();
 
             if(_records.containsKey(exchangeId))
             {
@@ -201,10 +200,10 @@ public class VirtualHostStoreUpgraderAnd
             {
                 Map.Entry<UUID, ConfiguredObjectRecord> entry = iterator.next();
                 final ConfiguredObjectRecord record = entry.getValue();
-                final ConfiguredObjectRecord exchangeParent = record.getParents().get(Exchange.class.getSimpleName());
-                final ConfiguredObjectRecord queueParent = record.getParents().get(Queue.class.getSimpleName());
-                if(isBinding(record.getType()) && (exchangeParent == null || unknownExchange(exchangeParent.getId())
-                                                   || queueParent == null || unknownQueue(queueParent.getId())))
+                final UUID exchangeParent = record.getParents().get(Exchange.class.getSimpleName());
+                final UUID queueParent = record.getParents().get(Queue.class.getSimpleName());
+                if(isBinding(record.getType()) && (exchangeParent == null || unknownExchange(exchangeParent)
+                                                   || queueParent == null || unknownQueue(queueParent)))
                 {
                     getDeleteMap().put(entry.getKey(), entry.getValue());
                     iterator.remove();
@@ -363,7 +362,7 @@ public class VirtualHostStoreUpgraderAnd
                 Map<String, Object> virtualHostAttributes = new HashMap<String, Object>(record.getAttributes());
                 virtualHostAttributes.put("name", _virtualHostNode.getName());
                 virtualHostAttributes.put("modelVersion", getToVersion());
-                record = new ConfiguredObjectRecordImpl(record.getId(), "VirtualHost", virtualHostAttributes, Collections.<String, ConfiguredObjectRecord>emptyMap());
+                record = new ConfiguredObjectRecordImpl(record.getId(), "VirtualHost", virtualHostAttributes, Collections.<String, UUID>emptyMap());
                 _virtualHostRecord = record;
             }
             else if("Exchange".equals(record.getType()))
@@ -389,7 +388,7 @@ public class VirtualHostStoreUpgraderAnd
                 attributes.put("type", type);
                 attributes.put("lifetimePolicy", "PERMANENT");
 
-                ConfiguredObjectRecord record = new ConfiguredObjectRecordImpl(id, Exchange.class.getSimpleName(), attributes, Collections.singletonMap(_virtualHostRecord.getType(), _virtualHostRecord));
+                ConfiguredObjectRecord record = new ConfiguredObjectRecordImpl(id, Exchange.class.getSimpleName(), attributes, Collections.singletonMap(_virtualHostRecord.getType(), _virtualHostRecord.getId()));
                 getUpdateMap().put(id, record);
 
                 getNextUpgrader().configuredObject(record);

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java Sat Jul 26 22:57:11 2014
@@ -167,7 +167,7 @@ public abstract class AbstractVirtualHos
 
         _dtxRegistry = new DtxRegistry();
 
-        _eventLogger = _broker.getParent(SystemContext.class).getEventLogger();
+        _eventLogger = _broker.getParent(SystemConfig.class).getEventLogger();
 
         _eventLogger.message(VirtualHostMessages.CREATED(getName()));
 

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java Sat Jul 26 22:57:11 2014
@@ -71,7 +71,7 @@ public abstract class AbstractStandardVi
             LOGGER.debug("Activating virtualhost node " + this);
         }
 
-        getConfigurationStore().openConfigurationStore(this);
+        getConfigurationStore().openConfigurationStore(this, false);
         getConfigurationStore().upgradeStoreStructure();
 
         getEventLogger().message(getConfigurationStoreLogSubject(), ConfigStoreMessages.CREATED());

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java Sat Jul 26 22:57:11 2014
@@ -31,7 +31,7 @@ import org.apache.qpid.server.model.Conf
 import org.apache.qpid.server.model.LifetimePolicy;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.StateTransition;
-import org.apache.qpid.server.model.SystemContext;
+import org.apache.qpid.server.model.SystemConfig;
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.model.VirtualHostNode;
 import org.apache.qpid.server.security.access.Operation;
@@ -65,8 +65,8 @@ public abstract class AbstractVirtualHos
         super(Collections.<Class<? extends ConfiguredObject>,ConfiguredObject<?>>singletonMap(Broker.class, parent),
               attributes);
         _broker = parent;
-        SystemContext<?> systemContext = _broker.getParent(SystemContext.class);
-        _eventLogger = systemContext.getEventLogger();
+        SystemConfig<?> systemConfig = _broker.getParent(SystemConfig.class);
+        _eventLogger = systemConfig.getEventLogger();
         _virtualHostNodeLogSubject = new VirtualHostNodeLogSubject(getName());
     }
 

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java Sat Jul 26 22:57:11 2014
@@ -27,6 +27,7 @@ import org.apache.qpid.server.model.Brok
 import org.apache.qpid.server.model.ManagedAttributeField;
 import org.apache.qpid.server.model.ManagedObject;
 import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
+import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.server.store.JsonFileConfigStore;
 
@@ -53,7 +54,7 @@ public class JsonVirtualHostNodeImpl ext
     @Override
     protected DurableConfigurationStore createConfigurationStore()
     {
-        return new JsonFileConfigStore();
+        return new JsonFileConfigStore(VirtualHost.class);
     }
 
     @Override

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/BrokerOptionsTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/BrokerOptionsTest.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/BrokerOptionsTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/BrokerOptionsTest.java Sat Jul 26 22:57:11 2014
@@ -38,7 +38,7 @@ public class BrokerOptionsTest extends Q
 
     public void testDefaultConfigurationStoreType()
     {
-        assertEquals("json", _options.getConfigurationStoreType());
+        assertEquals("JSON", _options.getConfigurationStoreType());
     }
 
     public void testOverriddenConfigurationStoreType()
@@ -52,7 +52,7 @@ public class BrokerOptionsTest extends Q
         String qpidWork = "/test/value";
         setTestSystemProperty("QPID_WORK", qpidWork);
 
-        String expectedPath = new File(qpidWork, BrokerOptions.DEFAULT_CONFIG_NAME_PREFIX + "." + BrokerOptions.DEFAULT_STORE_TYPE).getAbsolutePath();
+        String expectedPath = new File(qpidWork, BrokerOptions.DEFAULT_CONFIG_NAME_PREFIX + "." + BrokerOptions.DEFAULT_STORE_TYPE.toLowerCase()).getAbsolutePath();
         assertEquals (expectedPath, _options.getConfigurationStoreLocation());
     }
 
@@ -61,7 +61,7 @@ public class BrokerOptionsTest extends Q
         setTestSystemProperty("QPID_WORK", null);
         String userDir = System.getProperty("user.dir");
 
-        String expectedPath = new File(userDir, "work/" + BrokerOptions.DEFAULT_CONFIG_NAME_PREFIX + "." + BrokerOptions.DEFAULT_STORE_TYPE).getAbsolutePath();
+        String expectedPath = new File(userDir, "work/" + BrokerOptions.DEFAULT_CONFIG_NAME_PREFIX + "." + BrokerOptions.DEFAULT_STORE_TYPE.toLowerCase()).getAbsolutePath();
         assertEquals (expectedPath, _options.getConfigurationStoreLocation());
     }
 

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostCreationTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostCreationTest.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostCreationTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostCreationTest.java Sat Jul 26 22:57:11 2014
@@ -39,7 +39,7 @@ import org.apache.qpid.server.model.Brok
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.ConfiguredObjectFactory;
 import org.apache.qpid.server.model.ConfiguredObjectFactoryImpl;
-import org.apache.qpid.server.model.SystemContext;
+import org.apache.qpid.server.model.SystemConfig;
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.model.VirtualHostNode;
 import org.apache.qpid.server.security.SecurityManager;
@@ -58,19 +58,19 @@ public class VirtualHostCreationTest ext
         EventLogger eventLogger = mock(EventLogger.class);
         SecurityManager securityManager = mock(SecurityManager.class);
         TaskExecutor executor = CurrentThreadTaskExecutor.newStartedInstance();
-        SystemContext systemContext = mock(SystemContext.class);
+        SystemConfig systemConfig = mock(SystemConfig.class);
         ConfiguredObjectFactory objectFactory = new ConfiguredObjectFactoryImpl(BrokerModel.getInstance());
-        when(systemContext.getObjectFactory()).thenReturn(objectFactory);
-        when(systemContext.getModel()).thenReturn(objectFactory.getModel());
-        when(systemContext.getEventLogger()).thenReturn(eventLogger);
-        when(systemContext.getTaskExecutor()).thenReturn(executor);
+        when(systemConfig.getObjectFactory()).thenReturn(objectFactory);
+        when(systemConfig.getModel()).thenReturn(objectFactory.getModel());
+        when(systemConfig.getEventLogger()).thenReturn(eventLogger);
+        when(systemConfig.getTaskExecutor()).thenReturn(executor);
 
         Broker broker = mock(Broker.class);
         when(broker.getObjectFactory()).thenReturn(objectFactory);
         when(broker.getModel()).thenReturn(objectFactory.getModel());
         when(broker.getSecurityManager()).thenReturn(securityManager);
         when(broker.getCategoryClass()).thenReturn(Broker.class);
-        when(broker.getParent(eq(SystemContext.class))).thenReturn(systemContext);
+        when(broker.getParent(eq(SystemConfig.class))).thenReturn(systemConfig);
         when(broker.getTaskExecutor()).thenReturn(executor);
 
         _virtualHostNode = mock(VirtualHostNode.class);

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/ManagementModeStoreHandlerTest.java Sat Jul 26 22:57:11 2014
@@ -45,11 +45,11 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.logging.EventLogger;
 import org.apache.qpid.server.logging.LogRecorder;
 import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.JsonSystemConfigImpl;
 import org.apache.qpid.server.model.Port;
 import org.apache.qpid.server.model.Protocol;
 import org.apache.qpid.server.model.State;
-import org.apache.qpid.server.model.SystemContext;
-import org.apache.qpid.server.model.SystemContextImpl;
+import org.apache.qpid.server.model.SystemConfig;
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.store.ConfiguredObjectRecord;
 import org.apache.qpid.server.store.ConfiguredObjectRecordImpl;
@@ -65,7 +65,7 @@ public class ManagementModeStoreHandlerT
     private ConfiguredObjectRecord _root;
     private ConfiguredObjectRecord _portEntry;
     private UUID _rootId, _portEntryId;
-    private SystemContext _systemContext;
+    private SystemConfig _systemConfig;
     private TaskExecutor _taskExecutor;
 
     protected void setUp() throws Exception
@@ -77,19 +77,19 @@ public class ManagementModeStoreHandlerT
         _taskExecutor = new CurrentThreadTaskExecutor();
         _taskExecutor.start();
 
-        _systemContext = new SystemContextImpl(_taskExecutor, mock(EventLogger.class),
+        _systemConfig = new JsonSystemConfigImpl(_taskExecutor, mock(EventLogger.class),
                                                mock(LogRecorder.class), new BrokerOptions());
 
 
-        ConfiguredObjectRecord systemContextRecord = _systemContext.asObjectRecord();
+        ConfiguredObjectRecord systemContextRecord = _systemConfig.asObjectRecord();
 
 
 
-        _root = new ConfiguredObjectRecordImpl(_rootId, Broker.class.getSimpleName(), Collections.<String,Object>emptyMap(), Collections.singletonMap(SystemContext.class.getSimpleName(), systemContextRecord));
+        _root = new ConfiguredObjectRecordImpl(_rootId, Broker.class.getSimpleName(), Collections.<String,Object>emptyMap(), Collections.singletonMap(SystemConfig.class.getSimpleName(), systemContextRecord.getId()));
 
         _portEntry = mock(ConfiguredObjectRecord.class);
         when(_portEntry.getId()).thenReturn(_portEntryId);
-        when(_portEntry.getParents()).thenReturn(Collections.singletonMap(Broker.class.getSimpleName(), _root));
+        when(_portEntry.getParents()).thenReturn(Collections.singletonMap(Broker.class.getSimpleName(), _root.getId()));
         when(_portEntry.getType()).thenReturn(Port.class.getSimpleName());
 
         final ArgumentCaptor<ConfiguredObjectRecordHandler> recovererArgumentCaptor = ArgumentCaptor.forClass(ConfiguredObjectRecordHandler.class);
@@ -111,7 +111,7 @@ public class ManagementModeStoreHandlerT
         _options = new BrokerOptions();
         _handler = new ManagementModeStoreHandler(_store, _options);
 
-        _handler.openConfigurationStore(_systemContext);
+        _handler.openConfigurationStore(_systemConfig, false);
     }
 
     @Override
@@ -153,7 +153,7 @@ public class ManagementModeStoreHandlerT
     {
         _options.setManagementModeHttpPortOverride(9090);
         _handler = new ManagementModeStoreHandler(_store, _options);
-        _handler.openConfigurationStore(_systemContext);
+        _handler.openConfigurationStore(_systemConfig, false);
         ConfiguredObjectRecord root = getRootEntry();
         assertEquals("Unexpected root id", _rootId, root.getId());
         Collection<UUID> childrenIds = getChildrenIds(root);
@@ -165,7 +165,7 @@ public class ManagementModeStoreHandlerT
     {
         _options.setManagementModeRmiPortOverride(9090);
         _handler = new ManagementModeStoreHandler(_store, _options);
-        _handler.openConfigurationStore(_systemContext);
+        _handler.openConfigurationStore(_systemConfig, false);
 
         ConfiguredObjectRecord root = getRootEntry();
         assertEquals("Unexpected root id", _rootId, root.getId());
@@ -178,7 +178,7 @@ public class ManagementModeStoreHandlerT
     {
         _options.setManagementModeJmxPortOverride(9090);
         _handler = new ManagementModeStoreHandler(_store, _options);
-        _handler.openConfigurationStore(_systemContext);
+        _handler.openConfigurationStore(_systemConfig, false);
 
         ConfiguredObjectRecord root = getRootEntry();
         assertEquals("Unexpected root id", _rootId, root.getId());
@@ -193,7 +193,7 @@ public class ManagementModeStoreHandlerT
         _options.setManagementModeRmiPortOverride(2000);
         _options.setManagementModeJmxPortOverride(3000);
         _handler = new ManagementModeStoreHandler(_store, _options);
-        _handler.openConfigurationStore(_systemContext);
+        _handler.openConfigurationStore(_systemConfig, false);
 
         ConfiguredObjectRecord root = getRootEntry();
         assertEquals("Unexpected root id", _rootId, root.getId());
@@ -221,7 +221,7 @@ public class ManagementModeStoreHandlerT
     {
         _options.setManagementModeJmxPortOverride(9090);
         _handler = new ManagementModeStoreHandler(_store, _options);
-        _handler.openConfigurationStore(_systemContext);
+        _handler.openConfigurationStore(_systemConfig, false);
 
 
         UUID optionsPort = getOptionsPortId();
@@ -233,7 +233,7 @@ public class ManagementModeStoreHandlerT
     {
         _options.setManagementModeHttpPortOverride(9090);
         _handler = new ManagementModeStoreHandler(_store, _options);
-        _handler.openConfigurationStore(_systemContext);
+        _handler.openConfigurationStore(_systemConfig, false);
 
 
         UUID optionsPort = getOptionsPortId();
@@ -248,7 +248,7 @@ public class ManagementModeStoreHandlerT
         when(_portEntry.getAttributes()).thenReturn(attributes);
         _options.setManagementModeHttpPortOverride(9090);
         _handler = new ManagementModeStoreHandler(_store, _options);
-        _handler.openConfigurationStore(_systemContext);
+        _handler.openConfigurationStore(_systemConfig, false);
 
 
         ConfiguredObjectRecord portEntry = getEntry(_portEntryId);
@@ -262,7 +262,7 @@ public class ManagementModeStoreHandlerT
         when(_portEntry.getAttributes()).thenReturn(attributes);
         _options.setManagementModeRmiPortOverride(9090);
         _handler = new ManagementModeStoreHandler(_store, _options);
-        _handler.openConfigurationStore(_systemContext);
+        _handler.openConfigurationStore(_systemConfig, false);
 
 
         ConfiguredObjectRecord portEntry = getEntry(_portEntryId);
@@ -276,7 +276,7 @@ public class ManagementModeStoreHandlerT
         when(_portEntry.getAttributes()).thenReturn(attributes);
         _options.setManagementModeRmiPortOverride(9090);
         _handler = new ManagementModeStoreHandler(_store, _options);
-        _handler.openConfigurationStore(_systemContext);
+        _handler.openConfigurationStore(_systemConfig, false);
 
 
         ConfiguredObjectRecord portEntry = getEntry(_portEntryId);
@@ -299,7 +299,7 @@ public class ManagementModeStoreHandlerT
         Map<String, Object> attributes = new HashMap<String, Object>();
         attributes.put(VirtualHost.TYPE, "STANDARD");
 
-        final ConfiguredObjectRecord virtualHost = new ConfiguredObjectRecordImpl(virtualHostId, VirtualHost.class.getSimpleName(), attributes, Collections.singletonMap(Broker.class.getSimpleName(), _root));
+        final ConfiguredObjectRecord virtualHost = new ConfiguredObjectRecordImpl(virtualHostId, VirtualHost.class.getSimpleName(), attributes, Collections.singletonMap(Broker.class.getSimpleName(), _root.getId()));
         final ArgumentCaptor<ConfiguredObjectRecordHandler> recovererArgumentCaptor = ArgumentCaptor.forClass(ConfiguredObjectRecordHandler.class);
         doAnswer(
                 new Answer()
@@ -327,7 +327,7 @@ public class ManagementModeStoreHandlerT
         }
 
         _handler = new ManagementModeStoreHandler(_store, _options);
-        _handler.openConfigurationStore(_systemContext);
+        _handler.openConfigurationStore(_systemConfig, false);
 
         ConfiguredObjectRecord hostEntry = getEntry(virtualHostId);
         Map<String, Object> hostAttributes = new HashMap<String, Object>(hostEntry.getAttributes());
@@ -353,13 +353,13 @@ public class ManagementModeStoreHandlerT
         _options.setManagementModeRmiPortOverride(2000);
         _options.setManagementModeJmxPortOverride(3000);
         _handler = new ManagementModeStoreHandler(_store, _options);
-        _handler.openConfigurationStore(_systemContext);
+        _handler.openConfigurationStore(_systemConfig, false);
 
         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()));
+                Collections.singletonMap(Broker.class.getSimpleName(), getRootEntry().getId()));
         _handler.create(configurationEntry);
         verify(_store).create(any(ConfiguredObjectRecord.class));
     }
@@ -370,7 +370,7 @@ public class ManagementModeStoreHandlerT
         _options.setManagementModeRmiPortOverride(2000);
         _options.setManagementModeJmxPortOverride(3000);
         _handler = new ManagementModeStoreHandler(_store, _options);
-        _handler.openConfigurationStore(_systemContext);
+        _handler.openConfigurationStore(_systemConfig, false);
 
         ConfiguredObjectRecord root = getRootEntry();
         Map<String, Object> attributes = new HashMap<String, Object>();
@@ -385,7 +385,7 @@ public class ManagementModeStoreHandlerT
     {
         _options.setManagementModeHttpPortOverride(1000);
         _handler = new ManagementModeStoreHandler(_store, _options);
-        _handler.openConfigurationStore(_systemContext);
+        _handler.openConfigurationStore(_systemConfig, false);
 
         UUID portId = getOptionsPortId();
         Map<String, Object> attributes = new HashMap<String, Object>();
@@ -393,7 +393,7 @@ public class ManagementModeStoreHandlerT
         ConfiguredObjectRecord
                 configurationEntry = new ConfiguredObjectRecordImpl(portId, Port.class.getSimpleName(), attributes,
                                                                     Collections.singletonMap(Broker.class.getSimpleName(),
-                                                                                             getRootEntry()));
+                                                                                             getRootEntry().getId()));
         try
         {
             _handler.update(false, configurationEntry);
@@ -409,7 +409,7 @@ public class ManagementModeStoreHandlerT
     {
         _options.setManagementModeHttpPortOverride(1000);
         _handler = new ManagementModeStoreHandler(_store, _options);
-        _handler.openConfigurationStore(_systemContext);
+        _handler.openConfigurationStore(_systemConfig, false);
 
         ConfiguredObjectRecord record = new ConfiguredObjectRecord()
         {
@@ -432,7 +432,7 @@ public class ManagementModeStoreHandlerT
             }
 
             @Override
-            public Map<String, ConfiguredObjectRecord> getParents()
+            public Map<String, UUID> getParents()
             {
                 return null;
             }
@@ -445,7 +445,7 @@ public class ManagementModeStoreHandlerT
     {
         _options.setManagementModeHttpPortOverride(1000);
         _handler = new ManagementModeStoreHandler(_store, _options);
-        _handler.openConfigurationStore(_systemContext);
+        _handler.openConfigurationStore(_systemConfig, false);
 
         UUID portId = getOptionsPortId();
         ConfiguredObjectRecord record = mock(ConfiguredObjectRecord.class);
@@ -563,9 +563,9 @@ public class ManagementModeStoreHandlerT
 
             if(object.getParents() != null)
             {
-                for(ConfiguredObjectRecord parent : object.getParents().values())
+                for(UUID parent : object.getParents().values())
                 {
-                    if(parent.getId().equals(_parent.getId()))
+                    if(parent.equals(_parent.getId()))
                     {
                         _childIds.add(object.getId());
                     }

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java Sat Jul 26 22:57:11 2014
@@ -21,32 +21,32 @@
 package org.apache.qpid.server.configuration.store;
 
 import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
 import java.util.UUID;
 
-import org.apache.qpid.server.configuration.ConfigurationEntryStore;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ConfiguredObject;
 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.ConfiguredObjectRecord;
+import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.test.utils.QpidTestCase;
 
 public class StoreConfigurationChangeListenerTest extends QpidTestCase
 {
-    private ConfigurationEntryStore _store;
+    private DurableConfigurationStore _store;
     private StoreConfigurationChangeListener _listener;
 
     protected void setUp() throws Exception
     {
         super.setUp();
-        _store = mock(ConfigurationEntryStore.class);
+        _store = mock(DurableConfigurationStore.class);
         _listener = new StoreConfigurationChangeListener(_store);
     }
 

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java Sat Jul 26 22:57:11 2014
@@ -114,7 +114,7 @@ public abstract class AbstractDurableCon
         _parent = createVirtualHostNode(_storePath, _factory);
 
         _configStore = createConfigStore();
-        _configStore.openConfigurationStore(_parent);
+        _configStore.openConfigurationStore(_parent, false);
         _rootRecord = new ConfiguredObjectRecordImpl(UUID.randomUUID(), VirtualHost.class.getSimpleName(), Collections.<String, Object>emptyMap());
         _configStore.create(_rootRecord);
     }
@@ -263,14 +263,14 @@ public abstract class AbstractDurableCon
 
         private boolean matchesParents(ConfiguredObjectRecord binding)
         {
-            Map<String, ConfiguredObjectRecord> bindingParents = binding.getParents();
+            Map<String, UUID> bindingParents = binding.getParents();
             if(bindingParents.size() != _parents.size())
             {
                 return false;
             }
             for(Map.Entry<String,UUID> entry : _parents.entrySet())
             {
-                if(!bindingParents.get(entry.getKey()).getId().equals(entry.getValue()))
+                if(!bindingParents.get(entry.getKey()).equals(entry.getValue()))
                 {
                     return false;
                 }
@@ -490,7 +490,7 @@ public abstract class AbstractDurableCon
         when(objectRecord.getId()).thenReturn(_queueId);
         when(objectRecord.getType()).thenReturn(Queue.class.getSimpleName());
         when(objectRecord.getAttributes()).thenReturn(attributes);
-        when(objectRecord.getParents()).thenReturn(Collections.singletonMap(_rootRecord.getType(), _rootRecord));
+        when(objectRecord.getParents()).thenReturn(Collections.singletonMap(_rootRecord.getType(), _rootRecord.getId()));
         when(queue.asObjectRecord()).thenReturn(objectRecord);
         return queue;
     }
@@ -516,7 +516,7 @@ public abstract class AbstractDurableCon
         when(exchangeRecord.getId()).thenReturn(_exchangeId);
         when(exchangeRecord.getType()).thenReturn(Exchange.class.getSimpleName());
         when(exchangeRecord.getAttributes()).thenReturn(actualAttributes);
-        when(exchangeRecord.getParents()).thenReturn(Collections.singletonMap(_rootRecord.getType(), _rootRecord));
+        when(exchangeRecord.getParents()).thenReturn(Collections.singletonMap(_rootRecord.getType(), _rootRecord.getId()));
         when(exchange.asObjectRecord()).thenReturn(exchangeRecord);
         when(exchange.getEventLogger()).thenReturn(new EventLogger());
         return exchange;
@@ -526,7 +526,7 @@ public abstract class AbstractDurableCon
     {
         closeConfigStore();
         _configStore = createConfigStore();
-        _configStore.openConfigurationStore(_parent);
+        _configStore.openConfigurationStore(_parent, false);
     }
 
     protected abstract DurableConfigurationStore createConfigStore() throws Exception;

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java?rev=1613739&r1=1613738&r2=1613739&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/BrokerRecovererTest.java Sat Jul 26 22:57:11 2014
@@ -42,9 +42,9 @@ import org.apache.qpid.server.model.Brok
 import org.apache.qpid.server.model.BrokerModel;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.GroupProvider;
+import org.apache.qpid.server.model.JsonSystemConfigImpl;
 import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.SystemContext;
-import org.apache.qpid.server.model.SystemContextImpl;
+import org.apache.qpid.server.model.SystemConfig;
 
 public class BrokerRecovererTest extends TestCase
 {
@@ -53,7 +53,7 @@ public class BrokerRecovererTest extends
     private UUID _brokerId = UUID.randomUUID();
     private AuthenticationProvider<?> _authenticationProvider1;
     private UUID _authenticationProvider1Id = UUID.randomUUID();
-    private SystemContext<?> _systemContext;
+    private SystemConfig<?> _systemConfig;
     private TaskExecutor _taskExecutor;
 
     @Override
@@ -63,8 +63,8 @@ public class BrokerRecovererTest extends
 
         _taskExecutor = new CurrentThreadTaskExecutor();
         _taskExecutor.start();
-        _systemContext = new SystemContextImpl(_taskExecutor,
-                                               mock(EventLogger.class), mock(LogRecorder.class), mock(BrokerOptions.class));
+        _systemConfig = new JsonSystemConfigImpl(_taskExecutor,
+                                               mock(EventLogger.class), mock(LogRecorder.class), new BrokerOptions());
 
         when(_brokerEntry.getId()).thenReturn(_brokerId);
         when(_brokerEntry.getType()).thenReturn(Broker.class.getSimpleName());
@@ -73,7 +73,8 @@ public class BrokerRecovererTest extends
         attributesMap.put(Broker.NAME, getName());
 
         when(_brokerEntry.getAttributes()).thenReturn(attributesMap);
-        when(_brokerEntry.getParents()).thenReturn(Collections.singletonMap(SystemContext.class.getSimpleName(), _systemContext.asObjectRecord()));
+        when(_brokerEntry.getParents()).thenReturn(Collections.singletonMap(SystemConfig.class.getSimpleName(), _systemConfig
+                .getId()));
 
         //Add a base AuthenticationProvider for all tests
         _authenticationProvider1 = mock(AuthenticationProvider.class);
@@ -115,7 +116,7 @@ public class BrokerRecovererTest extends
         when(_brokerEntry.getAttributes()).thenReturn(entryAttributes);
 
         resolveObjects(_brokerEntry);
-        Broker<?> broker = _systemContext.getBroker();
+        Broker<?> broker = _systemConfig.getBroker();
 
         assertNotNull(broker);
 
@@ -137,7 +138,7 @@ public class BrokerRecovererTest extends
         authProviderAttrs.put(AuthenticationProvider.TYPE, "Anonymous");
 
         return new ConfiguredObjectRecordImpl(id, AuthenticationProvider.class.getSimpleName(), authProviderAttrs, Collections
-                .singletonMap(Broker.class.getSimpleName(), _brokerEntry));
+                .singletonMap(Broker.class.getSimpleName(), _brokerEntry.getId()));
     }
 
 
@@ -149,7 +150,7 @@ public class BrokerRecovererTest extends
         groupProviderAttrs.put("path", "/no-such-path");
 
         return new ConfiguredObjectRecordImpl(id, GroupProvider.class.getSimpleName(), groupProviderAttrs, Collections
-                .singletonMap(Broker.class.getSimpleName(), _brokerEntry));
+                .singletonMap(Broker.class.getSimpleName(), _brokerEntry.getId()));
     }
 
     public ConfiguredObjectRecord createPortRecord(UUID id, int port, Object authProviderRef)
@@ -161,7 +162,7 @@ public class BrokerRecovererTest extends
         portAttrs.put(Port.AUTHENTICATION_PROVIDER, authProviderRef);
 
         return new ConfiguredObjectRecordImpl(id, Port.class.getSimpleName(), portAttrs, Collections
-                .singletonMap(Broker.class.getSimpleName(), _brokerEntry));
+                .singletonMap(Broker.class.getSimpleName(), _brokerEntry.getId()));
     }
 
 
@@ -174,7 +175,7 @@ public class BrokerRecovererTest extends
                 portId,
                 5672,
                 "authProvider"));
-        Broker<?> broker = _systemContext.getBroker();
+        Broker<?> broker = _systemConfig.getBroker();
 
 
         assertNotNull(broker);
@@ -188,7 +189,7 @@ public class BrokerRecovererTest extends
         UUID authProviderId = UUID.randomUUID();
 
         resolveObjects(_brokerEntry, createAuthProviderRecord(authProviderId, "authProvider"));
-        Broker<?> broker = _systemContext.getBroker();
+        Broker<?> broker = _systemConfig.getBroker();
 
 
         assertNotNull(broker);
@@ -210,7 +211,7 @@ public class BrokerRecovererTest extends
                                       createPortRecord(portId, 5672, "authProvider"),
                                       createAuthProviderRecord(authProvider2Id, "authProvider2"),
                                       createPortRecord(port2Id, 5673, "authProvider2"));
-        Broker<?> broker = _systemContext.getBroker();
+        Broker<?> broker = _systemConfig.getBroker();
 
 
         assertNotNull(broker);
@@ -228,7 +229,7 @@ public class BrokerRecovererTest extends
         UUID authProviderId = UUID.randomUUID();
 
         resolveObjects(_brokerEntry, createGroupProviderRecord(authProviderId, "groupProvider"));
-        Broker<?> broker = _systemContext.getBroker();
+        Broker<?> broker = _systemConfig.getBroker();
 
 
         assertNotNull(broker);
@@ -253,7 +254,7 @@ public class BrokerRecovererTest extends
             try
             {
                 resolveObjects(_brokerEntry);
-                Broker<?> broker = _systemContext.getBroker();
+                Broker<?> broker = _systemConfig.getBroker();
                 broker.open();
                 fail("The broker creation should fail due to unsupported model version");
             }
@@ -278,7 +279,7 @@ public class BrokerRecovererTest extends
         try
         {
             UnresolvedConfiguredObject<? extends ConfiguredObject> recover =
-                    _systemContext.getObjectFactory().recover(_brokerEntry, _systemContext);
+                    _systemConfig.getObjectFactory().recover(_brokerEntry, _systemConfig);
 
             Broker<?> broker = (Broker<?>) recover.resolve();
             broker.open();
@@ -305,7 +306,7 @@ public class BrokerRecovererTest extends
             try
             {
                 UnresolvedConfiguredObject<? extends ConfiguredObject> recover =
-                        _systemContext.getObjectFactory().recover(_brokerEntry, _systemContext);
+                        _systemConfig.getObjectFactory().recover(_brokerEntry, _systemConfig);
                 Broker<?> broker = (Broker<?>) recover.resolve();
                 broker.open();
                 fail("The broker creation should fail due to unsupported model version");
@@ -324,7 +325,7 @@ public class BrokerRecovererTest extends
 
     private void resolveObjects(ConfiguredObjectRecord... records)
     {
-        GenericRecoverer recoverer = new GenericRecoverer(_systemContext, Broker.class.getSimpleName());
+        GenericRecoverer recoverer = new GenericRecoverer(_systemConfig, Broker.class.getSimpleName());
         recoverer.recover(Arrays.asList(records));
     }
 



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