qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ritch...@apache.org
Subject svn commit: r942109 - in /qpid/trunk/qpid/java/broker/src: main/java/org/apache/qpid/server/configuration/ main/java/org/apache/qpid/server/configuration/plugin/ main/java/org/apache/qpid/server/queue/ main/java/org/apache/qpid/server/registry/ test/ja...
Date Fri, 07 May 2010 15:12:22 GMT
Author: ritchiem
Date: Fri May  7 15:12:22 2010
New Revision: 942109

URL: http://svn.apache.org/viewvc?rev=942109&view=rev
Log:
QPID-2581 : Add ConfigurationManager and split config creation from config processing

Added:
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationManager.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugin/
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugin/ConfigurationPlugin.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugin/ConfigurationPluginFactory.java
Modified:
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ConfigurationFileApplicationRegistry.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
    qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/NullApplicationRegistry.java
    qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationManager.java?rev=942109&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationManager.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationManager.java Fri May  7 15:12:22 2010
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.log4j.Logger;
+import org.apache.qpid.server.configuration.plugin.ConfigurationPlugin;
+import org.apache.qpid.server.configuration.plugin.ConfigurationPluginFactory;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+
+import java.util.Map;
+
+public class ConfigurationManager
+{
+    Logger _logger = Logger.getLogger(ConfigurationManager.class);
+
+    public ConfigurationPlugin getConfigurationPlugin(String configurationElement, Configuration configuration) throws ConfigurationException
+    {
+        Map<String, ConfigurationPluginFactory> configPlugins =
+                ApplicationRegistry.getInstance().getPluginManager().getConfigurationPlugins();
+
+        ConfigurationPluginFactory factory = configPlugins.get(configurationElement);
+
+        if (_logger.isInfoEnabled())
+        {
+            _logger.info("Got Factory:" + factory + ": for :" + configurationElement);
+        }
+
+        if (_logger.isDebugEnabled())
+        {
+            _logger.debug("Loaded Plugins:");
+            for (String key : configPlugins.keySet())
+            {
+                _logger.debug(key + ":" + configPlugins.get(key));
+            }
+        }
+
+        return factory != null ? factory.newInstance(configurationElement, configuration) : null;
+    }
+}

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java?rev=942109&r1=942108&r2=942109&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/QueueConfiguration.java Fri May  7 15:12:22 2010
@@ -21,21 +21,48 @@
 package org.apache.qpid.server.configuration;
 
 import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
 
 import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.configuration.plugin.ConfigurationPlugin;
 
-public class QueueConfiguration
+public class QueueConfiguration extends ConfigurationPlugin
 {
-    
+
     private Configuration _config;
     private String _name;
     private VirtualHostConfiguration _vHostConfig;
 
-    public QueueConfiguration(String name, Configuration config, VirtualHostConfiguration virtualHostConfiguration)
+    public QueueConfiguration(String name, Configuration config, VirtualHostConfiguration virtualHostConfiguration) throws ConfigurationException
     {
         _vHostConfig = virtualHostConfiguration;
         _config = config;
         _name = name;
+
+        setConfiguration("virtualhosts.virtualhost.queues.queue", config);
+    }
+
+    public String[] getElementsProcessed()
+    {
+        return new String[]{"maximumMessageSize",
+                            "maximumQueueDepth",
+                            "maximumMessageCount",
+                            "maximumMessageAge",
+                            "minimumAlertRepeatGap",
+                            "durable",
+                            "exchange",
+                            "queue",
+                            "autodelete",
+                            "priority",
+                            "priorities",
+                            "routingKey",
+                            "capacity",
+                            "flowResumeCapacity",
+                            "lvq",
+                            "lvqKey"
+        };
     }
 
     public VirtualHostConfiguration getVirtualHostConfiguration()

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java?rev=942109&r1=942108&r2=942109&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java Fri May  7 15:12:22 2010
@@ -20,15 +20,6 @@
 
 package org.apache.qpid.server.configuration;
 
-import java.io.File;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-
 import org.apache.commons.configuration.CompositeConfiguration;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
@@ -37,38 +28,42 @@ import org.apache.commons.configuration.
 import org.apache.commons.configuration.SystemConfiguration;
 import org.apache.commons.configuration.XMLConfiguration;
 import org.apache.qpid.server.configuration.management.ConfigurationManagementMBean;
-import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.configuration.plugin.ConfigurationPlugin;
+import org.apache.qpid.server.configuration.plugin.ConfigurationPluginFactory;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
+import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.transport.NetworkDriverConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import sun.misc.Signal;
 import sun.misc.SignalHandler;
 
-public class ServerConfiguration implements SignalHandler
-{
-
-    private Configuration _config;
+import java.io.File;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
 
+public class ServerConfiguration extends ConfigurationPlugin implements SignalHandler
+{
     // Default Configuration values
     public static final int DEFAULT_BUFFER_READ_LIMIT_SIZE = 262144;
     public static final int DEFAULT_BUFFER_WRITE_LIMIT_SIZE = 262144;
     public static final boolean DEFAULT_BROKER_CONNECTOR_PROTECTIO_ENABLED = false;
     public static final String DEFAULT_STATUS_UPDATES = "on";
     public static final String SECURITY_CONFIG_RELOADED = "SECURITY CONFIGURATION RELOADED";
-    
+
     public static final int DEFAULT_FRAME_SIZE = 65536;
     public static final int DEFAULT_PORT = 5672;
     public static final int DEFAULT_SSL_PORT = 8672;
     public static final long DEFAULT_HOUSEKEEPING_PERIOD = 30000L;
     public static final int DEFAULT_JMXPORT = 8999;
 
-    private static int _jmxPort = DEFAULT_JMXPORT;
-
     private Map<String, VirtualHostConfiguration> _virtualHosts = new HashMap<String, VirtualHostConfiguration>();
-    private SecurityConfiguration _securityConfiguration = null;
 
     private File _configFile;
     private File _vhostsFile;
@@ -117,6 +112,23 @@ public class ServerConfiguration impleme
         envVarMap.put("QPID_STATUS-UPDATES", "status-updates");
     }
 
+    /**
+     * Loads the given file and sets up the HUP signal handler.
+     *
+     * This will load the file and present the root level properties but will
+     * not perform any virtualhost configuration.
+     *
+     * To perform this configure() must be called.
+     *
+     * This has been made a two step process to allow the Plugin Manager and
+     * Configuration Manager to be initialised in the Application Registry.
+     *
+     * If using this ServerConfiguration via an ApplicationRegistry there is no
+     * need to explictly call configure() as this is done via the AR.initialise()
+     *
+     * @param configurationURL
+     * @throws org.apache.commons.configuration.ConfigurationException
+     */
     public ServerConfiguration(File configurationURL) throws ConfigurationException
     {
         this(parseConfig(configurationURL));
@@ -132,15 +144,52 @@ public class ServerConfiguration impleme
         }
     }
 
-    public ServerConfiguration(Configuration conf) throws ConfigurationException
+    /**
+     * Wraps the given Commons Configuration as a ServerConfiguration.
+     *
+     * Mainly used during testing and in locations where configuration is not
+     * desired but the interface requires configuration.
+     *
+     * If the given configuration has VirtualHost configuration then configure()
+     * must be called to perform the required setup.
+     *
+     * This has been made a two step process to allow the Plugin Manager and
+     * Configuration Manager to be initialised in the Application Registry.
+     *
+     * If using this ServerConfiguration via an ApplicationRegistry there is no 
+     * need to explictly call configure() as this is done via the AR.initialise()
+     *
+     * @param conf
+     */
+    public ServerConfiguration(Configuration conf)
     {
-        setConfig(conf);
+        _configuration = conf;        
+    }
 
-        _jmxPort = getConfig().getInt("management.jmxport", 8999);
-        _securityConfiguration = new SecurityConfiguration(conf.subset("security"));
+    /**
+     * Processes this configuration and setups any VirtualHosts defined in the
+     * configuration.
+     *
+     * This has been separated from the constructor to allow the PluginManager
+     * time to be created and provide plugins to the ConfigurationManager for
+     * processing here.
+     *
+     * Called by ApplicationRegistry.initialise();
+     *
+     * NOTE: A DEFAULT ApplicationRegistry must exist when using this method
+     * or a new ApplicationRegistry will be created. 
+     *
+     * @throws ConfigurationException
+     */
+    public void configure() throws ConfigurationException
+    {
 
-        setupVirtualHosts(conf);
+        setupVirtualHosts(_configuration);
+    }
 
+    public String[] getElementsProcessed()
+    {
+        return new String[]{""};
     }
 
     /*
@@ -148,30 +197,30 @@ public class ServerConfiguration impleme
      * both, as a fix for QPID-2360 and QPID-2361.
      */
     @SuppressWarnings("unchecked")
-	private void setupVirtualHosts(Configuration conf) throws ConfigurationException
+    private void setupVirtualHosts(Configuration conf) throws ConfigurationException
     {
         List<String> vhostFiles = conf.getList("virtualhosts");
         Configuration vhostConfig = conf.subset("virtualhosts");
 
-    	// Only one configuration mechanism allowed
+        // Only one configuration mechanism allowed
         if (!vhostFiles.isEmpty() && !vhostConfig.subset("virtualhost").isEmpty())
         {
-        	throw new ConfigurationException("Only one of external or embedded virtualhosts configuration allowed.");
-        } 
-        
+            throw new ConfigurationException("Only one of external or embedded virtualhosts configuration allowed.");
+        }
+
         // We can only have one vhosts XML file included
-    	if (vhostFiles.size() > 1)
-    	{
-    		throw new ConfigurationException("Only one external virtualhosts configuration file allowed, multiple filenames found.");
-    	}
-        
+        if (vhostFiles.size() > 1)
+        {
+            throw new ConfigurationException("Only one external virtualhosts configuration file allowed, multiple filenames found.");
+        }
+
         // Virtualhost configuration object
         Configuration vhostConfiguration = new HierarchicalConfiguration();
-        
-    	// Load from embedded configuration if possible
+
+        // Load from embedded configuration if possible
         if (!vhostConfig.subset("virtualhost").isEmpty())
         {
-    		vhostConfiguration = vhostConfig;
+            vhostConfiguration = vhostConfig;
         }
         else
         {
@@ -181,19 +230,19 @@ public class ServerConfiguration impleme
 	            // Open the vhosts XML file and copy values from it to our config
                 _vhostsFile = new File(fileName);
 	        	vhostConfiguration = parseConfig(new File(fileName));
-                
+
                 // save the default virtualhost name
                 String defaultVirtualHost = vhostConfiguration.getString("default");
-                _config.setProperty("virtualhosts.default", defaultVirtualHost);
-	        }
+                _configuration.setProperty("virtualhosts.default", defaultVirtualHost);
+            }
         }
