qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oru...@apache.org
Subject svn commit: r1404902 [1/2] - in /qpid/branches/java-broker-config-qpid-4390/qpid/java: bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/ broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/ broker-plugins...
Date Fri, 02 Nov 2012 09:47:17 GMT
Author: orudyy
Date: Fri Nov  2 09:47:15 2012
New Revision: 1404902

URL: http://svn.apache.org/viewvc?rev=1404902&view=rev
Log:
QPID-4390: WIP - Convert management plugins into configured objects

Added:
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.PluginFactory
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXConfiguration.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.PluginFactory
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfiguredObjectRecoverer.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/RecovererProvider.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultBrokerRecoverer.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProvider.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PluginRecoverer.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/PluginFactory.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/PluginRecovererTest.java
Removed:
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ManagementFactory
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ManagementFactory
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/management/plugin/ManagementPlugin.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/plugin/ManagementFactory.java
Modified:
    qpid/branches/java-broker-config-qpid-4390/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStoreTest.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementFactoryTest.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementFactory.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/JMXManagementFactoryTest.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerLauncher.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntry.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObjectType.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/startup/BrokerRecovererTest.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java
    qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStoreTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStoreTest.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStoreTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAMessageStoreTest.java Fri Nov  2 09:47:15 2012
@@ -63,6 +63,8 @@ public class BDBHAMessageStoreTest exten
 
         FileUtils.delete(new File(_workDir), true);
         _configXml = new XMLConfiguration();
+        _configXml.addProperty("management.enabled", "false");
+        _configXml.addProperty("management.http.enabled", "false");
     }
 
     public void tearDown() throws Exception

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java Fri Nov  2 09:47:15 2012
@@ -23,9 +23,9 @@ package org.apache.qpid.server.managemen
 import java.io.File;
 import java.util.Collection;
 import java.util.Map;
+import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.commons.configuration.ConfigurationException;
 import org.apache.log4j.Logger;
 import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.logging.messages.ManagementConsoleMessages;
@@ -54,6 +54,7 @@ import org.apache.qpid.server.model.Sess
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.User;
 import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.adapter.AbstractPluginAdapter;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.SessionManager;
@@ -63,7 +64,7 @@ import org.eclipse.jetty.servlet.Servlet
 import org.eclipse.jetty.servlet.ServletHolder;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
 
