You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2013/02/15 19:04:39 UTC

svn commit: r1446710 - in /qpid/branches/java-broker-config-qpid-4390/qpid/java: broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/ broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/ broker/src/main/java...

Author: orudyy
Date: Fri Feb 15 18:04:38 2013
New Revision: 1446710

URL: http://svn.apache.org/r1446710
Log:
QPID-4390: Save the configuration changes into the broker store

Added:
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java
Modified:
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostMBean.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfigurationChangeListener.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractAdapter.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MessageStoreCreator.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/TestBrokerConfiguration.java

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java?rev=1446710&r1=1446709&r2=1446710&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java Fri Feb 15 18:04:38 2013
@@ -290,6 +290,12 @@ public class JMXManagement extends Abstr
         }
     }
 
+    @Override
+    public void attributeSet(ConfiguredObject object, String attributeName, Object oldAttributeValue, Object newAttributeValue)
+    {
+        // no-op
+    }
+
     private void createAdditionalMBeansFromProviders(ConfiguredObject child, AMQManagedObject mbean) throws JMException
     {
         _children.put(child, mbean);

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostMBean.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostMBean.java?rev=1446710&r1=1446709&r2=1446710&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostMBean.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/mbeans/VirtualHostMBean.java Fri Feb 15 18:04:38 2013
@@ -254,4 +254,10 @@ public class VirtualHostMBean extends AM
         _managerMBean.unregister();
     }
 
+    @Override
+    public void attributeSet(ConfiguredObject object, String attributeName, Object oldAttributeValue, Object newAttributeValue)
+    {
+        // no-op
+    }
+
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java?rev=1446710&r1=1446709&r2=1446710&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java Fri Feb 15 18:04:38 2013
@@ -16,6 +16,7 @@ import org.apache.qpid.server.model.Port
 import org.apache.qpid.server.model.adapter.AuthenticationProviderFactory;
 import org.apache.qpid.server.model.adapter.BrokerAdapter;
 import org.apache.qpid.server.model.adapter.PortFactory;
+import org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener;
 import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.security.group.GroupPrincipalAccessor;
 import org.apache.qpid.server.stats.StatisticsGatherer;
@@ -47,8 +48,10 @@ public class BrokerRecoverer implements 
     @Override
     public Broker create(RecovererProvider recovererProvider, ConfigurationEntry entry, ConfiguredObject... parents)
     {
+        StoreConfigurationChangeListener storeChangeListener = new StoreConfigurationChangeListener(entry.getStore());
         BrokerAdapter broker = new BrokerAdapter(entry.getId(), entry.getAttributes(), _statisticsGatherer, _virtualHostRegistry,
                 _logRecorder, _rootMessageLogger, _authenticationProviderFactory, _portFactory, _taskExecutor);
+        broker.addChangeListener(storeChangeListener);
         Map<String, Collection<ConfigurationEntry>> childEntries = entry.getChildren();
         for (String type : childEntries.keySet())
         {
@@ -66,6 +69,7 @@ public class BrokerRecoverer implements 
                     throw new IllegalConfigurationException("Cannot create configured object for the entry " + childEntry);
                 }
                 broker.recoverChild(object);
+                object.addChangeListener(storeChangeListener);
             }
         }
         wireUpConfiguredObjects(broker, entry.getAttributes());

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java?rev=1446710&r1=1446709&r2=1446710&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java Fri Feb 15 18:04:38 2013
@@ -519,4 +519,10 @@ public class JsonConfigurationEntryStore
         return array;
     }
 
