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/19 10:35:33 UTC

svn commit: r1447646 [5/16] - in /qpid/trunk/qpid/java: ./ bdbstore/ bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/ bdbstore/jmx/src/test/java/org/apache/qpid/server/store/berkeleydb/ bdbstore/src/main/java/org/apache/qpid/serv...

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/GroupProviderRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/GroupProviderRecoverer.java?rev=1447646&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/GroupProviderRecoverer.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/GroupProviderRecoverer.java Tue Feb 19 09:35:28 2013
@@ -0,0 +1,74 @@
+/*
+ *
+ * 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.startup;
+
+import java.util.Map;
+
+import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.configuration.RecovererProvider;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.GroupProvider;
+import org.apache.qpid.server.model.adapter.GroupProviderAdapter;
+import org.apache.qpid.server.plugin.GroupManagerFactory;
+import org.apache.qpid.server.plugin.QpidServiceLoader;
+import org.apache.qpid.server.security.group.GroupManager;
+
+public class GroupProviderRecoverer implements ConfiguredObjectRecoverer<GroupProvider>
+{
+    private QpidServiceLoader<GroupManagerFactory> _groupManagerServiceLoader;
+
+    public GroupProviderRecoverer(QpidServiceLoader<GroupManagerFactory> groupManagerServiceLoader)
+    {
+        super();
+        _groupManagerServiceLoader = groupManagerServiceLoader;
+    }
+
+    @Override
+    public GroupProvider create(RecovererProvider recovererProvider, ConfigurationEntry configurationEntry, ConfiguredObject... parents)
+    {
+        Broker broker = RecovererHelper.verifyOnlyBrokerIsParent(parents);
+        Map<String, Object> attributes = configurationEntry.getAttributes();
+        GroupManager groupManager = createGroupManager(attributes);
+        if (groupManager == null)
+        {
+            throw new IllegalConfigurationException("Cannot create GroupManager from attributes : " + attributes);
+        }
+        GroupProviderAdapter groupProviderAdapter = new GroupProviderAdapter(configurationEntry.getId(), groupManager, broker);
+        return groupProviderAdapter;
+    }
+
+    private GroupManager createGroupManager(Map<String, Object> attributes)
+    {
+        for(GroupManagerFactory factory : _groupManagerServiceLoader.instancesOf(GroupManagerFactory.class))
+        {
+            GroupManager groupManager = factory.createInstance(attributes);
+            if (groupManager != null)
+            {
+               return groupManager;
+            }
+        }
+        return null;
+    }
+
+}

Copied: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/KeyStoreRecoverer.java (from r1447519, qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementFactory.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/KeyStoreRecoverer.java?p2=qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/KeyStoreRecoverer.java&p1=qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementFactory.java&r1=1447519&r2=1447646&rev=1447646&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementFactory.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/KeyStoreRecoverer.java Tue Feb 19 09:35:28 2013
@@ -1,4 +1,5 @@
 /*
+ *
  * 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
@@ -15,32 +16,25 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.qpid.server.jmx;
+package org.apache.qpid.server.configuration.startup;
 
-import org.apache.log4j.Logger;
-import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer;
+import org.apache.qpid.server.configuration.RecovererProvider;
 import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.plugin.ManagementFactory;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.KeyStore;
+import org.apache.qpid.server.model.adapter.KeyStoreAdapter;
 
-public class JMXManagementFactory implements ManagementFactory
+public class KeyStoreRecoverer implements ConfiguredObjectRecoverer<KeyStore>
 {
-    private static final Logger _logger = Logger.getLogger(JMXManagementFactory.class);
-
     @Override
-    public JMXManagement createInstance(ServerConfiguration serverConfiguration, Broker broker)
+    public KeyStore create(RecovererProvider recovererProvider, ConfigurationEntry entry, ConfiguredObject... parents)
     {
-        if (serverConfiguration.getJMXManagementEnabled())
-        {
-            return new JMXManagement(serverConfiguration, broker);
-        }
-        else
-        {
-            if(_logger.isDebugEnabled())
-            {
-                _logger.debug("Skipping registration of JMX plugin as JMX Management disabled in config.");
-            }
-            return null;
-        }
+        Broker broker = RecovererHelper.verifyOnlyBrokerIsParent(parents);
+        return new KeyStoreAdapter(entry.getId(), broker, entry.getAttributes());
     }
+
 }

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PluginRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PluginRecoverer.java?rev=1447646&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PluginRecoverer.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PluginRecoverer.java Tue Feb 19 09:35:28 2013
@@ -0,0 +1,66 @@
+/*
+ *
+ * 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.startup;
+
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.configuration.RecovererProvider;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.plugin.PluginFactory;
+import org.apache.qpid.server.plugin.QpidServiceLoader;
+
+public class PluginRecoverer implements ConfiguredObjectRecoverer<ConfiguredObject>
+{
+    private QpidServiceLoader<PluginFactory> _serviceLoader;
+
+    public PluginRecoverer(QpidServiceLoader<PluginFactory> serviceLoader)
+    {
+        _serviceLoader = serviceLoader;
+    }
+
+    @Override
+    public ConfiguredObject create(RecovererProvider recovererProvider, ConfigurationEntry configurationEntry, ConfiguredObject... parents)
+    {
+        Broker broker = RecovererHelper.verifyOnlyBrokerIsParent(parents);
+        Map<String, Object> attributes = configurationEntry.getAttributes();
+        Iterable<PluginFactory> factories = _serviceLoader.instancesOf(PluginFactory.class);
+        for (PluginFactory pluginFactory : factories)
+        {
+            UUID configurationId = configurationEntry.getId();
+            ConfiguredObject pluginObject = pluginFactory.createInstance(configurationId, attributes, broker);
+            if (pluginObject != null)
+            {
+                UUID pluginId = pluginObject.getId();
+                if (!configurationId.equals(pluginId))
+                {
+                    throw new IllegalStateException("Plugin object id '" + pluginId + "' does not equal expected id " + configurationId);
+                }
+                return pluginObject;
+            }
+        }
+        throw new IllegalConfigurationException("Cannot create a plugin object for " + attributes + " with factories " + factories);
+    }
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PortRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PortRecoverer.java?rev=1447646&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PortRecoverer.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PortRecoverer.java Tue Feb 19 09:35:28 2013
@@ -0,0 +1,52 @@
+/*
+ *
+ * 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.startup;
+
+import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer;
+import org.apache.qpid.server.configuration.RecovererProvider;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.model.adapter.BrokerAdapter;
+import org.apache.qpid.server.model.adapter.PortFactory;
+
+public class PortRecoverer implements ConfiguredObjectRecoverer<Port>
+{
+    /**
+     * delegates to a {@link PortFactory} so that the logic can be shared by
+     * {@link BrokerAdapter}
+     */
+    private final PortFactory _portFactory;
+
+    public PortRecoverer(PortFactory portFactory)
+    {
+        _portFactory = portFactory;
+    }
+
+    @Override
+    public Port create(RecovererProvider recovererProvider, ConfigurationEntry configurationEntry, ConfiguredObject... parents)
+    {
+        Broker broker = RecovererHelper.verifyOnlyBrokerIsParent(parents);
+        return _portFactory.createPort(configurationEntry.getId(), broker, configurationEntry.getAttributes());
+    }
+
+}

