qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1583597 [3/8] - in /qpid/trunk: ./ qpid/ qpid/cpp/src/ qpid/cpp/src/tests/ qpid/java/ qpid/java/bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/ qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleyd...
Date Tue, 01 Apr 2014 10:35:37 GMT
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java Tue Apr  1 10:35:33 2014
@@ -20,7 +20,6 @@
  */
 package org.apache.qpid.server.model.adapter;
 
-import java.io.File;
 import java.lang.reflect.Type;
 import java.security.AccessControlException;
 import java.util.ArrayList;
@@ -31,15 +30,9 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.commons.configuration.CompositeConfiguration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.configuration.SystemConfiguration;
 import org.apache.log4j.Logger;
 import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
-import org.apache.qpid.server.configuration.VirtualHostConfiguration;
-import org.apache.qpid.server.configuration.XmlConfigurationUtilities.MyConfiguration;
 import org.apache.qpid.server.exchange.ExchangeImpl;
 import org.apache.qpid.server.message.MessageInstance;
 import org.apache.qpid.server.message.ServerMessage;
@@ -55,6 +48,7 @@ import org.apache.qpid.server.store.Mess
 import org.apache.qpid.server.txn.LocalTransaction;
 import org.apache.qpid.server.txn.ServerTransaction;
 import org.apache.qpid.server.util.MapValueConverter;
+import org.apache.qpid.server.util.ParameterizedTypeImpl;
 import org.apache.qpid.server.plugin.VirtualHostFactory;
 import org.apache.qpid.server.util.ServerScopedRuntimeException;
 import org.apache.qpid.server.virtualhost.ExchangeExistsException;
@@ -72,10 +66,32 @@ public final class VirtualHostAdapter ex
     public static final Map<String, Type> ATTRIBUTE_TYPES = Collections.unmodifiableMap(new HashMap<String, Type>(){{
         put(NAME, String.class);
         put(TYPE, String.class);
-        put(STORE_PATH, String.class);
-        put(STORE_TYPE, String.class);
-        put(CONFIG_PATH, String.class);
         put(STATE, State.class);
+
+        put(QUEUE_ALERT_REPEAT_GAP, Long.class);
+        put(QUEUE_ALERT_THRESHOLD_MESSAGE_AGE, Long.class);
+        put(QUEUE_ALERT_THRESHOLD_MESSAGE_SIZE, Long.class);
+        put(QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_BYTES, Long.class);
+        put(QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES, Long.class);
+        put(QUEUE_DEAD_LETTER_QUEUE_ENABLED, Boolean.class);
+        put(QUEUE_MAXIMUM_DELIVERY_ATTEMPTS, Integer.class);
+        put(QUEUE_FLOW_CONTROL_SIZE_BYTES, Long.class);
+        put(QUEUE_FLOW_RESUME_SIZE_BYTES, Long.class);
+
+        put(HOUSEKEEPING_CHECK_PERIOD, Long.class);
+        put(STORE_TRANSACTION_IDLE_TIMEOUT_CLOSE, Long.class);
+        put(STORE_TRANSACTION_IDLE_TIMEOUT_WARN, Long.class);
+        put(STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE, Long.class);
+        put(STORE_TRANSACTION_OPEN_TIMEOUT_WARN, Long.class);
+
+        put(MESSAGE_STORE_SETTINGS, new ParameterizedTypeImpl(Map.class, String.class, Object.class));
+        put(CONFIGURATION_STORE_SETTINGS, new ParameterizedTypeImpl(Map.class, String.class, Object.class));
+
+    }});
+
+    @SuppressWarnings("serial")
+    private static final Map<String, Object> DEFAULTS = Collections.unmodifiableMap(new HashMap<String, Object>(){{
+        put(HOUSE_KEEPING_THREAD_COUNT, Runtime.getRuntime().availableProcessors());
     }});
 
     private org.apache.qpid.server.virtualhost.VirtualHost _virtualHost;
@@ -89,7 +105,7 @@ public final class VirtualHostAdapter ex
 
     public VirtualHostAdapter(UUID id, Map<String, Object> attributes, Broker<?> broker, StatisticsGatherer brokerStatisticsGatherer, TaskExecutor taskExecutor)
     {
-        super(id, Collections.<String,Object>emptyMap(), MapValueConverter.convert(attributes, ATTRIBUTE_TYPES, false), taskExecutor, false);
+        super(id, DEFAULTS, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES, false), taskExecutor, false);
         _broker = broker;
         _brokerStatisticsGatherer = brokerStatisticsGatherer;
         validateAttributes();
@@ -103,58 +119,19 @@ public final class VirtualHostAdapter ex
         {
             throw new IllegalConfigurationException("Virtual host name must be specified");
         }
-
-        String configurationFile = (String) getAttribute(CONFIG_PATH);
-        String type = (String) getAttribute(TYPE);
-
-        boolean invalidAttributes = false;
-        if (configurationFile == null)
+        String type = getType();
+        if (type == null || "".equals(type.trim()))
         {
-            if (type == null)
-            {
-                invalidAttributes = true;
-            }
-            else
-            {
-                validateAttributes(type);
-            }
-        }/*
-        else
-        {
-            if (type != null)
-            {
-                invalidAttributes = true;
-            }
-
-        }*/
-        if (invalidAttributes)
-        {
-            throw new IllegalConfigurationException("Please specify either the 'configPath' attribute or 'type' attributes");
-        }
-
-        // pre-load the configuration in order to validate
-        try
-        {
-            createVirtualHostConfiguration(name);
+            throw new IllegalConfigurationException("Virtual host type must be specified");
         }
-        catch(ConfigurationException e)
-        {
-            throw new IllegalConfigurationException("Failed to validate configuration", e);
-        }
-    }
-
-    private void validateAttributes(String type)
-    {
         final VirtualHostFactory factory = VirtualHostFactory.FACTORIES.get(type);
         if(factory == null)
         {
             throw new IllegalArgumentException("Unknown virtual host type '"+ type +"'.  Valid types are: " + VirtualHostFactory.TYPES.get());
         }
         factory.validateAttributes(getActualAttributes());
-
     }
 
-
     public Collection<VirtualHostAlias> getAliases()
     {
         return Collections.unmodifiableCollection(_aliases);
@@ -681,95 +658,88 @@ public final class VirtualHostAdapter ex
         {
             return LifetimePolicy.PERMANENT;
         }
-        else if (_virtualHost != null)
+        else if(QUEUE_ALERT_REPEAT_GAP.equals(name))
         {
-            return getAttributeFromVirtualHostImplementation(name);
+            return getAttribute(QUEUE_ALERT_REPEAT_GAP, Broker.QUEUE_ALERT_REPEAT_GAP);
         }
-        return super.getAttribute(name);
-    }
-
-    private Object getAttributeFromVirtualHostImplementation(String name)
-    {
-        if(SUPPORTED_EXCHANGE_TYPES.equals(name))
+        else if(QUEUE_ALERT_THRESHOLD_MESSAGE_AGE.equals(name))
         {
-            List<String> types = new ArrayList<String>();
-            for(@SuppressWarnings("rawtypes") ExchangeType type : _virtualHost.getExchangeTypes())
-            {
-                types.add(type.getType());
-            }
-            return Collections.unmodifiableCollection(types);
+            return getAttribute(QUEUE_ALERT_THRESHOLD_MESSAGE_AGE, Broker.QUEUE_ALERT_THRESHOLD_MESSAGE_AGE);
         }
-        else if(SUPPORTED_QUEUE_TYPES.equals(name))
+        else if(QUEUE_ALERT_THRESHOLD_MESSAGE_SIZE.equals(name))
         {
-            // TODO
+            return getAttribute(QUEUE_ALERT_THRESHOLD_MESSAGE_SIZE, Broker.QUEUE_ALERT_THRESHOLD_MESSAGE_SIZE);
         }
-        else if(QUEUE_DEAD_LETTER_QUEUE_ENABLED.equals(name))
+        else if(QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_BYTES.equals(name))
         {
-            return _virtualHost.getConfiguration().isDeadLetterQueueEnabled();
+            return getAttribute(QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_BYTES, Broker.QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_BYTES);
         }
-        else if(HOUSEKEEPING_CHECK_PERIOD.equals(name))
+        else if(QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES.equals(name))
+        {
+            return getAttribute(QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES, Broker.QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES);
+        }
+        else if(QUEUE_DEAD_LETTER_QUEUE_ENABLED.equals(name))
         {
-            return _virtualHost.getConfiguration().getHousekeepingCheckPeriod();
+            return getAttribute(QUEUE_DEAD_LETTER_QUEUE_ENABLED, Broker.QUEUE_DEAD_LETTER_QUEUE_ENABLED);
         }
         else if(QUEUE_MAXIMUM_DELIVERY_ATTEMPTS.equals(name))
         {
-            return _virtualHost.getConfiguration().getMaxDeliveryCount();
+            return getAttribute(QUEUE_MAXIMUM_DELIVERY_ATTEMPTS, Broker.QUEUE_MAXIMUM_DELIVERY_ATTEMPTS);
         }
         else if(QUEUE_FLOW_CONTROL_SIZE_BYTES.equals(name))
         {
-            return _virtualHost.getConfiguration().getCapacity();
+            return getAttribute(QUEUE_FLOW_CONTROL_SIZE_BYTES, Broker.QUEUE_FLOW_CONTROL_SIZE_BYTES);
         }
         else if(QUEUE_FLOW_RESUME_SIZE_BYTES.equals(name))
         {
-            return _virtualHost.getConfiguration().getFlowResumeCapacity();
-        }
-        else if(STORE_TYPE.equals(name))
-        {
-            return _virtualHost.getMessageStore().getStoreType();
+            return getAttribute(QUEUE_FLOW_RESUME_SIZE_BYTES, Broker.QUEUE_FLOW_CONTROL_RESUME_SIZE_BYTES);
         }
-        else if(STORE_PATH.equals(name))
+        else if(HOUSEKEEPING_CHECK_PERIOD.equals(name))
         {
-            return _virtualHost.getMessageStore().getStoreLocation();
+            return getAttribute(HOUSEKEEPING_CHECK_PERIOD, Broker.VIRTUALHOST_HOUSEKEEPING_CHECK_PERIOD);
         }
         else if(STORE_TRANSACTION_IDLE_TIMEOUT_CLOSE.equals(name))
         {
-            return _virtualHost.getConfiguration().getTransactionTimeoutIdleClose();
+            return getAttribute(STORE_TRANSACTION_IDLE_TIMEOUT_CLOSE, Broker.VIRTUALHOST_STORE_TRANSACTION_IDLE_TIMEOUT_CLOSE);
         }
         else if(STORE_TRANSACTION_IDLE_TIMEOUT_WARN.equals(name))
         {
-            return _virtualHost.getConfiguration().getTransactionTimeoutIdleWarn();
+            return getAttribute(STORE_TRANSACTION_IDLE_TIMEOUT_WARN, Broker.VIRTUALHOST_STORE_TRANSACTION_IDLE_TIMEOUT_WARN);
         }
         else if(STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE.equals(name))
         {
-            return _virtualHost.getConfiguration().getTransactionTimeoutOpenClose();
+            return getAttribute(STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE, Broker.VIRTUALHOST_STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE);
         }
         else if(STORE_TRANSACTION_OPEN_TIMEOUT_WARN.equals(name))
         {
-            return _virtualHost.getConfiguration().getTransactionTimeoutOpenWarn();
+            return getAttribute(STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE, Broker.VIRTUALHOST_STORE_TRANSACTION_OPEN_TIMEOUT_WARN);
         }
-        else if(QUEUE_ALERT_REPEAT_GAP.equals(name))
-        {
-            return _virtualHost.getConfiguration().getMinimumAlertRepeatGap();
-        }
-        else if(QUEUE_ALERT_THRESHOLD_MESSAGE_AGE.equals(name))
-        {
-            return _virtualHost.getConfiguration().getMaximumMessageAge();
-        }
-        else if(QUEUE_ALERT_THRESHOLD_MESSAGE_SIZE.equals(name))
-        {
-            return _virtualHost.getConfiguration().getMaximumMessageSize();
-        }
-        else if(QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_BYTES.equals(name))
-        {
-            return _virtualHost.getConfiguration().getMaximumQueueDepth();
-        }
-        else if(QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES.equals(name))
+        else if (_virtualHost != null)
         {
-            return _virtualHost.getConfiguration().getMaximumMessageCount();
+            if(SUPPORTED_EXCHANGE_TYPES.equals(name))
+            {
+                List<String> types = new ArrayList<String>();
+                for(@SuppressWarnings("rawtypes") ExchangeType type : _virtualHost.getExchangeTypes())
+                {
+                    types.add(type.getType());
+                }
+                return Collections.unmodifiableCollection(types);
+            }
+            else if(SUPPORTED_QUEUE_TYPES.equals(name))
+            {
+                // TODO
+            }
         }
         return super.getAttribute(name);
     }
 