+    @Override
+    public String toString()
+    {
+        return "JsonConfigurationEntryStore [_storeFile=" + _storeFile + ", _rootId=" + _rootId + ", _initialStoreLocation="
+                + _initialStoreLocation + "]";
+    }
 }

Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java?rev=1446710&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java Fri Feb 15 18:04:38 2013
@@ -0,0 +1,205 @@
+/*
+ *
+ * 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.configuration.store;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.UUID;
+
+import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfigurationEntryStore;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfigurationChangeListener;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.Model;
+import org.apache.qpid.server.model.State;
+import org.apache.qpid.server.model.VirtualHost;
+
+public class StoreConfigurationChangeListener implements ConfigurationChangeListener
+{
+    private ConfigurationEntryStore _store;
+
+    public StoreConfigurationChangeListener(ConfigurationEntryStore store)
+    {
+        super();
+        _store = store;
+    }
+
+    @Override
+    public void stateChanged(ConfiguredObject object, State oldState, State newState)
+    {
+        if (newState == State.DELETED)
+        {
+            _store.remove(object.getId());
+            object.removeChangeListener(this);
+        }
+    }
+
+    @Override
+    public void childAdded(ConfiguredObject object, ConfiguredObject child)
+    {
+        // exclude VirtualHost children from storing in broker store
+        if (!(object instanceof VirtualHost))
+        {
+            child.addChangeListener(this);
+            ConfigurationEntry parentEntry = toConfigurationEntry(object);
+            ConfigurationEntry childEntry = toConfigurationEntry(child);
+            _store.save(parentEntry, childEntry);
+        }
+
+    }
+
+    @Override
+    public void childRemoved(ConfiguredObject object, ConfiguredObject child)
+    {
+        _store.save(toConfigurationEntry(object));
+    }
+
+    @Override
+    public void attributeSet(ConfiguredObject object, String attrinuteName, Object oldAttributeValue, Object newAttributeValue)
+    {
+        _store.save(toConfigurationEntry(object));
+    }
+
+    private ConfigurationEntry toConfigurationEntry(ConfiguredObject object)
+    {
+        Class<? extends ConfiguredObject> objectType = getConfiguredObjectType(object);
+        Set<UUID> childrenIds = getChildernIds(object, objectType);
+        ConfigurationEntry entry = new ConfigurationEntry(object.getId(), objectType.getSimpleName(),
+                object.getActualAttributes(), childrenIds, _store);
+        return entry;
+    }
+
+    private Set<UUID> getChildernIds(ConfiguredObject object, Class<? extends ConfiguredObject> objectType)
+    {
+        // Virtual Host children's IDs should not be stored in broker store
+        if (object instanceof VirtualHost)
+        {
+            return Collections.emptySet();
+        }
+        Set<UUID> childrenIds = new TreeSet<UUID>();
+        Collection<Class<? extends ConfiguredObject>> childClasses = Model.getInstance().getChildTypes(objectType);
+        if (childClasses != null)
+        {
+            for (Class<? extends ConfiguredObject> childClass : childClasses)
+            {
+                Collection<? extends ConfiguredObject> children = object.getChildren(childClass);
+                if (children != null)
+                {
+                    for (ConfiguredObject childObject : children)
+                    {
+                        childrenIds.add(childObject.getId());
+                    }
+                }
+            }
+        }
+        return childrenIds;
+    }
+
+    private Class<? extends ConfiguredObject> getConfiguredObjectType(ConfiguredObject object)
+    {
+        if (object instanceof Broker)
+        {
+            return Broker.class;
+        }
+        return getConfiguredObjectTypeFromImplementedInterfaces(object.getClass());
+    }
+
+    @SuppressWarnings("unchecked")
+    private Class<? extends ConfiguredObject> getConfiguredObjectTypeFromImplementedInterfaces(Class<?> objectClass)
+    {
+        // get all implemented interfaces extending ConfiguredObject
+        Set<Class<?>> interfaces = getImplementedInterfacesExtendingSuper(objectClass, ConfiguredObject.class);
+
+        if (interfaces.size() == 0)
+        {
+            throw new RuntimeException("Can not identify the configured object type");
+        }
+
+        if (interfaces.size() == 1)
+        {
+            return (Class<? extends ConfiguredObject>)interfaces.iterator().next();
+        }
+
+        Set<Class<?>> superInterfaces = new HashSet<Class<?>>();
+
+        // find all super interfaces
+        for (Class<?> interfaceClass : interfaces)
+        {
+            for (Class<?> interfaceClass2 : interfaces)
+            {
+                if (interfaceClass != interfaceClass2)
+                {
+                    if (interfaceClass.isAssignableFrom(interfaceClass2))
+                    {
+                        superInterfaces.add(interfaceClass);
+                    }
+                }
+            }
+        }
+
+        // remove super interfaces
+        for (Class<?> superInterface : superInterfaces)
+        {
+            interfaces.remove(superInterface);
+        }
+
+        if (interfaces.size() == 1)
+        {
+            return (Class<? extends ConfiguredObject>)interfaces.iterator().next();
+        }
+        else
+        {
+            throw new RuntimeException("Can not identify the configured object type as an it implements"
+                    + " more than one configured object interfaces: " + interfaces);
+        }
+
+    }
+
+    private Set<Class<?>> getImplementedInterfacesExtendingSuper(Class<?> classInstance, Class<?> superInterface)
+    {
+        Set<Class<?>> interfaces = new HashSet<Class<?>>();
+        Class<?>[] classInterfaces = classInstance.getInterfaces();
+        for (Class<?> interfaceClass : classInterfaces)
+        {
+            if (interfaceClass!= superInterface && superInterface.isAssignableFrom(interfaceClass))
+            {
+                interfaces.add(interfaceClass);
+            }
+        }
+        Class<?> superClass = classInstance.getSuperclass();
+        if (superClass != null)
+        {
+            Set<Class<?>> superClassInterfaces = getImplementedInterfacesExtendingSuper(superClass, superInterface);
+            interfaces.addAll(superClassInterfaces);
+        }
+        return interfaces;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "StoreConfigurationChangeListener [store=" + _store + "]";
+    }
+}

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfigurationChangeListener.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfigurationChangeListener.java?rev=1446710&r1=1446709&r2=1446710&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfigurationChangeListener.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfigurationChangeListener.java Fri Feb 15 18:04:38 2013
@@ -36,4 +36,5 @@ public interface ConfigurationChangeList
 
     void childRemoved(ConfiguredObject object, ConfiguredObject child);
 
+    void attributeSet(ConfiguredObject object, String attributeName, Object oldAttributeValue, Object newAttributeValue);
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractAdapter.java?rev=1446710&r1=1446709&r2=1446710&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractAdapter.java Fri Feb 15 18:04:38 2013
@@ -24,6 +24,7 @@ import java.security.AccessControlExcept
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
@@ -111,7 +112,8 @@ abstract class AbstractAdapter implement
     {
         synchronized (_changeListeners)
         {
-            for(ConfigurationChangeListener listener : _changeListeners)
+            List<ConfigurationChangeListener> copy = new ArrayList<ConfigurationChangeListener>(_changeListeners);
+            for(ConfigurationChangeListener listener : copy)
             {
                 listener.stateChanged(this, currentState, desiredState);
             }
@@ -149,7 +151,8 @@ abstract class AbstractAdapter implement
     {
         synchronized (_changeListeners)
         {
-            for(ConfigurationChangeListener listener : _changeListeners)
+            List<ConfigurationChangeListener> copy = new ArrayList<ConfigurationChangeListener>(_changeListeners);
+            for(ConfigurationChangeListener listener : copy)
             {
                 listener.childAdded(this, child);
             }
@@ -160,13 +163,26 @@ abstract class AbstractAdapter implement
     {
         synchronized (_changeListeners)
         {
-            for(ConfigurationChangeListener listener : _changeListeners)
+            List<ConfigurationChangeListener> copy = new ArrayList<ConfigurationChangeListener>(_changeListeners);
+            for(ConfigurationChangeListener listener : copy)
             {
                 listener.childRemoved(this, child);
             }
         }
     }
 
+    protected void attributeSet(String attrinuteName, Object oldAttributeValue, Object newAttributeValue)
+    {
+        synchronized (_changeListeners)
+        {
+            List<ConfigurationChangeListener> copy = new ArrayList<ConfigurationChangeListener>(_changeListeners);
+            for(ConfigurationChangeListener listener : copy)
+            {
+                listener.attributeSet(this, attrinuteName, oldAttributeValue, newAttributeValue);
+            }
+        }
+    }
+
     private final Object getDefaultAttribute(String name)
     {
         return _defaultAttributes.get(name);
@@ -205,16 +221,19 @@ abstract class AbstractAdapter implement
     {
         if (_taskExecutor.isTaskExecutorThread())
         {
-            return changeAttribute(name, expected, desired);
+            if (changeAttribute(name, expected, desired))
+            {
+                attributeSet(name, expected, desired);
+            }
         }
         else
         {
             _taskExecutor.submitAndWait(new SetAttributeTask(this, name, expected, desired));
-            return getAttribute(name);
         }
+        return getAttribute(name);
     }
 
-    protected Object changeAttribute(final String name, final Object expected, final Object desired)
+    protected boolean changeAttribute(final String name, final Object expected, final Object desired)
     {
         synchronized (_attributes)
         {
@@ -223,11 +242,11 @@ abstract class AbstractAdapter implement
                || (currentValue != null && currentValue.equals(expected)))
             {
                 _attributes.put(name, desired);
-                return desired;
+                return true;
             }
             else
             {
-                return currentValue;
+                return false;
             }
         }
     }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java?rev=1446710&r1=1446709&r2=1446710&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AuthenticationProviderAdapter.java Fri Feb 15 18:04:38 2013
@@ -505,12 +505,13 @@ public abstract class AuthenticationProv
             }
 
             @Override
-            public Object changeAttribute(String name, Object expected, Object desired)
+            public boolean changeAttribute(String name, Object expected, Object desired)
                     throws IllegalStateException, AccessControlException, IllegalArgumentException
             {
                 if(name.equals(PASSWORD))
                 {
                     setPassword((String)desired);
+                    return true;
                 }
                 return super.changeAttribute(name, expected, desired);
             }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java?rev=1446710&r1=1446709&r2=1446710&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java Fri Feb 15 18:04:38 2013
@@ -308,11 +308,14 @@ public class BrokerAdapter extends Abstr
         return virtualHostAdapter;
     }
 
-    private boolean deleteVirtualHost(final VirtualHost vhost)
-        throws AccessControlException, IllegalStateException
+    private boolean deleteVirtualHost(final VirtualHost vhost) throws AccessControlException, IllegalStateException
     {
-        //TODO implement deleteVirtualHost
-        throw new UnsupportedOperationException("Not yet implemented");
+        synchronized (_vhostAdapters)
+        {
+            _vhostAdapters.remove(vhost);
+        }
+        vhost.removeChangeListener(this);
+        return true;
     }
 
     public String getName()
@@ -759,6 +762,12 @@ public class BrokerAdapter extends Abstr
         // no-op
     }
 
+    @Override
+    public void attributeSet(ConfiguredObject object, String attributeName, Object oldAttributeValue, Object newAttributeValue)
+    {
+        // no-op
+    }
+
     private void addPlugin(ConfiguredObject plugin)
     {
         synchronized(_plugins)

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java?rev=1446710&r1=1446709&r2=1446710&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/QueueAdapter.java Fri Feb 15 18:04:38 2013
@@ -207,47 +207,47 @@ final class QueueAdapter extends Abstrac
     }
 
     @Override
-    public Object changeAttribute(String name, Object expected, Object desired) throws IllegalStateException, AccessControlException, IllegalArgumentException
+    public boolean changeAttribute(String name, Object expected, Object desired) throws IllegalStateException, AccessControlException, IllegalArgumentException
     {
         try
         {
             if(ALERT_REPEAT_GAP.equals(name))
             {
                 _queue.setMinimumAlertRepeatGap((Long)desired);
-                return desired;
+                return true;
             }
             else if(ALERT_THRESHOLD_MESSAGE_AGE.equals(name))
             {
                 _queue.setMaximumMessageAge((Long)desired);
-                return desired;
+                return true;
             }
             else if(ALERT_THRESHOLD_MESSAGE_SIZE.equals(name))
             {
                 _queue.setMaximumMessageSize((Long)desired);
-                return desired;
+                return true;
             }
             else if(ALERT_THRESHOLD_QUEUE_DEPTH_BYTES.equals(name))
             {
                 _queue.setMaximumQueueDepth((Long)desired);
-                return desired;
+                return true;
             }
             else if(ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES.equals(name))
             {
                 _queue.setMaximumMessageCount((Long)desired);
-                return desired;
+                return true;
             }
             else if(ALTERNATE_EXCHANGE.equals(name))
             {
                 // In future we may want to accept a UUID as an alternative way to identifying the exchange
                 ExchangeAdapter alternateExchange = (ExchangeAdapter) desired;
                 _queue.setAlternateExchange(alternateExchange == null ? null : alternateExchange.getExchange());
-                return desired;
+                return true;
             }
             else if(EXCLUSIVE.equals(name))
             {
                 Boolean exclusiveFlag = (Boolean) desired;
                 _queue.setExclusive(exclusiveFlag);
-                return desired;
+                return true;
             }
             else if(MESSAGE_GROUP_KEY.equals(name))
             {
@@ -268,7 +268,7 @@ final class QueueAdapter extends Abstrac
             else if(MAXIMUM_DELIVERY_ATTEMPTS.equals(name))
             {
                 _queue.setMaximumDeliveryCount((Integer)desired);
-                return desired;
+                return true;
             }
             else if(NO_LOCAL.equals(name))
             {
@@ -281,12 +281,12 @@ final class QueueAdapter extends Abstrac
             else if(QUEUE_FLOW_CONTROL_SIZE_BYTES.equals(name))
             {
                 _queue.setCapacity((Long)desired);
-                return desired;
+                return true;
             }
             else if(QUEUE_FLOW_RESUME_SIZE_BYTES.equals(name))
             {
                 _queue.setFlowResumeCapacity((Long)desired);
-                return desired;
+                return true;
             }
             else if(QUEUE_FLOW_STOPPED.equals(name))
             {
@@ -303,7 +303,7 @@ final class QueueAdapter extends Abstrac
             else if (DESCRIPTION.equals(name))
             {
                 _queue.setDescription((String) desired);
-                return desired;
+                return true;
             }
 
             return super.changeAttribute(name, expected, desired);

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java?rev=1446710&r1=1446709&r2=1446710&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java Fri Feb 15 18:04:38 2013
@@ -406,7 +406,28 @@ public final class VirtualHostAdapter ex
 
     public State getActualState()
     {
-        return getDesiredState();
+        if (_virtualHost == null)
+        {
+            return State.INITIALISING;
+        }
+        else
+        {
+            org.apache.qpid.server.virtualhost.State implementationState = _virtualHost.getState();
+            switch(implementationState)
+            {
+            case INITIALISING:
+                return State.INITIALISING;
+            case ACTIVE:
+                return State.ACTIVE;
+            case PASSIVE:
+                return State.QUIESCED;
+            case STOPPED:
+                return State.STOPPED;
+            default:
+                // unexpected state
+                return null;
+            }
+        }
     }
 
     public boolean isDurable()
@@ -932,6 +953,15 @@ public final class VirtualHostAdapter ex
             }
             return true;
         }
+        else if (desiredState == State.DELETED)
+        {
+            //TODO: add ACL check to authorize the operation
+            if (_virtualHost != null && _virtualHost.getState() == org.apache.qpid.server.virtualhost.State.ACTIVE)
+            {
+                setDesiredState(currentState, State.STOPPED);
+            }
+            return true;
+        }
         return false;
     }
 

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MessageStoreCreator.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MessageStoreCreator.java?rev=1446710&r1=1446709&r2=1446710&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MessageStoreCreator.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/store/MessageStoreCreator.java Fri Feb 15 18:04:38 2013
@@ -20,6 +20,8 @@
  */
 package org.apache.qpid.server.store;
 