-        
+
         // Now extract the virtual host names from the configuration object
-    	List hosts = vhostConfiguration.getList("virtualhost.name");
+        List hosts = vhostConfiguration.getList("virtualhost.name");
         for (int j = 0; j < hosts.size(); j++)
         {
             String name = (String) hosts.get(j);
-            
+
             // Add the virtual hosts to the server configuration
             VirtualHostConfiguration virtualhost = new VirtualHostConfiguration(name, vhostConfiguration.subset("virtualhost." + name));
             _virtualHosts.put(virtualhost.getName(), virtualhost);
@@ -217,7 +266,7 @@ public class ServerConfiguration impleme
         ConfigurationFactory factory = new ConfigurationFactory();
         factory.setConfigurationFileName(file.getAbsolutePath());
         Configuration conf = factory.getConfiguration();
-    	
+
         Iterator<?> keys = conf.getKeys();
         if (!keys.hasNext())
         {
@@ -232,6 +281,7 @@ public class ServerConfiguration impleme
 
     /**
      * Check the configuration file to see if status updates are enabled.
+     *
      * @return true if status updates are enabled
      */
     public boolean getStatusUpdatesEnabled()
@@ -244,6 +294,7 @@ public class ServerConfiguration impleme
 
     /**
      * The currently defined {@see Locale} for this broker
+     *
      * @return the configuration defined locale
      */
     public Locale getLocale()
@@ -331,7 +382,7 @@ public class ServerConfiguration impleme
         }
         catch (ConfigurationException e)
         {
-             _log.error("Could not reload configuration file security sections", e);
+            _log.error("Could not reload configuration file security sections", e);
         }
     }
 
@@ -340,9 +391,9 @@ public class ServerConfiguration impleme
         if (_configFile != null)
         {
             Configuration newConfig = parseConfig(_configFile);
-            
-            _securityConfiguration = new SecurityConfiguration(newConfig.subset("security"));
-         
+
+            setConfiguration("", newConfig);
+
             // Reload virtualhosts from correct location
             Configuration newVhosts;
             if (_vhostsFile == null)
@@ -353,30 +404,20 @@ public class ServerConfiguration impleme
             {
                 newVhosts = parseConfig(_vhostsFile);
             }
-            
+
             VirtualHostRegistry vhostRegistry = ApplicationRegistry.getInstance().getVirtualHostRegistry();
             for (String hostname : _virtualHosts.keySet())
             {
                 VirtualHost vhost = vhostRegistry.getVirtualHost(hostname);
                 SecurityConfiguration hostSecurityConfig = new SecurityConfiguration(newVhosts.subset("virtualhost."+hostname+".security"));
-                vhost.getAccessManager().configureGlobalPlugins(_securityConfiguration);
+                vhost.getAccessManager().configureGlobalPlugins(getSecurityConfiguration());
                 vhost.getAccessManager().configureHostPlugins(hostSecurityConfig);
             }
-            
+
             _log.warn(SECURITY_CONFIG_RELOADED);
         }
     }
 