+
+    Object getAttribute(String name, String brokerAttributeName)
+    {
+        return getAttribute(name, _broker, brokerAttributeName);
+    }
+
+
     @Override
     public Collection<String> getAttributeNames()
     {
@@ -806,115 +776,99 @@ public final class VirtualHostAdapter ex
     @Override
     public boolean isQueue_deadLetterQueueEnabled()
     {
-        return _virtualHost.getConfiguration().isDeadLetterQueueEnabled();
+        return (Boolean)getAttribute(VirtualHost.QUEUE_DEAD_LETTER_QUEUE_ENABLED);
     }
 
     @Override
     public long getHousekeepingCheckPeriod()
     {
-        return _virtualHost.getConfiguration().getHousekeepingCheckPeriod();
+        return (Long)getAttribute(VirtualHost.HOUSEKEEPING_CHECK_PERIOD);
     }
 
     @Override
     public int getQueue_maximumDeliveryAttempts()
     {
-        return _virtualHost.getConfiguration().getMaxDeliveryCount();
+        return (Integer)getAttribute(VirtualHost.QUEUE_MAXIMUM_DELIVERY_ATTEMPTS);
     }
 
     @Override
     public long getQueue_flowControlSizeBytes()
     {
-        return _virtualHost.getConfiguration().getCapacity();
+        return (Long)getAttribute(VirtualHost.QUEUE_FLOW_CONTROL_SIZE_BYTES);
     }
 
     @Override
     public long getQueue_flowResumeSizeBytes()
     {
-        return _virtualHost.getConfiguration().getFlowResumeCapacity();
-    }
-
-    @Override
-    public String getConfigStoreType()
-    {
-        return (String) getAttribute(CONFIG_STORE_TYPE);
-    }
-
-    @Override
-    public String getConfigStorePath()
-    {
-        return (String) getAttribute(CONFIG_PATH);
-    }
-
-    @Override
-    public String getStoreType()
-    {
-        return _virtualHost.getMessageStore().getStoreType();
-    }
-
-    @Override
-    public String getStorePath()
-    {
-        return _virtualHost.getMessageStore().getStoreLocation();
+        return (Long)getAttribute(VirtualHost.QUEUE_FLOW_RESUME_SIZE_BYTES);
     }
 
     @Override
     public long getStoreTransactionIdleTimeoutClose()
     {
-        return _virtualHost.getConfiguration().getTransactionTimeoutIdleClose();
+        return (Long)getAttribute(VirtualHost.STORE_TRANSACTION_IDLE_TIMEOUT_CLOSE);
     }
 
     @Override
     public long getStoreTransactionIdleTimeoutWarn()
     {
-        return _virtualHost.getConfiguration().getTransactionTimeoutIdleWarn();
+        return (Long)getAttribute(VirtualHost.STORE_TRANSACTION_IDLE_TIMEOUT_WARN);
     }
 
     @Override
     public long getStoreTransactionOpenTimeoutClose()
     {
-        return _virtualHost.getConfiguration().getTransactionTimeoutOpenClose();
+        return (Long)getAttribute(VirtualHost.STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE);
     }
 
     @Override
     public long getStoreTransactionOpenTimeoutWarn()
     {
-        return _virtualHost.getConfiguration().getTransactionTimeoutOpenWarn();
+        return (Long)getAttribute(VirtualHost.STORE_TRANSACTION_OPEN_TIMEOUT_WARN);
     }
 
     @Override
     public long getQueue_alertRepeatGap()
     {
-        return _virtualHost.getConfiguration().getMinimumAlertRepeatGap();
+        return (Long)getAttribute(VirtualHost.QUEUE_ALERT_REPEAT_GAP);
     }
 
     @Override
     public long getQueue_alertThresholdMessageAge()
     {
-        return _virtualHost.getConfiguration().getMaximumMessageAge();
+        return (Long)getAttribute(VirtualHost.QUEUE_ALERT_THRESHOLD_MESSAGE_AGE);
     }
 
     @Override
     public long getQueue_alertThresholdMessageSize()
     {
-        return _virtualHost.getConfiguration().getMaximumMessageSize();
+        return (Long)getAttribute(VirtualHost.QUEUE_ALERT_THRESHOLD_MESSAGE_SIZE);
     }
 
     @Override
     public long getQueue_alertThresholdQueueDepthBytes()
     {
-        return _virtualHost.getConfiguration().getMaximumQueueDepth();
+        return (Long)getAttribute(VirtualHost.QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_BYTES);
     }
 
     @Override
     public long getQueue_alertThresholdQueueDepthMessages()
     {
-        return _virtualHost.getConfiguration().getMaximumMessageCount();
+        return (Long)getAttribute(VirtualHost.QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES);
     }
 
+    @SuppressWarnings("unchecked")
     @Override
-    public String getConfigPath()
+    public Map<String, Object> getMessageStoreSettings()
     {
-        return (String) getAttribute(CONFIG_PATH);
+        return (Map<String, Object>)getAttribute(VirtualHost.MESSAGE_STORE_SETTINGS);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Map<String, Object> getConfigurationStoreSettings()
+    {
+        return (Map<String, Object>)getAttribute(VirtualHost.CONFIGURATION_STORE_SETTINGS);
     }
 
     @Override
@@ -959,6 +913,17 @@ public final class VirtualHostAdapter ex
         return _virtualHost.getMessageDeliveryStatistics().getTotal();
     }
 
+    @Override
+    public String getSecurityAcl()
+    {
+        return (String)getAttribute(SECURITY_ACL);
+    }
+
+    @Override
+    public int getHouseKeepingThreadCount()
+    {
+        return (Integer)getAttribute(HOUSE_KEEPING_THREAD_COUNT);
+    }
 
     @Override
     protected boolean setState(State currentState, State desiredState)
@@ -1040,8 +1005,7 @@ public final class VirtualHostAdapter ex
         String virtualHostName = getName();
         try
         {
-            VirtualHostConfiguration configuration = createVirtualHostConfiguration(virtualHostName);
-            String type = configuration.getType();
+            String type = (String) getAttribute(TYPE);
             final VirtualHostFactory factory = VirtualHostFactory.FACTORIES.get(type);
             if(factory == null)
             {
@@ -1052,11 +1016,10 @@ public final class VirtualHostAdapter ex
                 _virtualHost = factory.createVirtualHost(_broker.getVirtualHostRegistry(),
                                                          _brokerStatisticsGatherer,
                                                          _broker.getSecurityManager(),
-                                                         configuration,
                                                          this);
             }
         }
-        catch (ConfigurationException e)
+        catch (Exception e)
         {
             throw new ServerScopedRuntimeException("Failed to create virtual host " + virtualHostName, e);
         }
@@ -1077,53 +1040,6 @@ public final class VirtualHostAdapter ex
         }
     }
 