+import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -56,4 +58,9 @@ public class MessageStoreCreator
         }
         return factory.createMessageStore();
     }
+
+    public Collection<MessageStoreFactory> getFactories()
+    {
+        return Collections.unmodifiableCollection(_factories.values());
+    }
 }

Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java?rev=1446710&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListenerTest.java Fri Feb 15 18:04:38 2013
@@ -0,0 +1,83 @@
+package org.apache.qpid.server.configuration.store;
+
+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.when;
+
+import java.util.UUID;
+
+import org.apache.qpid.server.configuration.ConfigurationEntry;
+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.Queue;
+import org.apache.qpid.server.model.State;
+import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.test.utils.QpidTestCase;
+
+public class StoreConfigurationChangeListenerTest extends QpidTestCase
+{
+    private ConfigurationEntryStore _store;
+    private StoreConfigurationChangeListener _listener;
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        _store = mock(ConfigurationEntryStore.class);
+        _listener = new StoreConfigurationChangeListener(_store);
+    }
+
+    public void testStateChanged()
+    {
+        notifyBrokerStarted();
+        UUID id = UUID.randomUUID();
+        ConfiguredObject object = mock(VirtualHost.class);
+        when(object.getId()).thenReturn(id);
+        _listener.stateChanged(object, State.ACTIVE, State.DELETED);
+        verify(_store).remove(id);
+    }
+
+    public void testChildAdded()
+    {
+        notifyBrokerStarted();
+        Broker broker = mock(Broker.class);
+        VirtualHost child = mock(VirtualHost.class);
+        _listener.childAdded(broker, child);
+        verify(_store).save(any(ConfigurationEntry.class), any(ConfigurationEntry.class));
+    }
+
+    public void testChildRemoved()
+    {
+        notifyBrokerStarted();
+        Broker broker = mock(Broker.class);
+        VirtualHost child = mock(VirtualHost.class);
+        _listener.childRemoved(broker, child);
+        verify(_store).save(any(ConfigurationEntry.class));
+    }
+
+    public void testAttributeSet()
+    {
+        notifyBrokerStarted();
+        Broker broker = mock(Broker.class);
+        _listener.attributeSet(broker, Broker.FLOW_CONTROL_SIZE_BYTES, null, 1);
+        verify(_store).save(any(ConfigurationEntry.class));
+    }
+
+    public void testChildAddedForVirtualHost()
+    {
+        notifyBrokerStarted();
+
+        VirtualHost object = mock(VirtualHost.class);
+        Queue queue = mock(Queue.class);
+        _listener.childAdded(object, queue);
+        verifyNoMoreInteractions(_store);
+    }
+
+    private void notifyBrokerStarted()
+    {
+        Broker broker = mock(Broker.class);
+        _listener.stateChanged(broker, State.INITIALISING, State.ACTIVE);
+    }
+}

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java?rev=1446710&r1=1446709&r2=1446710&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java Fri Feb 15 18:04:38 2013
@@ -50,7 +50,7 @@ public class Asserts
     {
         assertNotNull("Virtualhost " + virtualHostName + " data are not found", virtualHost);
         assertAttributesPresent(virtualHost, VirtualHost.AVAILABLE_ATTRIBUTES, VirtualHost.TIME_TO_LIVE,
-                VirtualHost.CREATED, VirtualHost.UPDATED, VirtualHost.SUPPORTED_QUEUE_TYPES, VirtualHost.STORE_PATH);
+                VirtualHost.CREATED, VirtualHost.UPDATED, VirtualHost.SUPPORTED_QUEUE_TYPES, VirtualHost.STORE_PATH, VirtualHost.CONFIG_PATH);
 
         assertEquals("Unexpected value of attribute " + VirtualHost.NAME, virtualHostName, virtualHost.get(VirtualHost.NAME));
         assertNotNull("Unexpected value of attribute " + VirtualHost.ID, virtualHost.get(VirtualHost.ID));

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java?rev=1446710&r1=1446709&r2=1446710&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/VirtualHostRestTest.java Fri Feb 15 18:04:38 2013
@@ -20,6 +20,7 @@
  */
 package org.apache.qpid.systest.rest;
 