Copied: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/RecovererHelper.java (from r1447519, qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/RecovererHelper.java?p2=qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/RecovererHelper.java&p1=qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java&r1=1447519&r2=1447646&rev=1447646&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/RecovererHelper.java Tue Feb 19 09:35:28 2013
@@ -1,4 +1,5 @@
 /*
+ *
  * 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
@@ -17,22 +18,27 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.security.auth.manager;
+package org.apache.qpid.server.configuration.startup;
 
-import org.apache.commons.configuration.Configuration;
-import org.apache.qpid.server.plugin.AuthenticationManagerFactory;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
 
-public class AnonymousAuthenticationManagerFactory implements AuthenticationManagerFactory
+public class RecovererHelper
 {
-    @Override
-    public AuthenticationManager createInstance(Configuration configuration)
+    public static Broker verifyOnlyBrokerIsParent(ConfiguredObject... parents)
     {
-        if (configuration.subset("anonymous-auth-manager").isEmpty())
+        if (parents == null || parents.length == 0)
         {
-            return null;
+            throw new IllegalArgumentException("Broker parent is not passed!");
         }
-
-        return new AnonymousAuthenticationManager();
+        if (parents.length != 1)
+        {
+            throw new IllegalArgumentException("Only one parent is expected!");
+        }
+        if (!(parents[0] instanceof Broker))
+        {
+            throw new IllegalArgumentException("Parent is not a broker");
+        }
+        return (Broker)parents[0];
     }
-
 }

Copied: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/TrustStoreRecoverer.java (from r1447519, qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementFactory.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/TrustStoreRecoverer.java?p2=qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/TrustStoreRecoverer.java&p1=qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementFactory.java&r1=1447519&r2=1447646&rev=1447646&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementFactory.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/TrustStoreRecoverer.java Tue Feb 19 09:35:28 2013
@@ -1,4 +1,5 @@
 /*
+ *
  * 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
@@ -15,32 +16,25 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.qpid.server.jmx;
+package org.apache.qpid.server.configuration.startup;
 
-import org.apache.log4j.Logger;
-import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer;
+import org.apache.qpid.server.configuration.RecovererProvider;
 import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.plugin.ManagementFactory;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.TrustStore;
+import org.apache.qpid.server.model.adapter.TrustStoreAdapter;
 
-public class JMXManagementFactory implements ManagementFactory
+public class TrustStoreRecoverer implements ConfiguredObjectRecoverer<TrustStore>
 {
-    private static final Logger _logger = Logger.getLogger(JMXManagementFactory.class);
-
     @Override
-    public JMXManagement createInstance(ServerConfiguration serverConfiguration, Broker broker)
+    public TrustStore create(RecovererProvider recovererProvider, ConfigurationEntry entry, ConfiguredObject... parents)
     {
-        if (serverConfiguration.getJMXManagementEnabled())
-        {
-            return new JMXManagement(serverConfiguration, broker);
-        }
-        else
-        {
-            if(_logger.isDebugEnabled())
-            {
-                _logger.debug("Skipping registration of JMX plugin as JMX Management disabled in config.");
-            }
-            return null;
-        }
+        Broker broker = RecovererHelper.verifyOnlyBrokerIsParent(parents);
+        return new TrustStoreAdapter(entry.getId(), broker, entry.getAttributes());
     }
+
 }

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/VirtualHostRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/VirtualHostRecoverer.java?rev=1447646&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/VirtualHostRecoverer.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/VirtualHostRecoverer.java Tue Feb 19 09:35:28 2013
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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.startup;
+
+
+import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer;
+import org.apache.qpid.server.configuration.RecovererProvider;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.adapter.VirtualHostAdapter;
+import org.apache.qpid.server.stats.StatisticsGatherer;
+
+public class VirtualHostRecoverer implements ConfiguredObjectRecoverer<VirtualHost>
+{
+    private StatisticsGatherer _brokerStatisticsGatherer;
+
+    public VirtualHostRecoverer(StatisticsGatherer brokerStatisticsGatherer)
+    {
+        super();
+        _brokerStatisticsGatherer = brokerStatisticsGatherer;
+    }
+
+    @Override
+    public VirtualHost create(RecovererProvider recovererProvider, ConfigurationEntry entry, ConfiguredObject... parents)
+    {
+        Broker broker = RecovererHelper.verifyOnlyBrokerIsParent(parents);
+
+        return new VirtualHostAdapter(entry.getId(), entry.getAttributes(), broker, _brokerStatisticsGatherer, broker.getTaskExecutor());
+    }
+
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java?rev=1447646&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java Tue Feb 19 09:35:28 2013
@@ -0,0 +1,528 @@
+package org.apache.qpid.server.configuration.store;
+
+import static org.apache.qpid.server.configuration.ConfigurationEntry.ATTRIBUTE_NAME;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+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.configuration.BrokerConfigurationStoreCreator;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.Model;
+import org.apache.qpid.server.model.UUIDGenerator;
+import org.apache.qpid.util.FileUtils;
+import org.apache.qpid.util.Strings;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.node.ArrayNode;
+
+public class JsonConfigurationEntryStore implements ConfigurationEntryStore
+{
+    private static final String DEFAULT_BROKER_NAME = "Broker";
+    private static final String ID = "id";
+    private static final String TYPE = "@type";
+
+    private ObjectMapper _objectMapper;
+    private Map<UUID, ConfigurationEntry> _entries;
+    private File _storeFile;
+    private UUID _rootId;
+    private String _initialStoreLocation;
+    private Map<String, Class<? extends ConfiguredObject>> _relationshipClasses;
+
+    public JsonConfigurationEntryStore()
+    {
+        this(BrokerConfigurationStoreCreator.INITIAL_STORE_LOCATION);
+    }
+
+    public JsonConfigurationEntryStore(String initialStore)
+    {
+        _initialStoreLocation = initialStore;
+        _objectMapper = new ObjectMapper();
+        _objectMapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
+        _objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
+        _entries = new HashMap<UUID, ConfigurationEntry>();
+        _relationshipClasses = buildRelationshipClassMap();
+    }
+
+    private Map<String, Class<? extends ConfiguredObject>> buildRelationshipClassMap()
+    {
+        Map<String, Class<? extends ConfiguredObject>> relationships = new HashMap<String, Class<? extends ConfiguredObject>>();
+
+        Collection<Class<? extends ConfiguredObject>> children = Model.getInstance().getChildTypes(Broker.class);
+        for (Class<? extends ConfiguredObject> childClass : children)
+        {
+            String name = childClass.getSimpleName().toLowerCase();
+            String relationshipName = name + (name.endsWith("s") ? "es" : "s");
+            relationships.put(relationshipName, childClass);
+        }
+       return relationships;
+    }
+
+    public void load(URL storeURL)
+    {
+        if (_rootId != null)
+        {
+            throw new IllegalStateException("Cannot load the store from");
+        }
+        JsonNode node = load(storeURL, _objectMapper);
+        ConfigurationEntry brokerEntry = toEntry(node, Broker.class, _entries);
+        _rootId = brokerEntry.getId();
+    }
+
+    @Override
+    public void open(String storeLocation)
+    {
+        _storeFile = new File(storeLocation);
+        if (!_storeFile.exists() || _storeFile.length() == 0)
+        {
+            copyInitialStore();
+        }
+
+        load(fileToURL(_storeFile));
+    }
+
+    private void copyInitialStore()
+    {
+        InputStream in = null;
+        try
+        {
+            in = JsonConfigurationEntryStore.class.getClassLoader().getResourceAsStream(_initialStoreLocation);
+            FileUtils.copy(in, _storeFile);
+        }
+        catch (IOException e)
+        {
+            throw new IllegalConfigurationException("Cannot create store file by copying initial store", e);
+        }
+        finally
+        {
+            if (in != null)
+            {
+                try
+                {
+                    in.close();
+                }
+                catch (IOException e)
+                {
+                    throw new IllegalConfigurationException("Cannot close initial store input stream", e);
+                }
+            }
+        }
+    }
+
+    @Override
+    public synchronized UUID[] remove(UUID... entryIds)
+    {
+        List<UUID> removedIds = new ArrayList<UUID>();
+        boolean anyRemoved = false;
+        for (UUID uuid : entryIds)
+        {
+            if (_rootId.equals(uuid))
+            {
+                throw new IllegalConfigurationException("Cannot remove root entry");
+            }
+        }
+        for (UUID uuid : entryIds)
+        {
+            if (removeInternal(uuid))
+            {
+                anyRemoved = true;
+
+                // remove references to the entry from parent entries
+                for (ConfigurationEntry entry : _entries.values())
+                {
+                    if (entry.hasChild(uuid))
+                    {
+                        Set<UUID> children = new HashSet<UUID>(entry.getChildrenIds());
+                        children.remove(uuid);
+                        ConfigurationEntry referal = new ConfigurationEntry(entry.getId(), entry.getType(),
+                                entry.getAttributes(), children, this);
+                        _entries.put(entry.getId(), referal);
+                    }
+                }
+                removedIds.add(uuid);
+            }
+        }
+        if (anyRemoved)
+        {
+            saveAsTree();
+        }
+        return removedIds.toArray(new UUID[removedIds.size()]);
+    }
+
+    @Override
+    public synchronized void save(ConfigurationEntry... entries)
+    {
+        boolean anySaved = false;
+        for (ConfigurationEntry entry : entries)
+        {
+            ConfigurationEntry oldEntry = _entries.put(entry.getId(), entry);
+            if (!entry.equals(oldEntry))
+            {
+                anySaved = true;
+            }
+        }
+        if (anySaved)
+        {
+            saveAsTree();
+        }
+    }
+
+    @Override
+    public ConfigurationEntry getRootEntry()
+    {
+        return getEntry(_rootId);
+    }
+
+    @Override
+    public synchronized ConfigurationEntry getEntry(UUID id)
+    {
+        return _entries.get(id);
+    }
+
+    public void saveTo(File file)
+    {
+        saveAsTree(_rootId, _entries, _objectMapper, file);
+    }
+
+    private URL fileToURL(File storeFile)
+    {
+        URL storeURL = null;
+        try
+        {
+            storeURL = storeFile.toURI().toURL();
+        }
+        catch (MalformedURLException e)
+        {
+            throw new IllegalConfigurationException("Cannot create URL for file " + storeFile, e);
+        }
+        return storeURL;
+    }
+
+    private boolean removeInternal(UUID entryId)
+    {
+        ConfigurationEntry oldEntry = _entries.remove(entryId);
+        if (oldEntry != null)
+        {
+            Set<UUID> children = oldEntry.getChildrenIds();
+            if (children != null && !children.isEmpty())
+            {
+                for (UUID childId : children)
+                {
+                    removeInternal(childId);
+                }
+            }
+            return true;
+        }
+        return false;
+    }
+
+    private void saveAsTree()
+    {
+        if (_storeFile != null)
+        {
+            saveAsTree(_rootId, _entries, _objectMapper, _storeFile);
+        }
+    }
+
+    private void saveAsTree(UUID rootId, Map<UUID, ConfigurationEntry> entries, ObjectMapper mapper, File file)
+    {
+        Map<String, Object> tree = toTree(rootId, entries);
+        try
+        {
+            mapper.writeValue(file, tree);
+        }
+        catch (JsonGenerationException e)
+        {
+            throw new IllegalConfigurationException("Cannot generate json!", e);
+        }
+        catch (JsonMappingException e)
+        {
+            throw new IllegalConfigurationException("Cannot map objects for json serialization!", e);
+        }
+        catch (IOException e)
+        {
+            throw new IllegalConfigurationException("Cannot save configuration into " + file + "!", e);
+        }
+    }
+
+    private Map<String, Object> toTree(UUID rootId, Map<UUID, ConfigurationEntry> entries)
+    {
+        ConfigurationEntry entry = entries.get(rootId);
+        if (entry == null || !entry.getId().equals(rootId))
+        {
+            throw new IllegalConfigurationException("Cannot find entry with id " + rootId + "!");
+        }
+        Map<String, Object> tree = new TreeMap<String, Object>();
+        Map<String, Object> attributes = entry.getAttributes();
+        if (attributes != null)
+        {
+            tree.putAll( attributes);
+        }
+        tree.put(ID, entry.getId());
+        tree.put(TYPE, entry.getType());
+        Set<UUID> childrenIds = entry.getChildrenIds();
+        if (childrenIds != null && !childrenIds.isEmpty())
+        {
+            for (UUID relationship : childrenIds)
+            {
+                ConfigurationEntry child = entries.get(relationship);
+                if (child != null)
+                {
+                    String relationshipName = child.getType().toLowerCase() + "s";
+
+                    @SuppressWarnings("unchecked")
+                    Collection<Map<String, Object>> children = (Collection<Map<String, Object>>) tree.get(relationshipName);
+                    if (children == null)
+                    {
+                        children = new ArrayList<Map<String, Object>>();
+                        tree.put(relationshipName, children);
+                    }
+                    Map<String, Object> childAsMap = toTree(relationship, entries);
+                    children.add(childAsMap);
+                }
+            }
+        }
+        return tree;
+    }
+
+    private JsonNode load(URL url, ObjectMapper mapper)
+    {
+        JsonNode root = null;
+        try
+        {
+            root = mapper.readTree(url);
+        }
+        catch (JsonProcessingException e)
+        {
+            throw new IllegalConfigurationException("Cannot parse json from '" + url + "'", e);
+        }
+        catch (IOException e)
+        {
+            throw new IllegalConfigurationException("Cannot read from '" + url + "'", e);
+        }
+        return root;
+    }
+
+    private ConfigurationEntry toEntry(JsonNode parent, Class<? extends ConfiguredObject> expectedConfiguredObjectClass, Map<UUID, ConfigurationEntry> entries)
+    {
+        Map<String, Object> attributes = null;
+        Set<UUID> childrenIds = new TreeSet<UUID>();
+        Iterator<String> fieldNames = parent.getFieldNames();
+        String type = null;
+        String idAsString = null;
+        while (fieldNames.hasNext())
+        {
+            String fieldName = fieldNames.next();
+            JsonNode fieldNode = parent.get(fieldName);
+            if (fieldName.equals(ID))
+            {
+                idAsString = fieldNode.asText();
+            }
+            else if (fieldName.equals(TYPE))
+            {
+                type = fieldNode.asText();
+            }
+            else if (fieldNode.isArray())
+            {
+                // array containing either broker children or attribute values
+                Iterator<JsonNode> elements = fieldNode.getElements();
+                List<Object> fieldValues = null;
+                while (elements.hasNext())
+                {
+                    JsonNode element = elements.next();
+                    if (element.isObject())
+                    {
+                        Class<? extends ConfiguredObject> expectedChildConfiguredObjectClass = _relationshipClasses.get(fieldName);
+                        // assuming it is a child node
+                        ConfigurationEntry entry = toEntry(element, expectedChildConfiguredObjectClass, entries);
+                        childrenIds.add(entry.getId());
+                    }
+                    else
+                    {
+                        if (fieldValues == null)
+                        {
+                            fieldValues = new ArrayList<Object>();
+                        }
+                        fieldValues.add(toObject(element));
+                    }
+                }
+                if (fieldValues != null)
+                {
+                    Object[] array = fieldValues.toArray(new Object[fieldValues.size()]);
+                    attributes.put(fieldName, array);
+                }
+            }
+            else if (fieldNode.isObject())
+            {
+                // ignore, in-line objects are not supported yet
+            }
+            else
+            {
+                // primitive attribute
+                Object value = toObject(fieldNode);
+                if (attributes == null)
+                {
+                    attributes = new HashMap<String, Object>();
+                }
+                attributes.put(fieldName, value);
+            }
+        }
+
+        if (type == null)
+        {
+            if (expectedConfiguredObjectClass == null)
+            {
+                throw new IllegalConfigurationException("Type attribute is not provided for configuration entry " + parent);
+            }
+            else
+            {
+                type = expectedConfiguredObjectClass.getSimpleName();
+            }
+        }
+        String name = null;
+        if (attributes != null)
+        {
+            name = (String) attributes.get(ATTRIBUTE_NAME);
+        }
+        if ((name == null || "".equals(name)))
+        {
+            if (expectedConfiguredObjectClass == Broker.class)
+            {
+                name = DEFAULT_BROKER_NAME;
+            }
+            else
+            {
+                throw new IllegalConfigurationException("Name attribute is not provided for configuration entry " + parent);
+            }
+        }
+        UUID id = null;
+        if (idAsString == null)
+        {
+            if (expectedConfiguredObjectClass == Broker.class)
+            {
+                id = UUIDGenerator.generateRandomUUID();
+            }
+            else
+            {
+                id = UUIDGenerator.generateBrokerChildUUID(type, name);
+            }
+        }
+        else
+        {
+            try
+            {
+                id = UUID.fromString(idAsString);
+            }
+            catch (Exception e)
+            {
+                throw new IllegalConfigurationException(
+                        "ID attribute value does not conform to UUID format for configuration entry " + parent);
+            }
+        }
+        ConfigurationEntry entry = new ConfigurationEntry(id, type, attributes, childrenIds, this);
+        if (entries.containsKey(id))
+        {
+            throw new IllegalConfigurationException("Duplicate id is found: " + id
+                    + "! The following configuration entries have the same id: " + entries.get(id) + ", " + entry);
+        }
+        entries.put(id, entry);
+        return entry;
+    }
+
+    private Object toObject(JsonNode node)
+    {
+        if (node.isValueNode())
+        {
+            if (node.isBoolean())
+            {
+                return node.asBoolean();
+            }
+            else if (node.isDouble())
+            {
+                return node.asDouble();
+            }
+            else if (node.isInt())
+            {
+                return node.asInt();
+            }
+            else if (node.isLong())
+            {
+                return node.asLong();
+            }
+            else if (node.isNull())
+            {
+                return null;
+            }
+            else
+            {
+                return Strings.expand(node.asText());
+            }
+        }
+        else if (node.isArray())
+        {
+            return toArray(node);
+        }
+        else if (node.isObject())
+        {
+            return toMap(node);
+        }
+        else
+        {
+            throw new IllegalConfigurationException("Unexpected node: " + node);
+        }
+    }
+
+    private Map<String, Object> toMap(JsonNode node)
+    {
+        Map<String, Object> object = new TreeMap<String, Object>();
+        Iterator<String> fieldNames = node.getFieldNames();
+        while (fieldNames.hasNext())
+        {
+            String name = fieldNames.next();
+            Object value = toObject(node.get(name));
+            object.put(name, value);
+        }
+        return object;
+    }
+
+    private Object toArray(JsonNode node)
+    {
+        ArrayNode arrayNode = (ArrayNode) node;
+        Object[] array = new Object[arrayNode.size()];
+        Iterator<JsonNode> elements = arrayNode.getElements();
+        for (int i = 0; i < array.length; i++)
+        {
+            array[i] = toObject(elements.next());
+        }
+        return array;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "JsonConfigurationEntryStore [_storeFile=" + _storeFile + ", _rootId=" + _rootId + ", _initialStoreLocation="
+                + _initialStoreLocation + "]";
+    }
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java?rev=1447646&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/StoreConfigurationChangeListener.java Tue Feb 19 09:35:28 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 + "]";
+    }
+}

Copied: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/factory/JsonConfigurationStoreFactory.java (from r1447519, qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/management/jmx/UserManagementWithBase64MD5PasswordsTest.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/factory/JsonConfigurationStoreFactory.java?p2=qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/factory/JsonConfigurationStoreFactory.java&p1=qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/management/jmx/UserManagementWithBase64MD5PasswordsTest.java&r1=1447519&r2=1447646&rev=1447646&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/systest/management/jmx/UserManagementWithBase64MD5PasswordsTest.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/factory/JsonConfigurationStoreFactory.java Tue Feb 19 09:35:28 2013
@@ -1,4 +1,5 @@
 /*
+ *
  * 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
@@ -15,25 +16,28 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.qpid.systest.management.jmx;
+package org.apache.qpid.server.configuration.store.factory;
 
-import org.apache.qpid.server.security.auth.database.Base64MD5PasswordFilePrincipalDatabase;
-import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
-import org.apache.qpid.tools.security.Passwd;
+import org.apache.qpid.server.configuration.ConfigurationEntryStore;
+import org.apache.qpid.server.configuration.ConfigurationStoreFactory;
+import org.apache.qpid.server.configuration.store.JsonConfigurationEntryStore;
 
-public class UserManagementWithBase64MD5PasswordsTest extends UserManagementTest
+public class JsonConfigurationStoreFactory implements ConfigurationStoreFactory
 {
+    private static final String STORE_TYPE = "json";
+
     @Override
-    protected Passwd createPasswordEncodingUtility()
+    public ConfigurationEntryStore createStore()
     {
-        return new Passwd();
+        return new JsonConfigurationEntryStore();
     }
 
     @Override
-    protected Class<? extends PrincipalDatabase> getPrincipalDatabaseImplClass()
+    public String getStoreType()
     {
-        return Base64MD5PasswordFilePrincipalDatabase.class;
+        return STORE_TYPE;
     }
 
 }

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/updater/ChangeStateTask.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/updater/ChangeStateTask.java?rev=1447646&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/updater/ChangeStateTask.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/updater/ChangeStateTask.java Tue Feb 19 09:35:28 2013
@@ -0,0 +1,67 @@
+/*
+ *
+ * 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.updater;
+
+import java.util.concurrent.Callable;
+
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.State;
+
+public final class ChangeStateTask implements Callable<State>
+{
+    private ConfiguredObject _object;
+    private State _expectedState;
+    private State _desiredState;
+
+    public ChangeStateTask(ConfiguredObject object, State expectedState, State desiredState)
+    {
+        _object = object;
+        _expectedState = expectedState;
+        _desiredState = desiredState;
+    }
+
+    public ConfiguredObject getObject()
+    {
+        return _object;
+    }
+
+    public State getExpectedState()
+    {
+        return _expectedState;
+    }
+
+    public State getDesiredState()
+    {
+        return _desiredState;
+    }
+
+    @Override
+    public State call()
+    {
+        return _object.setDesiredState(_expectedState, _desiredState);
+    }
+
+    @Override
+    public String toString()
+    {
+        return "ChangeStateTask [object=" + _object + ", expectedState=" + _expectedState + ", desiredState=" + _desiredState + "]";
+    }
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/updater/CreateChildTask.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/updater/CreateChildTask.java?rev=1447646&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/updater/CreateChildTask.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/updater/CreateChildTask.java Tue Feb 19 09:35:28 2013
@@ -0,0 +1,78 @@
+/*
+ *
+ * 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.updater;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.concurrent.Callable;
+
+import org.apache.qpid.server.model.ConfiguredObject;
+
+public final class CreateChildTask implements Callable<ConfiguredObject>
+{
+    private ConfiguredObject _object;
+    private Class<? extends ConfiguredObject> _childClass;
+    private Map<String, Object> _attributes;
+    private ConfiguredObject[] _otherParents;
+
+    public CreateChildTask(ConfiguredObject object, Class<? extends ConfiguredObject> childClass, Map<String, Object> attributes,
+            ConfiguredObject... otherParents)
+    {
+        _object = object;
+        _childClass = childClass;
+        _attributes = attributes;
+        _otherParents = otherParents;
+    }
+
+    public ConfiguredObject getObject()
+    {
+        return _object;
+    }
+
+    public Class<? extends ConfiguredObject> getChildClass()
+    {
+        return _childClass;
+    }
+
+    public Map<String, Object> getAttributes()
+    {
+        return _attributes;
+    }
+
+    public ConfiguredObject[] getOtherParents()
+    {
+        return _otherParents;
+    }
+
+    @Override
+    public ConfiguredObject call()
+    {
+        return _object.createChild(_childClass, _attributes, _otherParents);
+    }
+
+    @Override
+    public String toString()
+    {
+        return "CreateChildTask [object=" + _object + ", childClass=" + _childClass + ", attributes=" + _attributes
+                + ", otherParents=" + Arrays.toString(_otherParents) + "]";
+    }
+
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/updater/SetAttributeTask.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/updater/SetAttributeTask.java?rev=1447646&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/updater/SetAttributeTask.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/updater/SetAttributeTask.java Tue Feb 19 09:35:28 2013
@@ -0,0 +1,74 @@
+/*
+ *
+ * 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.updater;
+
+import java.util.concurrent.Callable;
+
+import org.apache.qpid.server.model.ConfiguredObject;
+
+public final class SetAttributeTask implements Callable<Object>
+{
+    private ConfiguredObject _object;
+    private String _attributeName;
+    private Object _expectedValue;
+    private Object _desiredValue;
+
+    public SetAttributeTask(ConfiguredObject object, String attributeName, Object expectedValue, Object desiredValue)
+    {
+        _object = object;
+        _attributeName = attributeName;
+        _expectedValue = expectedValue;
+        _desiredValue = desiredValue;
+    }
+
+    public ConfiguredObject getObject()
+    {
+        return _object;
+    }
+
+    public String getAttributeName()
+    {
+        return _attributeName;
+    }
+
+    public Object getExpectedValue()
+    {
+        return _expectedValue;
+    }
+
+    public Object getDesiredValue()
+    {
+        return _desiredValue;
+    }
+
+    @Override
+    public Object call()
+    {
+        return _object.setAttribute(_attributeName, _expectedValue, _desiredValue);
+    }
+
+    @Override
+    public String toString()
+    {
+        return "SetAttributeTask [object=" + _object + ", attributeName=" + _attributeName + ", expectedValue=" + _expectedValue
+                + ", desiredValue=" + _desiredValue + "]";
+    }
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/updater/TaskExecutor.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/updater/TaskExecutor.java?rev=1447646&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/updater/TaskExecutor.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/updater/TaskExecutor.java Tue Feb 19 09:35:28 2013
@@ -0,0 +1,324 @@
+/*
+ *
+ * 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.updater;
+
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.RunnableFuture;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.security.auth.Subject;
+
+import org.apache.log4j.Logger;
+import org.apache.qpid.server.logging.LogActor;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.model.State;
+import org.apache.qpid.server.security.SecurityManager;
+
+public class TaskExecutor
+{
+    private static final String TASK_EXECUTION_THREAD_NAME = "Broker-Configuration-Thread";
+    private static final Logger LOGGER = Logger.getLogger(TaskExecutor.class);
+
+    private volatile Thread _taskThread;
+    private final AtomicReference<State> _state;
+    private volatile ExecutorService _executor;
+
+    public TaskExecutor()
+    {
+        _state = new AtomicReference<State>(State.INITIALISING);
+    }
+
+    public State getState()
+    {
+        return _state.get();
+    }
+
+    public void start()
+    {
+        if (_state.compareAndSet(State.INITIALISING, State.ACTIVE))
+        {
+            LOGGER.debug("Starting task executor");
+            _executor = Executors.newFixedThreadPool(1, new ThreadFactory()
+            {
+                @Override
+                public Thread newThread(Runnable r)
+                {
+                    _taskThread = new Thread(r, TASK_EXECUTION_THREAD_NAME);
+                    return _taskThread;
+                }
+            });
+            LOGGER.debug("Task executor is started");
+        }
+    }
+
+    public void stopImmediately()
+    {
+        if (_state.compareAndSet(State.ACTIVE, State.STOPPED))
+        {
+            ExecutorService executor = _executor;
+            if (executor != null)
+            {
+                LOGGER.debug("Stopping task executor immediately");
+                List<Runnable> cancelledTasks = executor.shutdownNow();
+                if (cancelledTasks != null)
+                {
+                    for (Runnable runnable : cancelledTasks)
+                    {
+                        if (runnable instanceof RunnableFuture<?>)
+                        {
+                            ((RunnableFuture<?>) runnable).cancel(true);
+                        }
+                    }
+                }
+                _executor = null;
+                _taskThread = null;
+                LOGGER.debug("Task executor was stopped immediately. Number of unfinished tasks: " + cancelledTasks.size());
+            }
+        }
+    }
+
+    public void stop()
+    {
+        if (_state.compareAndSet(State.ACTIVE, State.STOPPED))
+        {
+            ExecutorService executor = _executor;
+            if (executor != null)
+            {
+                LOGGER.debug("Stopping task executor");
+                executor.shutdown();
+                _executor = null;
+                _taskThread = null;
+                LOGGER.debug("Task executor is stopped");
+            }
+        }
+    }
+
+    Future<?> submit(Callable<?> task)
+    {
+        checkState();
+        if (LOGGER.isDebugEnabled())
+        {
+            LOGGER.debug("Submitting task: " + task);
+        }
+        Future<?> future = null;
+        if (isTaskExecutorThread())
+        {
+            Object result = executeTaskAndHandleExceptions(task);
+            return new ImmediateFuture(result);
+        }
+        else
+        {
+            future = _executor.submit(new CallableWrapper(task));
+        }
+        return future;
+    }
+
+    public Object submitAndWait(Callable<?> task) throws CancellationException
+    {
+        try
+        {
+            Future<?> future = submit(task);
+            return future.get();
+        }
+        catch (InterruptedException e)
+        {
+            throw new RuntimeException("Task execution was interrupted: " + task, e);
+        }
+        catch (ExecutionException e)
+        {
+            Throwable cause = e.getCause();
+            if (cause instanceof RuntimeException)
+            {
+                throw (RuntimeException) cause;
+            }
+            else if (cause instanceof Exception)
+            {
+                throw new RuntimeException("Failed to execute user task: " + task, cause);
+            }
+            else if (cause instanceof Error)
+            {
+                throw (Error) cause;
+            }
+            else
+            {
+                throw new RuntimeException("Failed to execute user task: " + task, cause);
+            }
+        }
+    }
+
+    public boolean isTaskExecutorThread()
+    {
+        return Thread.currentThread() == _taskThread;
+    }
+
+    private void checkState()
+    {
+        if (_state.get() != State.ACTIVE)
+        {
+            throw new IllegalStateException("Task executor is not in ACTIVE state");
+        }
+    }
+
+    private Object executeTaskAndHandleExceptions(Callable<?> userTask)
+    {
+        try
+        {
+            return executeTask(userTask);
+        }
+        catch (Exception e)
+        {
+            if (e instanceof RuntimeException)
+            {
+                throw (RuntimeException) e;
+            }
+            throw new RuntimeException("Failed to execute user task: " + userTask, e);
+        }
+    }
+
+    private Object executeTask(Callable<?> userTask) throws Exception
+    {
+        if (LOGGER.isDebugEnabled())
+        {
+            LOGGER.debug("Performing task " + userTask);
+        }
+        Object result = userTask.call();
+        if (LOGGER.isDebugEnabled())
+        {
+            LOGGER.debug("Task " + userTask + " is performed successfully with result:" + result);
+        }
+        return result;
+    }
+
+    private class CallableWrapper implements Callable<Object>
+    {
+        private Callable<?> _userTask;
+        private Subject _securityManagerSubject;
+        private LogActor _actor;
+        private Subject _contextSubject;
+
+        public CallableWrapper(Callable<?> userWork)
+        {
+            _userTask = userWork;
+            _securityManagerSubject = SecurityManager.getThreadSubject();
+            _actor = CurrentActor.get();
+            _contextSubject = Subject.getSubject(AccessController.getContext());
+        }
+
+        @Override
+        public Object call() throws Exception
+        {
+            SecurityManager.setThreadSubject(_securityManagerSubject);
+            CurrentActor.set(_actor);
+
+            try
+            {
+                Object result = null;
+                try
+                {
+                    result = Subject.doAs(_contextSubject, new PrivilegedExceptionAction<Object>()
+                    {
+                        @Override
+                        public Object run() throws Exception
+                        {
+                            return executeTask(_userTask);
+                        }
+                    });
+                }
+                catch (PrivilegedActionException e)
+                {
+                    throw e.getException();
+                }
+                return result;
+            }
+            finally
+            {
+                try
+                {
+                    CurrentActor.remove();
+                }
+                catch (Exception e)
+                {
+                    LOGGER.warn("Unxpected exception on current actor removal", e);
+                }
+                try
+                {
+                    SecurityManager.setThreadSubject(null);
+                }
+                catch (Exception e)
+                {
+                    LOGGER.warn("Unxpected exception on nullifying of subject for a security manager", e);
+                }
+            }
+        }
+    }
+
+    private class ImmediateFuture implements Future<Object>
+    {
+        private Object _result;
+
+        public ImmediateFuture(Object result)
+        {
+            super();
+            this._result = result;
+        }
+
+        @Override
+        public boolean cancel(boolean mayInterruptIfRunning)
+        {
+            return false;
+        }
+
+        @Override
+        public boolean isCancelled()
+        {
+            return false;
+        }
+
+        @Override
+        public boolean isDone()
+        {
+            return true;
+        }
+
+        @Override
+        public Object get()
+        {
+            return _result;
+        }
+
+        @Override
+        public Object get(long timeout, TimeUnit unit)
+        {
+            return get();
+        }
+    }
+}

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionSecureOkMethodHandler.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionSecureOkMethodHandler.java?rev=1447646&r1=1447645&r2=1447646&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionSecureOkMethodHandler.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionSecureOkMethodHandler.java Tue Feb 19 09:35:28 2013
@@ -30,8 +30,9 @@ import org.apache.qpid.framing.Connectio
 import org.apache.qpid.framing.ConnectionTuneBody;
 import org.apache.qpid.framing.MethodRegistry;
 import org.apache.qpid.protocol.AMQConstant;
+import org.apache.qpid.server.configuration.BrokerProperties;
+import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
-import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.security.SubjectCreator;
 import org.apache.qpid.server.security.auth.SubjectAuthenticationResult;
 import org.apache.qpid.server.state.AMQState;
@@ -58,6 +59,7 @@ public class ConnectionSecureOkMethodHan
 
     public void methodReceived(AMQStateManager stateManager, ConnectionSecureOkBody body, int channelId) throws AMQException
     {
+        Broker broker = stateManager.getBroker();
         AMQProtocolSession session = stateManager.getProtocolSession();
 
         SubjectCreator subjectCreator = stateManager.getSubjectCreator();
@@ -96,9 +98,9 @@ public class ConnectionSecureOkMethodHan
                 stateManager.changeState(AMQState.CONNECTION_NOT_TUNED);
 
                 ConnectionTuneBody tuneBody =
-                        methodRegistry.createConnectionTuneBody(ApplicationRegistry.getInstance().getConfiguration().getMaxChannelCount(),
-                                                                ConnectionStartOkMethodHandler.getConfiguredFrameSize(),
-                                                                ApplicationRegistry.getInstance().getConfiguration().getHeartBeatDelay());
+                        methodRegistry.createConnectionTuneBody((Integer)broker.getAttribute(Broker.SESSION_COUNT_LIMIT),
+                                                                BrokerProperties.DEFAULT_FRAME_SIZE,
+                                                                (Integer)broker.getAttribute(Broker.HEART_BEAT_DELAY));
                 session.writeFrame(tuneBody.generateFrame(0));
                 session.setAuthorizedSubject(authResult.getSubject());
                 disposeSaslServer(session);

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java?rev=1447646&r1=1447645&r2=1447646&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/ConnectionStartOkMethodHandler.java Tue Feb 19 09:35:28 2013
@@ -29,9 +29,9 @@ import org.apache.qpid.framing.Connectio
 import org.apache.qpid.framing.ConnectionTuneBody;
 import org.apache.qpid.framing.MethodRegistry;
 import org.apache.qpid.protocol.AMQConstant;
-import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.configuration.BrokerProperties;
+import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
-import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.security.SubjectCreator;
 import org.apache.qpid.server.security.auth.SubjectAuthenticationResult;
 import org.apache.qpid.server.state.AMQState;
@@ -59,6 +59,7 @@ public class ConnectionStartOkMethodHand
 
     public void methodReceived(AMQStateManager stateManager, ConnectionStartOkBody body, int channelId) throws AMQException
     {
+        Broker broker = stateManager.getBroker();
         AMQProtocolSession session = stateManager.getProtocolSession();
 
         _logger.info("SASL Mechanism selected: " + body.getMechanism());
@@ -111,9 +112,9 @@ public class ConnectionStartOkMethodHand
 
                     stateManager.changeState(AMQState.CONNECTION_NOT_TUNED);
 
-                    ConnectionTuneBody tuneBody = methodRegistry.createConnectionTuneBody(ApplicationRegistry.getInstance().getConfiguration().getMaxChannelCount(),
-                                                                                          getConfiguredFrameSize(),
-                                                                                          ApplicationRegistry.getInstance().getConfiguration().getHeartBeatDelay());
+                    ConnectionTuneBody tuneBody = methodRegistry.createConnectionTuneBody((Integer)broker.getAttribute(Broker.SESSION_COUNT_LIMIT),
+                                                                                          BrokerProperties.DEFAULT_FRAME_SIZE,
+                                                                                          (Integer)broker.getAttribute(Broker.HEART_BEAT_DELAY));
                     session.writeFrame(tuneBody.generateFrame(0));
                     break;
                 case CONTINUE:
@@ -147,13 +148,6 @@ public class ConnectionStartOkMethodHand
         }
     }
 
-    static int getConfiguredFrameSize()
-    {
-        final ServerConfiguration config = ApplicationRegistry.getInstance().getConfiguration();
-        final int framesize = config.getFrameSize();
-        _logger.info("Framesize set to " + framesize);
-        return framesize;
-    }
 }
 
 

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java?rev=1447646&r1=1447645&r2=1447646&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java Tue Feb 19 09:35:28 2013
@@ -38,7 +38,6 @@ import org.apache.qpid.server.protocol.A
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.AMQQueueFactory;
 import org.apache.qpid.server.queue.QueueRegistry;
-import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.state.AMQStateManager;
 import org.apache.qpid.server.state.StateAwareMethodListener;
 import org.apache.qpid.server.store.DurableConfigurationStore;
@@ -59,8 +58,6 @@ public class QueueDeclareHandler impleme
         return _instance;
     }
 
-    private boolean autoRegister = ApplicationRegistry.getInstance().getConfiguration().getQueueAutoRegister();
-
     public void methodReceived(AMQStateManager stateManager, QueueDeclareBody body, int channelId) throws AMQException
     {
         final AMQProtocolSession protocolConnection = stateManager.getProtocolSession();
@@ -148,13 +145,11 @@ public class QueueDeclareHandler impleme
                             });
                         }
                     }
-                    if (autoRegister)
-                    {
-                        Exchange defaultExchange = exchangeRegistry.getDefaultExchange();
+                    Exchange defaultExchange = exchangeRegistry.getDefaultExchange();
 
-                        virtualHost.getBindingFactory().addBinding(String.valueOf(queueName), queue, defaultExchange, Collections.EMPTY_MAP);
-                        _logger.info("Queue " + queueName + " bound to default exchange(" + defaultExchange.getNameShortString() + ")");
-                    }
+                    virtualHost.getBindingFactory().addBinding(String.valueOf(queueName), queue, defaultExchange,
+                            Collections.<String, Object> emptyMap());
+                    _logger.info("Queue " + queueName + " bound to default exchange(" + defaultExchange.getNameShortString() + ")");
                 }
             }
             else if (queue.isExclusive() && !queue.isDurable() && (owningSession == null || owningSession.getConnectionModel() != protocolConnection))

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/AbstractRootMessageLogger.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/AbstractRootMessageLogger.java?rev=1447646&r1=1447645&r2=1447646&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/AbstractRootMessageLogger.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/AbstractRootMessageLogger.java Tue Feb 19 09:35:28 2013
@@ -20,7 +20,6 @@
  */
 package org.apache.qpid.server.logging;
 
-import org.apache.qpid.server.configuration.ServerConfiguration;
 
 public abstract class AbstractRootMessageLogger implements RootMessageLogger
 {
@@ -33,9 +32,9 @@ public abstract class AbstractRootMessag
 
     }
     
-    public AbstractRootMessageLogger(ServerConfiguration config)
+    public AbstractRootMessageLogger(boolean statusUpdatesEnabled)
     {
-        _enabled = config.getStatusUpdatesEnabled();
+        _enabled = statusUpdatesEnabled;
     }
     
     public boolean isEnabled()

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/Log4jMessageLogger.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/Log4jMessageLogger.java?rev=1447646&r1=1447645&r2=1447646&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/Log4jMessageLogger.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/Log4jMessageLogger.java Tue Feb 19 09:35:28 2013
@@ -21,7 +21,6 @@
 package org.apache.qpid.server.logging;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.server.configuration.ServerConfiguration;
 
 public class Log4jMessageLogger extends AbstractRootMessageLogger
 {
@@ -30,9 +29,9 @@ public class Log4jMessageLogger extends 
         super();
     }
 
-    public Log4jMessageLogger(ServerConfiguration config)
+    public Log4jMessageLogger(boolean statusUpdatesEnabled)
     {
-        super(config);
+        super(statusUpdatesEnabled);
     }
     
     @Override

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java?rev=1447646&r1=1447645&r2=1447646&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java Tue Feb 19 09:35:28 2013
@@ -24,6 +24,9 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 
+import org.apache.qpid.server.security.SubjectCreator;
+import org.apache.qpid.server.security.group.GroupPrincipalAccessor;
+
 public interface AuthenticationProvider extends ConfiguredObject
 {
 
@@ -52,4 +55,15 @@ public interface AuthenticationProvider 
                                   TYPE));
     //children
     Collection<VirtualHostAlias> getVirtualHostPortBindings();