-    private VirtualHostConfiguration createVirtualHostConfiguration(String virtualHostName) throws ConfigurationException
-    {
-        VirtualHostConfiguration configuration;
-        String configurationFile = (String)getAttribute(CONFIG_PATH);
-        if (configurationFile == null)
-        {
-            final MyConfiguration basicConfiguration = new MyConfiguration();
-            PropertiesConfiguration config = new PropertiesConfiguration();
-            final String type = (String) getAttribute(TYPE);
-            config.addProperty("type", type);
-            VirtualHostFactory factory = VirtualHostFactory.FACTORIES.get(type);
-            if(factory != null)
-            {
-                for(Map.Entry<String,Object> entry : factory.createVirtualHostConfiguration(this).entrySet())
-                {
-                    config.addProperty(entry.getKey(), entry.getValue());
-                }
-            }
-            basicConfiguration.addConfiguration(config);
-
-            CompositeConfiguration compositeConfiguration = new CompositeConfiguration();
-            compositeConfiguration.addConfiguration(new SystemConfiguration());
-            compositeConfiguration.addConfiguration(basicConfiguration);
-            configuration = new VirtualHostConfiguration(virtualHostName, compositeConfiguration , _broker);
-        }
-        else
-        {
-            if (!new File(configurationFile).exists())
-            {
-                throw new IllegalConfigurationException("Configuration file '" + configurationFile + "' does not exist");
-            }
-            configuration = new VirtualHostConfiguration(virtualHostName, new File(configurationFile) , _broker);
-            String type = configuration.getType();
-            changeAttribute(TYPE,null,type);
-            VirtualHostFactory factory = VirtualHostFactory.FACTORIES.get(type);
-            if(factory != null)
-            {
-                for(Map.Entry<String,Object> entry : factory.convertVirtualHostConfiguration(configuration.getConfig()).entrySet())
-                {
-                    changeAttribute(entry.getKey(), getAttribute(entry.getKey()), entry.getValue());
-                }
-            }
-
-        }
-        return configuration;
-    }
-
     @Override
     public MessageStore getMessageStore()
     {

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/DurableConfigurationStoreFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/DurableConfigurationStoreFactory.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/DurableConfigurationStoreFactory.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/DurableConfigurationStoreFactory.java Tue Apr  1 10:35:33 2014
@@ -21,9 +21,7 @@
 package org.apache.qpid.server.plugin;
 
 import java.util.Map;
-import org.apache.commons.configuration.Configuration;
 import org.apache.qpid.server.store.DurableConfigurationStore;
-import org.apache.qpid.server.store.MessageStore;
 
 public interface DurableConfigurationStoreFactory extends Pluggable
 {

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/JDBCConnectionProviderFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/JDBCConnectionProviderFactory.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/JDBCConnectionProviderFactory.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/JDBCConnectionProviderFactory.java Tue Apr  1 10:35:33 2014
@@ -25,15 +25,15 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
-import org.apache.commons.configuration.Configuration;
-import org.apache.qpid.server.model.VirtualHost;
+import java.util.Map;
+
 import org.apache.qpid.server.store.jdbc.ConnectionProvider;
 
 public interface JDBCConnectionProviderFactory extends Pluggable
 {
     String getType();
 
-    ConnectionProvider getConnectionProvider(String connectionUrl, VirtualHost virtualHost)
+    ConnectionProvider getConnectionProvider(String connectionUrl, Map<String, Object> storeSettings)
             throws SQLException;
 
     static final class TYPES

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/MessageStoreFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/MessageStoreFactory.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/MessageStoreFactory.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/MessageStoreFactory.java Tue Apr  1 10:35:33 2014
@@ -21,16 +21,16 @@
 package org.apache.qpid.server.plugin;
 
 import java.util.Map;
-import org.apache.commons.configuration.Configuration;
+
 import org.apache.qpid.server.store.MessageStore;
 
 public interface MessageStoreFactory extends Pluggable
 {
+    PluggableFactoryLoader<MessageStoreFactory> FACTORY_LOADER = new PluggableFactoryLoader<MessageStoreFactory>(MessageStoreFactory.class);
+
     String getType();
 
     MessageStore createMessageStore();
 
-    public Map<String, Object> convertStoreConfiguration(Configuration configuration);
-
     void validateAttributes(Map<String, Object> attributes);
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluggableFactoryLoader.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluggableFactoryLoader.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluggableFactoryLoader.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluggableFactoryLoader.java Tue Apr  1 10:35:33 2014
@@ -19,7 +19,6 @@
 
 package org.apache.qpid.server.plugin;
 
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -56,7 +55,7 @@ public class PluggableFactoryLoader<T ex
         return _factoriesMap.get(type);
     }
 
-    public Collection<String> getDescriptiveTypes()
+    public Set<String> getSupportedTypes()
     {
         return _types;
     }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PreferencesProviderFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PreferencesProviderFactory.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PreferencesProviderFactory.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PreferencesProviderFactory.java Tue Apr  1 10:35:33 2014
@@ -26,7 +26,7 @@ import org.apache.qpid.server.model.Pref
 
 public interface PreferencesProviderFactory extends Pluggable
 {
-    PluggableFactoryLoader<PreferencesProviderFactory> FACTORIES = new PluggableFactoryLoader<PreferencesProviderFactory>(PreferencesProviderFactory.class);
+    PluggableFactoryLoader<PreferencesProviderFactory> FACTORY_LOADER = new PluggableFactoryLoader<PreferencesProviderFactory>(PreferencesProviderFactory.class);
 
     PreferencesProvider createInstance(UUID id, Map<String, Object> attributes, AuthenticationProvider<? extends AuthenticationProvider> authenticationProvider);
 

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/VirtualHostFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/VirtualHostFactory.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/VirtualHostFactory.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/VirtualHostFactory.java Tue Apr  1 10:35:33 2014
@@ -25,9 +25,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
-import org.apache.commons.configuration.Configuration;
-import org.apache.qpid.server.configuration.VirtualHostConfiguration;
-import org.apache.qpid.server.model.adapter.VirtualHostAdapter;
+
 import org.apache.qpid.server.security.SecurityManager;
 import org.apache.qpid.server.stats.StatisticsGatherer;
 import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -40,15 +38,10 @@ public interface VirtualHostFactory exte
     VirtualHost createVirtualHost(VirtualHostRegistry virtualHostRegistry,
                                   StatisticsGatherer brokerStatisticsGatherer,
                                   SecurityManager parentSecurityManager,
-                                  VirtualHostConfiguration hostConfig,
                                   org.apache.qpid.server.model.VirtualHost virtualHost);
 
     void validateAttributes(Map<String, Object> attributes);
 
-    Map<String, Object> createVirtualHostConfiguration(VirtualHostAdapter virtualHostAdapter);
-
-    Map<String,Object> convertVirtualHostConfiguration(Configuration configuration);
-
     static final class TYPES
     {
         private TYPES()

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java Tue Apr  1 10:35:33 2014
@@ -26,11 +26,9 @@ import java.util.UUID;
 
 import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
 import org.apache.qpid.server.exchange.ExchangeImpl;
-import org.apache.qpid.server.model.ExclusivityPolicy;
 import org.apache.qpid.server.model.LifetimePolicy;
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.server.configuration.BrokerProperties;
-import org.apache.qpid.server.configuration.QueueConfiguration;
 import org.apache.qpid.server.exchange.DefaultExchangeFactory;
 import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.model.UUIDGenerator;
@@ -59,7 +57,7 @@ public class AMQQueueFactory implements 
     {
         _virtualHost = virtualHost;
         _queueRegistry = queueRegistry;
-    }   
+    }
 
     @Override
     public AMQQueue restoreQueue(Map<String, Object> attributes)
@@ -74,50 +72,10 @@ public class AMQQueueFactory implements 
         return createOrRestoreQueue(attributes, true);
     }
 
-    private AMQQueue createOrRestoreQueue(Map<String, Object> attributes,
-                                          boolean createInStore)
+    private AMQQueue createOrRestoreQueue(Map<String, Object> attributes, boolean createInStore)
     {
-
-
         String queueName = MapValueConverter.getStringAttribute(Queue.NAME,attributes);
-
-        QueueConfiguration config = _virtualHost.getConfiguration().getQueueConfiguration(queueName);
-
-        if (!attributes.containsKey(Queue.ALERT_THRESHOLD_MESSAGE_AGE) && config.getMaximumMessageAge() != 0)
-        {
-            attributes.put(Queue.ALERT_THRESHOLD_MESSAGE_AGE, config.getMaximumMessageAge());
-        }
-        if (!attributes.containsKey(Queue.ALERT_THRESHOLD_QUEUE_DEPTH_BYTES) && config.getMaximumQueueDepth() != 0)
-        {
-            attributes.put(Queue.ALERT_THRESHOLD_QUEUE_DEPTH_BYTES, config.getMaximumQueueDepth());
-        }
-        if (!attributes.containsKey(Queue.ALERT_THRESHOLD_MESSAGE_SIZE) && config.getMaximumMessageSize() != 0)
-        {
-            attributes.put(Queue.ALERT_THRESHOLD_MESSAGE_SIZE, config.getMaximumMessageSize());
-        }
-        if (!attributes.containsKey(Queue.ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES) && config.getMaximumMessageCount() != 0)
-        {
-            attributes.put(Queue.ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES, config.getMaximumMessageCount());
-        }
-        if (!attributes.containsKey(Queue.ALERT_REPEAT_GAP) && config.getMinimumAlertRepeatGap() != 0)
-        {
-            attributes.put(Queue.ALERT_REPEAT_GAP, config.getMinimumAlertRepeatGap());
-        }
-        if (config.getMaxDeliveryCount() != 0 && !attributes.containsKey(Queue.MAXIMUM_DELIVERY_ATTEMPTS))
-        {
-            attributes.put(Queue.MAXIMUM_DELIVERY_ATTEMPTS, config.getMaxDeliveryCount());
-        }
-        if (!attributes.containsKey(Queue.QUEUE_FLOW_CONTROL_SIZE_BYTES) && config.getCapacity() != 0)
-        {
-            attributes.put(Queue.QUEUE_FLOW_CONTROL_SIZE_BYTES, config.getCapacity());
-        }
-        if (!attributes.containsKey(Queue.QUEUE_FLOW_RESUME_SIZE_BYTES) && config.getFlowResumeCapacity() != 0)
-        {
-            attributes.put(Queue.QUEUE_FLOW_RESUME_SIZE_BYTES, config.getFlowResumeCapacity());
-        }
-
-
-        boolean createDLQ = createDLQ(attributes, config);
+        boolean createDLQ = createInStore && shouldCreateDLQ(attributes, _virtualHost.getDefaultDeadLetterQueueEnabled());
         if (createDLQ)
         {
             validateDLNames(queueName);
@@ -259,30 +217,7 @@ public class AMQQueueFactory implements 
         queue.setAlternateExchange(dlExchange);
     }
 
-    public AMQQueue createAMQQueueImpl(QueueConfiguration config)
-    {
-
-        Map<String, Object> arguments = createQueueAttributesFromConfig(_virtualHost, config);
-        
-        AMQQueue q = createOrRestoreQueue(arguments, false);
-        return q;
-    }
-
-    /**
-     * Validates DLQ and DLE names
-     * <p>
-     * DLQ name and DLQ exchange name need to be validated in order to keep
-     * integrity in cases when queue name passes validation check but DLQ name
-     * or DL exchange name fails to pass it. Otherwise, we might have situations
-     * when queue is created but DL exchange or/and DLQ creation fail.
-     * <p>
-     *
-     * @param name
-     *            queue name
-     * @throws IllegalArgumentException
-     *             thrown if length of queue name or exchange name exceed 255
-     */
-    protected static void validateDLNames(String name)
+    private static void validateDLNames(String name)
     {
         // check if DLQ name and DLQ exchange name do not exceed 255
         String exchangeName = getDeadLetterExchangeName(name);
@@ -299,16 +234,7 @@ public class AMQQueueFactory implements 
         }
     }
 
-    /**
-     * Checks if DLQ is enabled for the queue.
-     *
-     * @param arguments
-     *            queue arguments
-     * @param qConfig
-     *            queue configuration
-     * @return true if DLQ enabled
-     */
-    protected static boolean createDLQ(Map<String, Object> arguments, QueueConfiguration qConfig)
+    private static boolean shouldCreateDLQ(Map<String, Object> arguments, boolean virtualHostDefaultDeadLetterQueueEnabled)
     {
         boolean autoDelete = MapValueConverter.getEnumAttribute(LifetimePolicy.class,
                                                                 Queue.LIFETIME_POLICY,
@@ -320,7 +246,7 @@ public class AMQQueueFactory implements 
         {
             boolean dlqArgumentPresent = arguments != null
                                          && arguments.containsKey(Queue.CREATE_DLQ_ON_CREATION);
-            if (dlqArgumentPresent || qConfig.isDeadLetterQueueEnabled())
+            if (dlqArgumentPresent)
             {
                 boolean dlqEnabled = true;
                 if (dlqArgumentPresent)
@@ -329,89 +255,21 @@ public class AMQQueueFactory implements 
                     dlqEnabled = (argument instanceof Boolean && ((Boolean)argument).booleanValue())
                                 || (argument instanceof String && Boolean.parseBoolean(argument.toString()));
                 }
-                return dlqEnabled ;
+                return dlqEnabled;
             }
+            return virtualHostDefaultDeadLetterQueueEnabled;
         }
         return false;
     }
 
-    /**
-     * Generates a dead letter queue name for a given queue name
-     *
-     * @param name
-     *            queue name
-     * @return DLQ name
-     */
-    protected static String getDeadLetterQueueName(String name)
+    private static String getDeadLetterQueueName(String name)
     {
         return name + System.getProperty(BrokerProperties.PROPERTY_DEAD_LETTER_QUEUE_SUFFIX, DEFAULT_DLQ_NAME_SUFFIX);
     }
 
-    /**
-     * Generates a dead letter exchange name for a given queue name
-     *
-     * @param name
-     *            queue name
-     * @return DL exchange name
-     */
-    protected static String getDeadLetterExchangeName(String name)
+    private static String getDeadLetterExchangeName(String name)
     {
         return name + System.getProperty(BrokerProperties.PROPERTY_DEAD_LETTER_EXCHANGE_SUFFIX, DefaultExchangeFactory.DEFAULT_DLE_NAME_SUFFIX);
     }
 
-    private static Map<String, Object> createQueueAttributesFromConfig(final VirtualHost virtualHost,
-                                                                       QueueConfiguration config)
-    {
-        Map<String,Object> attributes = new HashMap<String,Object>();
-
-        if(config.getArguments() != null && !config.getArguments().isEmpty())
-        {
-            attributes.putAll(QueueArgumentsConverter.convertWireArgsToModel(new HashMap<String, Object>(config.getArguments())));
-        }
-
-        if(config.isLVQ() || config.getLVQKey() != null)
-        {
-            attributes.put(Queue.LVQ_KEY,
-                          config.getLVQKey() == null ? ConflationQueue.DEFAULT_LVQ_KEY : config.getLVQKey());
-        }
-        else if (config.getPriority() || config.getPriorities() > 0)
-        {
-            attributes.put(Queue.PRIORITIES, config.getPriorities() < 0 ? 10 : config.getPriorities());
-        }
-        else if (config.getQueueSortKey() != null && !"".equals(config.getQueueSortKey()))
-        {
-            attributes.put(Queue.SORT_KEY, config.getQueueSortKey());
-        }
-
-        if (!config.getAutoDelete() && config.isDeadLetterQueueEnabled())
-        {
-            attributes.put(Queue.CREATE_DLQ_ON_CREATION, true);
-        }
-
-        if (config.getDescription() != null && !"".equals(config.getDescription()))
-        {
-            attributes.put(Queue.DESCRIPTION, config.getDescription());
-        }
-
-        attributes.put(Queue.DURABLE, config.getDurable());
-        attributes.put(Queue.LIFETIME_POLICY,
-                      config.getAutoDelete() ? LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS : LifetimePolicy.PERMANENT);
-        if(config.getExclusive())
-        {
-            attributes.put(Queue.EXCLUSIVE, ExclusivityPolicy.CONTAINER);
-        }
-        if(config.getOwner() != null)
-        {
-            attributes.put(Queue.OWNER, config.getOwner());
-        }
-        
-        attributes.put(Queue.NAME, config.getName());
-        
-        // we need queues that are defined in config to have deterministic ids.
-        attributes.put(Queue.ID, UUIDGenerator.generateQueueUUID(config.getName(), virtualHost.getName()));
-
-
-        return attributes;
-    }
-
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java Tue Apr  1 10:35:33 2014
@@ -139,7 +139,7 @@ public abstract class AbstractAuthentica
         {
             String name = MapValueConverter.getStringAttribute(PreferencesProvider.NAME, attributes);
             String type = MapValueConverter.getStringAttribute(PreferencesProvider.TYPE, attributes);
-            PreferencesProviderFactory factory = PreferencesProviderFactory.FACTORIES.get(type);
+            PreferencesProviderFactory factory = PreferencesProviderFactory.FACTORY_LOADER.get(type);
             UUID id = UUIDGenerator.generatePreferencesProviderUUID(name, getName());
             PreferencesProvider pp = factory.createInstance(id, attributes, this);
             pp.setDesiredState(State.INITIALISING, State.ACTIVE);

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCMessageStore.java Tue Apr  1 10:35:33 2014
@@ -21,11 +21,7 @@
 package org.apache.qpid.server.store;
 
 import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
 import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.lang.ref.SoftReference;
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
@@ -36,16 +32,24 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.sql.Types;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
+
 import org.apache.log4j.Logger;
 import org.apache.qpid.server.message.EnqueueableMessage;
 import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.plugin.MessageMetaDataType;
 import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.transport.ConnectionOpen;
 import org.codehaus.jackson.JsonGenerationException;
 import org.codehaus.jackson.JsonGenerator;
 import org.codehaus.jackson.JsonParseException;
@@ -77,15 +81,15 @@ abstract public class AbstractJDBCMessag
 
     private static final int DEFAULT_CONFIG_VERSION = 0;
 
-    public static String[] ALL_TABLES =
-            new String[]{DB_VERSION_TABLE_NAME, XID_ACTIONS_TABLE_NAME,
-                    XID_TABLE_NAME, QUEUE_ENTRY_TABLE_NAME, MESSAGE_CONTENT_TABLE_NAME, META_DATA_TABLE_NAME,
-                    CONFIGURED_OBJECTS_TABLE_NAME, CONFIGURED_OBJECT_HIERARCHY_TABLE_NAME, CONFIGURATION_VERSION_TABLE_NAME};
+    public static final Set<String> CONFIGURATION_STORE_TABLE_NAMES = new HashSet<String>(Arrays.asList(CONFIGURED_OBJECTS_TABLE_NAME, CONFIGURATION_VERSION_TABLE_NAME));
+    public static final Set<String> MESSAGE_STORE_TABLE_NAMES = new HashSet<String>(Arrays.asList(DB_VERSION_TABLE_NAME,
+                                                                                                  META_DATA_TABLE_NAME, MESSAGE_CONTENT_TABLE_NAME,
+                                                                                                    QUEUE_ENTRY_TABLE_NAME,
+                                                                                                    XID_TABLE_NAME, XID_ACTIONS_TABLE_NAME));
 
     private static final int DB_VERSION = 8;
 
     private final AtomicLong _messageId = new AtomicLong(0);
-    private final AtomicBoolean _closed = new AtomicBoolean(false);
 
     private static final String CREATE_DB_VERSION_TABLE = "CREATE TABLE "+ DB_VERSION_TABLE_NAME + " ( version int not null )";
     private static final String INSERT_INTO_DB_VERSION = "INSERT INTO "+ DB_VERSION_TABLE_NAME + " ( version ) VALUES ( ? )";
@@ -172,69 +176,130 @@ abstract public class AbstractJDBCMessag
 
     protected final EventManager _eventManager = new EventManager();
 
-    protected final StateManager _stateManager;
+    private final AtomicBoolean _messageStoreOpen = new AtomicBoolean();
+    private final AtomicBoolean _configurationStoreOpen = new AtomicBoolean();
 
-    private MessageStoreRecoveryHandler _messageRecoveryHandler;
-    private TransactionLogRecoveryHandler _tlogRecoveryHandler;
-    private ConfigurationRecoveryHandler _configRecoveryHandler;
-    private VirtualHost _virtualHost;
+    private boolean _initialized;
 
-    public AbstractJDBCMessageStore()
-    {
-        _stateManager = new StateManager(_eventManager);
-    }
 
     @Override
-    public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler configRecoveryHandler)
+    public void openConfigurationStore(ConfiguredObject<?> parent, Map<String, Object> storeSettings)
     {
-        _stateManager.attainState(State.INITIALISING);
-        _configRecoveryHandler = configRecoveryHandler;
-        _virtualHost = virtualHost;
+        if (_configurationStoreOpen.compareAndSet(false,  true))
+        {
+            initialiseIfNecessary(parent.getName(), storeSettings);
+            try
+            {
+                createOrOpenConfigurationStoreDatabase();
+                upgradeIfVersionTableExists(parent);
+            }
+            catch(SQLException e)
+            {
+                throw new StoreException("Cannot create databases or upgrade", e);
+            }
+        }
+    }
 
+    private void initialiseIfNecessary(String virtualHostName, Map<String, Object> storeSettings)
+    {
+        if (!_initialized)
+        {
+            try
+            {
+                implementationSpecificConfiguration(virtualHostName, storeSettings);
+            }
+            catch (ClassNotFoundException e)
+            {
+               throw new StoreException("Cannot find driver class", e);
+            }
+            catch (SQLException e)
+            {
+                throw new StoreException("Unexpected exception occured", e);
+            }
+            _initialized = true;
+        }
     }
 
     @Override
-    public void configureMessageStore(VirtualHost virtualHost, MessageStoreRecoveryHandler recoveryHandler,
-                                      TransactionLogRecoveryHandler tlogRecoveryHandler)
+    public void recoverConfigurationStore(ConfigurationRecoveryHandler recoveryHandler)
     {
-        if(_stateManager.isInState(State.INITIAL))
+        checkConfigurationStoreOpen();
+
+        try
         {
-            _stateManager.attainState(State.INITIALISING);
+            recoveryHandler.beginConfigurationRecovery(this, getConfigVersion());
+            loadConfiguredObjects(recoveryHandler);
+            setConfigVersion(recoveryHandler.completeConfigurationRecovery());
         }
+        catch (SQLException e)
+        {
+            throw new StoreException("Error recovering persistent state: " + e.getMessage(), e);
+        }
+    }
 
-        _virtualHost = virtualHost;
-        _tlogRecoveryHandler = tlogRecoveryHandler;
-        _messageRecoveryHandler = recoveryHandler;
-
-        completeInitialisation();
+    private void checkConfigurationStoreOpen()
+    {
+        if (!_configurationStoreOpen.get())
+        {
+            throw new IllegalStateException("Configuration store is not open");
+        }
     }
 
-    private void completeInitialisation()
+    private void checkMessageStoreOpen()
     {
-        commonConfiguration();
+        if (!_messageStoreOpen.get())
+        {
+            throw new IllegalStateException("Message store is not open");
+        }
+    }
 
-        _stateManager.attainState(State.INITIALISED);
+    private void upgradeIfVersionTableExists(ConfiguredObject<?> parent)
+            throws SQLException {
+        Connection conn = newAutoCommitConnection();
+        try
+        {
+            if (tableExists(DB_VERSION_TABLE_NAME, conn))
+            {
+                upgradeIfNecessary(parent);
+            }
+        }
+        finally
+        {
+            if (conn != null)
+            {
+                conn.close();
+            }
+        }
     }
 
     @Override
-    public void activate()
+    public void openMessageStore(ConfiguredObject<?> parent, Map<String, Object> messageStoreSettings)
     {
-        if(_stateManager.isInState(State.INITIALISING))
+        if (_messageStoreOpen.compareAndSet(false,  true))
         {
-            completeInitialisation();
+            initialiseIfNecessary(parent.getName(), messageStoreSettings);
+            try
+            {
+                createOrOpenMessageStoreDatabase();
+                upgradeIfNecessary(parent);
+            }
+            catch (SQLException e)
+            {
+                throw new StoreException("Unable to activate message store ", e);
+            }
         }
-        _stateManager.attainState(State.ACTIVATING);
+    }
 
-        // this recovers durable exchanges, queues, and bindings
-        if(_configRecoveryHandler != null)
-        {
-            recoverConfiguration(_configRecoveryHandler);
-        }
-        if(_messageRecoveryHandler != null)
+    @Override
+    public void recoverMessageStore(MessageStoreRecoveryHandler messageRecoveryHandler, TransactionLogRecoveryHandler transactionLogRecoveryHandler)
+    {
+        checkMessageStoreOpen();
+
+        if(messageRecoveryHandler != null)
         {
             try
             {
-                recoverMessages(_messageRecoveryHandler);
+                recoverMessages(messageRecoveryHandler);
             }
             catch (SQLException e)
             {
@@ -242,11 +307,11 @@ abstract public class AbstractJDBCMessag
                                                        "persistent store ", e);
             }
         }
-        if(_tlogRecoveryHandler != null)
+        if(transactionLogRecoveryHandler != null)
         {
             try
             {
-                TransactionLogRecoveryHandler.DtxRecordRecoveryHandler dtxrh = recoverQueueEntries(_tlogRecoveryHandler);
+                TransactionLogRecoveryHandler.DtxRecordRecoveryHandler dtxrh = recoverQueueEntries(transactionLogRecoveryHandler);
                 recoverXids(dtxrh);
             }
             catch (SQLException e)
@@ -256,29 +321,9 @@ abstract public class AbstractJDBCMessag
             }
 
         }
-
-        _stateManager.attainState(State.ACTIVE);
     }
 
-    private void commonConfiguration()
-    {
-        try
-        {
-            implementationSpecificConfiguration(_virtualHost.getName(), _virtualHost);
-            createOrOpenDatabase();
-            upgradeIfNecessary();
-        }
-        catch (ClassNotFoundException e)
-        {
-            throw new StoreException("Unable to configure message store ", e);
-        }
-        catch (SQLException e)
-        {
-            throw new StoreException("Unable to configure message store ", e);
-        }
-    }
-
-    protected void upgradeIfNecessary() throws SQLException
+    protected void upgradeIfNecessary(ConfiguredObject<?> parent) throws SQLException
     {
         Connection conn = newAutoCommitConnection();
         try
@@ -300,7 +345,7 @@ abstract public class AbstractJDBCMessag
                         case 6:
                             upgradeFromV6();
                         case 7:
-                            upgradeFromV7();
+                            upgradeFromV7(parent);
                         case DB_VERSION:
                             return;
                         default:
@@ -330,7 +375,7 @@ abstract public class AbstractJDBCMessag
     }
 
 
-    private void upgradeFromV7() throws SQLException
+    private void upgradeFromV7(ConfiguredObject<?> parent) throws SQLException
     {
         Connection connection = newConnection();
         try
@@ -390,7 +435,7 @@ abstract public class AbstractJDBCMessag
                 {
                     stmt.setString(1, id.toString());
                     stmt.setString(2, "VirtualHost");
-                    stmt.setString(3, _virtualHost.getId().toString());
+                    stmt.setString(3, parent.getId().toString());
                     stmt.execute();
                 }
                 for(Map.Entry<UUID, Map<String,Object>> bindingEntry : bindingsToUpdate.entrySet())
@@ -481,8 +526,7 @@ abstract public class AbstractJDBCMessag
         }
     }
 