+import java.io.File;
 import java.io.IOException;
 import java.net.HttpURLConnection;
 import java.util.HashMap;
@@ -29,11 +30,15 @@ import java.util.Map;
 import javax.jms.Session;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.XMLConfiguration;
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.server.model.Exchange;
 import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.queue.AMQQueueFactory;
+import org.apache.qpid.test.utils.TestFileUtils;
+import org.apache.qpid.util.FileUtils;
 import org.codehaus.jackson.JsonGenerationException;
 import org.codehaus.jackson.map.JsonMappingException;
 
@@ -98,6 +103,72 @@ public class VirtualHostRestTest extends
         Asserts.assertConnection(connections.get(0), _connection);
     }
 
+    public void testPutCreateVirtualHostUsingStoreType() throws Exception
+    {
+        String hostName = getTestName();
+        String storeType = getTestProfileMessageStoreType();
+        String storeLocation = createHost(hostName, storeType, null);
+        try
+        {
+            // make sure that the host is saved in the broker store
+            restartBroker();
+            Map<String, Object> hostDetails = getRestTestHelper().getJsonAsSingletonList("/rest/virtualhost/" + hostName);
+            Asserts.assertVirtualHost(hostName, hostDetails);
+            assertEquals("Unexpected store type", storeType, hostDetails.get(VirtualHost.STORE_TYPE));
+
+            assertNewVirtualHost(hostDetails);
+        }
+        finally
+        {
+            if (storeLocation != null)
+            {
+                FileUtils.delete(new File(storeLocation), true);
+            }
+        }
+    }
+
+    public void testPutCreateVirtualHostUsingConfigPath() throws Exception
+    {
+        String hostName = getTestName();
+        File configFile = TestFileUtils.createTempFile(this, hostName + "-config.xml");
+        String configPath = configFile.getAbsolutePath();
+        String storeLocation = getStoreLocation(hostName);
+        createAndSaveVirtualHostConfiguration(hostName, configFile, storeLocation);
+        createHost(hostName, null, configPath);
+        try
+        {
+            // make sure that the host is saved in the broker store
+            restartBroker();
+            Map<String, Object> hostDetails = getRestTestHelper().getJsonAsSingletonList("/rest/virtualhost/" + hostName);
+            Asserts.assertVirtualHost(hostName, hostDetails);
+            assertEquals("Unexpected config path", configPath, hostDetails.get(VirtualHost.CONFIG_PATH));
+
+            assertNewVirtualHost(hostDetails);
+        }
+        finally
+        {
+            if (storeLocation != null)
+            {
+                FileUtils.delete(new File(storeLocation), true);
+            }
+            configFile.delete();
+        }
+    }
+
+    public void testDeleteHost() throws Exception
+    {
+        String hostToDelete = TEST3_VIRTUALHOST;
+        HttpURLConnection connection = getRestTestHelper().openManagementConnection("/rest/virtualhost/" + hostToDelete, "DELETE");
+        connection.connect();
+        assertEquals("Unexpected response code", 200, connection.getResponseCode());
+
+        // make sure that changes are saved in the broker store
+        restartBroker();
+
+        List<Map<String, Object>> hosts = getRestTestHelper().getJsonAsList("/rest/virtualhost/" + hostToDelete);
+        assertEquals("Host should be deleted", 0, hosts.size());
+    }
+
     public void testPutCreateQueue() throws Exception
     {
         String queueName = getTestQueueName();
@@ -431,4 +502,75 @@ public class VirtualHostRestTest extends
         return responseCode;
     }
 