+
+    String getName();
+
+    /**
+     * A temporary method to create SubjectCreator.
+     *
+     * TODO: move all the functionality from SubjectCreator into AuthenticationProvider
+     */
+    SubjectCreator getSubjectCreator();
+
+    void setGroupAccessor(GroupPrincipalAccessor groupPrincipalAccessor);
 }

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java?rev=1447646&r1=1447645&r2=1447646&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java Tue Feb 19 09:35:28 2013
@@ -20,12 +20,20 @@
  */
 package org.apache.qpid.server.model;
 
+import java.net.SocketAddress;
 import java.security.AccessControlException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
 
+import org.apache.qpid.server.logging.LogRecorder;
+import org.apache.qpid.server.logging.RootMessageLogger;
+import org.apache.qpid.server.configuration.updater.TaskExecutor;
+import org.apache.qpid.server.security.SecurityManager;
+import org.apache.qpid.server.security.SubjectCreator;
+import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
+
 public interface Broker extends ConfiguredObject
 {
 
@@ -44,9 +52,49 @@ public interface Broker extends Configur
     String STATE = "state";
     String TIME_TO_LIVE = "timeToLive";
     String UPDATED = "updated";
+    String DEFAULT_AUTHENTICATION_PROVIDER = "defaultAuthenticationProvider";
+    String DEFAULT_VIRTUAL_HOST = "defaultVirtualHost";
+
+    String ALERT_THRESHOLD_MESSAGE_AGE = "alertThresholdMessageAge";
+    String ALERT_THRESHOLD_MESSAGE_COUNT = "alertThresholdMessageCount";
+    String ALERT_THRESHOLD_QUEUE_DEPTH = "alertThresholdQueueDepth";
+    String ALERT_THRESHOLD_MESSAGE_SIZE = "alertThresholdMessageSize";
+    String ALERT_REPEAT_GAP = "alertRepeatGap";
+    String FLOW_CONTROL_SIZE_BYTES = "queueFlowControlSizeBytes";
+    String FLOW_CONTROL_RESUME_SIZE_BYTES = "queueFlowResumeSizeBytes";
+    String MAXIMUM_DELIVERY_ATTEMPTS = "maximumDeliveryAttempts";
+    String DEAD_LETTER_QUEUE_ENABLED = "deadLetterQueueEnabled";
+    String HOUSEKEEPING_CHECK_PERIOD = "housekeepingCheckPeriod";
+
+    String SESSION_COUNT_LIMIT = "sessionCountLimit";
+    String HEART_BEAT_DELAY = "heartBeatDelay";
+    String STATISTICS_REPORTING_PERIOD = "statisticsReportingPeriod";
+    String STATISTICS_REPORTING_RESET_ENABLED = "statisticsReportingResetEnabled";
+
+    /*
+     * A temporary attribute to pass the path to ACL file.
+     * TODO: It should be a part of AuthorizationProvider.
+     */
+    String ACL_FILE = "aclFile";
+
+    /*
+     * A temporary attributes to set the broker default key/trust stores.
+     * TODO: Remove them after adding a full support to configure KeyStore/TrustStore via management layers.
+     */
+    String KEY_STORE_PATH = "keyStorePath";
+    String KEY_STORE_PASSWORD = "keyStorePassword";
+    String KEY_STORE_CERT_ALIAS = "keyStoreCertAlias";
+    String TRUST_STORE_PATH = "trustStorePath";
+    String TRUST_STORE_PASSWORD = "trustStorePassword";
+
+    /*
+     * A temporary attributes to set the broker group file.
+     * TODO: Remove them after adding a full support to configure authorization providers via management layers.
+     */
+    String GROUP_FILE = "groupFile";
 
     // Attributes
-    public static final Collection<String> AVAILABLE_ATTRIBUTES =
+    Collection<String> AVAILABLE_ATTRIBUTES =
             Collections.unmodifiableList(
                 Arrays.asList(BUILD_VERSION,
                               BYTES_RETAINED,
@@ -62,7 +110,32 @@ public interface Broker extends Configur
                               NAME,
                               STATE,
                               TIME_TO_LIVE,
-                              UPDATED));
+                              UPDATED,
+                              DEFAULT_AUTHENTICATION_PROVIDER,
+                              DEFAULT_VIRTUAL_HOST,
+                              ALERT_THRESHOLD_MESSAGE_AGE,
+                              ALERT_THRESHOLD_MESSAGE_COUNT,
+                              ALERT_THRESHOLD_QUEUE_DEPTH,
+                              ALERT_THRESHOLD_MESSAGE_SIZE,
+                              ALERT_REPEAT_GAP,
+                              FLOW_CONTROL_SIZE_BYTES,
+                              FLOW_CONTROL_RESUME_SIZE_BYTES,
+                              MAXIMUM_DELIVERY_ATTEMPTS,
+                              DEAD_LETTER_QUEUE_ENABLED,
+                              HOUSEKEEPING_CHECK_PERIOD,
+                              SESSION_COUNT_LIMIT,
+                              HEART_BEAT_DELAY,
+                              STATISTICS_REPORTING_PERIOD,
+                              STATISTICS_REPORTING_RESET_ENABLED,
+
+                              ACL_FILE,
+                              KEY_STORE_PATH,
+                              KEY_STORE_PASSWORD,
+                              KEY_STORE_CERT_ALIAS,
+                              TRUST_STORE_PATH,
+                              TRUST_STORE_PASSWORD,
+                              GROUP_FILE
+                              ));
 
     //children
     Collection < VirtualHost > getVirtualHosts();