-    protected abstract void implementationSpecificConfiguration(String name,
-                                                                VirtualHost virtualHost) throws ClassNotFoundException, SQLException;
+    protected abstract void implementationSpecificConfiguration(String name, Map<String, Object> messageStoreSettings) throws ClassNotFoundException, SQLException;
 
     abstract protected Logger getLogger();
 
@@ -492,14 +536,11 @@ abstract public class AbstractJDBCMessag
 
     abstract protected String getSqlBigIntType();
 
-    protected void createOrOpenDatabase() throws SQLException
+    protected void createOrOpenMessageStoreDatabase() throws SQLException
     {
         Connection conn = newAutoCommitConnection();
 
         createVersionTable(conn);
-        createConfigVersionTable(conn);
-        createConfiguredObjectsTable(conn);
-        createConfiguredObjectHierarchyTable(conn);
         createQueueEntryTable(conn);
         createMetaDataTable(conn);
         createMessageContentTable(conn);
@@ -508,6 +549,17 @@ abstract public class AbstractJDBCMessag
         conn.close();
     }
 
+    protected void createOrOpenConfigurationStoreDatabase() throws SQLException
+    {
+        Connection conn = newAutoCommitConnection();
+
+        createConfigVersionTable(conn);
+        createConfiguredObjectsTable(conn);
+        createConfiguredObjectHierarchyTable(conn);
+
+        conn.close();
+    }
+
     private void createVersionTable(final Connection conn) throws SQLException
     {
         if(!tableExists(DB_VERSION_TABLE_NAME, conn))
@@ -596,8 +648,6 @@ abstract public class AbstractJDBCMessag
         }
     }
 