-    public void setConfig(Configuration _config)
-    {
-        this._config = _config;
-    }
-
-    public Configuration getConfig()
-    {
-        return _config;
-    }
-
     public String getQpidWork()
     {
         return System.getProperty("QPID_WORK", System.getProperty("java.io.tmpdir"));
@@ -384,19 +425,19 @@ public class ServerConfiguration impleme
 
     public void setJMXManagementPort(int mport)
     {
-        _jmxPort = mport;
+        getConfig().setProperty("management.jmxport", mport);
     }
 
     public int getJMXManagementPort()
     {
-        return _jmxPort;
+        return getConfig().getInt("management.jmxport", DEFAULT_JMXPORT);
     }
-    
+
     public boolean getUseCustomRMISocketFactory()
     {
         return getConfig().getBoolean(MGMT_CUSTOM_REGISTRY_SOCKET, true);
     }
-    
+
     public void setUseCustomRMISocketFactory(boolean bool)
     {
         getConfig().setProperty(MGMT_CUSTOM_REGISTRY_SOCKET, bool);
@@ -422,6 +463,11 @@ public class ServerConfiguration impleme
         return _virtualHosts.get(name);
     }
 
+    public void setVirtualHostConfig(VirtualHostConfiguration config)
+    {
+        _virtualHosts.put(config.getName(), config);
+    }
+
     public List<String> getPrincipalDatabaseNames()
     {
         return getConfig().getList("security.principal-databases.principal-database.name");
@@ -506,7 +552,7 @@ public class ServerConfiguration impleme
 
     public SecurityConfiguration getSecurityConfiguration()
     {
-        return _securityConfiguration;
+        return new SecurityConfiguration(_configuration.subset("security"));
     }
 
     public boolean getQueueAutoRegister()
@@ -604,7 +650,6 @@ public class ServerConfiguration impleme
         return getConfig().getList("connector.non08port", Collections.EMPTY_LIST);
     }
 
-
     public String getBind()
     {
         return getConfig().getString("connector.bind", "wildcard");
@@ -685,6 +730,11 @@ public class ServerConfiguration impleme
         return getConfig().getString("virtualhosts.default");
     }
 
+    public void setDefaultVirtualHost(String vhost)
+    {
+         getConfig().setProperty("virtualhosts.default", vhost);
+    }    
+
     public void setHousekeepingExpiredMessageCheckPeriod(long value)
     {
         getConfig().setProperty("housekeeping.expiredMessageCheckPeriod", value);
@@ -693,8 +743,8 @@ public class ServerConfiguration impleme
     public long getHousekeepingCheckPeriod()
     {
         return getConfig().getLong("housekeeping.checkPeriod",
-                   getConfig().getLong("housekeeping.expiredMessageCheckPeriod",
-                           DEFAULT_HOUSEKEEPING_PERIOD));
+                                   getConfig().getLong("housekeeping.expiredMessageCheckPeriod",
+                                                       DEFAULT_HOUSEKEEPING_PERIOD));
     }
 
     public NetworkDriverConfiguration getNetworkConfiguration()

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java?rev=942109&r1=942108&r2=942109&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/VirtualHostConfiguration.java Fri May  7 15:12:22 2010
@@ -20,97 +20,118 @@
  */
 package org.apache.qpid.server.configuration;
 
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.commons.configuration.CompositeConfiguration;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.store.MemoryMessageStore;
+import org.apache.qpid.server.configuration.plugin.ConfigurationPlugin;
+import org.apache.qpid.server.configuration.plugin.ConfigurationPluginFactory;
 
-public class VirtualHostConfiguration
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
+
+public class VirtualHostConfiguration extends ConfigurationPlugin
 {
-	private Configuration _config;
-	private String _name;
-	private Map<String, QueueConfiguration> _queues = new HashMap<String, QueueConfiguration>();
-	private Map<String, ExchangeConfiguration> _exchanges = new HashMap<String, ExchangeConfiguration>();
-
-	public VirtualHostConfiguration(String name, Configuration config) throws ConfigurationException
-	{
-		_config = config;
-		_name = name;
-		Iterator i = _config.getList("queues.queue.name").iterator();
-		
-		while (i.hasNext())
-		{
-			String queueName = (String) i.next();
-			CompositeConfiguration mungedConf = new CompositeConfiguration();
-			mungedConf.addConfiguration(_config.subset("queues.queue." + queueName));
-			mungedConf.addConfiguration(_config.subset("queues"));
-			_queues.put(queueName, new QueueConfiguration(queueName, mungedConf, this));
-        }
+    private Configuration _config;
+    private String _name;
+    private Map<String, QueueConfiguration> _queues = new HashMap<String, QueueConfiguration>();
+    private Map<String, ExchangeConfiguration> _exchanges = new HashMap<String, ExchangeConfiguration>();
+
+    public VirtualHostConfiguration(String name, Configuration config) throws ConfigurationException
+    {
+        _config = config;
+        _name = name;
+        setConfiguration(config);
+    }
+
+    /**
+     * Apply the given configuration to this VirtualHostConfiguration
+     *
+     * @param config the config to apply
+     * @throws ConfigurationException if a problem occurs with configuration
+     */
+    public void setConfiguration(Configuration config) throws ConfigurationException
+    {
+        super.setConfiguration("virtualhosts.virtualhost",config);
+
+        Iterator i = _config.getList("queues.queue.name").iterator();
 
-		i = _config.getList("exchanges.exchange.name").iterator();
-		int count = 0;
-		while (i.hasNext())
+        while (i.hasNext())
         {
-			CompositeConfiguration mungedConf = new CompositeConfiguration();
-			mungedConf.addConfiguration(config.subset("exchanges.exchange(" + count++ + ")"));
-			mungedConf.addConfiguration(_config.subset("exchanges"));
-			String exchName = (String) i.next();
-			_exchanges.put(exchName, new ExchangeConfiguration(exchName, mungedConf));
+            String queueName = (String) i.next();
+            CompositeConfiguration mungedConf = new CompositeConfiguration();
+            mungedConf.addConfiguration(_config.subset("queues.queue." + queueName));
+            mungedConf.addConfiguration(_config.subset("queues"));
+            _queues.put(queueName, new QueueConfiguration(queueName, mungedConf, this));
         }
 
+        i = _config.getList("exchanges.exchange.name").iterator();
+        int count = 0;
+        while (i.hasNext())
+        {
+            CompositeConfiguration mungedConf = new CompositeConfiguration();
+            mungedConf.addConfiguration(config.subset("exchanges.exchange(" + count++ + ")"));
+            mungedConf.addConfiguration(_config.subset("exchanges"));
+            String exchName = (String) i.next();
+            _exchanges.put(exchName, new ExchangeConfiguration(exchName, mungedConf));
+        }
     }
 
-	public String getName()
-	{
+    public String getName()
+    {
         return _name;
     }
 
-	public long getHousekeepingExpiredMessageCheckPeriod()
-	{
-		return _config.getLong("housekeeping.expiredMessageCheckPeriod", ApplicationRegistry.getInstance().getConfiguration().getHousekeepingCheckPeriod());
-	}
-
-	public String getAuthenticationDatabase()
-	{
-		return _config.getString("security.authentication.name");
-	}
-	
-	public List getCustomExchanges()
-	{
-		return _config.getList("custom-exchanges.class-name");
-	}
-	
-	public SecurityConfiguration getSecurityConfiguration()
-	{
-		return new SecurityConfiguration(_config.subset("security"));
-	}
-
-	public Configuration getStoreConfiguration()
-	{
-		return _config.subset("store");
-	}
-
-	public String getMessageStoreClass()
-	{
-		return _config.getString("store.class", MemoryMessageStore.class.getName());
-	}
-
-	public List getExchanges()
-	{
-		return _config.getList("exchanges.exchange.name");
-	}
-
-	public String[] getQueueNames()
-	{
-		return _queues.keySet().toArray(new String[_queues.size()]);
-	}
+    public long getHousekeepingExpiredMessageCheckPeriod()
+    {
+        return _config.getLong("housekeeping.expiredMessageCheckPeriod", ApplicationRegistry.getInstance().getConfiguration().getHousekeepingCheckPeriod());
+    }
+
+    public String getAuthenticationDatabase()
+    {
+        return _config.getString("security.authentication.name");
+    }
+
+    public List getCustomExchanges()
+    {
+        return _config.getList("custom-exchanges.class-name");
+    }
+
+    public SecurityConfiguration getSecurityConfiguration()
+    {
+        return new SecurityConfiguration(_config.subset("security"));
+    }
+
+    public Configuration getStoreConfiguration()
+    {
+        return _config.subset("store");
+    }
+
+    public String getMessageStoreClass()
+    {
+        return _config.getString("store.class", MemoryMessageStore.class.getName());
+    }
+
+    public void setMessageStoreClass(String storeClass)
+    {
+        _config.setProperty("store.class", storeClass);
+    }
+
+    public List getExchanges()
+    {
+        return _config.getList("exchanges.exchange.name");
+    }
+
+    public String[] getQueueNames()
+    {
+        return _queues.keySet().toArray(new String[_queues.size()]);
+    }
 
     public ExchangeConfiguration getExchangeConfiguration(String exchangeName)
     {
@@ -121,13 +142,21 @@ public class VirtualHostConfiguration
     {
         // We might be asked for the config for a queue we don't know about,
         // such as one that's been dynamically created. Those get the defaults by default.
-        if (_queues.containsKey(queueName)) 
+        if (_queues.containsKey(queueName))
         {
             return _queues.get(queueName);
-        } 
+        }
         else
         {
-            return new QueueConfiguration(queueName, new PropertiesConfiguration(), this);
+            try
+            {
+                return new QueueConfiguration(queueName, new PropertiesConfiguration(), this);
+            }
+            catch (ConfigurationException e)
+            {
+                // The configuration is empty so there can't be an error.
+                return null;
+            }
         }
     }
 
@@ -140,7 +169,7 @@ public class VirtualHostConfiguration
     {
         return _config.getLong("queues.minimumMemoryUsage", 0);
     }
-    
+
     public int getMaximumMessageAge()
     {
         return _config.getInt("queues.maximumMessageAge", 0);
@@ -166,7 +195,6 @@ public class VirtualHostConfiguration
         return _config.getLong("queues.minimumAlertRepeatGap", 0);
     }
 
-
     public long getCapacity()
     {
         return _config.getLong("queues.capacity", 0l);
@@ -177,4 +205,10 @@ public class VirtualHostConfiguration
         return _config.getLong("queues.flowResumeCapacity", getCapacity());
     }
 
+    public String[] getElementsProcessed()
+    {
+        return new String[]{"queues", "exchanges", "custom-exchanges",
+                            "security", "store", "housekeeping"};
+
+    }
 }

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugin/ConfigurationPlugin.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugin/ConfigurationPlugin.java?rev=942109&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugin/ConfigurationPlugin.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugin/ConfigurationPlugin.java Fri May  7 15:12:22 2010
@@ -0,0 +1,147 @@
+/*
+ *
+ * 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.plugin;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.qpid.server.configuration.ConfigurationManager;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.log4j.Logger;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+public abstract class ConfigurationPlugin
+{
+    protected Logger _logger = Logger.getLogger(this.getClass());
+
+    private Map<Class<? extends ConfigurationPlugin>, ConfigurationPlugin>
+            _pluginConfiguration = new HashMap<Class<? extends ConfigurationPlugin>, ConfigurationPlugin>();
+
+    protected Configuration _configuration;
+
+    /**
+     * The Elements that this Plugin can process.
+     * i.e.
+     *   For a Queues plugin that would be a list containing:
+     *      queue - the queue entries
+     *      the alerting values for defaults
+     *      exchange - the default exchange
+     *      durable - set the default durablity
+     *      etc
+     *
+     * @return 
+     */
+    abstract public String[] getElementsProcessed();
+
+    public Configuration getConfig()
+    {
+        return _configuration;
+    }
+
+    public <C extends ConfigurationPlugin> C getConfiguration(Class<C> plugin)
+    {
+        return (C) _pluginConfiguration.get(plugin);
+    }
+
+    /**
+     * Sets the configuration for this plugin
+     *
+     * @param path
+     * @param configuration the configuration for this plugin.
+     */
+
+    public void setConfiguration(String path, Configuration configuration) throws ConfigurationException
+    {
+        _configuration = configuration;
+
+        // Extract a list of elements for processing
+        Iterator<?> keys = configuration.getKeys();
+
+        Set<String> elements = new HashSet<String>();
+        while (keys.hasNext())
+        {
+            String key = (String) keys.next();
+
+            int elementNameIndex = key.indexOf(".");
+
+            String element = key.trim();
+            if (elementNameIndex != -1)
+            {
+                element = key.substring(0, elementNameIndex).trim();
+            }
+
+            //Trim any element properties
+            elementNameIndex = element.indexOf("[");
+            if (elementNameIndex != -1)
+            {
+                element = element.substring(0,elementNameIndex).trim();
+            }
+
+            elements.add(element);
+        }
+
+
+        //Remove the items we already expect in the configuration
+        for (String tag : getElementsProcessed())
+        {
+            elements.remove(tag);
+        }
+
+        if (_logger.isInfoEnabled())
+        {
+            if (!elements.isEmpty())
+            {
+                _logger.info("Elements to lookup:" + path);
+                for (String tag : elements)
+                {
+                    _logger.info(tag);
+                }
+            }
+        }
+
+        // Process the elements in the configuration
+        for (String element : elements.toArray(new String[elements.size()]))
+        {
+            ConfigurationManager configurationManager = ApplicationRegistry.getInstance().getConfigurationManager();
+
+            String configurationElement = path +"."+ element;
+            ConfigurationPlugin elementHandler = configurationManager.
+                    getConfigurationPlugin(configurationElement,
+                                           configuration.subset(element));
+
+
+            if (elementHandler == null)
+            {
+                _logger.warn("Unused configuration element:" + configurationElement);
+            }
+            else
+            {
+                _pluginConfiguration.put(elementHandler.getClass(), elementHandler);
+            }
+        }
+    }
+}
+
+

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugin/ConfigurationPluginFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugin/ConfigurationPluginFactory.java?rev=942109&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugin/ConfigurationPluginFactory.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/plugin/ConfigurationPluginFactory.java Fri May  7 15:12:22 2010
@@ -0,0 +1,41 @@
+/*
+ *
+ * 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.plugin;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+
+public interface ConfigurationPluginFactory
+{
+
+    /**
+     * The Parent paths of the configuration that this plugin supports.
+     * i.e.
+     *   For Queue Elements the parent path is
+     *     virtualhosts.virtualhost
+     * @return
+     */
+    abstract public String[] getParentPaths();
+    
+
+    public ConfigurationPlugin newInstance(String path, Configuration config) throws ConfigurationException;
+
+}

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java?rev=942109&r1=942108&r2=942109&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueue.java Fri May  7 15:12:22 2010
@@ -272,5 +272,7 @@ public interface AMQQueue extends Managa
 
     void configure(QueueConfiguration config);
 
+    QueueConfiguration getConfiguration();
+
     ManagedObject getManagedObject();
 }

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java?rev=942109&r1=942108&r2=942109&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java Fri May  7 15:12:22 2010
@@ -186,7 +186,7 @@ public class SimpleAMQQueue implements A
 
     //TODO : persist creation time
     private long _createTime = System.currentTimeMillis();