-public class HttpManagement implements ManagementPlugin
+public class HttpManagement extends AbstractPluginAdapter
 {
     private final Logger _logger = Logger.getLogger(HttpManagement.class);
 
@@ -80,16 +81,34 @@ public class HttpManagement implements M
     private int _sessionTimeout;
 
     // XXX refactor back to use a single instance of server and add connectors for different ports
-    public HttpManagement(Broker broker, String keyStorePath, String keyStorePassword, int sessionTimeout) throws ConfigurationException
+    public HttpManagement(UUID id, Broker broker, String keyStorePath, String keyStorePassword, int sessionTimeout)
     {
+        super(id);
         _broker = broker;
         _keyStorePassword = keyStorePassword;
         _keyStorePath = keyStorePath;
         _sessionTimeout = sessionTimeout;
+        addParent(Broker.class, broker);
     }
 
     @Override
-    public void start() throws Exception
+    protected boolean setState(State currentState, State desiredState)
+    {
+        if(desiredState == State.ACTIVE)
+        {
+            start();
+            return true;
+        }
+        else if(desiredState == State.STOPPED)
+        {
+            stop();
+            return true;
+        }
+        return false;
+    }
+
+
+    private void start()
     {
         CurrentActor.get().message(ManagementConsoleMessages.STARTUP(OPERATIONAL_LOGGING_NAME));
 
@@ -108,8 +127,7 @@ public class HttpManagement implements M
         CurrentActor.get().message(ManagementConsoleMessages.READY(OPERATIONAL_LOGGING_NAME));
     }
 
-    @Override
-    public void stop() throws Exception
+    private void stop()
     {
         Collection<Port> ports = _broker.getPorts();
         for (Port port : ports)
@@ -320,4 +338,11 @@ public class HttpManagement implements M
     {
         return connector instanceof SslSocketConnector ? "HTTPS" : "HTTP";
     }
+
+
+    @Override
+    public String getName()
+    {
+        return "HttpManagement";
+    }
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.java Fri Nov  2 09:47:15 2012
@@ -18,37 +18,36 @@
  */
 package org.apache.qpid.server.management.plugin;
 
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.log4j.Logger;
-import org.apache.qpid.server.configuration.ServerConfiguration;
+import java.util.Map;
+import java.util.UUID;
+
 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.plugin.PluginFactory;
+import org.apache.qpid.server.util.MapValueConverter;
 
-public class HttpManagementFactory implements ManagementFactory
+public class HttpManagementFactory implements PluginFactory
 {
-    private static final Logger LOGGER = Logger.getLogger(HttpManagementFactory.class);
+    // 10 minutes by default
+    private static final int DEFAULT_TIMEOUT_IN_SECONDS = 60 * 10;
+
+    public static final String TIME_OUT = "sessionTimeout";
+    public static final String KEY_STORE_PATH = "keyStorePath";
+    public static final String KEY_STORE_PASSWORD = "keyStorePassword";
+
+    public static final String PLUGIN_NAME = "MANAGEMENT-HTTP";
 
+    // XXX create a configuration POJO containing SASL and basic auth configuration
     @Override
-    public HttpManagement createInstance(ServerConfiguration configuration, Broker broker)
+    public ConfiguredObject createInstance(UUID id, Map<String, Object> attributes, Broker broker)
     {
-
-        if (!configuration.getHTTPManagementEnabled() && !configuration.getHTTPSManagementEnabled())
+        if (!PLUGIN_NAME.equals(attributes.get(PLUGIN_TYPE)))
         {
-            LOGGER.info("HttpManagement is disabled");
             return null;
         }
-
-        try
-        {
-            return new HttpManagement(
-                    broker,
-                    configuration.getManagementKeyStorePath(),
-                    configuration.getManagementKeyStorePassword(),
-                    configuration.getHTTPManagementSessionTimeout());
-        }
-        catch (ConfigurationException e)
-        {
-            throw new RuntimeException(e);
-        }
+        Integer sessionTimeout = MapValueConverter.getIntegerAttribute(TIME_OUT, attributes, DEFAULT_TIMEOUT_IN_SECONDS);
+        String keyStorePath = MapValueConverter.getStringAttribute(KEY_STORE_PATH, attributes, null);
+        String keyStorePasssword = MapValueConverter.getStringAttribute(KEY_STORE_PASSWORD, attributes, null);
+        return new HttpManagement( id, broker, keyStorePath, keyStorePasssword, sessionTimeout);
     }
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java Fri Nov  2 09:47:15 2012
@@ -200,6 +200,7 @@ public class SaslServlet extends Abstrac
         boolean saslAuthEnabled;
         if (request.isSecure())
         {
+            // XXX replace getHTTPSManagementSaslAuthEnabled with access to a field set from config
             saslAuthEnabled = ApplicationRegistry.getInstance().getConfiguration().getHTTPSManagementSaslAuthEnabled();
         }
         else

Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.PluginFactory
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.PluginFactory?rev=1404902&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.PluginFactory (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.PluginFactory Fri Nov  2 09:47:15 2012
@@ -0,0 +1 @@
+org.apache.qpid.server.management.plugin.HttpManagementFactory

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementFactoryTest.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementFactoryTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementFactoryTest.java Fri Nov  2 09:47:15 2012
@@ -19,10 +19,13 @@
 package org.apache.qpid.server.management.plugin;
 
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
-import org.apache.qpid.server.configuration.ServerConfiguration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
 import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.plugin.PluginFactory;
 import org.apache.qpid.test.utils.QpidTestCase;
 
 public class HttpManagementFactoryTest extends QpidTestCase
@@ -31,49 +34,43 @@ public class HttpManagementFactoryTest e
     private static final String KEY_STORE_PATH = "keyStorePath";
     private static final int SESSION_TIMEOUT = 3600;
 
-    private HttpManagementFactory _managementFactory = new HttpManagementFactory();
-    private ServerConfiguration _configuration = mock(ServerConfiguration.class);
+    private PluginFactory _pluginFactory = new HttpManagementFactory();
+    private Map<String, Object> _attributes = new HashMap<String, Object>();
     private Broker _broker = mock(Broker.class);
+    private UUID _id = UUID.randomUUID();
 
-    public void testNoHttpManagementConfigured() throws Exception
+    public void testCreateInstanceReturnsNullWhenPluginTypeMissing() throws Exception
     {
-        ManagementPlugin management = _managementFactory.createInstance(_configuration, _broker);
-        assertNull(management);
+        assertNull(_pluginFactory.createInstance(_id, _attributes, _broker));
     }
-
-    public void testHttpTransportConfigured() throws Exception
+    public void testCreateInstanceReturnsNullWhenPluginTypeNotHttp()
     {
-        when(_configuration.getHTTPManagementEnabled()).thenReturn(true);
-        when(_configuration.getHTTPSManagementEnabled()).thenReturn(false);
-
-        when(_configuration.getManagementKeyStorePassword()).thenReturn(null);
-        when(_configuration.getManagementKeyStorePath()).thenReturn(null);
+        _attributes.put(PluginFactory.PLUGIN_TYPE, "notHttp");
+        assertNull(_pluginFactory.createInstance(_id, _attributes, _broker));
+    }
 
-        when(_configuration.getHTTPManagementSessionTimeout()).thenReturn(SESSION_TIMEOUT);
+    public void testCreateInstanceWithoutKeystore() throws Exception
+    {
+        _attributes.put(PluginFactory.PLUGIN_TYPE, HttpManagementFactory.PLUGIN_NAME);
+        _attributes.put(HttpManagementFactory.TIME_OUT, SESSION_TIMEOUT);
 
-        HttpManagement management = _managementFactory.createInstance(_configuration, _broker);
+        HttpManagement management = (HttpManagement) _pluginFactory.createInstance(_id, _attributes, _broker);
 
-        assertNotNull(management);
         assertEquals(_broker, management.getBroker());
         assertNull(management.getKeyStorePassword());
         assertNull(management.getKeyStorePath());
         assertEquals(SESSION_TIMEOUT, management.getSessionTimeout());
-
     }
 
-    public void testHttpsTransportConfigured() throws Exception
+    public void testCreateInstanceWithKeystore() throws Exception
     {
-        when(_configuration.getHTTPManagementEnabled()).thenReturn(false);
-        when(_configuration.getHTTPSManagementEnabled()).thenReturn(true);
-
-        when(_configuration.getManagementKeyStorePassword()).thenReturn(KEY_STORE_PASSWORD);
-        when(_configuration.getManagementKeyStorePath()).thenReturn(KEY_STORE_PATH);
-
-        when(_configuration.getHTTPManagementSessionTimeout()).thenReturn(SESSION_TIMEOUT);
+        _attributes.put(PluginFactory.PLUGIN_TYPE, HttpManagementFactory.PLUGIN_NAME);
+        _attributes.put(HttpManagementFactory.KEY_STORE_PASSWORD, KEY_STORE_PASSWORD);
+        _attributes.put(HttpManagementFactory.KEY_STORE_PATH, KEY_STORE_PATH);
+        _attributes.put(HttpManagementFactory.TIME_OUT, SESSION_TIMEOUT);
 
-        HttpManagement management = _managementFactory.createInstance(_configuration, _broker);
+        HttpManagement management = (HttpManagement) _pluginFactory.createInstance(_id, _attributes, _broker);
 
-        assertNotNull(management);
         assertEquals(_broker, management.getBroker());
         assertEquals(KEY_STORE_PASSWORD, management.getKeyStorePassword());
         assertEquals(KEY_STORE_PATH, management.getKeyStorePath());

Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXConfiguration.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXConfiguration.java?rev=1404902&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXConfiguration.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXConfiguration.java Fri Nov  2 09:47:15 2012
@@ -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.jmx;
+
+public class JMXConfiguration
+{
+    private final boolean _useCustomRMISocketFactory;
+    private final boolean _platformMBeanServer;
+    private final String _managementKeyStorePath;
+    private final String  _managementKeyStorePassword;
+
+    public JMXConfiguration(boolean useCustomRMISocketFactory, boolean platformMBeanServer, String managementKeyStorePath,
+            String managementKeyStorePassword)
+    {
+        _useCustomRMISocketFactory = useCustomRMISocketFactory;
+        _platformMBeanServer = platformMBeanServer;
+        _managementKeyStorePath = managementKeyStorePath;
+        _managementKeyStorePassword = managementKeyStorePassword;
+    }
+
+    public boolean isUseCustomRMISocketFactory()
+    {
+        return _useCustomRMISocketFactory;
+    }
+
+    public boolean isPlatformMBeanServer()
+    {
+        return _platformMBeanServer;
+    }
+
+    public String getManagementKeyStorePath()
+    {
+        return _managementKeyStorePath;
+    }
+
+    public String getManagementKeyStorePassword()
+    {
+        return _managementKeyStorePassword;
+    }
+
+}

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java Fri Nov  2 09:47:15 2012
@@ -20,10 +20,8 @@
  */
 package org.apache.qpid.server.jmx;
 
-import org.apache.commons.configuration.ConfigurationException;
 import org.apache.log4j.Logger;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.logging.messages.ManagementConsoleMessages;
 import org.apache.qpid.server.model.Port;
@@ -48,7 +46,6 @@ import java.io.IOException;
 import java.lang.management.ManagementFactory;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
-import java.net.MalformedURLException;
 import java.net.UnknownHostException;
 import java.rmi.AlreadyBoundException;
 import java.rmi.NoSuchObjectException;
@@ -73,32 +70,37 @@ public class JMXManagedObjectRegistry im
 
     private final MBeanServer _mbeanServer;
     private final boolean _useCustomSocketFactory;
-    private final ServerConfiguration _serverConfiguration;
 
     private JMXConnectorServer _cs;
     private Registry _rmiRegistry;
 
-    private Port _registryPort;
-    private Port _connectorPort;
+    private final Port _registryPort;
+    private final Port _connectorPort;
 
-    // XXX get rid from ServerConfiguration
-    public JMXManagedObjectRegistry(ServerConfiguration serverConfiguration, Port connectorPort, Port registryPort) throws AMQException
+    private final String _managementKeyStorePath;
+    private final String  _managementKeyStorePassword;
+
+    public JMXManagedObjectRegistry(
+            Port connectorPort, Port registryPort,
+            JMXConfiguration jmxConfiguration)
     {
-        _serverConfiguration = serverConfiguration;
         _registryPort = registryPort;
         _connectorPort = connectorPort;
 
         // Retrieve the config parameters
-        _useCustomSocketFactory = _serverConfiguration.getUseCustomRMISocketFactory();
-        boolean platformServer = _serverConfiguration.getPlatformMbeanserver();
+        _useCustomSocketFactory = jmxConfiguration.isUseCustomRMISocketFactory();
+        boolean platformServer = jmxConfiguration.isPlatformMBeanServer();
 
         _mbeanServer =
                 platformServer ? ManagementFactory.getPlatformMBeanServer()
                 : MBeanServerFactory.createMBeanServer(ManagedObject.DOMAIN);
+
+        _managementKeyStorePath = jmxConfiguration.getManagementKeyStorePath();
+        _managementKeyStorePassword = jmxConfiguration.getManagementKeyStorePassword();
     }
 
     @Override
-    public void start() throws IOException, ConfigurationException
+    public void start() throws IOException
     {
         CurrentActor.get().message(ManagementConsoleMessages.STARTUP(OPERATIONAL_LOGGING_NAME));
 
@@ -113,9 +115,7 @@ public class JMXManagedObjectRegistry im
         }
     }
 
-    private void startRegistryAndConnector() throws ConfigurationException,
-            FileNotFoundException, RemoteException, IOException,
-            MalformedURLException
+    private void startRegistryAndConnector() throws IOException
     {
         //Socket factories for the RMIConnectorServer, either default or SSL depending on configuration
         RMIClientSocketFactory csf;
@@ -129,19 +129,18 @@ public class JMXManagedObjectRegistry im
         {
             //set the SSL related system properties used by the SSL RMI socket factories to the values
             //given in the configuration file
-            String keyStorePath = _serverConfiguration.getManagementKeyStorePath();
-            checkKeyStorePathExistsAndIsReadable(keyStorePath);
+            checkKeyStorePathExistsAndIsReadable(_managementKeyStorePath);
 
-            CurrentActor.get().message(ManagementConsoleMessages.SSL_KEYSTORE(keyStorePath));
+            CurrentActor.get().message(ManagementConsoleMessages.SSL_KEYSTORE(_managementKeyStorePath));
 
-            if (_serverConfiguration.getManagementKeyStorePassword() == null)
+            if (_managementKeyStorePassword == null)
             {
-                throw new ConfigurationException("JMX management SSL keystore password not defined, " +
-                                                 "unable to start requested SSL protected JMX server");
+                throw new IllegalConfigurationException(
+                        "JMX management SSL keystore password not defined, unable to start requested SSL protected JMX server");
             }
             else
             {
-               System.setProperty("javax.net.ssl.keyStorePassword", _serverConfiguration.getManagementKeyStorePassword());
+               System.setProperty("javax.net.ssl.keyStorePassword", _managementKeyStorePassword);
             }
 
             //create the SSL RMI socket factories
@@ -276,14 +275,13 @@ public class JMXManagedObjectRegistry im
         return rmiRegistry;
     }
 
-    private void checkKeyStorePathExistsAndIsReadable(String keyStorePath)
-            throws ConfigurationException, FileNotFoundException
+    private void checkKeyStorePathExistsAndIsReadable(String keyStorePath) throws FileNotFoundException
     {
         //check the keystore path value is valid
         if (keyStorePath == null)
         {
-            throw new ConfigurationException("JMX management SSL keystore path not defined, " +
-                                             "unable to start SSL protected JMX ConnectorServer");
+            throw new IllegalConfigurationException(
+                    "JMX management SSL keystore path not defined, unable to start SSL protected JMX ConnectorServer");
         }
         else
         {

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java Fri Nov  2 09:47:15 2012
@@ -21,21 +21,21 @@
 
 package org.apache.qpid.server.jmx;
 
+import java.io.IOException;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.UUID;
+
 import javax.management.JMException;
-import javax.management.StandardMBean;
 
 import org.apache.log4j.Logger;
-import org.apache.qpid.server.configuration.ServerConfiguration;
 import org.apache.qpid.server.jmx.mbeans.LoggingManagementMBean;
 import org.apache.qpid.server.jmx.mbeans.UserManagementMBean;
 import org.apache.qpid.server.jmx.mbeans.ServerInformationMBean;
 import org.apache.qpid.server.jmx.mbeans.Shutdown;
 import org.apache.qpid.server.jmx.mbeans.VirtualHostMBean;
 import org.apache.qpid.server.logging.log4j.LoggingManagementFacade;
-import org.apache.qpid.server.management.plugin.ManagementPlugin;
 import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ConfigurationChangeListener;
@@ -45,9 +45,10 @@ import org.apache.qpid.server.model.Port
 import org.apache.qpid.server.model.Protocol;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.adapter.AbstractPluginAdapter;
 import org.apache.qpid.server.plugin.QpidServiceLoader;
 
-public class JMXManagement implements ConfigurationChangeListener, ManagementPlugin
+public class JMXManagement extends AbstractPluginAdapter implements ConfigurationChangeListener
 {
     private static final Logger LOGGER = Logger.getLogger(JMXManagement.class);
 
@@ -59,16 +60,43 @@ public class JMXManagement implements Co
 
     private final Map<ConfiguredObject, AMQManagedObject> _children = new HashMap<ConfiguredObject, AMQManagedObject>();
 
-    private final ServerConfiguration _serverConfiguration;
+    private final JMXConfiguration _jmxConfiguration;
 
-    public JMXManagement(ServerConfiguration serverConfiguration, Broker broker)
+    public JMXManagement(UUID id, Broker broker, JMXConfiguration jmxConfiguration)
     {
+        super(id);
         _broker = broker;
-        _serverConfiguration = serverConfiguration;
+        _jmxConfiguration = jmxConfiguration;
     }
 
     @Override
-    public void start() throws Exception
+    protected boolean setState(State currentState, State desiredState)
+    {
+        if(desiredState == State.ACTIVE)
+        {
+            try
+            {
+                start();
+            }
+            catch (JMException e)
+            {
+                throw new RuntimeException("Couldn't start JMX management", e);
+            }
+            catch (IOException e)
+            {
+                throw new RuntimeException("Couldn't start JMX management", e);
+            }
+            return true;
+        }
+        else if(desiredState == State.STOPPED)
+        {
+            stop();
+            return true;
+        }
+        return false;
+    }
+
+    private void start() throws JMException, IOException
     {
         Port connectorPort = null;
         Port registryPort = null;
@@ -96,8 +124,7 @@ public class JMXManagement implements Co
             throw new IllegalStateException("No JMX port found with name " + REGISTRY_PORT_NAME);
         }
 
-        //XXX review MBean creation process
-        _objectRegistry = new JMXManagedObjectRegistry(_serverConfiguration, connectorPort, registryPort);
+        _objectRegistry = new JMXManagedObjectRegistry(connectorPort, registryPort, _jmxConfiguration);
 
         _broker.addChangeListener(this);
 
@@ -107,7 +134,9 @@ public class JMXManagement implements Co
             {
                 if(!_children.containsKey(virtualHost))
                 {
+                    LOGGER.debug("Create MBean for virtual host:" + virtualHost.getName());
                     VirtualHostMBean mbean = new VirtualHostMBean(virtualHost, _objectRegistry);
+                    LOGGER.debug("Check for additional MBeans for virtual host:" + virtualHost.getName());
                     createAdditionalMBeansFromProviders(virtualHost, mbean);
                 }
             }
@@ -130,8 +159,7 @@ public class JMXManagement implements Co
         _objectRegistry.start();
     }
 
-    @Override
-    public void stop()
+    private void stop()
     {
         synchronized (_children)
         {
@@ -228,7 +256,7 @@ public class JMXManagement implements Co
     private void createAdditionalMBeansFromProviders(ConfiguredObject child, AMQManagedObject mbean) throws JMException
     {
         _children.put(child, mbean);
-
+        // XXX: MBeanProvider does not work at the moment
         QpidServiceLoader<MBeanProvider> qpidServiceLoader = new QpidServiceLoader<MBeanProvider>();
         for (MBeanProvider provider : qpidServiceLoader.instancesOf(MBeanProvider.class))
         {
@@ -236,7 +264,7 @@ public class JMXManagement implements Co
             if (provider.isChildManageableByMBean(child))
             {
                 LOGGER.debug("Provider will create mbean ");
-                StandardMBean bean = provider.createMBean(child, mbean);
+                provider.createMBean(child, mbean);
                 // TODO track the mbeans that have been created on behalf of a child in a map, then
                 // if the child is ever removed, destroy these beans too.
             }
@@ -249,9 +277,9 @@ public class JMXManagement implements Co
         return _broker;
     }
 
-    /** Added for testing purposes */
-    ServerConfiguration getServerConfiguration()
+    @Override
+    public String getName()
     {
-        return _serverConfiguration;
+        return "JMXManagement";
     }
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementFactory.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementFactory.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagementFactory.java Fri Nov  2 09:47:15 2012
@@ -18,27 +18,46 @@
  */
 package org.apache.qpid.server.jmx;
 
+import static org.apache.qpid.server.util.MapValueConverter.getBooleanAttribute;
+import static org.apache.qpid.server.util.MapValueConverter.getStringAttribute;
+
+import java.util.Map;
+import java.util.UUID;
+
 import org.apache.log4j.Logger;
-import org.apache.qpid.server.configuration.ServerConfiguration;
 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.plugin.PluginFactory;
 
-public class JMXManagementFactory implements ManagementFactory
+public class JMXManagementFactory implements PluginFactory
 {
-    private static final Logger _logger = Logger.getLogger(JMXManagementFactory.class);
+    private static final Logger LOGGER = Logger.getLogger(JMXManagementFactory.class);
+
+    public static final String USE_CUSTOM_RMI_SOCKET_FACTORY = "useCustomRMISocketFactory";
+    public static final String USE_PLATFORM_MBEAN_SERVER = "usePlatformMBeanServer";
+    public static final String KEY_STORE_PATH = "keyStorePath";
+    public static final String KEY_STORE_PASSWORD = "keyStorePassword";
+
+    public static final String PLUGIN_NAME = "MANAGEMENT-JMX";
 
     @Override
-    public JMXManagement createInstance(ServerConfiguration serverConfiguration, Broker broker)
+    public ConfiguredObject createInstance(UUID id, Map<String, Object> attributes, Broker broker)
     {
-        if (serverConfiguration.getJMXManagementEnabled())
+        if (PLUGIN_NAME.equals(attributes.get(PLUGIN_TYPE)))
         {
-            return new JMXManagement(serverConfiguration, broker);
+            JMXConfiguration jmxConfiguration = new JMXConfiguration(
+                    getBooleanAttribute(USE_CUSTOM_RMI_SOCKET_FACTORY, attributes, false),
+                    getBooleanAttribute(USE_PLATFORM_MBEAN_SERVER, attributes, true),
+                    getStringAttribute(KEY_STORE_PATH, attributes, null),
+                    getStringAttribute(KEY_STORE_PASSWORD, attributes, null));
+
+            return new JMXManagement(id, broker, jmxConfiguration);
         }
         else
         {
-            if(_logger.isDebugEnabled())
+            if(LOGGER.isDebugEnabled())
             {
-                _logger.debug("Skipping registration of JMX plugin as JMX Management disabled in config.");
+                LOGGER.debug("Skipping registration of JMX plugin as JMX Management disabled in config.");
             }
             return null;
         }

Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.PluginFactory
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.PluginFactory?rev=1404902&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.PluginFactory (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.PluginFactory Fri Nov  2 09:47:15 2012
@@ -0,0 +1 @@
+org.apache.qpid.server.jmx.JMXManagementFactory

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/JMXManagementFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/JMXManagementFactoryTest.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/JMXManagementFactoryTest.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker-plugins/management-jmx/src/test/java/org/apache/qpid/server/jmx/JMXManagementFactoryTest.java Fri Nov  2 09:47:15 2012
@@ -19,33 +19,39 @@
 package org.apache.qpid.server.jmx;
 
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
-import org.apache.qpid.server.configuration.ServerConfiguration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
 import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.plugin.PluginFactory;
 import org.apache.qpid.test.utils.QpidTestCase;
 
 public class JMXManagementFactoryTest extends QpidTestCase
 {
     private final JMXManagementFactory _jmxManagementFactory = new JMXManagementFactory();
-    private final ServerConfiguration _serverConfiguration = mock(ServerConfiguration.class);
+    private final Map<String, Object> _attributes = new HashMap<String, Object>();
     private final Broker _broker = mock(Broker.class);
+    private UUID _id = UUID.randomUUID();
 
     public void testJMXConfigured() throws Exception
     {
-        when(_serverConfiguration.getJMXManagementEnabled()).thenReturn(true);
+        _attributes.put(PluginFactory.PLUGIN_TYPE, JMXManagementFactory.PLUGIN_NAME);
 
-        JMXManagement jmxManagement = _jmxManagementFactory.createInstance(_serverConfiguration, _broker);
+        JMXManagement jmxManagement = (JMXManagement) _jmxManagementFactory.createInstance(_id, _attributes, _broker);
 
         assertNotNull(jmxManagement);
     }
 
-    public void testJMXNotConfigured() throws Exception
+    public void testCreateInstanceReturnsNullWhenPluginTypeMissing()
     {
-        when(_serverConfiguration.getJMXManagementEnabled()).thenReturn(false);
-
-        JMXManagement jmxManagement = _jmxManagementFactory.createInstance(_serverConfiguration, _broker);
+        assertNull(_jmxManagementFactory.createInstance(_id, _attributes, _broker));
+    }
 
-        assertNull(jmxManagement);
+    public void testCreateInstanceReturnsNullWhenPluginTypeNotJmx()
+    {
+        _attributes.put(PluginFactory.PLUGIN_TYPE, "notJmx");
+        assertNull(_jmxManagementFactory.createInstance(_id, _attributes, _broker));
     }
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerLauncher.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerLauncher.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerLauncher.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerLauncher.java Fri Nov  2 09:47:15 2012
@@ -23,11 +23,7 @@ package org.apache.qpid.server;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
@@ -38,13 +34,8 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.logging.SystemOutMessageLogger;
 import org.apache.qpid.server.logging.actors.BrokerActor;
 import org.apache.qpid.server.logging.actors.CurrentActor;
-import org.apache.qpid.server.logging.actors.GenericActor;
 import org.apache.qpid.server.logging.log4j.LoggingManagementFacade;
 import org.apache.qpid.server.logging.messages.BrokerMessages;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.Protocol;
-import org.apache.qpid.server.model.Transport;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 
 public class BrokerLauncher
@@ -121,33 +112,13 @@ public class BrokerLauncher
 
         configureLogging(logConfigFile, options.getLogWatchFrequency());
 
+        // XXX create ConfigurationEntryStore and pass it into registry constructor
         ServerConfiguration serverConfig = new ServerConfiguration(configFile);
 
         ApplicationRegistry applicationRegistry = new ApplicationRegistry(serverConfig, options);
 
         ApplicationRegistry.initialise(applicationRegistry);
 
-        // We have already loaded the BrokerMessages class by this point so we
-        // need to refresh the locale setting in case we had a different value in
-        // the configuration.
-       // BrokerMessages.reload();
-
-        // AR.initialise() sets and removes its own actor so we now need to set the actor
-        // for the remainder of the startup, and the default actor if the stack is empty
-        //CurrentActor.set(new BrokerActor(applicationRegistry.getCompositeStartupMessageLogger()));
-        //CurrentActor.setDefault(new BrokerActor(applicationRegistry.getRootMessageLogger()));
-        //GenericActor.setDefaultMessageLogger(applicationRegistry.getRootMessageLogger());
-/*
-        try
-        {
-            CurrentActor.get().message(BrokerMessages.READY());
-        }
-        finally
-        {
-            // Startup is complete so remove the AR initialised Startup actor
-            CurrentActor.remove();
-        }
-        */
     }
 
 

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntry.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntry.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntry.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntry.java Fri Nov  2 09:47:15 2012
@@ -145,7 +145,7 @@ public class ConfigurationEntry
     public String toString()
     {
         return "ConfigurationEntry [_id=" + _id + ", _type=" + _type + ", _attributes=" + _attributes + ", _childrenIds="
-                + _childrenIds + ", _store=" + _store + "]";
+                + _childrenIds + "]";
     }
 
 }

Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfiguredObjectRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfiguredObjectRecoverer.java?rev=1404902&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfiguredObjectRecoverer.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfiguredObjectRecoverer.java Fri Nov  2 09:47:15 2012
@@ -0,0 +1,28 @@
+/*
+ *
+ * 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.qpid.server.model.ConfiguredObject;
+
+public interface ConfiguredObjectRecoverer<T extends ConfiguredObject>
+{
+    T create(RecovererProvider recovererProvider, ConfigurationEntry entry, ConfiguredObject... parents);
+}

Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/RecovererProvider.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/RecovererProvider.java?rev=1404902&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/RecovererProvider.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/RecovererProvider.java Fri Nov  2 09:47:15 2012
@@ -0,0 +1,28 @@
+/*
+ *
+ * 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.qpid.server.model.ConfiguredObjectType;
+
+public interface RecovererProvider
+{
+    ConfiguredObjectRecoverer<?> getRecoverer(ConfiguredObjectType type);
+}

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java Fri Nov  2 09:47:15 2012
@@ -28,6 +28,7 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.ConfiguredObjectType;
 import org.apache.qpid.server.model.GroupProvider;
 import org.apache.qpid.server.model.Port;
@@ -40,6 +41,7 @@ import org.apache.qpid.server.model.adap
 import org.apache.qpid.server.registry.IApplicationRegistry;
 import org.apache.qpid.server.security.group.GroupPrincipalAccessor;
 
+// XXX delete it and rename DefaultBrokerRecoverer into BrokerRecoverer
 public class BrokerRecoverer
 {
     private static final Logger LOGGER = Logger.getLogger(BrokerRecoverer.class);
@@ -55,10 +57,12 @@ public class BrokerRecoverer
 
     private final GroupProviderRecoverer _groupProviderRecoverer;
 
+    private final PluginRecoverer _pluginRecoverer;
+
     public BrokerRecoverer(PortRecoverer portRecoverer, VirtualHostRecoverer virtualHostRecoverer,
             AuthenticationProviderRecoverer authenticationProviderRecoverer,
             AuthenticationProviderFactory authenticationProviderFactory, PortFactory portFactory,
-            GroupProviderRecoverer groupProviderRecoverer, IApplicationRegistry registry)
+            GroupProviderRecoverer groupProviderRecoverer, PluginRecoverer pluginRecoverer, IApplicationRegistry registry)
     {
         _registry = registry;
         _virtualHostRecoverer = virtualHostRecoverer;
@@ -67,6 +71,7 @@ public class BrokerRecoverer
         _authenticationProviderRecoverer = authenticationProviderRecoverer;
         _authenticationProviderFactory = authenticationProviderFactory;
         _groupProviderRecoverer = groupProviderRecoverer;
+        _pluginRecoverer = pluginRecoverer;
     }
 
     public Broker create(ConfigurationEntry entry)
@@ -77,6 +82,7 @@ public class BrokerRecoverer
         recoverPorts(broker, childEntries);
         recoverGroupProviders(broker, childEntries);
         recoverAuthenticationProviders(broker, childEntries);
+        recoverPlugins(broker, childEntries);
 
         wireUpAuthenticationProviders(broker, entry.getAttributesAsAttributeMap());
 
@@ -93,7 +99,7 @@ public class BrokerRecoverer
         {
             LOGGER.error("No authentication providers configured");
             return;
-            // XXX reinstate when wire-up has been separated from createion: throw new IllegalConfigurationException("No authentication providers configured");
+            // XXX reinstate when wire-up has been separated from creation: throw new IllegalConfigurationException("No authentication providers configured");
         }
         else if (numberOfAuthenticationProviders == 1)
         {
@@ -195,4 +201,24 @@ public class BrokerRecoverer
             }
         }
     }
+
+    private void recoverPlugins(BrokerAdapter broker, Map<ConfiguredObjectType, Collection<ConfigurationEntry>> childEntries)
+    {
+        Collection<ConfigurationEntry> entries = childEntries.get(ConfiguredObjectType.PLUGIN);
+        if (entries != null)
+        {
+            for (ConfigurationEntry entry : entries)
+            {
+                ConfiguredObject pluginObject = _pluginRecoverer.create(entry, broker);
+                if (pluginObject == null)
+                {
+                    LOGGER.warn("Cannot instantiate plugin for configuration entry:" + entry);
+                }
+                else
+                {
+                    broker.addPlugin(pluginObject);
+                }
+            }
+        }
+    }
 }

Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultBrokerRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultBrokerRecoverer.java?rev=1404902&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultBrokerRecoverer.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultBrokerRecoverer.java Fri Nov  2 09:47:15 2012
@@ -0,0 +1,126 @@
+package org.apache.qpid.server.configuration.startup;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+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.AuthenticationProvider;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.ConfiguredObjectType;
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.model.adapter.AuthenticationProviderAdapter;
+import org.apache.qpid.server.model.adapter.AuthenticationProviderFactory;
+import org.apache.qpid.server.model.adapter.BrokerAdapter;
+import org.apache.qpid.server.model.adapter.PortAdapter;
+import org.apache.qpid.server.model.adapter.PortFactory;
+import org.apache.qpid.server.registry.IApplicationRegistry;
+import org.apache.qpid.server.security.group.GroupPrincipalAccessor;
+
+// XXX remove BrokerRecoverer and rename DefaultBrokerRecoverer into BrokerRecoverer
+public class DefaultBrokerRecoverer implements ConfiguredObjectRecoverer<Broker>
+{
+    private static final Logger LOGGER = Logger.getLogger(BrokerRecoverer.class);
+
+    private final IApplicationRegistry _registry;
+    private final PortFactory _portFactory;
+    private final AuthenticationProviderFactory _authenticationProviderFactory;
+
+    public DefaultBrokerRecoverer(AuthenticationProviderFactory authenticationProviderFactory, PortFactory portFactory, IApplicationRegistry registry)
+    {
+        _registry = registry;
+        _portFactory = portFactory;
+        _authenticationProviderFactory = authenticationProviderFactory;
+    }
+
+    @Override
+    public Broker create(RecovererProvider recovererProvider, ConfigurationEntry entry, ConfiguredObject... parents)
+    {
+        BrokerAdapter broker = new BrokerAdapter(entry.getId(), _registry, _authenticationProviderFactory, _portFactory);
+        Map<ConfiguredObjectType, Collection<ConfigurationEntry>> childEntries = entry.getChildren();
+        for (ConfiguredObjectType type : childEntries.keySet())
+        {
+            ConfiguredObjectRecoverer<?> recoverer = recovererProvider.getRecoverer(type);
+            Collection<ConfigurationEntry> entries = childEntries.get(type);
+            for (ConfigurationEntry childEntry : entries)
+            {
+                ConfiguredObject object = recoverer.create(recovererProvider, childEntry, broker);
+                if (object == null)
+                {
+                    throw new IllegalConfigurationException("Cannot create configured object for the entry " + childEntry);
+                }
+                broker.recoverChild(object);
+            }
+        }
+        wireUpConfiguredObjects(broker, entry.getAttributesAsAttributeMap());
+
+        return broker;
+    }
+
+    // XXX unit test this
+    private void wireUpConfiguredObjects(BrokerAdapter broker, AttributeMap brokerAttributes)
+    {
+        AuthenticationProvider defaultAuthenticationProvider = null;
+        Collection<AuthenticationProvider> authenticationProviders = broker.getAuthenticationProviders();
+        int numberOfAuthenticationProviders = authenticationProviders.size();
+        if (numberOfAuthenticationProviders == 0)
+        {
+            LOGGER.error("No authentication providers configured");
+            return;
+            // XXX reinstate when wire-up has been separated from creation:
+            // throw new
+            // IllegalConfigurationException("No authentication providers configured");
+        }
+        else if (numberOfAuthenticationProviders == 1)
+        {
+            defaultAuthenticationProvider = authenticationProviders.iterator().next();
+        }
+        else
+        {
+            String name = brokerAttributes.getStringAttribute(Broker.DEFAULT_AUTHENTICATION_PROVIDER);
+            defaultAuthenticationProvider = getAuthenticationProviderByName(broker, name);
+        }
+        broker.setDefaultAuthenticationProvider(defaultAuthenticationProvider);
+
+        GroupPrincipalAccessor groupPrincipalAccessor = new GroupPrincipalAccessor(broker.getGroupProviders());
+        for (AuthenticationProvider authenticationProvider : authenticationProviders)
+        {
+            // XXX : review this cast
+            if (authenticationProvider instanceof AuthenticationProviderAdapter)
+            {
+                ((AuthenticationProviderAdapter<?>) authenticationProvider).setGroupAccessor(groupPrincipalAccessor);
+            }
+        }
+        Collection<Port> ports = broker.getPorts();
+        for (Port port : ports)
+        {
+            String authenticationProviderName = port.getAuthenticationManager();
+            AuthenticationProvider provider = null;
+            if (authenticationProviderName != null)
+            {
+                provider = getAuthenticationProviderByName(broker, authenticationProviderName);
+            }
+            else
+            {
+                provider = defaultAuthenticationProvider;
+            }
+            ((PortAdapter) port).setAuthenticationProvider(provider);
+        }
+    }
+
+    private AuthenticationProvider getAuthenticationProviderByName(BrokerAdapter broker, String authenticationProviderName)
+    {
+        AuthenticationProvider provider = broker.getAuthenticationProviderByName(authenticationProviderName);
+        if (provider == null)
+        {
+            throw new IllegalConfigurationException("Cannot find the authentication provider with name: "
+                    + authenticationProviderName);
+        }
+        return provider;
+    }
+
+}

Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProvider.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProvider.java?rev=1404902&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProvider.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProvider.java Fri Nov  2 09:47:15 2012
@@ -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.startup;
+
+import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer;
+import org.apache.qpid.server.configuration.RecovererProvider;
+import org.apache.qpid.server.model.ConfiguredObjectType;
+import org.apache.qpid.server.model.adapter.AuthenticationProviderFactory;
+import org.apache.qpid.server.model.adapter.PortFactory;
+import org.apache.qpid.server.registry.IApplicationRegistry;
+
+public class DefaultRecovererProvider implements RecovererProvider
+{
+
+    private final AuthenticationProviderFactory _authenticationProviderFactory;
+    private final PortFactory _portFactory;
+    private final IApplicationRegistry _registry;
+
+    public DefaultRecovererProvider(AuthenticationProviderFactory authenticationProviderFactory, PortFactory portFactory,
+            IApplicationRegistry registry)
+    {
+        super();
+        _authenticationProviderFactory = authenticationProviderFactory;
+        _portFactory = portFactory;
+        _registry = registry;
+    }
+
+
+
+    @Override
+    public ConfiguredObjectRecoverer<?> getRecoverer(ConfiguredObjectType type)
+    {
+        switch(type)
+        {
+        case BROKER:
+            return new DefaultBrokerRecoverer(_authenticationProviderFactory, _portFactory, _registry);
+        }
+        return null;
+    }
+
+}

Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PluginRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PluginRecoverer.java?rev=1404902&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PluginRecoverer.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PluginRecoverer.java Fri Nov  2 09:47:15 2012
@@ -0,0 +1,62 @@
+/*
+ *
+ * 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.IllegalConfigurationException;
+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
+{
+    private QpidServiceLoader<PluginFactory> _serviceLoader;
+
+    public PluginRecoverer(QpidServiceLoader<PluginFactory> serviceLoader)
+    {
+        _serviceLoader = serviceLoader;
+    }
+
+    public ConfiguredObject create(ConfigurationEntry configurationEntry, Broker broker)
+    {
+        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);
+    }
+}

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java Fri Nov  2 09:47:15 2012
@@ -49,6 +49,8 @@ import org.apache.qpid.server.model.Grou
 import org.apache.qpid.server.model.Port;
 import org.apache.qpid.server.model.Protocol;
 import org.apache.qpid.server.model.Transport;
+import org.apache.qpid.server.plugin.PluginFactory;
+import org.apache.qpid.server.plugin.QpidServiceLoader;
 import org.apache.qpid.server.security.group.FileGroupManagerFactory;
 
 public class XMLConfigurationEntryStore implements ConfigurationEntryStore
@@ -73,11 +75,19 @@ public class XMLConfigurationEntryStore 
 
         updateManagementPorts(_serverConfiguration, options);
 
-        getGroupProviders(_configuration, _rootChildren);
-        getAuthenticationProviders(_configuration, _rootChildren);
-        getAmqpPorts(_serverConfiguration, _rootChildren, options);
-        getManagementPorts(_serverConfiguration, _rootChildren, options);
-        getVirtualHosts(_serverConfiguration, _rootChildren);
+        createGroupProviderConfig(_configuration, _rootChildren);
+        createAuthenticationProviderConfig(_configuration, _rootChildren);
+        createAmqpPortConfig(_serverConfiguration, _rootChildren, options);
+        createManagementPortConfig(_serverConfiguration, _rootChildren, options);
+        createVirtualHostConfig(_serverConfiguration, _rootChildren);
+
+        // In order to avoid plugin recoverer failures for broker tests we are checking whether plugins classes are present in classpath
+        Iterable<PluginFactory> factories= new QpidServiceLoader().instancesOf(PluginFactory.class);
+        if (factories.iterator().hasNext())
+        {
+            createHttpManagementConfig(_serverConfiguration, _rootChildren);
+            createJmxManagementConfig(_serverConfiguration, _rootChildren);
+        }
         _logger.warn("Root children are: " + _rootChildren);
     }
 
@@ -95,7 +105,7 @@ public class XMLConfigurationEntryStore 
         return rootEntry;
     }
 
-    private void getAuthenticationProviders(Configuration configuration, Map<UUID, ConfigurationEntry> rootChildren)
+    private void createAuthenticationProviderConfig(Configuration configuration, Map<UUID, ConfigurationEntry> rootChildren)
     {
         HierarchicalConfiguration securityConfiguration = ConfigurationUtils.convertToHierarchical(
                 configuration.subset("security"));
@@ -140,7 +150,7 @@ public class XMLConfigurationEntryStore 
     }
 
     /** hard-coded values match those in {@link FileGroupManagerFactory} */
-    private void getGroupProviders(Configuration configuration, Map<UUID, ConfigurationEntry> rootChildren)
+    private void createGroupProviderConfig(Configuration configuration, Map<UUID, ConfigurationEntry> rootChildren)
     {
         Configuration fileGroupManagerConfig = configuration.subset("security.file-group-manager");
         if(fileGroupManagerConfig != null && !fileGroupManagerConfig.isEmpty())
@@ -154,7 +164,7 @@ public class XMLConfigurationEntryStore 
         }
     }
 
-    private void getAmqpPorts(ServerConfiguration serverConfig, Map<UUID, ConfigurationEntry> rootChildren,
+    private void createAmqpPortConfig(ServerConfiguration serverConfig, Map<UUID, ConfigurationEntry> rootChildren,
             BrokerOptions options)
     {
         Map<UUID, ConfigurationEntry> amqpPortConfiguration = _portConfigurationHelper.getPortConfiguration(serverConfig,
@@ -163,7 +173,7 @@ public class XMLConfigurationEntryStore 
 
     }
 
-    private void getManagementPorts(ServerConfiguration serverConfiguration, Map<UUID, ConfigurationEntry> rootChildren,
+    private void createManagementPortConfig(ServerConfiguration serverConfiguration, Map<UUID, ConfigurationEntry> rootChildren,
             BrokerOptions options)
     {
         if (serverConfiguration.getHTTPManagementEnabled())
@@ -250,7 +260,7 @@ public class XMLConfigurationEntryStore 
         return new ConfigurationEntry(UUID.randomUUID(), ConfiguredObjectType.PORT, attributes, null, this);
     }
 
-    private void getVirtualHosts(ServerConfiguration serverConfiguration, Map<UUID, ConfigurationEntry> rootChildren)
+    private void createVirtualHostConfig(ServerConfiguration serverConfiguration, Map<UUID, ConfigurationEntry> rootChildren)
     {
         for (String name : serverConfiguration.getVirtualHostsNames())
         {
@@ -304,6 +314,37 @@ public class XMLConfigurationEntryStore 
         return entry;
     }
 
+    private void createHttpManagementConfig(ServerConfiguration serverConfiguration, Map<UUID, ConfigurationEntry> rootChildren)
+    {
+        if(serverConfiguration.getHTTPManagementEnabled() || serverConfiguration.getHTTPSManagementEnabled())
+        {
+            Map<String, Object> attributes = new HashMap<String, Object>();
+            attributes.put(PluginFactory.PLUGIN_TYPE, "MANAGEMENT-HTTP");
+            attributes.put("keyStorePath", serverConfiguration.getManagementKeyStorePath());
+            attributes.put("keyStorePassword", serverConfiguration.getManagementKeyStorePassword());
+            attributes.put("sessionTimeout", serverConfiguration.getHTTPManagementSessionTimeout());
+
+            ConfigurationEntry entry = new ConfigurationEntry(UUID.randomUUID(), ConfiguredObjectType.PLUGIN, attributes, null, this);
+            rootChildren.put(entry.getId(), entry);
+        }
+    }
+
+    private void createJmxManagementConfig(ServerConfiguration serverConfiguration, Map<UUID, ConfigurationEntry> rootChildren)
+    {
+        if(serverConfiguration.getJMXManagementEnabled())
+        {
+            Map<String, Object> attributes = new HashMap<String, Object>();
+            attributes.put(PluginFactory.PLUGIN_TYPE, "MANAGEMENT-JMX");
+            attributes.put("keyStorePath", serverConfiguration.getManagementKeyStorePath());
+            attributes.put("keyStorePassword", serverConfiguration.getManagementKeyStorePassword());
+            attributes.put("useCustomRMISocketFactory", serverConfiguration.getUseCustomRMISocketFactory());
+            attributes.put("usePlatformMBeanServer", serverConfiguration.getPlatformMbeanserver());
+
+            ConfigurationEntry entry = new ConfigurationEntry(UUID.randomUUID(), ConfiguredObjectType.PLUGIN, attributes, null, this);
+            rootChildren.put(entry.getId(), entry);
+        }
+    }
+
     private String getBindAddress(ServerConfiguration serverConfig)
     {
         String bindAddr = serverConfig.getBind();

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java Fri Nov  2 09:47:15 2012
@@ -80,4 +80,5 @@ public interface Broker extends Configur
     AuthenticationProvider getDefaultAuthenticationProvider();
 
     Collection<GroupProvider> getGroupProviders();
+
 }

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java Fri Nov  2 09:47:15 2012
@@ -234,7 +234,7 @@ public interface ConfiguredObject
     /**
      * Return children of the ConfiguredObject of the given class
      *
-     * @param clazz the class of the children to return
+     * @param clazz the class of the children to return.
      * @return the children
      *
      * @throws NullPointerException if the supplied class null

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObjectType.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObjectType.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObjectType.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObjectType.java Fri Nov  2 09:47:15 2012
@@ -20,6 +20,16 @@
  */
 package org.apache.qpid.server.model;
 
+/**
+ * This enum declares the types of all possible configured objects.
+ * At the moment, we have got fixed number of types.
+ * <p>
+ * In future, we might need to convert this enum into abstract class and
+ * implement the subclasses for each type of configured object, which in turn
+ * will register themselves in the static map.
+ * <p>
+ * That would allow us to implement plugins more effectively instead of relying on {@link ConfiguredObjectType#PLUGIN}.
+ */
 public enum ConfiguredObjectType
 {
     BROKER(Broker.class),
@@ -39,7 +49,8 @@ public enum ConfiguredObjectType
     PUBLISHER(Publisher.class),
     QUEUE(Queue.class),
     CONNECTION(Connection.class),
-    GROUP_PROVIDER(GroupProvider.class);
+    GROUP_PROVIDER(GroupProvider.class),
+    PLUGIN(ConfiguredObject.class);
 
     private final Class<? extends ConfiguredObject> _type;
 

Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java?rev=1404902&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java Fri Nov  2 09:47:15 2012
@@ -0,0 +1,108 @@
+/*
+ *
+ * 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.model.adapter;
+
+import java.security.AccessControlException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.LifetimePolicy;
+import org.apache.qpid.server.model.State;
+import org.apache.qpid.server.model.Statistics;
+
+public abstract class AbstractPluginAdapter extends AbstractAdapter
+{
+
+    protected AbstractPluginAdapter(UUID id)
+    {
+        super(id);
+    }
+
+    @Override
+    public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public State getActualState()
+    {
+        return null;
+    }
+
+    @Override
+    public boolean isDurable()
+    {
+        return true;
+    }
+
+    @Override
+    public void setDurable(boolean durable) throws IllegalStateException, AccessControlException, IllegalArgumentException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public LifetimePolicy getLifetimePolicy()
+    {
+        return LifetimePolicy.PERMANENT;
+    }
+
+    @Override
+    public LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) throws IllegalStateException, AccessControlException, IllegalArgumentException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public long getTimeToLive()
+    {
+        return 0;
+    }
+
+    @Override
+    public long setTimeToLive(long expected, long desired) throws IllegalStateException, AccessControlException, IllegalArgumentException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Statistics getStatistics()
+    {
+        return null;
+    }
+
+    @Override
+    public <C extends ConfiguredObject> Collection<C> getChildren(Class<C> clazz)
+    {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public <C extends ConfiguredObject> C createChild(Class<C> childClass, Map<String, Object> attributes, ConfiguredObject... otherParents)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+}

Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java?rev=1404902&r1=1404901&r2=1404902&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java Fri Nov  2 09:47:15 2012
@@ -61,12 +61,14 @@ public class BrokerAdapter extends Abstr
     private final Map<Integer, Port> _portAdapters = new HashMap<Integer, Port>();
     private final Map<String, AuthenticationProvider> _authenticationProviders = new HashMap<String, AuthenticationProvider>();
     private final Map<String, GroupProvider> _groupProviders = new HashMap<String, GroupProvider>();
+    private final Map<UUID, ConfiguredObject> _plugins = new HashMap<UUID, ConfiguredObject>();
 
     private final AuthenticationProviderFactory _authenticationProviderFactory;
     private AuthenticationProvider _defaultAuthenticationProvider;
 
     private final PortFactory _portFactory;
 
+
     public BrokerAdapter(UUID id, IApplicationRegistry instance, AuthenticationProviderFactory authenticationProviderFactory, PortFactory portFactory)
     {
         super(id);
@@ -255,6 +257,10 @@ public class BrokerAdapter extends Abstr
         {
             return (Collection<C>) getGroupProviders();
         }
+        else if(clazz == ConfiguredObject.class)
+        {
+            return (Collection<C>) getPlugins();
+        }
 
         return Collections.emptySet();
     }
@@ -489,10 +495,12 @@ public class BrokerAdapter extends Abstr
             }
 
             changeState(_portAdapters, currentState,State.ACTIVE, false);
+            changeState(_plugins, currentState,State.ACTIVE, false);
             return true;
         }
         else if (desiredState == State.STOPPED)
         {
+            changeState(_plugins, currentState,State.STOPPED, true);
             changeState(_portAdapters, currentState, State.STOPPED, true);
             changeState(_vhostAdapters,currentState, State.STOPPED, true);
             changeState(_authenticationProviders, currentState, State.STOPPED, true);
@@ -569,4 +577,49 @@ public class BrokerAdapter extends Abstr
         // no-op
     }
 
+    public void addPlugin(ConfiguredObject plugin)
+    {
+        synchronized(_plugins)
+        {
+            if (_plugins.containsKey(plugin.getId()))
+            {
+                throw new IllegalConfigurationException("Plugin with id '" + plugin.getId() + "' is already registered!");
+            }
+            _plugins.put(plugin.getId(), plugin);
+        }
+        plugin.addChangeListener(this);
+    }
+
+
+    private Collection<ConfiguredObject> getPlugins()
+    {
+        synchronized(_plugins)
+        {
+            return Collections.unmodifiableCollection(_plugins.values());
+        }
+    }
+
+    public void recoverChild(ConfiguredObject object)
+    {
+        if(object instanceof AuthenticationProvider)
+        {
+            addAuthenticationProvider((AuthenticationProvider)object);
+        }
+        else if(object instanceof Port)
+        {
+            addPort((Port)object);
+        }
+        else if(object instanceof VirtualHost)
+        {
+            addVirtualHost((VirtualHost)object);
+        }
+        else if(object instanceof GroupProvider)
+        {
+            addGroupProvider((GroupProvider)object);
+        }
+        else
+        {
+            addPlugin(object);
+        }
+    }
 }



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


Mime
View raw message