-
-
     private void createQueueEntryTable(final Connection conn) throws SQLException
     {
         if(!tableExists(QUEUE_ENTRY_TABLE_NAME, conn))
@@ -662,8 +712,6 @@ abstract public class AbstractJDBCMessag
 
     }
 
-
-
     private void createXidTable(final Connection conn) throws SQLException
     {
         if(!tableExists(XID_TABLE_NAME, conn))
@@ -734,21 +782,6 @@ abstract public class AbstractJDBCMessag
         }
     }
 
-    protected void recoverConfiguration(ConfigurationRecoveryHandler recoveryHandler)
-    {
-        try
-        {
-            recoveryHandler.beginConfigurationRecovery(this, getConfigVersion());
-            loadConfiguredObjects(recoveryHandler);
-
-            setConfigVersion(recoveryHandler.completeConfigurationRecovery());
-        }
-        catch (SQLException e)
-        {
-            throw new StoreException("Error recovering persistent state: " + e.getMessage(), e);
-        }
-    }
-
     private void setConfigVersion(int version) throws SQLException
     {
         Connection conn = newAutoCommitConnection();
@@ -811,24 +844,36 @@ abstract public class AbstractJDBCMessag
     }
 
     @Override
-    public void close()
+    public void closeMessageStore()
     {
-        if (_closed.compareAndSet(false, true))
+        if (_messageStoreOpen.compareAndSet(true, false))
         {
-            _stateManager.attainState(State.CLOSING);
-
-            doClose();
-
-            _stateManager.attainState(State.CLOSED);
+            if (!_configurationStoreOpen.get())
+            {
+                doClose();
+            }
         }
     }
 