+    private String createHost(String hostName, String storeType, String configPath) throws IOException, JsonGenerationException,
+            JsonMappingException
+    {
+        String storePath = getStoreLocation(hostName);
+        int responseCode = tryCreateVirtualHost(hostName, storeType, storePath, configPath);
+        assertEquals("Unexpected response code", 201, responseCode);
+        return storePath;
+    }
+
+    private String getStoreLocation(String hostName)
+    {
+        return new File(TMP_FOLDER, "store-" + hostName + "-" + System.currentTimeMillis()).getAbsolutePath();
+    }
+
+    private int tryCreateVirtualHost(String hostName, String storeType, String storePath, String configPath) throws IOException,
+            JsonGenerationException, JsonMappingException
+    {
+        HttpURLConnection connection = getRestTestHelper().openManagementConnection("/rest/virtualhost/" + hostName, "PUT");
+
+        Map<String, Object> hostData = new HashMap<String, Object>();
+        hostData.put(VirtualHost.NAME, hostName);
+        if (storeType == null)
+        {
+            hostData.put(VirtualHost.CONFIG_PATH, configPath);
+        }
+        else
+        {
+            hostData.put(VirtualHost.STORE_PATH, storePath);
+            hostData.put(VirtualHost.STORE_TYPE, storeType);
+        }
+
+        getRestTestHelper().writeJsonRequest(connection, hostData);
+        int responseCode = connection.getResponseCode();
+        connection.disconnect();
+        return responseCode;
+    }
+
+    private XMLConfiguration createAndSaveVirtualHostConfiguration(String hostName, File configFile, String storeLocation)
+            throws ConfigurationException
+    {
+        XMLConfiguration testConfiguration = new XMLConfiguration();
+        testConfiguration.setProperty("virtualhosts.virtualhost." + hostName + ".store.class",
+                getTestProfileMessageStoreClassName());
+        testConfiguration.setProperty("virtualhosts.virtualhost." + hostName + ".store.environment-path", storeLocation);
+        testConfiguration.save(configFile);
+        return testConfiguration;
+    }
+
+    private void assertNewVirtualHost(Map<String, Object> hostDetails)
+    {
+        @SuppressWarnings("unchecked")
+        Map<String, Object> statistics = (Map<String, Object>) hostDetails.get(Asserts.STATISTICS_ATTRIBUTE);
+        assertEquals("Unexpected number of exchanges in statistics", EXPECTED_EXCHANGES.length,
+                statistics.get(VirtualHost.EXCHANGE_COUNT));
+        assertEquals("Unexpected number of queues in statistics", 0, statistics.get(VirtualHost.QUEUE_COUNT));
+        assertEquals("Unexpected number of connections in statistics", 0, statistics.get(VirtualHost.CONNECTION_COUNT));
+
+        @SuppressWarnings("unchecked")
+        List<Map<String, Object>> exchanges = (List<Map<String, Object>>) hostDetails.get(VIRTUALHOST_EXCHANGES_ATTRIBUTE);
+        assertEquals("Unexpected number of exchanges", EXPECTED_EXCHANGES.length, exchanges.size());
+        RestTestHelper restTestHelper = getRestTestHelper();
+        Asserts.assertDurableExchange("amq.fanout", "fanout", restTestHelper.find(Exchange.NAME, "amq.fanout", exchanges));
+        Asserts.assertDurableExchange("amq.topic", "topic", restTestHelper.find(Exchange.NAME, "amq.topic", exchanges));
+        Asserts.assertDurableExchange("amq.direct", "direct", restTestHelper.find(Exchange.NAME, "amq.direct", exchanges));
+        Asserts.assertDurableExchange("amq.match", "headers", restTestHelper.find(Exchange.NAME, "amq.match", exchanges));
+        Asserts.assertDurableExchange("<<default>>", "direct", restTestHelper.find(Exchange.NAME, "<<default>>", exchanges));
+
+        assertNull("Unexpected queues", hostDetails.get(VIRTUALHOST_QUEUES_ATTRIBUTE));
+        assertNull("Unexpected connections", hostDetails.get(VIRTUALHOST_CONNECTIONS_ATTRIBUTE));
+    }
+
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java?rev=1446710&r1=1446709&r2=1446710&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java Fri Feb 15 18:04:38 2013
@@ -23,6 +23,7 @@ import java.io.PrintStream;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -65,7 +66,10 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.model.Port;
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.protocol.AmqpProtocolVersion;
+import org.apache.qpid.server.store.MemoryMessageStore;
 import org.apache.qpid.server.store.MessageStoreConstants;