-
+    private QueueConfiguration _queueConfiguration;
 
     protected SimpleAMQQueue(AMQShortString name, boolean durable, AMQShortString owner, boolean autoDelete, VirtualHost virtualHost, Map<String,Object> arguments)
     {
@@ -2069,9 +2069,17 @@ public class SimpleAMQQueue implements A
             setMinimumAlertRepeatGap(config.getMinimumAlertRepeatGap());
             _capacity = config.getCapacity();
             _flowResumeCapacity = config.getFlowResumeCapacity();
+
+            _queueConfiguration = config;
         }
     }
 
+
+    public QueueConfiguration getConfiguration()
+    {
+        return _queueConfiguration;
+    }
+
     public String getResourceName()
     {
         return _resourceName;

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java?rev=942109&r1=942108&r2=942109&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java Fri May  7 15:12:22 2010
@@ -22,22 +22,30 @@ package org.apache.qpid.server.registry;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.log4j.Logger;
-
+import org.apache.qpid.AMQException;
+import org.apache.qpid.common.QpidProperties;
 import org.apache.qpid.qmf.QMFService;
 import org.apache.qpid.server.configuration.BrokerConfig;
 import org.apache.qpid.server.configuration.ConfigStore;
+import org.apache.qpid.server.configuration.ConfigurationManager;
 import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.configuration.SystemConfig;
 import org.apache.qpid.server.configuration.SystemConfigImpl;
 import org.apache.qpid.server.configuration.VirtualHostConfiguration;
 import org.apache.qpid.server.logging.RootMessageLogger;
+import org.apache.qpid.server.logging.RootMessageLoggerImpl;
+import org.apache.qpid.server.logging.actors.BrokerActor;
 import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.logging.messages.BrokerMessages;
+import org.apache.qpid.server.logging.rawloggers.Log4jMessageLogger;
 import org.apache.qpid.server.management.ManagedObjectRegistry;
+import org.apache.qpid.server.management.NoopManagedObjectRegistry;
 import org.apache.qpid.server.plugins.PluginManager;
 import org.apache.qpid.server.security.access.ACLManager;
+import org.apache.qpid.server.security.auth.database.ConfigurationFilePrincipalDatabaseManager;
 import org.apache.qpid.server.security.auth.database.PrincipalDatabaseManager;
 import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
+import org.apache.qpid.server.security.auth.manager.PrincipalDatabaseAuthenticationManager;
 import org.apache.qpid.server.transport.QpidAcceptor;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.server.virtualhost.VirtualHostImpl;
@@ -82,6 +90,8 @@ public abstract class ApplicationRegistr
 
     protected PluginManager _pluginManager;
 
+    protected ConfigurationManager _configurationManager;
+
     protected RootMessageLogger _rootMessageLogger;
 
     protected UUID _brokerId = UUID.randomUUID();
@@ -92,6 +102,8 @@ public abstract class ApplicationRegistr
 
     private ConfigStore _configStore;
 
+    protected String _registryName;
+
     static
     {
         Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownService()));