+    @Override
+    public void closeConfigurationStore()
+    {
+        if (_configurationStoreOpen.compareAndSet(true, false))
+        {
+            if (!_messageStoreOpen.get())
+            {
+                doClose();
+            }
+        }
+    }
 
     protected abstract void doClose();
 
     @Override
     public StoredMessage addMessage(StorableMessageMetaData metaData)
     {
+        checkMessageStoreOpen();
+
         if(metaData.isPersistent())
         {
             return new StoredJDBCMessage(_messageId.incrementAndGet(), metaData);
@@ -839,12 +884,7 @@ abstract public class AbstractJDBCMessag
         }
     }
 
-    public StoredMessage getMessage(long messageNumber)
-    {
-        return null;
-    }
-
-    public void removeMessage(long messageId)
+    private void removeMessage(long messageId)
     {
         try
         {
@@ -908,27 +948,24 @@ abstract public class AbstractJDBCMessag
     @Override
     public void create(ConfiguredObjectRecord object) throws StoreException
     {
-        if (_stateManager.isInState(State.ACTIVE))
+        checkConfigurationStoreOpen();
+        try
         {
+            Connection conn = newConnection();
             try
             {
-                Connection conn = newConnection();
-                try
-                {
-                    insertConfiguredObject(object, conn);
-                    conn.commit();
-                }
-                finally
-                {
-                    conn.close();
-                }
+                insertConfiguredObject(object, conn);
+                conn.commit();
             }
-            catch (SQLException e)
+            finally
             {
-                throw new StoreException("Error creating ConfiguredObject " + object);
+                conn.close();
             }
         }
-
+        catch (SQLException e)
+        {
+            throw new StoreException("Error creating ConfiguredObject " + object);
+        }
     }
 
     /**
@@ -986,46 +1023,15 @@ abstract public class AbstractJDBCMessag
 
     protected abstract Connection getConnection() throws SQLException;
 
-    private byte[] convertStringMapToBytes(final Map<String, String> arguments) throws StoreException
-    {
-        byte[] argumentBytes;
-        if(arguments == null)
-        {
-            argumentBytes = new byte[0];
-        }
-        else
-        {
-            ByteArrayOutputStream bos = new ByteArrayOutputStream();
-            DataOutputStream dos = new DataOutputStream(bos);
-
-
-            try
-            {
-                dos.writeInt(arguments.size());
-                for(Map.Entry<String,String> arg : arguments.entrySet())
-                {
-                    dos.writeUTF(arg.getKey());
-                    dos.writeUTF(arg.getValue());
-                }
-            }
-            catch (IOException e)
-            {
-                // This should never happen
-                throw new StoreException(e.getMessage(), e);
-            }
-            argumentBytes = bos.toByteArray();
-        }
-        return argumentBytes;
-    }
-
     @Override
     public Transaction newTransaction()
     {
+        checkMessageStoreOpen();
+
         return new JDBCTransaction();
     }
 
-    public void enqueueMessage(ConnectionWrapper connWrapper, final TransactionLogResource queue, Long messageId) throws
-                                                                                                                  StoreException
+    private void enqueueMessage(ConnectionWrapper connWrapper, final TransactionLogResource queue, Long messageId) throws StoreException
     {
         Connection conn = connWrapper.getConnection();
 
@@ -1068,8 +1074,7 @@ abstract public class AbstractJDBCMessag
 
     }
 
-    public void dequeueMessage(ConnectionWrapper connWrapper, final TransactionLogResource  queue, Long messageId) throws
-                                                                                                                   StoreException
+    private void dequeueMessage(ConnectionWrapper connWrapper, final TransactionLogResource  queue, Long messageId) throws StoreException
     {
 
         Connection conn = connWrapper.getConnection();
@@ -1233,11 +1238,6 @@ abstract public class AbstractJDBCMessag
 
     }
 
-    protected boolean isConfigStoreOnly()
-    {
-        return _messageRecoveryHandler == null;
-    }
-
     private static final class ConnectionWrapper
     {
         private final Connection _connection;
@@ -1254,7 +1254,7 @@ abstract public class AbstractJDBCMessag
     }
 
 
-    public void commitTran(ConnectionWrapper connWrapper) throws StoreException
+    private void commitTran(ConnectionWrapper connWrapper) throws StoreException
     {
 
         try
@@ -1279,13 +1279,13 @@ abstract public class AbstractJDBCMessag
         }
     }
 
-    public StoreFuture commitTranAsync(ConnectionWrapper connWrapper) throws StoreException
+    private StoreFuture commitTranAsync(ConnectionWrapper connWrapper) throws StoreException
     {
         commitTran(connWrapper);
         return StoreFuture.IMMEDIATE_FUTURE;
     }
 
-    public void abortTran(ConnectionWrapper connWrapper) throws StoreException
+    private void abortTran(ConnectionWrapper connWrapper) throws StoreException
     {
         if (connWrapper == null)
         {
@@ -1310,11 +1310,6 @@ abstract public class AbstractJDBCMessag
 
     }
 
-    public Long getNewMessageId()
-    {
-        return _messageId.incrementAndGet();
-    }
-
     private void storeMetaData(Connection conn, long messageId, StorableMessageMetaData metaData)
         throws SQLException
     {
@@ -1368,7 +1363,7 @@ abstract public class AbstractJDBCMessag
 
     }
 
-    protected void recoverMessages(MessageStoreRecoveryHandler recoveryHandler) throws SQLException
+    private void recoverMessages(MessageStoreRecoveryHandler recoveryHandler) throws SQLException
     {
         Connection conn = newAutoCommitConnection();
         try
@@ -1425,7 +1420,7 @@ abstract public class AbstractJDBCMessag
     }
 
 
-    protected TransactionLogRecoveryHandler.DtxRecordRecoveryHandler recoverQueueEntries(TransactionLogRecoveryHandler recoveryHandler) throws SQLException
+    private TransactionLogRecoveryHandler.DtxRecordRecoveryHandler recoverQueueEntries(TransactionLogRecoveryHandler recoveryHandler) throws SQLException
     {
         Connection conn = newAutoCommitConnection();
         try
@@ -1555,7 +1550,7 @@ abstract public class AbstractJDBCMessag
         }
     }
 
-    protected void recoverXids(TransactionLogRecoveryHandler.DtxRecordRecoveryHandler dtxrh) throws SQLException
+    private void recoverXids(TransactionLogRecoveryHandler.DtxRecordRecoveryHandler dtxrh) throws SQLException
     {
         Connection conn = newAutoCommitConnection();
         try
@@ -1642,7 +1637,7 @@ abstract public class AbstractJDBCMessag
 
     }
 
-    StorableMessageMetaData getMetaData(long messageId) throws SQLException
+    private StorableMessageMetaData getMetaData(long messageId) throws SQLException
     {
 
         Connection conn = newAutoCommitConnection();
@@ -1724,7 +1719,7 @@ abstract public class AbstractJDBCMessag
 
     }
 
-    public int getContent(long messageId, int offset, ByteBuffer dst)
+    private int getContent(long messageId, int offset, ByteBuffer dst)
     {
         Connection conn = null;
         PreparedStatement stmt = null;
@@ -1805,6 +1800,8 @@ abstract public class AbstractJDBCMessag
         @Override
         public void enqueueMessage(TransactionLogResource queue, EnqueueableMessage message)
         {
+            checkMessageStoreOpen();
+
             final StoredMessage storedMessage = message.getStoredMessage();
             if(storedMessage instanceof StoredJDBCMessage)
             {
@@ -1825,12 +1822,16 @@ abstract public class AbstractJDBCMessag
         @Override
         public void dequeueMessage(TransactionLogResource queue, EnqueueableMessage message)
         {
+            checkMessageStoreOpen();
+
             AbstractJDBCMessageStore.this.dequeueMessage(_connWrapper, queue, message.getMessageNumber());
         }
 
         @Override
         public void commitTran()
         {
+            checkMessageStoreOpen();
+
             AbstractJDBCMessageStore.this.commitTran(_connWrapper);
             storedSizeChange(_storeSizeIncrease);
         }
@@ -1838,6 +1839,8 @@ abstract public class AbstractJDBCMessag
         @Override
         public StoreFuture commitTranAsync()
         {
+            checkMessageStoreOpen();
+
             StoreFuture storeFuture = AbstractJDBCMessageStore.this.commitTranAsync(_connWrapper);
             storedSizeChange(_storeSizeIncrease);
             return storeFuture;
@@ -1846,18 +1849,24 @@ abstract public class AbstractJDBCMessag
         @Override
         public void abortTran()
         {
+            checkMessageStoreOpen();
+
             AbstractJDBCMessageStore.this.abortTran(_connWrapper);
         }
 
         @Override
         public void removeXid(long format, byte[] globalId, byte[] branchId)
         {
+            checkMessageStoreOpen();
+
             AbstractJDBCMessageStore.this.removeXid(_connWrapper, format, globalId, branchId);
         }
 
         @Override
         public void recordXid(long format, byte[] globalId, byte[] branchId, Record[] enqueues, Record[] dequeues)
         {
+            checkMessageStoreOpen();
+
             AbstractJDBCMessageStore.this.recordXid(_connWrapper, format, globalId, branchId, enqueues, dequeues);
         }
     }
@@ -1899,6 +1908,7 @@ abstract public class AbstractJDBCMessag
             StorableMessageMetaData metaData = _metaData == null ? _metaDataRef.get() : _metaData;
             if(metaData == null)
             {
+                checkMessageStoreOpen();
                 try
                 {
                     metaData = AbstractJDBCMessageStore.this.getMetaData(_messageId);
@@ -1954,6 +1964,7 @@ abstract public class AbstractJDBCMessag
             }
             else
             {
+                checkMessageStoreOpen();
                 return AbstractJDBCMessageStore.this.getContent(_messageId, offsetInMessage, dst);
             }
         }
@@ -1972,6 +1983,8 @@ abstract public class AbstractJDBCMessag
         @Override
         public synchronized StoreFuture flushToStore()
         {
+            checkMessageStoreOpen();
+
             Connection conn = null;
             try
             {
@@ -2003,6 +2016,8 @@ abstract public class AbstractJDBCMessag
         @Override
         public void remove()
         {
+            checkMessageStoreOpen();
+
             int delta = getMetaData().getContentSize();
             AbstractJDBCMessageStore.this.removeMessage(_messageId);
             storedSizeChange(-delta);
@@ -2147,12 +2162,13 @@ abstract public class AbstractJDBCMessag
         {
             throw new StoreException("Error inserting of configured object " + configuredObject + " into database: " + e.getMessage(), e);
         }
-
     }
 
     @Override
     public UUID[] remove(ConfiguredObjectRecord... objects) throws StoreException
     {
+        checkConfigurationStoreOpen();
+
         Collection<UUID> removed = new ArrayList<UUID>(objects.length);
         try
         {
@@ -2209,31 +2225,27 @@ abstract public class AbstractJDBCMessag
 
     public void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws StoreException
     {
-        if (_stateManager.isInState(State.ACTIVE) || _stateManager.isInState(State.ACTIVATING))
+        checkConfigurationStoreOpen();
+        try
         {
+            Connection conn = newConnection();
             try
             {
-                Connection conn = newConnection();
-                try
-                {
-                    for(ConfiguredObjectRecord record : records)
-                    {
-                        updateConfiguredObject(record, createIfNecessary, conn);
-                    }
-                    conn.commit();
-                }
-                finally
+                for(ConfiguredObjectRecord record : records)
                 {
-                    conn.close();
+                    updateConfiguredObject(record, createIfNecessary, conn);
                 }
+                conn.commit();
             }
-            catch (SQLException e)
+            finally
             {
-                throw new StoreException("Error updating configured objects in database: " + e.getMessage(), e);
+                conn.close();
             }
-
         }
-
+        catch (SQLException e)
+        {
+            throw new StoreException("Error updating configured objects in database: " + e.getMessage(), e);
+        }
     }
 
     private void updateConfiguredObject(ConfiguredObjectRecord configuredObject,
@@ -2241,89 +2253,88 @@ abstract public class AbstractJDBCMessag
                                         Connection conn)
             throws SQLException, StoreException
     {
-            PreparedStatement stmt = conn.prepareStatement(FIND_CONFIGURED_OBJECT);
+        PreparedStatement stmt = conn.prepareStatement(FIND_CONFIGURED_OBJECT);
+        try
+        {
+            stmt.setString(1, configuredObject.getId().toString());
+            ResultSet rs = stmt.executeQuery();
             try
             {
-                stmt.setString(1, configuredObject.getId().toString());
-                ResultSet rs = stmt.executeQuery();
-                try
+                final ObjectMapper objectMapper = new ObjectMapper();
+                objectMapper.registerModule(_module);
+                if (rs.next())
                 {
-                    final ObjectMapper objectMapper = new ObjectMapper();
-                    objectMapper.registerModule(_module);
-                    if (rs.next())
+                    PreparedStatement stmt2 = conn.prepareStatement(UPDATE_CONFIGURED_OBJECTS);
+                    try
                     {
-                        PreparedStatement stmt2 = conn.prepareStatement(UPDATE_CONFIGURED_OBJECTS);
-                        try
+                        stmt2.setString(1, configuredObject.getType());
+                        if (configuredObject.getAttributes() != null)
                         {
-                            stmt2.setString(1, configuredObject.getType());
-                            if (configuredObject.getAttributes() != null)
-                            {
-                                byte[] attributesAsBytes = objectMapper.writeValueAsBytes(
-                                        configuredObject.getAttributes());
-                                ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes);
-                                stmt2.setBinaryStream(2, bis, attributesAsBytes.length);
-                            }
-                            else
-                            {
-                                stmt2.setNull(2, Types.BLOB);
-                            }
-                            stmt2.setString(3, configuredObject.getId().toString());
-                            stmt2.execute();
+                            byte[] attributesAsBytes = objectMapper.writeValueAsBytes(
+                                    configuredObject.getAttributes());
+                            ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes);
+                            stmt2.setBinaryStream(2, bis, attributesAsBytes.length);
                         }
-                        finally
+                        else
                         {
-                            stmt2.close();
+                            stmt2.setNull(2, Types.BLOB);
                         }
+                        stmt2.setString(3, configuredObject.getId().toString());
+                        stmt2.execute();
+                    }
+                    finally
+                    {
+                        stmt2.close();
                     }
-                    else if(createIfNecessary)
+                }
+                else if(createIfNecessary)
+                {
+                    PreparedStatement insertStmt = conn.prepareStatement(INSERT_INTO_CONFIGURED_OBJECTS);
+                    try
                     {
-                        PreparedStatement insertStmt = conn.prepareStatement(INSERT_INTO_CONFIGURED_OBJECTS);
-                        try
+                        insertStmt.setString(1, configuredObject.getId().toString());
+                        insertStmt.setString(2, configuredObject.getType());
+                        if(configuredObject.getAttributes() == null)
                         {
-                            insertStmt.setString(1, configuredObject.getId().toString());
-                            insertStmt.setString(2, configuredObject.getType());
-                            if(configuredObject.getAttributes() == null)
-                            {
-                                insertStmt.setNull(3, Types.BLOB);
-                            }
-                            else
-                            {
-                                final Map<String, Object> attributes = configuredObject.getAttributes();
-                                byte[] attributesAsBytes = objectMapper.writeValueAsBytes(attributes);
-                                ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes);
-                                insertStmt.setBinaryStream(3, bis, attributesAsBytes.length);
-                            }
-                            insertStmt.execute();
+                            insertStmt.setNull(3, Types.BLOB);
                         }
-                        finally
+                        else
                         {
-                            insertStmt.close();
+                            final Map<String, Object> attributes = configuredObject.getAttributes();
+                            byte[] attributesAsBytes = objectMapper.writeValueAsBytes(attributes);
+                            ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes);
+                            insertStmt.setBinaryStream(3, bis, attributesAsBytes.length);
                         }
-                        writeHierarchy(configuredObject, conn);
+                        insertStmt.execute();
                     }
+                    finally
+                    {
+                        insertStmt.close();
+                    }
+                    writeHierarchy(configuredObject, conn);
                 }
-                finally
-                {
-                    rs.close();
-                }
-            }
-            catch (JsonMappingException e)
-            {
-                throw new StoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e);
-            }
-            catch (JsonGenerationException e)
-            {
-                throw new StoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e);
-            }
-            catch (IOException e)
-            {
-                throw new StoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e);
             }
             finally
             {
-                stmt.close();
+                rs.close();
             }
-
+        }
+        catch (JsonMappingException e)
+        {
+            throw new StoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e);
+        }
+        catch (JsonGenerationException e)
+        {
+            throw new StoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e);
+        }
+        catch (IOException e)
+        {
+            throw new StoreException("Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e);
+        }
+        finally
+        {
+            stmt.close();
+        }
     }
 
     private void writeHierarchy(final ConfiguredObjectRecord configuredObject, final Connection conn) throws SQLException, StoreException
@@ -2450,18 +2461,27 @@ abstract public class AbstractJDBCMessag
     @Override
     public void onDelete()
     {
+        // TODO should probably check we are closed
         try
         {
             Connection conn = newAutoCommitConnection();
             try
             {
-                for (String tableName : ALL_TABLES)
+                List<String> tables = new ArrayList<String>();
+                tables.addAll(CONFIGURATION_STORE_TABLE_NAMES);
+                tables.addAll(MESSAGE_STORE_TABLE_NAMES);
+
+                for (String tableName : tables)
                 {
                     Statement stmt = conn.createStatement();
                     try
                     {
                         stmt.execute("DROP TABLE " +  tableName);
                     }
+                    catch(SQLException e)
+                    {
+                        getLogger().warn("Failed to drop table '" + tableName + "' :" + e);
+                    }
                     finally
                     {
                         stmt.close();

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryMessageStore.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryMessageStore.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractMemoryMessageStore.java Tue Apr  1 10:35:33 2014
@@ -20,17 +20,14 @@
  */
 package org.apache.qpid.server.store;
 
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.qpid.server.message.EnqueueableMessage;
-import org.apache.qpid.server.model.VirtualHost;
 
 /** A simple message store that stores the messages in a thread-safe structure in memory. */
 abstract public class AbstractMemoryMessageStore extends NullMessageStore
 {
     private final AtomicLong _messageId = new AtomicLong(1);
-    private final AtomicBoolean _closed = new AtomicBoolean(false);
 
     private static final Transaction IN_MEMORY_TRANSACTION = new Transaction()
     {
@@ -71,43 +68,8 @@ abstract public class AbstractMemoryMess
         }
     };
 
-    private final StateManager _stateManager;
     private final EventManager _eventManager = new EventManager();
 
-    public AbstractMemoryMessageStore()
-    {
-        _stateManager = new StateManager(_eventManager);
-    }
-
-    @Override
-    public void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler)
-    {
-        _stateManager.attainState(State.INITIALISING);
-    }
-
-    @Override
-    public void configureMessageStore(VirtualHost virtualHost, MessageStoreRecoveryHandler recoveryHandler,
-                                      TransactionLogRecoveryHandler tlogRecoveryHandler)
-    {
-        if(_stateManager.isInState(State.INITIAL))
-        {
-            _stateManager.attainState(State.INITIALISING);
-        }
-        _stateManager.attainState(State.INITIALISED);
-    }
-
-    @Override
-    public void activate()
-    {
-
-        if(_stateManager.isInState(State.INITIALISING))
-        {
-            _stateManager.attainState(State.INITIALISED);
-        }
-        _stateManager.attainState(State.ACTIVATING);
-
-        _stateManager.attainState(State.ACTIVE);
-    }
 
     @Override
     public StoredMessage addMessage(StorableMessageMetaData metaData)
@@ -131,16 +93,6 @@ abstract public class AbstractMemoryMess
     }
 
     @Override