+import org.apache.qpid.server.store.MessageStoreCreator;
+import org.apache.qpid.server.store.MessageStoreFactory;
 import org.apache.qpid.server.store.derby.DerbyMessageStore;
 import org.apache.qpid.url.URLSyntaxException;
 import org.apache.qpid.util.FileUtils;
@@ -104,6 +108,8 @@ public class QpidBrokerTestCase extends 
 
     private static final String DEFAULT_INITIAL_CONTEXT = "org.apache.qpid.jndi.PropertiesFileInitialContextFactory";
 
+    private static Map<String, String> supportedStoresClassToTypeMapping = new HashMap<String, String>();
+
     static
     {
         String initialContext = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
@@ -112,6 +118,13 @@ public class QpidBrokerTestCase extends 
         {
             System.setProperty(Context.INITIAL_CONTEXT_FACTORY, DEFAULT_INITIAL_CONTEXT);
         }
+
+        MessageStoreCreator messageStoreCreator = new MessageStoreCreator();
+        Collection<MessageStoreFactory> factories = messageStoreCreator.getFactories();
+        for (MessageStoreFactory messageStoreFactory : factories)
+        {
+            supportedStoresClassToTypeMapping.put(messageStoreFactory.createMessageStore().getClass().getName(), messageStoreFactory.getType());
+        }
     }
 
     // system properties