@@ -114,7 +126,7 @@ public abstract class ApplicationRegistr
     {
         if (instance != null)
         {
-            _logger.info("Initialising Application Registry:" + instanceID);
+            _logger.info("Initialising Application Registry(" + instance + "):" + instanceID);
             _instanceMap.put(instanceID, instance);
 
             final ConfigStore store = ConfigStore.newInstance();
@@ -170,9 +182,7 @@ public abstract class ApplicationRegistr
         return _instanceMap.containsKey(instanceID);
     }
 
-    /**
-     * Method to cleanly shutdown the default registry running in this JVM
-     */
+    /** Method to cleanly shutdown the default registry running in this JVM */
     public static void remove()
     {
         remove(DEFAULT_INSTANCE);
@@ -223,6 +233,82 @@ public abstract class ApplicationRegistr
         _configuration = configuration;
     }
 
+    public void configure() throws ConfigurationException
+    {
+        _logger.error("Configure AR");
+
+        _configurationManager = new ConfigurationManager();
+
+        try
+        {
+            _pluginManager = new PluginManager(_configuration.getPluginDirectory());
+        }
+        catch (Exception e)
+        {
+            throw new ConfigurationException(e);
+        }
+
+        _configuration.configure();
+    }
+
+    public void initialise(int instanceID) throws Exception
+    {
+        _logger.error("Creating RML:" + this);
+        _rootMessageLogger = new RootMessageLoggerImpl(_configuration,
+                                                       new Log4jMessageLogger());
+        _logger.error("Created RML:" + _rootMessageLogger + ":" + this);
+        _registryName = String.valueOf(instanceID);
+
+        // Set the Actor for current log messages
+        CurrentActor.set(new BrokerActor(_registryName, _rootMessageLogger));
+
+        _logger.error("Init AR:" + this);
+        configure();
+        _logger.error("Configured AR:" + this);
+
+        _qmfService = new QMFService(getConfigStore(), this);
+
+        CurrentActor.get().message(BrokerMessages.BRK_STARTUP(QpidProperties.getReleaseVersion(), QpidProperties.getBuildVersion()));
+
+        initialiseManagedObjectRegistry();
+
+        _virtualHostRegistry = new VirtualHostRegistry(this);
+
+        _accessManager = new ACLManager(_configuration.getSecurityConfiguration(), _pluginManager);
+
+        createDatabaseManager(_configuration);
+
+        _authenticationManager = new PrincipalDatabaseAuthenticationManager(null, null);
+
+        _databaseManager.initialiseManagement(_configuration);
+
+        _managedObjectRegistry.start();
+
+        initialiseVirtualHosts();
+
+        // Startup complete pop the current actor
+        CurrentActor.remove();
+    }
+
+    protected void createDatabaseManager(ServerConfiguration configuration) throws Exception
+    {
+        _databaseManager = new ConfigurationFilePrincipalDatabaseManager(_configuration);
+    }
+
+    protected void initialiseVirtualHosts() throws Exception
+    {
+        for (String name : _configuration.getVirtualHosts())
+        {
+            createVirtualHost(_configuration.getVirtualHostConfig(name));
+        }
+        getVirtualHostRegistry().setDefaultVirtualHostName(_configuration.getDefaultVirtualHost());
+    }
+
+    protected void initialiseManagedObjectRegistry() throws AMQException
+    {
+        _managedObjectRegistry = new NoopManagedObjectRegistry();
+    }
+
     public static IApplicationRegistry getInstance()
     {
         return getInstance(DEFAULT_INSTANCE);
@@ -239,6 +325,8 @@ public abstract class ApplicationRegistr
                 try
                 {
                     _logger.info("Creating DEFAULT_APPLICATION_REGISTRY: " + _APPLICATION_REGISTRY + " : Instance:" + instanceID);
+                    new Exception().printStackTrace(System.out);
+                    new Exception().printStackTrace(System.err);
                     IApplicationRegistry registry = (IApplicationRegistry) Class.forName(_APPLICATION_REGISTRY).getConstructor((Class[]) null).newInstance((Object[]) null);
                     ApplicationRegistry.initialise(registry, instanceID);
                     _logger.info("Initialised Application Registry:" + instanceID);
@@ -262,38 +350,69 @@ public abstract class ApplicationRegistr
     {
         if (_logger.isInfoEnabled())
         {
-            _logger.info("Shutting down ApplicationRegistry:"+this);
+            _logger.info("Shutting down ApplicationRegistry:" + this);
         }
 
-        //Stop incomming connections
-        unbind();
-
-        //Shutdown virtualhosts
-        for (VirtualHost virtualHost : getVirtualHostRegistry().getVirtualHosts())
+        try
         {
-            virtualHost.close();
+            //Stop incoming connections
+            unbind();
         }
+        finally
+        {
+            try
+            {
+//                Replace with this
+//                _virtualHostRegistry.close();
 
-        // Replace above with this
-//        _virtualHostRegistry.close();
-
-//        _accessManager.close();
-
-//        _databaseManager.close();
-
-        _authenticationManager.close();
+                //Shutdown virtualhosts
+                for (VirtualHost virtualHost : getVirtualHostRegistry().getVirtualHosts())
+                {
+                    virtualHost.close();
+                }
+            }
+            finally
+            {
+//                _accessManager.close();
+//
+//                _databaseManager.close();
 
-//        _databaseManager.close();
+                try
+                {
+                    _authenticationManager.close();
+                }
+                finally
+                {
+                    try
+                    {
+                        // close the rmi registry(if any) started for management
+                        if (_managedObjectRegistry != null)
+                        {
+                            _managedObjectRegistry.close();
+                        }
+                    }
+                    finally
+                    {
+                        try
+                        {
+                            _qmfService.close();
+                        }
+                        finally
+                        {
+                            try
+                            {
+                                _pluginManager.close();
+                            }
+                            finally
+                            {
+                                CurrentActor.get().message(BrokerMessages.BRK_STOPPED());
+                            }
+                        }
+                    }
 
-        // close the rmi registry(if any) started for management
-        if (_managedObjectRegistry != null)
-        {
-            _managedObjectRegistry.close();
+                }
+            }
         }
-
-//        _pluginManager.close();
-
-        CurrentActor.get().message(BrokerMessages.BRK_STOPPED());
     }
 
     private void unbind()
@@ -357,6 +476,11 @@ public abstract class ApplicationRegistr
         return _pluginManager;
     }
 
+    public ConfigurationManager getConfigurationManager()
+    {
+        return _configurationManager;
+    }
+
     public RootMessageLogger getRootMessageLogger()
     {
         return _rootMessageLogger;

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ConfigurationFileApplicationRegistry.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ConfigurationFileApplicationRegistry.java?rev=942109&r1=942108&r2=942109&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ConfigurationFileApplicationRegistry.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ConfigurationFileApplicationRegistry.java Fri May  7 15:12:22 2010
@@ -23,70 +23,21 @@ package org.apache.qpid.server.registry;
 import org.apache.commons.configuration.ConfigurationException;
 
 import org.apache.qpid.AMQException;
-import org.apache.qpid.common.QpidProperties;
-import org.apache.qpid.qmf.QMFService;
 import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.server.logging.RootMessageLoggerImpl;
 import org.apache.qpid.server.logging.actors.BrokerActor;
 import org.apache.qpid.server.logging.actors.CurrentActor;
-import org.apache.qpid.server.logging.messages.BrokerMessages;
-import org.apache.qpid.server.logging.rawloggers.Log4jMessageLogger;
 import org.apache.qpid.server.management.JMXManagedObjectRegistry;
 import org.apache.qpid.server.management.NoopManagedObjectRegistry;
-import org.apache.qpid.server.plugins.PluginManager;
-import org.apache.qpid.server.security.access.ACLManager;
-import org.apache.qpid.server.security.auth.database.ConfigurationFilePrincipalDatabaseManager;
-import org.apache.qpid.server.security.auth.manager.PrincipalDatabaseAuthenticationManager;
-import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
 
 import java.io.File;
 
 public class ConfigurationFileApplicationRegistry extends ApplicationRegistry
 {
-    private String _registryName;
-
     public ConfigurationFileApplicationRegistry(File configurationURL) throws ConfigurationException
     {
         super(new ServerConfiguration(configurationURL));
     }
 
-    public void initialise(int instanceID) throws Exception
-    {
-        _qmfService = new QMFService(getConfigStore(), this);
-
-
-        _rootMessageLogger = new RootMessageLoggerImpl(_configuration,
-                                                       new Log4jMessageLogger());
-
-        _registryName = String.valueOf(instanceID);
-
-        // Set the Actor for current log messages
-        CurrentActor.set(new BrokerActor(_registryName, _rootMessageLogger));
-
-        CurrentActor.get().message(BrokerMessages.BRK_STARTUP(QpidProperties.getReleaseVersion(),QpidProperties.getBuildVersion()));
-
-        initialiseManagedObjectRegistry();
-
-        _virtualHostRegistry = new VirtualHostRegistry(this);
-
-        _pluginManager = new PluginManager(_configuration.getPluginDirectory());
-
-        _accessManager = new ACLManager(_configuration.getSecurityConfiguration(), _pluginManager);
-
-        _databaseManager = new ConfigurationFilePrincipalDatabaseManager(_configuration);
-
-        _authenticationManager = new PrincipalDatabaseAuthenticationManager(null, null);
-
-        _databaseManager.initialiseManagement(_configuration);
-
-
-        _managedObjectRegistry.start();
-
-        initialiseVirtualHosts();
-
-        // Startup complete pop the current actor
-        CurrentActor.remove();
-    }
 
     @Override
     public void close() throws Exception
@@ -104,16 +55,9 @@ public class ConfigurationFileApplicatio
         }
     }
 
-    private void initialiseVirtualHosts() throws Exception
-    {
-        for (String name : _configuration.getVirtualHosts())
-        {
-            createVirtualHost(_configuration.getVirtualHostConfig(name));
-        }
-        getVirtualHostRegistry().setDefaultVirtualHostName(_configuration.getDefaultVirtualHost());
-    }
 
-    private void initialiseManagedObjectRegistry() throws AMQException
+    @Override
+    protected void initialiseManagedObjectRegistry() throws AMQException
     {
         if (_configuration.getManagementEnabled())
         {
@@ -124,4 +68,5 @@ public class ConfigurationFileApplicatio
             _managedObjectRegistry = new NoopManagedObjectRegistry();
         }
     }
+
 }

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java?rev=942109&r1=942108&r2=942109&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java Fri May  7 15:12:22 2010
@@ -27,6 +27,7 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.configuration.ConfigStore;
 import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.configuration.VirtualHostConfiguration;
+import org.apache.qpid.server.configuration.ConfigurationManager;
 import org.apache.qpid.server.logging.RootMessageLogger;
 import org.apache.qpid.server.management.ManagedObjectRegistry;
 import org.apache.qpid.server.plugins.PluginManager;
@@ -75,6 +76,8 @@ public interface IApplicationRegistry
 
     PluginManager getPluginManager();
 
+    ConfigurationManager getConfigurationManager();
+
     RootMessageLogger getRootMessageLogger();
 
     /**

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/NullApplicationRegistry.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/NullApplicationRegistry.java?rev=942109&r1=942108&r2=942109&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/NullApplicationRegistry.java (original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/NullApplicationRegistry.java Fri May  7 15:12:22 2010
@@ -23,85 +23,84 @@ package org.apache.qpid.server.util;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
 
-import org.apache.qpid.qmf.QMFService;
 import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.configuration.VirtualHostConfiguration;
-import org.apache.qpid.server.logging.RootMessageLoggerImpl;
 import org.apache.qpid.server.logging.actors.BrokerActor;
 import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.logging.actors.TestLogActor;
-import org.apache.qpid.server.logging.rawloggers.Log4jMessageLogger;
-import org.apache.qpid.server.management.NoopManagedObjectRegistry;
-import org.apache.qpid.server.plugins.PluginManager;
 import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.security.access.ACLManager;
-import org.apache.qpid.server.security.access.plugins.AllowAll;
 import org.apache.qpid.server.security.auth.database.PropertiesPrincipalDatabaseManager;
-import org.apache.qpid.server.security.auth.manager.PrincipalDatabaseAuthenticationManager;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
 
-import java.util.Arrays;
-import java.util.Collection;
 import java.util.NoSuchElementException;
 import java.util.Properties;
 
 public class NullApplicationRegistry extends ApplicationRegistry
 {
+    // Private Exception to track tests that cause Log Actor to become unset.
+    private Exception _startup;
+
     public NullApplicationRegistry() throws ConfigurationException
     {
-        super(new ServerConfiguration(new PropertiesConfiguration()));
+        this(new ServerConfiguration(new PropertiesConfiguration()));
+        _logger.error("Creating NAR:"+this);
     }
 
-    public void initialise(int instanceID) throws Exception
+    public NullApplicationRegistry(ServerConfiguration config) throws ConfigurationException
     {
-        _logger.info("Initialising NullApplicationRegistry");
-
-        _rootMessageLogger = new RootMessageLoggerImpl(_configuration, new Log4jMessageLogger());
-
-        //We should use a Test Actor Here not the Broker Actor
-        CurrentActor.set(new TestLogActor(_rootMessageLogger));
-
-        _configuration.setHousekeepingExpiredMessageCheckPeriod(200);
+        super(config);
 
-        Properties users = new Properties();
+        addTestVhost();
 
-        users.put("guest", "guest");
+        _logger.error("Creating NAR with config:"+this);
+    }
 
-        _databaseManager = new PropertiesPrincipalDatabaseManager("default", users);
+    private void addTestVhost() throws ConfigurationException
+    {
+        if (_configuration.getVirtualHostConfig("test") == null)
+        {
+            PropertiesConfiguration vhostProps = new PropertiesConfiguration();
+            VirtualHostConfiguration hostConfig = new VirtualHostConfiguration("test", vhostProps);
+            _configuration.setVirtualHostConfig(hostConfig);
+            _configuration.setDefaultVirtualHost("test");
+        }
+    }
 
-        _accessManager = new ACLManager(_configuration.getSecurityConfiguration(), _pluginManager, AllowAll.FACTORY);
 
-        _authenticationManager = new PrincipalDatabaseAuthenticationManager(null, null);
+    @Override
+    public void initialise(int instanceID) throws Exception
+    {
+        _logger.info("Initialising NullApplicationRegistry(" + this + ")");
 
-        _managedObjectRegistry = new NoopManagedObjectRegistry();
-        _virtualHostRegistry = new VirtualHostRegistry(this);
-        _qmfService = new QMFService(getConfigStore(),this);
+        _configuration.setHousekeepingExpiredMessageCheckPeriod(200);
 
-        PropertiesConfiguration vhostProps = new PropertiesConfiguration();
-        VirtualHostConfiguration hostConfig = new VirtualHostConfiguration("test", vhostProps);
-        VirtualHost dummyHost = ApplicationRegistry.getInstance().createVirtualHost(hostConfig);
-        _virtualHostRegistry.setDefaultVirtualHostName("test");
-        _pluginManager = new PluginManager("");
-        _startup = new Exception("NAR");
+        super.initialise(instanceID);
 
+        // Tests don't correctly setup logging
+        CurrentActor.set(new TestLogActor(_rootMessageLogger));
+        _startup = new Exception("NAR Test didn't correctly setup Log Actors");
     }
-       private Exception _startup;
-    public Collection<String> getVirtualHostNames()
+
+    /**
+     * Create a user data base with just a single user guest with pwd guest.
+     * @param configuration This is ignored here as it will be empty.
+     */
+    @Override
+    protected void createDatabaseManager(ServerConfiguration configuration)
     {
-        String[] hosts = {"test"};
-        return Arrays.asList(hosts);
+        Properties users = new Properties();
+        users.put("guest", "guest");
+        _databaseManager = new PropertiesPrincipalDatabaseManager("default", users);
     }
 
+
     @Override
     public void close() throws Exception
-    {
-        CurrentActor.set(new BrokerActor(_rootMessageLogger));
-
+    {        
         try
         {
+            _logger.error("Closing NAR:"+this);            
+            CurrentActor.set(new BrokerActor(_rootMessageLogger));
             super.close();
-            _qmfService.close();
         }
         finally
         {

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java?rev=942109&r1=942108&r2=942109&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java (original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java Fri May  7 15:12:22 2010
@@ -22,143 +22,24 @@ package org.apache.qpid.server.util;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
-
-import org.apache.qpid.qmf.QMFService;
 import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.server.configuration.VirtualHostConfiguration;
-import org.apache.qpid.server.exchange.ExchangeFactory;
-import org.apache.qpid.server.exchange.ExchangeRegistry;
-import org.apache.qpid.server.logging.RootMessageLoggerImpl;
-import org.apache.qpid.server.logging.actors.CurrentActor;
-import org.apache.qpid.server.logging.actors.TestLogActor;
-import org.apache.qpid.server.logging.rawloggers.Log4jMessageLogger;
-import org.apache.qpid.server.management.NoopManagedObjectRegistry;
-import org.apache.qpid.server.queue.QueueRegistry;
-import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.security.access.ACLManager;
-import org.apache.qpid.server.security.access.plugins.AllowAll;
-import org.apache.qpid.server.security.auth.database.PropertiesPrincipalDatabaseManager;
-import org.apache.qpid.server.security.auth.manager.PrincipalDatabaseAuthenticationManager;
-import org.apache.qpid.server.store.MessageStore;
 import org.apache.qpid.server.store.TestableMemoryMessageStore;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.virtualhost.VirtualHostImpl;
-import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Properties;
 
-public class TestApplicationRegistry extends ApplicationRegistry
+public class TestApplicationRegistry extends NullApplicationRegistry
 {
-    private QueueRegistry _queueRegistry;
-
-    private ExchangeRegistry _exchangeRegistry;
-
-    private ExchangeFactory _exchangeFactory;
-
-    private MessageStore _messageStore;
-
-    private VirtualHost _vHost;
-
-
-    private ServerConfiguration _config;
-
     public TestApplicationRegistry() throws ConfigurationException
     {
-    	super(new ServerConfiguration(new PropertiesConfiguration()));
+        this(new ServerConfiguration(new PropertiesConfiguration()));
     }
 
     public TestApplicationRegistry(ServerConfiguration config) throws ConfigurationException
     {
-    	super(config);
-    	_config = config;
-    }
-
-    public void initialise(int instanceID) throws Exception
-    {
-        _rootMessageLogger = new RootMessageLoggerImpl(_configuration,
-                                                       new Log4jMessageLogger());
-
-        //Add a Test Actor as a lot of our System Tests reach in to the broker
-        // and manipulate it so the CurrentActor is not set.
-        CurrentActor.set(new TestLogActor(_rootMessageLogger));
-
-        Properties users = new Properties();
-
-        users.put("guest", "guest");
-
-        _databaseManager = new PropertiesPrincipalDatabaseManager("default", users);
-
-        _accessManager = new ACLManager(_configuration.getSecurityConfiguration(), _pluginManager, AllowAll.FACTORY);
-
-        _authenticationManager = new PrincipalDatabaseAuthenticationManager(null, null);
-
-        _managedObjectRegistry = new NoopManagedObjectRegistry();
-
-        _messageStore = new TestableMemoryMessageStore();
-
-        _virtualHostRegistry = new VirtualHostRegistry(this);
-        _qmfService = new QMFService(getConfigStore(),this);
-
-
-        PropertiesConfiguration vhostProps = new PropertiesConfiguration();
-        VirtualHostConfiguration hostConfig = new VirtualHostConfiguration("test", vhostProps);
-        _vHost = new VirtualHostImpl(hostConfig, _messageStore);
-
-        _virtualHostRegistry.registerVirtualHost(_vHost);
-
-        _queueRegistry = _vHost.getQueueRegistry();
-        _exchangeFactory = _vHost.getExchangeFactory();
-        _exchangeRegistry = _vHost.getExchangeRegistry();
-
-    }
-
-    public QueueRegistry getQueueRegistry()
-    {
-        return _queueRegistry;
-    }
-
-    public ExchangeRegistry getExchangeRegistry()
-    {
-        return _exchangeRegistry;
-    }
-
-    public ExchangeFactory getExchangeFactory()
-    {
-        return _exchangeFactory;
-    }
-
-    public Collection<String> getVirtualHostNames()
-    {
-        String[] hosts = {"test"};
-        return Arrays.asList(hosts);
-    }
-
-    public void setAccessManager(ACLManager newManager)
-    {
-        _accessManager = newManager;
-    }
-
-    public MessageStore getMessageStore()
-    {
-        return _messageStore;
-    }
-
-    @Override
-    public void close() throws Exception
-    {
-        try
-        {
-            super.close();
-            _qmfService.close();
-        }
-        finally
-        {
-            CurrentActor.remove();
-        }
+        super(config);
+        _configuration.getConfig().setProperty("virtualhosts.virtualhost.name",
+                                               "test");
+        _configuration.getConfig().setProperty("virtualhosts.virtualhost.test.store.class",
+                                               TestableMemoryMessageStore.class.getName());
     }
-
 }
 
 



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message