-    public void close()
-    {
-        if (_closed.compareAndSet(false, true))
-        {
-            _stateManager.attainState(State.CLOSING);
-            _stateManager.attainState(State.CLOSED);
-        }
-    }
-
-    @Override
     public void addEventListener(EventListener eventListener, Event... events)
     {
         _eventManager.addEventListener(eventListener, events);

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java Tue Apr  1 10:35:33 2014
@@ -27,6 +27,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+
 import org.apache.log4j.Logger;
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.logging.EventLogger;
@@ -74,6 +75,7 @@ public class DurableConfigurationRecover
 
         _store = store;
         _upgrader = _upgraderProvider.getUpgrader(configVersion, this);
+        _eventLogger.message(_logSubject, ConfigStoreMessages.RECOVERY_START());
     }
 
     @Override

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=1583597&r1=1583596&r2=1583597&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 Tue Apr  1 10:35:33 2014
@@ -23,10 +23,14 @@ package org.apache.qpid.server.store;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.ConfiguredObject;
 
 public interface DurableConfigurationStore
 {
+    String STORE_TYPE                    = "storeType";
+    String STORE_PATH                    = "storePath";
+    String IS_MESSAGE_STORE_TOO          = "isMessageStoreToo";
+
 
     public static interface Source
     {
@@ -36,16 +40,16 @@ public interface DurableConfigurationSto
     /**
      * Called after instantiation in order to configure the message store. A particular implementation can define
      * whatever parameters it wants.
-     *
-     *
-     *
-     *
-     *
-     * @param virtualHost
-     * @param recoveryHandler  Handler to be called as the store recovers on start up
+     * @param parent host name
+     * @param storeSettings store settings
      */
-    void configureConfigStore(VirtualHost virtualHost, ConfigurationRecoveryHandler recoveryHandler);
+    void openConfigurationStore(ConfiguredObject<?> parent, Map<String, Object> storeSettings) throws StoreException;
 
+    /**
+     * Recovers configuration from the store using given recovery handler
+     * @param recoveryHandler recovery handler
+     */
+    void recoverConfigurationStore(ConfigurationRecoveryHandler recoveryHandler) throws StoreException;
 
     /**
      * Makes the specified object persistent.
@@ -78,6 +82,6 @@ public interface DurableConfigurationSto
      */
     void update(boolean createIfNecessary, ConfiguredObjectRecord... records) throws StoreException;
 
+    void closeConfigurationStore() throws StoreException;
 
-    void close() throws Exception;
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/Event.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/Event.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/Event.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/Event.java Tue Apr  1 10:35:33 2014
@@ -21,22 +21,6 @@ package org.apache.qpid.server.store;
 
 public enum Event
 {
-    BEFORE_INIT,
-    AFTER_INIT,
-
-    BEFORE_ACTIVATE,
-    AFTER_ACTIVATE,
-
-    BEFORE_PASSIVATE,
-    AFTER_PASSIVATE,
-
-    BEFORE_CLOSE,
-    AFTER_CLOSE,
-
-    BEFORE_QUIESCE,
-    AFTER_QUIESCE,
-    BEFORE_RESTART,
-
     PERSISTENT_MESSAGE_SIZE_OVERFULL,
     PERSISTENT_MESSAGE_SIZE_UNDERFULL
 }

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=1583597&r1=1583596&r2=1583597&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 Tue Apr  1 10:35:33 2014
@@ -89,12 +89,17 @@ public class JsonFileConfigStore impleme
     }
 
     @Override
-    public void configureConfigStore(final VirtualHost virtualHost, final ConfigurationRecoveryHandler recoveryHandler)
+    public void openConfigurationStore(ConfiguredObject<?> parent, Map<String, Object> storeSettings)
     {
-        _name = virtualHost.getName();
+        _name = parent.getName();
 
-        setup(virtualHost);
+        setup(storeSettings);
         load();
+    }
+
+    @Override
+    public void recoverConfigurationStore(ConfigurationRecoveryHandler recoveryHandler)
+    {
         recoveryHandler.beginConfigurationRecovery(this,_configVersion);
         List<ConfiguredObjectRecord> records = new ArrayList<ConfiguredObjectRecord>(_objectsById.values());
         for(ConfiguredObjectRecord record : records)
@@ -109,9 +114,9 @@ public class JsonFileConfigStore impleme
         }
     }
 