@@ -619,14 +632,16 @@ public class QpidBrokerTestCase extends 
         return configLocation.getAbsolutePath().replace(workingDirectory.getAbsolutePath(), "").substring(1);
     }
 
-    protected String saveTestConfiguration(int port, TestBrokerConfiguration testConfiguration) throws ConfigurationException
+    protected String saveTestConfiguration(int port, TestBrokerConfiguration testConfiguration)
     {
-        // Specify the test config file
         String testConfig = getTestConfigFile(port);
         String relative = getPathRelativeToWorkingDirectory(testConfig);
-        _logger.info("Saving test broker configuration at: " + testConfig);
-
-        testConfiguration.save(new File(testConfig));
+        if (!testConfiguration.isSaved())
+        {
+            _logger.info("Saving test broker configuration at: " + testConfig);
+            testConfiguration.save(new File(testConfig));
+            testConfiguration.setSaved(true);
+        }
         return relative;
     }
 
@@ -1363,4 +1378,14 @@ public class QpidBrokerTestCase extends 
         _testVirtualhosts = testVirtualhosts;
     }
 
+    public String getTestProfileMessageStoreType()
+    {
+        final String storeClass = getTestProfileMessageStoreClassName();
+        if (storeClass == null)
+        {
+            return MemoryMessageStore.TYPE;
+        }
+        return supportedStoresClassToTypeMapping.get(storeClass);
+    }
+
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/TestBrokerConfiguration.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/TestBrokerConfiguration.java?rev=1446710&r1=1446709&r2=1446710&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/TestBrokerConfiguration.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/TestBrokerConfiguration.java Fri Feb 15 18:04:38 2013
@@ -55,6 +55,7 @@ public class TestBrokerConfiguration
     public static final String ENTRY_NAME_ANONYMOUS_PROVIDER = "anonymous";
 
     private JsonConfigurationEntryStore _store;
+    private boolean _saved;
 
     public TestBrokerConfiguration(String storeType, String intialStoreLocation)
     {
@@ -214,4 +215,15 @@ public class TestBrokerConfiguration
         _store.save(newEntry);
         return true;
     }
+
+    public boolean isSaved()
+    {
+        return _saved;
+    }
+
+    public void setSaved(boolean saved)
+    {
+        _saved = saved;
+    }
+
 }



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