@@ -75,6 +148,49 @@ public interface Broker extends Configur
                                   LifetimePolicy lifetime, long ttl, Map<String, Object> attributes)
             throws AccessControlException, IllegalArgumentException;
 
-    void deleteVirtualHost(VirtualHost virtualHost)
-            throws AccessControlException, IllegalStateException;
+    AuthenticationProvider getDefaultAuthenticationProvider();
+
+    Collection<GroupProvider> getGroupProviders();
+
+    /**
+     * A temporary hack to expose root message logger via broker instance.
+     * TODO We need a better way to do operational logging, for example, via logging listeners
+     */
+    RootMessageLogger getRootMessageLogger();
+
+    /**
+     * A temporary hack to expose security manager via broker instance.
+     * TODO We need to add and implement an authorization provider configured object instead
+     */
+    SecurityManager getSecurityManager();
+
+    /**
+     * TODO: A temporary hack to expose log recorder via broker instance.
+     */
+    LogRecorder getLogRecorder();
+
+    VirtualHost findVirtualHostByName(String name);
+
+    /**
+     * Get the SubjectCreator for the given socket address.
+     * TODO: move the authentication related functionality into host aliases and AuthenticationProviders
+     *
+     * @param address The (listening) socket address for which the AuthenticationManager is required
+     */
+    SubjectCreator getSubjectCreator(SocketAddress localAddress);
+
+    Collection<KeyStore> getKeyStores();
+
+    Collection<TrustStore> getTrustStores();
+
+    /*
+     * TODO: Remove this method. Eventually the broker will become a registry.
+     */
+    VirtualHostRegistry getVirtualHostRegistry();
+
+    KeyStore getDefaultKeyStore();
+
+    TrustStore getDefaultTrustStore();
+
+    TaskExecutor getTaskExecutor();
 }



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