-    protected void setup(final VirtualHost virtualHost)
+    private void setup(final Map<String, Object> configurationStoreSettings)
     {
-        Object storePathAttr = virtualHost.getAttribute(VirtualHost.CONFIG_STORE_PATH);
+        Object storePathAttr = configurationStoreSettings.get(DurableConfigurationStore.STORE_PATH);
         if(!(storePathAttr instanceof String))
         {
             throw new StoreException("Cannot determine path for configuration storage");
@@ -533,12 +538,17 @@ public class JsonFileConfigStore impleme
         save();
     }
 
-    public void close() throws Exception
+    @Override
+    public void closeConfigurationStore()
     {
         try
         {
             releaseFileLock();
         }
+        catch (IOException e)
+        {
+            throw new StoreException("Failed to release lock", e);
+        }
         finally
         {
             _fileLock = null;

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStoreFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStoreFactory.java?rev=1583597&r1=1583596&r2=1583597&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStoreFactory.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStoreFactory.java Tue Apr  1 10:35:33 2014
@@ -21,6 +21,7 @@
 package org.apache.qpid.server.store;
 
 import java.util.Map;
+
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory;
 
@@ -41,10 +42,13 @@ public class JsonFileConfigStoreFactory 
     @Override
     public void validateAttributes(Map<String, Object> attributes)
     {
-        Object storePath = attributes.get(VirtualHost.CONFIG_STORE_PATH);
+        @SuppressWarnings("unchecked")
+        Map<String, Object> configurationStoreSettings = (Map<String, Object>) attributes.get(VirtualHost.CONFIGURATION_STORE_SETTINGS);
+
+        Object storePath = configurationStoreSettings.get(DurableConfigurationStore.STORE_PATH);
         if(!(storePath instanceof String))
         {
-            throw new IllegalArgumentException("Attribute '"+ VirtualHost.CONFIG_STORE_PATH
+            throw new IllegalArgumentException("Setting '"+ DurableConfigurationStore.STORE_PATH
                                                            +"' is required and must be of type String.");
 
         }



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


Mime
View raw message