qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1584931 [3/7] - in /qpid/trunk/qpid/java: ./ bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/ bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ bdbstore/src/main/java/org/apache/qpid/server/store/be...
Date Fri, 04 Apr 2014 22:34:30 GMT
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java Fri Apr  4 22:34:26 2014
@@ -20,47 +20,49 @@
  */
 package org.apache.qpid.server.model.adapter;
 
-import java.lang.reflect.Type;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.security.AccessControlException;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
 import org.apache.log4j.Logger;
 import org.apache.qpid.common.QpidProperties;
 import org.apache.qpid.server.BrokerOptions;
-import org.apache.qpid.server.configuration.BrokerConfigurationStoreCreator;
-import org.apache.qpid.server.configuration.ConfigurationEntryStore;
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.logging.EventLogger;
 import org.apache.qpid.server.logging.LogRecorder;
 import org.apache.qpid.server.logging.messages.BrokerMessages;
+import org.apache.qpid.server.logging.messages.VirtualHostMessages;
 import org.apache.qpid.server.model.*;
+import org.apache.qpid.server.model.port.AmqpPort;
+import org.apache.qpid.server.model.port.PortWithAuthProvider;
+import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory;
 import org.apache.qpid.server.plugin.MessageStoreFactory;
-import org.apache.qpid.server.plugin.PreferencesProviderFactory;
 import org.apache.qpid.server.plugin.VirtualHostFactory;
+import org.apache.qpid.server.security.FileKeyStore;
+import org.apache.qpid.server.security.FileTrustStore;
 import org.apache.qpid.server.security.SecurityManager;
 import org.apache.qpid.server.security.SubjectCreator;
 import org.apache.qpid.server.security.access.Operation;
 import org.apache.qpid.server.security.auth.manager.SimpleAuthenticationManager;
+import org.apache.qpid.server.stats.StatisticsCounter;
 import org.apache.qpid.server.stats.StatisticsGatherer;
 import org.apache.qpid.server.util.MapValueConverter;
 import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
 import org.apache.qpid.util.SystemUtils;
 
 import javax.security.auth.Subject;
+import java.lang.reflect.Type;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.security.AccessControlException;
+import java.security.PrivilegedAction;
+import java.util.*;
+import java.util.regex.Pattern;
 
-public class BrokerAdapter<X extends Broker<X>> extends AbstractConfiguredObject<X> implements Broker<X>, ConfigurationChangeListener
+@ManagedObject(category = false, type = "adapter")
+public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> implements Broker<BrokerAdapter>, ConfigurationChangeListener, StatisticsGatherer, StatisticsGatherer.Source
 {
     private static final Logger LOGGER = Logger.getLogger(BrokerAdapter.class);
 
+    private static final Pattern MODEL_VERSION_PATTERN = Pattern.compile("^\\d+\\.\\d+$");
+
     @SuppressWarnings("serial")
     public static final Map<String, Type> ATTRIBUTE_TYPES = Collections.unmodifiableMap(new HashMap<String, Type>(){{
         put(QUEUE_ALERT_THRESHOLD_MESSAGE_AGE, Long.class);
@@ -136,6 +138,7 @@ public class BrokerAdapter<X extends Bro
         put(Broker.VIRTUALHOST_STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE, DEFAULT_STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE);
         put(Broker.VIRTUALHOST_STORE_TRANSACTION_OPEN_TIMEOUT_WARN, DEFAULT_STORE_TRANSACTION_OPEN_TIMEOUT_WARN);
     }});
+    private final ConfiguredObjectFactory _objectFactory;
 
     private String[] POSITIVE_NUMERIC_ATTRIBUTES = { QUEUE_ALERT_THRESHOLD_MESSAGE_AGE, QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES,
             QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_BYTES, QUEUE_ALERT_THRESHOLD_MESSAGE_SIZE, QUEUE_ALERT_REPEAT_GAP, QUEUE_FLOW_CONTROL_SIZE_BYTES,
@@ -146,7 +149,6 @@ public class BrokerAdapter<X extends Bro
 
 
     private EventLogger _eventLogger;
-    private final StatisticsGatherer _statisticsGatherer;
     private final VirtualHostRegistry _virtualHostRegistry;
     private final LogRecorder _logRecorder;
 
@@ -160,46 +162,33 @@ public class BrokerAdapter<X extends Bro
     private final Map<String, TrustStore<?>> _trustStores = new HashMap<String, TrustStore<?>>();
     private final Map<UUID, AccessControlProvider<?>> _accessControlProviders = new HashMap<UUID, AccessControlProvider<?>>();
 
-    private final GroupProviderFactory _groupProviderFactory;
-    private final AuthenticationProviderFactory _authenticationProviderFactory;
-    private final AccessControlProviderFactory _accessControlProviderFactory;
-    private final PortFactory _portFactory;
     private final SecurityManager _securityManager;
 
     private final Collection<String> _supportedVirtualHostStoreTypes;
-    private Collection<String> _supportedBrokerStoreTypes;
-    private final ConfigurationEntryStore _brokerStore;
 
     private AuthenticationProvider<?> _managementAuthenticationProvider;
     private BrokerOptions _brokerOptions;
 
+    private Timer _reportingTimer;
+    private StatisticsCounter _messagesDelivered, _dataDelivered, _messagesReceived, _dataReceived;
+
+
     public BrokerAdapter(UUID id,
                          Map<String, Object> attributes,
-                         StatisticsGatherer statisticsGatherer,
-                         VirtualHostRegistry virtualHostRegistry,
-                         LogRecorder logRecorder,
-                         AuthenticationProviderFactory authenticationProviderFactory,
-                         GroupProviderFactory groupProviderFactory,
-                         AccessControlProviderFactory accessControlProviderFactory,
-                         PortFactory portFactory,
-                         TaskExecutor taskExecutor,
-                         ConfigurationEntryStore brokerStore,
-                         BrokerOptions brokerOptions)
-    {
-        super(id, DEFAULTS,  MapValueConverter.convert(attributes, ATTRIBUTE_TYPES), taskExecutor);
-        _statisticsGatherer = statisticsGatherer;
-        _virtualHostRegistry = virtualHostRegistry;
-        _logRecorder = logRecorder;
-        _eventLogger = virtualHostRegistry.getEventLogger();
-        _authenticationProviderFactory = authenticationProviderFactory;
-        _groupProviderFactory = groupProviderFactory;
-        _accessControlProviderFactory = accessControlProviderFactory;
-        _portFactory = portFactory;
-        _brokerOptions = brokerOptions;
+                         SystemContext parent)
+    {
+        super(Collections.<Class<? extends ConfiguredObject>, ConfiguredObject<?>>singletonMap(SystemContext.class, parent), DEFAULTS, combineIdWithAttributes(id,MapValueConverter.convert(attributes, ATTRIBUTE_TYPES)), parent.getTaskExecutor());
+        validateModelVersion();
+
+        _objectFactory = parent.getObjectFactory();
+        _virtualHostRegistry = new VirtualHostRegistry(parent.getEventLogger());
+        _virtualHostRegistry.setDefaultVirtualHostName((String)getAttribute(Broker.DEFAULT_VIRTUAL_HOST));
+
+        _logRecorder = parent.getLogRecorder();
+        _eventLogger = parent.getEventLogger();
+        _brokerOptions = parent.getBrokerOptions();
         _securityManager = new SecurityManager(this, _brokerOptions.isManagementMode());
         _supportedVirtualHostStoreTypes = MessageStoreFactory.FACTORY_LOADER.getSupportedTypes();
-        _supportedBrokerStoreTypes = new BrokerConfigurationStoreCreator().getStoreTypes();
-        _brokerStore = brokerStore;
         if (_brokerOptions.isManagementMode())
         {
             Map<String,Object> authManagerAttrs = new HashMap<String, Object>();
@@ -209,8 +198,52 @@ public class BrokerAdapter<X extends Bro
             authManager.addUser(BrokerOptions.MANAGEMENT_MODE_USER_NAME, _brokerOptions.getManagementModePassword());
             _managementAuthenticationProvider = authManager;
         }
+        initialiseStatistics();
+    }
+
+    private void validateModelVersion()
+    {
+        String modelVersion = (String) getActualAttributes().get(Broker.MODEL_VERSION);
+        if (modelVersion == null)
+        {
+            throw new IllegalConfigurationException("Broker " + Broker.MODEL_VERSION + " must be specified");
+        }
+
+        if (!MODEL_VERSION_PATTERN.matcher(modelVersion).matches())
+        {
+            throw new IllegalConfigurationException("Broker " + Broker.MODEL_VERSION + " is specified in incorrect format: "
+                                                    + modelVersion);
+        }
+
+        int versionSeparatorPosition = modelVersion.indexOf(".");
+        String majorVersionPart = modelVersion.substring(0, versionSeparatorPosition);
+        int majorModelVersion = Integer.parseInt(majorVersionPart);
+        int minorModelVersion = Integer.parseInt(modelVersion.substring(versionSeparatorPosition + 1));
+
+        if (majorModelVersion != Model.MODEL_MAJOR_VERSION || minorModelVersion > Model.MODEL_MINOR_VERSION)
+        {
+            throw new IllegalConfigurationException("The model version '" + modelVersion
+                                                    + "' in configuration is incompatible with the broker model version '" + Model.MODEL_VERSION + "'");
+        }
+
+    }
+
+    private void initialiseStatisticsReporting()
+    {
+        long report = ((Number)getAttribute(Broker.STATISTICS_REPORTING_PERIOD)).intValue() * 1000; // convert to ms
+        final boolean reset = (Boolean)getAttribute(Broker.STATISTICS_REPORTING_RESET_ENABLED);
+
+        /* add a timer task to report statistics if generation is enabled for broker or virtualhosts */
+        if (report > 0L)
+        {
+            _reportingTimer = new Timer("Statistics-Reporting", true);
+            StatisticsReportingTask task = new StatisticsReportingTask(reset, _eventLogger);
+            _reportingTimer.scheduleAtFixedRate(task, report / 2, report);
+        }
     }
 
+
+
     @Override
     public String getBuildVersion()
     {
@@ -242,12 +275,6 @@ public class BrokerAdapter<X extends Bro
     }
 
     @Override
-    public Collection<String> getSupportedBrokerStoreTypes()
-    {
-        return _supportedBrokerStoreTypes;
-    }
-
-    @Override
     public Collection<String> getSupportedVirtualHostStoreTypes()
     {
         return _supportedVirtualHostStoreTypes;
@@ -256,13 +283,13 @@ public class BrokerAdapter<X extends Bro
     @Override
     public Collection<String> getSupportedAuthenticationProviders()
     {
-        return _authenticationProviderFactory.getSupportedAuthenticationProviders();
+        return _objectFactory.getSupportedTypes(AuthenticationProvider.class);
     }
 
     @Override
     public Collection<String> getSupportedPreferencesProviderTypes()
     {
-        return PreferencesProviderFactory.FACTORY_LOADER.getSupportedTypes();
+        return _objectFactory.getSupportedTypes(PreferencesProvider.class);
     }
 
     @Override
@@ -362,24 +389,6 @@ public class BrokerAdapter<X extends Bro
     }
 
     @Override
-    public String getStoreType()
-    {
-        return _brokerStore.getType();
-    }
-
-    @Override
-    public int getStoreVersion()
-    {
-        return _brokerStore.getVersion();
-    }
-
-    @Override
-    public String getStorePath()
-    {
-        return _brokerStore.getStoreLocation();
-    }
-
-    @Override
     public String getModelVersion()
     {
         return Model.MODEL_VERSION;
@@ -478,9 +487,9 @@ public class BrokerAdapter<X extends Bro
     private VirtualHost createVirtualHost(final Map<String, Object> attributes)
             throws AccessControlException, IllegalArgumentException
     {
-        final VirtualHostAdapter virtualHostAdapter = new VirtualHostAdapter(UUID.randomUUID(), attributes, this,
-                _statisticsGatherer, getTaskExecutor());
-        addVirtualHost(virtualHostAdapter);
+        ConfiguredObjectTypeFactory virtualHostFactory =
+                _objectFactory.getConfiguredObjectTypeFactory(VirtualHost.class, attributes);
+        final VirtualHostAdapter virtualHostAdapter = (VirtualHostAdapter) virtualHostFactory.create(attributes,this);
 
         // permission has already been granted to create the virtual host
         // disable further access check on other operations, e.g. create exchange
@@ -556,25 +565,25 @@ public class BrokerAdapter<X extends Bro
     @Override
     public long getBytesIn()
     {
-        return _statisticsGatherer.getDataReceiptStatistics().getTotal();
+        return getDataReceiptStatistics().getTotal();
     }
 
     @Override
     public long getBytesOut()
     {
-        return _statisticsGatherer.getDataDeliveryStatistics().getTotal();
+        return getDataDeliveryStatistics().getTotal();
     }
 
     @Override
     public long getMessagesIn()
     {
-        return _statisticsGatherer.getMessageReceiptStatistics().getTotal();
+        return getMessageReceiptStatistics().getTotal();
     }
 
     @Override
     public long getMessagesOut()
     {
-        return _statisticsGatherer.getMessageDeliveryStatistics().getTotal();
+        return getMessageDeliveryStatistics().getTotal();
     }
     @SuppressWarnings("unchecked")
     @Override
@@ -657,17 +666,16 @@ public class BrokerAdapter<X extends Bro
     /**
      * Called when adding a new port via the management interface
      */
-    private Port createPort(Map<String, Object> attributes)
+    private Port<?> createPort(Map<String, Object> attributes)
     {
-        Port<?> port = _portFactory.createPort(UUID.randomUUID(), this, attributes);
-        addPort(port);
+        Port<?> port = createChild(Port.class, attributes);
 
         //1. AMQP ports are disabled during ManagementMode.
         //2. The management plugins can currently only start ports at broker startup and
         //   not when they are newly created via the management interfaces.
         //3. When active ports are deleted, or their port numbers updated, the broker must be
         //   restarted for it to take effect so we can't reuse port numbers until it is.
-        boolean quiesce = isManagementMode() || !(port instanceof AmqpPortAdapter) || isPreviouslyUsedPortNumber(port);
+        boolean quiesce = isManagementMode() || !(port instanceof AmqpPort) || isPreviouslyUsedPortNumber(port);
 
         port.setDesiredState(State.INITIALISING, quiesce ? State.QUIESCED : State.ACTIVE);
 
@@ -710,8 +718,7 @@ public class BrokerAdapter<X extends Bro
         AccessControlProvider<?> accessControlProvider;
         synchronized (_accessControlProviders)
         {
-            accessControlProvider = _accessControlProviderFactory.create(UUID.randomUUID(), this, attributes);
-            addAccessControlProvider(accessControlProvider);
+            accessControlProvider = (AccessControlProvider<?>) createChild(AccessControlProvider.class, attributes);
         }
 
         boolean quiesce = isManagementMode() ;
@@ -765,12 +772,25 @@ public class BrokerAdapter<X extends Bro
 
     private AuthenticationProvider createAuthenticationProvider(Map<String, Object> attributes)
     {
-        AuthenticationProvider<?> authenticationProvider = _authenticationProviderFactory.create(UUID.randomUUID(), this, attributes);
+        AuthenticationProvider<?> authenticationProvider = createChild(AuthenticationProvider.class, attributes);
         authenticationProvider.setDesiredState(State.INITIALISING, State.ACTIVE);
-        addAuthenticationProvider(authenticationProvider);
         return authenticationProvider;
     }
 
+    private <X extends ConfiguredObject> X createChild(Class<X> clazz, Map<String, Object> attributes)
+    {
+        ConfiguredObjectTypeFactory factory =
+                _objectFactory.getConfiguredObjectTypeFactory(clazz, attributes);
+        if(!attributes.containsKey(ConfiguredObject.ID))
+        {
+            attributes = new HashMap<String, Object>(attributes);
+            attributes.put(ConfiguredObject.ID, UUID.randomUUID());
+        }
+        final X instance = (X) factory.create(attributes, this);
+
+        return instance;
+    }
+
     /**
      * @throws IllegalConfigurationException if an AuthenticationProvider with the same name already exists
      */
@@ -797,9 +817,8 @@ public class BrokerAdapter<X extends Bro
 
     private GroupProvider<?> createGroupProvider(Map<String, Object> attributes)
     {
-        GroupProvider<?> groupProvider = _groupProviderFactory.create(UUID.randomUUID(), this, attributes);
+        GroupProvider<?> groupProvider = createChild(GroupProvider.class, attributes);
         groupProvider.setDesiredState(State.INITIALISING, State.ACTIVE);
-        addGroupProvider(groupProvider);
         return groupProvider;
     }
 
@@ -835,17 +854,13 @@ public class BrokerAdapter<X extends Bro
 
     private KeyStore createKeyStore(Map<String, Object> attributes)
     {
-        KeyStore keyStore = new KeyStoreAdapter(UUIDGenerator.generateRandomUUID(), this, attributes);
-        addKeyStore(keyStore);
-
+        KeyStore keyStore = new FileKeyStore(UUIDGenerator.generateRandomUUID(), this, attributes);
         return keyStore;
     }
 
     private TrustStore createTrustStore(Map<String, Object> attributes)
     {
-        TrustStore trustStore = new TrustStoreAdapter(UUIDGenerator.generateRandomUUID(), this, attributes);
-        addTrustStore(trustStore);
-
+        TrustStore trustStore = new FileTrustStore(UUIDGenerator.generateRandomUUID(), this, attributes);
         return trustStore;
     }
 
@@ -951,10 +966,6 @@ public class BrokerAdapter<X extends Bro
         {
             return QpidProperties.getReleaseVersion();
         }
-        else if(SUPPORTED_BROKER_STORE_TYPES.equals(name))
-        {
-            return _supportedBrokerStoreTypes;
-        }
         else if(SUPPORTED_VIRTUALHOST_STORE_TYPES.equals(name))
         {
             return _supportedVirtualHostStoreTypes;
@@ -965,28 +976,16 @@ public class BrokerAdapter<X extends Bro
         }
         else if(SUPPORTED_AUTHENTICATION_PROVIDERS.equals(name))
         {
-            return _authenticationProviderFactory.getSupportedAuthenticationProviders();
+            return getSupportedAuthenticationProviders();
         }
         else if (SUPPORTED_PREFERENCES_PROVIDER_TYPES.equals(name))
         {
-            return PreferencesProviderFactory.FACTORY_LOADER.getSupportedTypes();
+            return getSupportedPreferencesProviderTypes();
         }
         else if (MODEL_VERSION.equals(name))
         {
             return Model.MODEL_VERSION;
         }
-        else if (STORE_VERSION.equals(name))
-        {
-            return _brokerStore.getVersion();
-        }
-        else if (STORE_TYPE.equals(name))
-        {
-            return _brokerStore.getType();
-        }
-        else if (STORE_PATH.equals(name))
-        {
-            return _brokerStore.getStoreLocation();
-        }
         return super.getAttribute(name);
     }
 
@@ -1048,6 +1047,7 @@ public class BrokerAdapter<X extends Bro
     {
         if (desiredState == State.ACTIVE)
         {
+            initialiseStatisticsReporting();
             changeState(_groupProviders, currentState, State.ACTIVE, false);
             changeState(_authenticationProviders, currentState, State.ACTIVE, false);
             changeState(_accessControlProviders, currentState, State.ACTIVE, false);
@@ -1067,11 +1067,18 @@ public class BrokerAdapter<X extends Bro
         }
         else if (desiredState == State.STOPPED)
         {
+            //Stop Statistics Reporting
+            if (_reportingTimer != null)
+            {
+                _reportingTimer.cancel();
+            }
+
             changeState(_plugins, currentState,State.STOPPED, true);
             changeState(_portAdapters, currentState, State.STOPPED, true);
             changeState(_vhostAdapters,currentState, State.STOPPED, true);
             changeState(_authenticationProviders, currentState, State.STOPPED, true);
             changeState(_groupProviders, currentState, State.STOPPED, true);
+            _virtualHostRegistry.close();
             return true;
         }
         return false;
@@ -1201,46 +1208,46 @@ public class BrokerAdapter<X extends Bro
         }
     }
 
-    public void recoverChild(ConfiguredObject object)
+    public void instantiateAuthenticationProvider(AuthenticationProvider object)
     {
-        if(object instanceof AuthenticationProvider)
-        {
-            addAuthenticationProvider((AuthenticationProvider)object);
-        }
-        else if(object instanceof AccessControlProvider)
-        {
-            addAccessControlProvider((AccessControlProvider)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 if(object instanceof KeyStore)
-        {
-            addKeyStore((KeyStore)object);
-        }
-        else if(object instanceof TrustStore)
-        {
-            addTrustStore((TrustStore)object);
-        }
-        else if(object instanceof Plugin)
-        {
-            addPlugin(object);
-        }
-        else
-        {
-            throw new IllegalArgumentException("Attempted to recover unexpected type of configured object: " + object.getClass().getName());
-        }
+        addAuthenticationProvider(object);
+    }
+
+    public void instantiateAccessControlProvider(AccessControlProvider object)
+    {
+        addAccessControlProvider(object);
+    }
+
+    public void instantiatePort(Port object)
+    {
+        addPort(object);
+    }
+
+    public void instantiateVirtualHost(VirtualHost object)
+    {
+        addVirtualHost(object);
+    }
+
+    public void instantiateGroupProvider(GroupProvider object)
+    {
+        addGroupProvider(object);
     }
 
+    public void instantiateKeyStore(KeyStore object)
+    {
+        addKeyStore(object);
+    }
+
+    public void instantiateTrustStore(TrustStore object)
+    {
+        addTrustStore(object);
+    }
+
+    public void instantiatePlugin(Plugin object)
+    {
+        addPlugin(object);
+    }
+   
     @Override
     public SecurityManager getSecurityManager()
     {
@@ -1280,9 +1287,9 @@ public class BrokerAdapter<X extends Bro
         Collection<Port<?>> ports = getPorts();
         for (Port<?> p : ports)
         {
-            if (inetSocketAddress.getPort() == p.getPort())
+            if (p instanceof PortWithAuthProvider && inetSocketAddress.getPort() == p.getPort())
             {
-                provider = p.getAuthenticationProvider();
+                provider = ((PortWithAuthProvider<?>) p).getAuthenticationProvider();
                 break;
             }
         }
@@ -1335,12 +1342,6 @@ public class BrokerAdapter<X extends Bro
             throw new IllegalConfigurationException("Cannot change the model version");
         }
 
-        if (convertedAttributes.containsKey(STORE_VERSION)
-                && !new Integer(_brokerStore.getVersion()).equals(convertedAttributes.get(STORE_VERSION)))
-        {
-            throw new IllegalConfigurationException("Cannot change the store version");
-        }
-
         String defaultVirtualHost = (String) convertedAttributes.get(DEFAULT_VIRTUAL_HOST);
         if (defaultVirtualHost != null)
         {
@@ -1447,4 +1448,138 @@ public class BrokerAdapter<X extends Bro
     {
         _eventLogger = eventLogger;
     }
+
+    @Override
+    public StatisticsGatherer getStatisticsGatherer()
+    {
+        return this;
+    }
+
+    public void registerMessageDelivered(long messageSize)
+    {
+        _messagesDelivered.registerEvent(1L);
+        _dataDelivered.registerEvent(messageSize);
+    }
+
+    public void registerMessageReceived(long messageSize, long timestamp)
+    {
+        _messagesReceived.registerEvent(1L, timestamp);
+        _dataReceived.registerEvent(messageSize, timestamp);
+    }
+
+    public StatisticsCounter getMessageReceiptStatistics()
+    {
+        return _messagesReceived;
+    }
+
+    public StatisticsCounter getDataReceiptStatistics()
+    {
+        return _dataReceived;
+    }
+
+    public StatisticsCounter getMessageDeliveryStatistics()
+    {
+        return _messagesDelivered;
+    }
+
+    public StatisticsCounter getDataDeliveryStatistics()
+    {
+        return _dataDelivered;
+    }
+
+    public void resetStatistics()
+    {
+        _messagesDelivered.reset();
+        _dataDelivered.reset();
+        _messagesReceived.reset();
+        _dataReceived.reset();
+
+        for (org.apache.qpid.server.virtualhost.VirtualHost vhost : _virtualHostRegistry.getVirtualHosts())
+        {
+            vhost.resetStatistics();
+        }
+    }
+
+    public void initialiseStatistics()
+    {
+        _messagesDelivered = new StatisticsCounter("messages-delivered");
+        _dataDelivered = new StatisticsCounter("bytes-delivered");
+        _messagesReceived = new StatisticsCounter("messages-received");
+        _dataReceived = new StatisticsCounter("bytes-received");
+    }
+
+    private class StatisticsReportingTask extends TimerTask
+    {
+        private final int DELIVERED = 0;
+        private final int RECEIVED = 1;
+
+        private final boolean _reset;
+        private final EventLogger _logger;
+        private final Subject _subject;
+
+        public StatisticsReportingTask(boolean reset, EventLogger logger)
+        {
+            _reset = reset;
+            _logger = logger;
+            _subject = SecurityManager.getSystemTaskSubject("Statistics");
+        }
+
+        public void run()
+        {
+            Subject.doAs(_subject, new PrivilegedAction<Object>()
+            {
+                @Override
+                public Object run()
+                {
+                    reportStatistics();
+                    return null;
+                }
+            });
+        }
+
+        protected void reportStatistics()
+        {
+            try
+            {
+                _eventLogger.message(BrokerMessages.STATS_DATA(DELIVERED, _dataDelivered.getPeak() / 1024.0, _dataDelivered.getTotal()));
+                _eventLogger.message(BrokerMessages.STATS_MSGS(DELIVERED, _messagesDelivered.getPeak(), _messagesDelivered.getTotal()));
+                _eventLogger.message(BrokerMessages.STATS_DATA(RECEIVED, _dataReceived.getPeak() / 1024.0, _dataReceived.getTotal()));
+                _eventLogger.message(BrokerMessages.STATS_MSGS(RECEIVED,
+                                                               _messagesReceived.getPeak(),
+                                                               _messagesReceived.getTotal()));
+                Collection<org.apache.qpid.server.virtualhost.VirtualHost> hosts = _virtualHostRegistry.getVirtualHosts();
+
+                if (hosts.size() > 1)
+                {
+                    for (org.apache.qpid.server.virtualhost.VirtualHost vhost : hosts)
+                    {
+                        String name = vhost.getName();
+                        StatisticsCounter dataDelivered = vhost.getDataDeliveryStatistics();
+                        StatisticsCounter messagesDelivered = vhost.getMessageDeliveryStatistics();
+                        StatisticsCounter dataReceived = vhost.getDataReceiptStatistics();
+                        StatisticsCounter messagesReceived = vhost.getMessageReceiptStatistics();
+                        EventLogger logger = vhost.getEventLogger();
+                        logger.message(VirtualHostMessages.STATS_DATA(name,
+                                                                      DELIVERED,
+                                                                      dataDelivered.getPeak() / 1024.0,
+                                                                      dataDelivered.getTotal()));
+                        logger.message(VirtualHostMessages.STATS_MSGS(name, DELIVERED, messagesDelivered.getPeak(), messagesDelivered.getTotal()));
+                        logger.message(VirtualHostMessages.STATS_DATA(name, RECEIVED, dataReceived.getPeak() / 1024.0, dataReceived.getTotal()));
+                        logger.message(VirtualHostMessages.STATS_MSGS(name, RECEIVED, messagesReceived.getPeak(), messagesReceived.getTotal()));
+                    }
+                }
+
+                if (_reset)
+                {
+                    resetStatistics();
+                }
+            }
+            catch(Exception e)
+            {
+                LOGGER.warn("Unexpected exception occurred while reporting the statistics", e);
+            }
+        }
+    }
+
+
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java Fri Apr  4 22:34:26 2014
@@ -30,7 +30,6 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.protocol.AMQConnectionModel;
 import org.apache.qpid.server.protocol.AMQSessionModel;
 import org.apache.qpid.server.protocol.SessionModelListener;
-import org.apache.qpid.server.stats.StatisticsGatherer;
 
 final class ConnectionAdapter extends AbstractConfiguredObject<ConnectionAdapter> implements Connection<ConnectionAdapter>,
                                                                                              SessionModelListener

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java Fri Apr  4 22:34:26 2014
@@ -21,6 +21,16 @@
 
 package org.apache.qpid.server.model.adapter;
 
+import org.apache.log4j.Logger;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.model.*;
+import org.apache.qpid.server.util.MapValueConverter;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.type.TypeReference;
+
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
@@ -31,27 +41,10 @@ import java.nio.channels.FileChannel;
 import java.nio.channels.FileLock;
 import java.nio.channels.OverlappingFileLockException;
 import java.security.AccessControlException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.UUID;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
 
-import org.apache.log4j.Logger;
-import org.apache.qpid.server.configuration.IllegalConfigurationException;
-import org.apache.qpid.server.configuration.updater.TaskExecutor;
-import org.apache.qpid.server.model.*;
-import org.apache.qpid.server.util.MapValueConverter;
-import org.codehaus.jackson.JsonParser;
-import org.codehaus.jackson.JsonProcessingException;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.SerializationConfig;
-import org.codehaus.jackson.type.TypeReference;
-
+@ManagedObject( category = false, type = "FileSystemPreferences" )
 public class FileSystemPreferencesProvider extends AbstractConfiguredObject<FileSystemPreferencesProvider> implements PreferencesProvider<FileSystemPreferencesProvider>
 {
     private static final Logger LOGGER = Logger.getLogger(FileSystemPreferencesProvider.class);
@@ -77,16 +70,18 @@ public class FileSystemPreferencesProvid
 
     private FileSystemPreferencesStore _store;
 
-    protected FileSystemPreferencesProvider(UUID id, Map<String, Object> attributes,
-                                            AuthenticationProvider<? extends AuthenticationProvider> authenticationProvider,
-                                            TaskExecutor taskExecutor)
+    public FileSystemPreferencesProvider(UUID id, Map<String, Object> attributes,
+                                            AuthenticationProvider<? extends AuthenticationProvider> authenticationProvider)
     {
-        super(id, DEFAULTS, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES), taskExecutor);
+        super(Collections.<Class<? extends ConfiguredObject>, ConfiguredObject<?>>singletonMap(AuthenticationProvider.class, authenticationProvider),
+              DEFAULTS,
+              combineIdWithAttributes(id,MapValueConverter.convert(attributes, ATTRIBUTE_TYPES)),
+              authenticationProvider.getParent(Broker.class).getTaskExecutor());
         State state = MapValueConverter.getEnumAttribute(State.class, STATE, attributes, State.INITIALISING);
         _state = new AtomicReference<State>(state);
-        addParent(AuthenticationProvider.class, authenticationProvider);
         _authenticationProvider = authenticationProvider;
         _store = new FileSystemPreferencesStore(new File(MapValueConverter.getStringAttribute(PATH, attributes)));
+        createStoreIfNotExist();
     }
 
     @Override

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactory.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactory.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactory.java Fri Apr  4 22:34:26 2014
@@ -21,33 +21,29 @@
 
 package org.apache.qpid.server.model.adapter;
 
+import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory;
+import org.apache.qpid.server.model.AuthenticationProvider;
+import org.apache.qpid.server.model.ConfiguredObject;
+
+import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.qpid.server.model.AuthenticationProvider;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.PreferencesProvider;
-import org.apache.qpid.server.plugin.PreferencesProviderFactory;
-
-public class FileSystemPreferencesProviderFactory implements PreferencesProviderFactory
+public class FileSystemPreferencesProviderFactory extends AbstractConfiguredObjectTypeFactory<FileSystemPreferencesProvider>
 {
 
-    @Override
-    public String getType()
+    public FileSystemPreferencesProviderFactory()
     {
-        return FileSystemPreferencesProvider.PROVIDER_TYPE;
+        super(FileSystemPreferencesProvider.class);
     }
 
     @Override
-    public PreferencesProvider createInstance(UUID id, Map<String, Object> attributes,
-            AuthenticationProvider<? extends AuthenticationProvider> authenticationProvider)
+    public FileSystemPreferencesProvider createInstance(final Map<String, Object> attributes,
+                                                        final ConfiguredObject<?>... parents)
     {
-        Broker<?> broker = authenticationProvider.getParent(Broker.class);
-        FileSystemPreferencesProvider provider = new FileSystemPreferencesProvider(id, attributes, authenticationProvider, broker.getTaskExecutor());
-
-        // create store if such does not exist
-        provider.createStoreIfNotExist();
-        return provider;
+        Map<String,Object> attributesWithoutId = new HashMap<String, Object>(attributes);
+        Object idObj = attributesWithoutId.remove(ConfiguredObject.ID);
+        UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString());
+        return new FileSystemPreferencesProvider(id, attributesWithoutId, getParent(AuthenticationProvider.class,parents));
     }
-
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java Fri Apr  4 22:34:26 2014
@@ -21,7 +21,6 @@
 package org.apache.qpid.server.model.adapter;
 
 import java.security.AccessControlException;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -29,12 +28,10 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.qpid.server.consumer.ConsumerImpl;
 import org.apache.qpid.server.model.*;
 import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.protocol.AMQSessionModel;
 import org.apache.qpid.server.protocol.ConsumerListener;
-import org.apache.qpid.server.queue.QueueConsumer;
 
 final class SessionAdapter extends AbstractConfiguredObject<SessionAdapter> implements Session<SessionAdapter>
 {
@@ -165,12 +162,6 @@ final class SessionAdapter extends Abstr
     }
 
     @Override
-    public <C extends ConfiguredObject> C createChild(Class<C> childClass, Map<String, Object> attributes, ConfiguredObject... otherParents)
-    {
-        throw new  UnsupportedOperationException();
-    }
-
-    @Override
     public long getConsumerCount()
     {
         return _session.getConsumerCount();

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java Fri Apr  4 22:34:26 2014
@@ -20,45 +20,44 @@
  */
 package org.apache.qpid.server.model.adapter;
 
-import java.lang.reflect.Type;
-import java.security.AccessControlException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
 import org.apache.log4j.Logger;
-import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.configuration.updater.TaskExecutor;
+import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
 import org.apache.qpid.server.exchange.ExchangeImpl;
 import org.apache.qpid.server.message.MessageInstance;
 import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.model.*;
-import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.plugin.ExchangeType;
+import org.apache.qpid.server.plugin.VirtualHostFactory;
 import org.apache.qpid.server.protocol.AMQConnectionModel;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.ConflationQueue;
 import org.apache.qpid.server.security.access.Operation;
-import org.apache.qpid.server.stats.StatisticsGatherer;
 import org.apache.qpid.server.store.MessageStore;
 import org.apache.qpid.server.txn.LocalTransaction;
 import org.apache.qpid.server.txn.ServerTransaction;
 import org.apache.qpid.server.util.MapValueConverter;
 import org.apache.qpid.server.util.ParameterizedTypeImpl;
-import org.apache.qpid.server.plugin.VirtualHostFactory;
-import org.apache.qpid.server.util.ServerScopedRuntimeException;
 import org.apache.qpid.server.virtualhost.ExchangeExistsException;
+import org.apache.qpid.server.virtualhost.QueueExistsException;
 import org.apache.qpid.server.virtualhost.ReservedExchangeNameException;
 import org.apache.qpid.server.virtualhost.UnknownExchangeException;
 import org.apache.qpid.server.virtualhost.VirtualHostListener;
 import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
-import org.apache.qpid.server.virtualhost.QueueExistsException;
 
-public final class VirtualHostAdapter extends AbstractConfiguredObject<VirtualHostAdapter> implements VirtualHost<VirtualHostAdapter>, VirtualHostListener
+import java.lang.reflect.Type;
+import java.security.AccessControlException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+@ManagedObject( category = false, type = "STANDARD")
+public class VirtualHostAdapter<X extends VirtualHostAdapter<X>> extends AbstractConfiguredObject<X> implements VirtualHost<X>, VirtualHostListener
 {
     private static final Logger LOGGER = Logger.getLogger(VirtualHostAdapter.class);
 
@@ -101,15 +100,19 @@ public final class VirtualHostAdapter ex
 
     private final Broker<?> _broker;
     private final List<VirtualHostAlias> _aliases = new ArrayList<VirtualHostAlias>();
-    private StatisticsGatherer _brokerStatisticsGatherer;
 
-    public VirtualHostAdapter(UUID id, Map<String, Object> attributes, Broker<?> broker, StatisticsGatherer brokerStatisticsGatherer, TaskExecutor taskExecutor)
-    {
-        super(id, DEFAULTS, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES, false), taskExecutor, false);
+    public VirtualHostAdapter(UUID id,
+                              Map<String, Object> attributes,
+                              Broker<?> broker)
+    {
+        super(Collections.<Class<? extends ConfiguredObject>, ConfiguredObject<?>>singletonMap(Broker.class,broker),
+              DEFAULTS,
+              combineIdWithAttributes(id, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES, false)),
+              broker.getTaskExecutor(),
+              false);
+
         _broker = broker;
-        _brokerStatisticsGatherer = brokerStatisticsGatherer;
         validateAttributes();
-        addParent(Broker.class, broker);
     }
 
     private void validateAttributes()
@@ -1003,25 +1006,18 @@ public final class VirtualHostAdapter ex
     {
         VirtualHostRegistry virtualHostRegistry = _broker.getVirtualHostRegistry();
         String virtualHostName = getName();
-        try
+        String type = (String) getAttribute(TYPE);
+        final VirtualHostFactory factory = VirtualHostFactory.FACTORIES.get(type);
+        if(factory == null)
         {
-            String type = (String) getAttribute(TYPE);
-            final VirtualHostFactory factory = VirtualHostFactory.FACTORIES.get(type);
-            if(factory == null)
-            {
-                throw new IllegalArgumentException("Unknown virtual host type: " + type);
-            }
-            else
-            {
-                _virtualHost = factory.createVirtualHost(_broker.getVirtualHostRegistry(),
-                                                         _brokerStatisticsGatherer,
-                                                         _broker.getSecurityManager(),
-                                                         this);
-            }
+            throw new IllegalArgumentException("Unknown virtual host type: " + type);
         }
-        catch (Exception e)
+        else
         {
-            throw new ServerScopedRuntimeException("Failed to create virtual host " + virtualHostName, e);
+            _virtualHost = factory.createVirtualHost(_broker.getVirtualHostRegistry(),
+                                                     _broker,
+                                                     _broker.getSecurityManager(),
+                                                     this);
         }
 
         virtualHostRegistry.registerVirtualHost(_virtualHost);

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java Fri Apr  4 22:34:26 2014
@@ -23,14 +23,8 @@ package org.apache.qpid.server.model.ada
 
 import java.util.HashMap;
 import java.util.Map;
-import org.apache.qpid.server.model.AuthenticationMethod;
-import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.LifetimePolicy;
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.State;
-import org.apache.qpid.server.model.UUIDGenerator;
-import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.model.VirtualHostAlias;
+
+import org.apache.qpid.server.model.*;
 
 import java.security.AccessControlException;
 import java.util.Collection;
@@ -119,12 +113,6 @@ public class VirtualHostAliasAdapter ext
     }
 
     @Override
-    public <C extends ConfiguredObject> C createChild(Class<C> childClass, Map<String, Object> attributes, ConfiguredObject... otherParents)
-    {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
     protected boolean setState(State currentState, State desiredState)
     {
         // TODO: state is not supported at the moment

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AuthenticationManagerFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AuthenticationManagerFactory.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AuthenticationManagerFactory.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AuthenticationManagerFactory.java Fri Apr  4 22:34:26 2014
@@ -21,10 +21,11 @@ package org.apache.qpid.server.plugin;
 import java.util.Collection;
 import java.util.Map;
 
+import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.security.auth.manager.AbstractAuthenticationManager;
 
-public interface AuthenticationManagerFactory extends Pluggable
+public interface AuthenticationManagerFactory<X extends AuthenticationProvider<X>> extends ConfiguredObjectTypeFactory<X>
 {
 
     /**
@@ -34,22 +35,7 @@ public interface AuthenticationManagerFa
     String getType();
 
     /**
-     * Creates authentication manager from the provided attributes
-     *
-     * @param broker
-     *            broker model object
-     * @param attributes
-     *            attributes to create authentication manager
-     *
-     * @param recovering
-     * @return authentication manager instance
-     */
-    AbstractAuthenticationManager createInstance(Broker broker,
-                                                 Map<String, Object> attributes,
-                                                 final boolean recovering);
-
-    /**
-     * Get the names of attributes the authentication manager which can be passed into {@link #createInstance(org.apache.qpid.server.model.Broker, java.util.Map, boolean)} to create the
+     * Get the names of attributes the authentication manager
      * authentication manager
      *
      * @return the collection of attribute names

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfigurationStoreFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfigurationStoreFactory.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfigurationStoreFactory.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfigurationStoreFactory.java Fri Apr  4 22:34:26 2014
@@ -24,6 +24,7 @@ import java.util.Map;
 
 import org.apache.qpid.server.configuration.ConfigurationEntryStore;
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.model.SystemContext;
 
 
 public interface ConfigurationStoreFactory extends Pluggable
@@ -38,11 +39,11 @@ public interface ConfigurationStoreFacto
      * <p>
      * If location does not exist, or the overwrite option is specified, then a new store is created from the initial store if it is provided
      *
-     * @param storeLocation store location
+     * @param systemContext application configuration
      * @param initialStore initial store
      * @param overwrite overwrite existing store with initial store
      * @param configProperties a map of configuration properties the store can use to resolve configuration variables
      * @throws IllegalConfigurationException if store cannot be opened in the given location
      */
-    public ConfigurationEntryStore createStore(String storeLocation, ConfigurationEntryStore initialStore, boolean overwrite, Map<String, String> configProperties);
+    public ConfigurationEntryStore createStore(SystemContext systemContext, ConfigurationEntryStore initialStore, boolean overwrite, Map<String, String> configProperties);
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluginFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluginFactory.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluginFactory.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluginFactory.java Fri Apr  4 22:34:26 2014
@@ -18,15 +18,13 @@
  */
 package org.apache.qpid.server.plugin;
 
-import java.util.Map;
-import java.util.UUID;
-
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.Plugin;
 
+import java.util.Map;
+import java.util.UUID;
+
 public interface PluginFactory extends Pluggable
 {
-    static final String PLUGIN_TYPE = "pluginType";
-
     Plugin createInstance(UUID id, Map<String, Object> attributes, Broker broker);
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/AbstractQueue.java Fri Apr  4 22:34:26 2014
@@ -42,7 +42,7 @@ import org.apache.qpid.server.logging.Ev
 import org.apache.qpid.server.message.MessageSource;
 import org.apache.qpid.server.model.*;
 import org.apache.qpid.server.model.Queue;
-import org.apache.qpid.server.model.adapter.AbstractConfiguredObject;
+import org.apache.qpid.server.model.AbstractConfiguredObject;
 import org.apache.qpid.server.protocol.AMQConnectionModel;
 import org.apache.qpid.pool.ReferenceCountingExecutorService;
 import org.apache.qpid.server.configuration.BrokerProperties;

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java Fri Apr  4 22:34:26 2014
@@ -35,7 +35,7 @@ import org.apache.qpid.server.model.Conf
 import org.apache.qpid.server.model.LifetimePolicy;
 import org.apache.qpid.server.model.ManagedAttributeField;
 import org.apache.qpid.server.model.State;
-import org.apache.qpid.server.model.adapter.AbstractConfiguredObject;
+import org.apache.qpid.server.model.AbstractConfiguredObject;
 import org.apache.qpid.server.protocol.AMQSessionModel;
 import org.apache.qpid.server.protocol.MessageConverterRegistry;
 import org.apache.qpid.server.consumer.ConsumerTarget;

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java Fri Apr  4 22:34:26 2014
@@ -20,37 +20,23 @@
  */
 package org.apache.qpid.server.registry;
 
-import java.security.PrivilegedAction;
-import java.util.Collection;
-import java.util.Timer;
-import java.util.TimerTask;
-
 import org.apache.log4j.Logger;
-import org.apache.qpid.common.Closeable;
 import org.apache.qpid.common.QpidProperties;
 import org.apache.qpid.server.BrokerOptions;
 import org.apache.qpid.server.configuration.BrokerProperties;
-import org.apache.qpid.server.configuration.ConfigurationEntryStore;
-import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer;
-import org.apache.qpid.server.configuration.RecovererProvider;
-import org.apache.qpid.server.configuration.startup.DefaultRecovererProvider;
-import org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener;
-import org.apache.qpid.server.logging.*;
+import org.apache.qpid.server.configuration.startup.BrokerStoreUpgrader;
+import org.apache.qpid.server.logging.CompositeStartupMessageLogger;
+import org.apache.qpid.server.logging.EventLogger;
+import org.apache.qpid.server.logging.Log4jMessageLogger;
+import org.apache.qpid.server.logging.MessageLogger;
+import org.apache.qpid.server.logging.SystemOutMessageLogger;
 import org.apache.qpid.server.logging.messages.BrokerMessages;
-import org.apache.qpid.server.logging.messages.VirtualHostMessages;
 import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.State;
-import org.apache.qpid.server.configuration.updater.TaskExecutor;
-import org.apache.qpid.server.security.SecurityManager;
-import org.apache.qpid.server.stats.StatisticsCounter;
-import org.apache.qpid.server.stats.StatisticsGatherer;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
+import org.apache.qpid.server.model.SystemContext;
+import org.apache.qpid.server.store.DurableConfigurationStore;
 import org.apache.qpid.util.SystemUtils;
 
-import javax.security.auth.Subject;
-
 
 /**
  * An abstract application registry that provides access to configuration information and handles the
@@ -62,169 +48,45 @@ public class ApplicationRegistry impleme
 {
     private static final Logger _logger = Logger.getLogger(ApplicationRegistry.class);
 
-    private final EventLogger _eventLogger;
-
-    private final VirtualHostRegistry _virtualHostRegistry;
-
-    private volatile MessageLogger _messageLogger;
+    private final SystemContext _systemContext;
 
     private Broker _broker;
 
-    private Timer _reportingTimer;
-    private StatisticsCounter _messagesDelivered, _dataDelivered, _messagesReceived, _dataReceived;
-
-    private LogRecorder _logRecorder;
+    private DurableConfigurationStore _store;
 
-    private ConfigurationEntryStore _store;
-    private TaskExecutor _taskExecutor;
-
-    public ApplicationRegistry(ConfigurationEntryStore store, EventLogger eventLogger)
+    public ApplicationRegistry(DurableConfigurationStore store, SystemContext systemContext)
     {
         _store = store;
-        _eventLogger = eventLogger;
-        _virtualHostRegistry = new VirtualHostRegistry(_eventLogger);
-        initialiseStatistics();
+        _systemContext = systemContext;
     }
 
     public void initialise(BrokerOptions brokerOptions) throws Exception
     {
         // Create the RootLogger to be used during broker operation
         boolean statusUpdatesEnabled = Boolean.parseBoolean(System.getProperty(BrokerProperties.PROPERTY_STATUS_UPDATES, "true"));
-        _messageLogger = new Log4jMessageLogger(statusUpdatesEnabled);
-        _eventLogger.setMessageLogger(_messageLogger);
-        _logRecorder = new LogRecorder();
+        MessageLogger messageLogger = new Log4jMessageLogger(statusUpdatesEnabled);
+        final EventLogger eventLogger = _systemContext.getEventLogger();
+        eventLogger.setMessageLogger(messageLogger);
 
         //Create the composite (log4j+SystemOut MessageLogger to be used during startup
-        MessageLogger[] messageLoggers = {new SystemOutMessageLogger(), _messageLogger};
+        MessageLogger[] messageLoggers = {new SystemOutMessageLogger(), messageLogger};
 
         CompositeStartupMessageLogger startupMessageLogger = new CompositeStartupMessageLogger(messageLoggers);
         EventLogger startupLogger = new EventLogger(startupMessageLogger);
 
-
         logStartupMessages(startupLogger);
 
-        _taskExecutor = new TaskExecutor();
-        _taskExecutor.start();
+        BrokerStoreUpgrader upgrader = new BrokerStoreUpgrader(_systemContext);
+        _broker = upgrader.upgrade(_store);
 
-        StoreConfigurationChangeListener storeChangeListener = new StoreConfigurationChangeListener(_store);
-        RecovererProvider provider = new DefaultRecovererProvider((StatisticsGatherer)this, _virtualHostRegistry, _logRecorder,
-                                                                  _taskExecutor, brokerOptions, storeChangeListener);
-        ConfiguredObjectRecoverer<? extends ConfiguredObject> brokerRecoverer =  provider.getRecoverer(Broker.class.getSimpleName());
-        _broker = (Broker) brokerRecoverer.create(provider, _store.getRootEntry());
         _broker.setEventLogger(startupLogger);
-        _virtualHostRegistry.setDefaultVirtualHostName((String)_broker.getAttribute(Broker.DEFAULT_VIRTUAL_HOST));
-
-        initialiseStatisticsReporting();
 
         // starting the broker
         _broker.setDesiredState(State.INITIALISING, State.ACTIVE);
 
         startupLogger.message(BrokerMessages.READY());
-        _broker.setEventLogger(_eventLogger);
-
-    }
-
-    private void initialiseStatisticsReporting()
-    {
-        long report = ((Number)_broker.getAttribute(Broker.STATISTICS_REPORTING_PERIOD)).intValue() * 1000; // convert to ms
-        final boolean reset = (Boolean)_broker.getAttribute(Broker.STATISTICS_REPORTING_RESET_ENABLED);
-
-        /* add a timer task to report statistics if generation is enabled for broker or virtualhosts */
-        if (report > 0L)
-        {
-            _reportingTimer = new Timer("Statistics-Reporting", true);
-            StatisticsReportingTask task = new StatisticsReportingTask(reset, _messageLogger);
-            _reportingTimer.scheduleAtFixedRate(task, report / 2, report);
-        }
-    }
-
-    private class StatisticsReportingTask extends TimerTask
-    {
-        private final int DELIVERED = 0;
-        private final int RECEIVED = 1;
-
-        private final boolean _reset;
-        private final MessageLogger _logger;
-        private final Subject _subject;
-
-        public StatisticsReportingTask(boolean reset, MessageLogger logger)
-        {
-            _reset = reset;
-            _logger = logger;
-            _subject = SecurityManager.getSystemTaskSubject("Statistics");
-        }
-
-        public void run()
-        {
-            Subject.doAs(_subject, new PrivilegedAction<Object>()
-            {
-                @Override
-                public Object run()
-                {
-                    reportStatistics();
-                    return null;
-                }
-            });
-        }
-
-        protected void reportStatistics()
-        {
-            try
-            {
-                _eventLogger.message(BrokerMessages.STATS_DATA(DELIVERED, _dataDelivered.getPeak() / 1024.0, _dataDelivered.getTotal()));
-                _eventLogger.message(BrokerMessages.STATS_MSGS(DELIVERED, _messagesDelivered.getPeak(), _messagesDelivered.getTotal()));
-                _eventLogger.message(BrokerMessages.STATS_DATA(RECEIVED, _dataReceived.getPeak() / 1024.0, _dataReceived.getTotal()));
-                _eventLogger.message(BrokerMessages.STATS_MSGS(RECEIVED,
-                                                               _messagesReceived.getPeak(),
-                                                               _messagesReceived.getTotal()));
-                Collection<VirtualHost> hosts = _virtualHostRegistry.getVirtualHosts();
-
-                if (hosts.size() > 1)
-                {
-                    for (VirtualHost vhost : hosts)
-                    {
-                        String name = vhost.getName();
-                        StatisticsCounter dataDelivered = vhost.getDataDeliveryStatistics();
-                        StatisticsCounter messagesDelivered = vhost.getMessageDeliveryStatistics();
-                        StatisticsCounter dataReceived = vhost.getDataReceiptStatistics();
-                        StatisticsCounter messagesReceived = vhost.getMessageReceiptStatistics();
-                        EventLogger logger = vhost.getEventLogger();
-                        logger.message(VirtualHostMessages.STATS_DATA(name, DELIVERED, dataDelivered.getPeak() / 1024.0, dataDelivered.getTotal()));
-                        logger.message(VirtualHostMessages.STATS_MSGS(name, DELIVERED, messagesDelivered.getPeak(), messagesDelivered.getTotal()));
-                        logger.message(VirtualHostMessages.STATS_DATA(name, RECEIVED, dataReceived.getPeak() / 1024.0, dataReceived.getTotal()));
-                        logger.message(VirtualHostMessages.STATS_MSGS(name, RECEIVED, messagesReceived.getPeak(), messagesReceived.getTotal()));
-                    }
-                }
-
-                if (_reset)
-                {
-                    resetStatistics();
-                }
-            }
-            catch(Exception e)
-            {
-                ApplicationRegistry._logger.warn("Unexpected exception occurred while reporting the statistics", e);
-            }
-        }
-    }
+        _broker.setEventLogger(eventLogger);
 
-    /**
-     * Close non-null Closeable items and log any errors
-     * @param close
-     */
-    private void close(Closeable close)
-    {
-        try
-        {
-            if (close != null)
-            {
-                close.close();
-            }
-        }
-        catch (Throwable e)
-        {
-            _logger.error("Error thrown whilst closing " + close.getClass().getSimpleName(), e);
-        }
     }
 
     public void close()
@@ -236,93 +98,19 @@ public class ApplicationRegistry impleme
 
         try
         {
-            //Stop Statistics Reporting
-            if (_reportingTimer != null)
-            {
-                _reportingTimer.cancel();
-            }
-
             if (_broker != null)
             {
                 _broker.setDesiredState(_broker.getState(), State.STOPPED);
             }
-
-            //Shutdown virtualhosts
-            close(_virtualHostRegistry);
-
-            if (_taskExecutor != null)
-            {
-                _taskExecutor.stop();
-            }
-
-            _eventLogger.message(BrokerMessages.STOPPED());
-
-            _logRecorder.closeLogRecorder();
-
         }
         finally
         {
-            if (_taskExecutor != null)
-            {
-                _taskExecutor.stopImmediately();
-            }
+            _systemContext.close();
         }
         _store = null;
         _broker = null;
     }
 
-    public void registerMessageDelivered(long messageSize)
-    {
-        _messagesDelivered.registerEvent(1L);
-        _dataDelivered.registerEvent(messageSize);
-    }
-
-    public void registerMessageReceived(long messageSize, long timestamp)
-    {
-        _messagesReceived.registerEvent(1L, timestamp);
-        _dataReceived.registerEvent(messageSize, timestamp);
-    }
-
-    public StatisticsCounter getMessageReceiptStatistics()
-    {
-        return _messagesReceived;
-    }
-
-    public StatisticsCounter getDataReceiptStatistics()
-    {
-        return _dataReceived;
-    }
-
-    public StatisticsCounter getMessageDeliveryStatistics()
-    {
-        return _messagesDelivered;
-    }
-
-    public StatisticsCounter getDataDeliveryStatistics()
-    {
-        return _dataDelivered;
-    }
-
-    public void resetStatistics()
-    {
-        _messagesDelivered.reset();
-        _dataDelivered.reset();
-        _messagesReceived.reset();
-        _dataReceived.reset();
-
-        for (VirtualHost vhost : _virtualHostRegistry.getVirtualHosts())
-        {
-            vhost.resetStatistics();
-        }
-    }
-
-    public void initialiseStatistics()
-    {
-        _messagesDelivered = new StatisticsCounter("messages-delivered");
-        _dataDelivered = new StatisticsCounter("bytes-delivered");
-        _messagesReceived = new StatisticsCounter("messages-received");
-        _dataReceived = new StatisticsCounter("bytes-received");
-    }
 
     private void logStartupMessages(EventLogger eventLogger)
     {

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/registry/IApplicationRegistry.java Fri Apr  4 22:34:26 2014
@@ -24,7 +24,7 @@ import org.apache.qpid.server.BrokerOpti
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.stats.StatisticsGatherer;
 
-public interface IApplicationRegistry extends StatisticsGatherer
+public interface IApplicationRegistry
 {
 
     void initialise(BrokerOptions brokerOptions) throws Exception;

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AbstractAuthenticationManager.java Fri Apr  4 22:34:26 2014
@@ -22,9 +22,9 @@ package org.apache.qpid.server.security.
 
 import org.apache.log4j.Logger;
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
-import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.model.*;
-import org.apache.qpid.server.model.adapter.AbstractConfiguredObject;
+import org.apache.qpid.server.model.AbstractConfiguredObject;
+import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory;
 import org.apache.qpid.server.plugin.PreferencesProviderFactory;
 import org.apache.qpid.server.security.SubjectCreator;
 import org.apache.qpid.server.security.access.Operation;
@@ -34,6 +34,7 @@ import java.security.AccessControlExcept
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicReference;
@@ -92,6 +93,11 @@ public abstract class AbstractAuthentica
         throw new IllegalConfigurationException("Cannot associate  " + user + " with authentication provider " + this);
     }
 
+    public void instantiatePreferencesProvider(final PreferencesProvider preferencesProvider)
+    {
+        _preferencesProvider = preferencesProvider;
+    }
+
     @Override
     public String setName(final String currentName, final String desiredName)
             throws IllegalStateException, AccessControlException
@@ -137,11 +143,13 @@ public abstract class AbstractAuthentica
     {
         if(childClass == PreferencesProvider.class)
         {
-            String name = MapValueConverter.getStringAttribute(PreferencesProvider.NAME, attributes);
-            String type = MapValueConverter.getStringAttribute(PreferencesProvider.TYPE, attributes);
-            PreferencesProviderFactory factory = PreferencesProviderFactory.FACTORY_LOADER.get(type);
-            UUID id = UUIDGenerator.generatePreferencesProviderUUID(name, getName());
-            PreferencesProvider pp = factory.createInstance(id, attributes, this);
+            // TODO RG - get the configured object factory from parents
+            ConfiguredObjectFactory factory = new ConfiguredObjectFactory();
+            attributes = new HashMap<String, Object>(attributes);
+            attributes.put(ConfiguredObject.ID, UUID.randomUUID());
+            final ConfiguredObjectTypeFactory preferencesFactory =
+                    factory.getConfiguredObjectTypeFactory(PreferencesProvider.class, attributes);
+            PreferencesProvider pp = (PreferencesProvider) preferencesFactory.create(attributes, this);
             pp.setDesiredState(State.INITIALISING, State.ACTIVE);
             _preferencesProvider = pp;
             return (C)pp;

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManager.java Fri Apr  4 22:34:26 2014
@@ -27,12 +27,13 @@ import javax.security.auth.Subject;
 import javax.security.sasl.SaslException;
 import javax.security.sasl.SaslServer;
 
-import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ManagedObject;
 import org.apache.qpid.server.security.auth.AuthenticationResult;
 import org.apache.qpid.server.security.auth.UsernamePrincipal;
 import org.apache.qpid.server.security.auth.sasl.anonymous.AnonymousSaslServer;
 
+@ManagedObject( category = false, type= "Anonymous" )
 public class AnonymousAuthenticationManager extends AbstractAuthenticationManager<AnonymousAuthenticationManager>
 {
     private static final String ANONYMOUS = "ANONYMOUS";

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/AnonymousAuthenticationManagerFactory.java Fri Apr  4 22:34:26 2014
@@ -19,45 +19,43 @@
  */
 package org.apache.qpid.server.security.auth.manager;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
+import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory;
 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.plugin.AuthenticationManagerFactory;
 
-public class AnonymousAuthenticationManagerFactory implements AuthenticationManagerFactory
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+public class AnonymousAuthenticationManagerFactory extends AbstractConfiguredObjectTypeFactory<AnonymousAuthenticationManager> implements AuthenticationManagerFactory<AnonymousAuthenticationManager>
 {
     public static final String PROVIDER_TYPE = "Anonymous";
 
-    @Override
-    public AnonymousAuthenticationManager createInstance(Broker broker,
-                                                         Map<String, Object> attributes,
-                                                         final boolean recovering)
+    public AnonymousAuthenticationManagerFactory()
     {
-        if (attributes != null && PROVIDER_TYPE.equals(attributes.get(AuthenticationProvider.TYPE)))
-        {
-            return new AnonymousAuthenticationManager(broker, Collections.<String,Object>emptyMap(),attributes);
-        }
-        return null;
+        super(AnonymousAuthenticationManager.class);
     }
 
     @Override
     public Collection<String> getAttributeNames()
     {
-        return Collections.<String>singletonList(AuthenticationProvider.TYPE);
+        return Collections.singletonList(AuthenticationProvider.TYPE);
     }
 
+
     @Override
-    public String getType()
+    public Map<String, String> getAttributeDescriptions()
     {
-        return PROVIDER_TYPE;
+        return Collections.emptyMap();
     }
 
-    @Override
-    public Map<String, String> getAttributeDescriptions()
+    public AnonymousAuthenticationManager createInstance(final Map<String, Object> attributes,
+                                                         final ConfiguredObject<?>... parents)
     {
-        return null;
+        return new AnonymousAuthenticationManager(getParent(Broker.class,parents), Collections.<String,Object>emptyMap(),attributes);
     }
+
+
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordDatabaseAuthenticationManager.java Fri Apr  4 22:34:26 2014
@@ -22,6 +22,7 @@ package org.apache.qpid.server.security.
 
 import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ManagedObject;
 import org.apache.qpid.server.security.auth.database.Base64MD5PasswordFilePrincipalDatabase;
 import org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase;
 import org.apache.qpid.server.security.auth.database.PrincipalDatabase;
@@ -31,6 +32,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
 
+@ManagedObject( category = false, type = "Base64MD5PasswordFile" )
 public class Base64MD5PasswordDatabaseAuthenticationManager
         extends PrincipalDatabaseAuthenticationManager<Base64MD5PasswordDatabaseAuthenticationManager>
 {

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordFileAuthenticationManagerFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordFileAuthenticationManagerFactory.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordFileAuthenticationManagerFactory.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/Base64MD5PasswordFileAuthenticationManagerFactory.java Fri Apr  4 22:34:26 2014
@@ -20,17 +20,21 @@
  */
 package org.apache.qpid.server.security.auth.manager;
 
+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.store.ConfiguredObjectRecord;
+import org.apache.qpid.server.store.ResolvedObject;
+import org.apache.qpid.server.store.UnresolvedConfiguredObject;
+import org.apache.qpid.server.util.ResourceBundleLoader;
+
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.qpid.server.model.AuthenticationProvider;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.plugin.AuthenticationManagerFactory;
-import org.apache.qpid.server.util.ResourceBundleLoader;
-
-public class Base64MD5PasswordFileAuthenticationManagerFactory implements AuthenticationManagerFactory
+public class Base64MD5PasswordFileAuthenticationManagerFactory extends AbstractAuthenticationManagerFactory<Base64MD5PasswordDatabaseAuthenticationManager>
 {
     public static final String PROVIDER_TYPE = "Base64MD5PasswordFile";
     public static final String RESOURCE_BUNDLE = "org.apache.qpid.server.security.auth.manager.PasswordFileAuthenticationProviderAttributeDescriptions";
@@ -41,10 +45,9 @@ public class Base64MD5PasswordFileAuthen
             AuthenticationProvider.TYPE,
             ATTRIBUTE_PATH));
 
-    @Override
-    public String getType()
+    public Base64MD5PasswordFileAuthenticationManagerFactory()
     {
-        return PROVIDER_TYPE;
+        super(Base64MD5PasswordDatabaseAuthenticationManager.class);
     }
 
     @Override
@@ -53,24 +56,31 @@ public class Base64MD5PasswordFileAuthen
         return ResourceBundleLoader.getResources(RESOURCE_BUNDLE);
     }
 
-
     @Override
-    public AbstractAuthenticationManager createInstance(final Broker broker,
-                                                        final Map<String, Object> attributes,
-                                                        final boolean recovering)
+    public Collection<String> getAttributeNames()
     {
-        if (attributes == null || !getType().equals(attributes.get(AuthenticationProvider.TYPE)))
-        {
-            return null;
-        }
-
-        return new Base64MD5PasswordDatabaseAuthenticationManager(broker, Collections.<String,Object>emptyMap(),attributes,recovering);
+        return ATTRIBUTES;
     }
 
     @Override
-    public Collection<String> getAttributeNames()
+    public Base64MD5PasswordDatabaseAuthenticationManager createInstance(final Map<String, Object> attributes,
+                                                                         final ConfiguredObject<?>... parents)
     {
-        return ATTRIBUTES;
+        return new Base64MD5PasswordDatabaseAuthenticationManager(getParent(Broker.class, parents), Collections.<String,Object>emptyMap(),attributes,false);
     }
 
+    @Override
+    public UnresolvedConfiguredObject<Base64MD5PasswordDatabaseAuthenticationManager> recover(final ConfiguredObjectRecord record,
+                                                                                              final ConfiguredObject<?>... parents)
+    {
+
+        Map<String, Object> attributes = new HashMap<String, Object>(record.getAttributes());
+        attributes.put(ConfiguredObject.ID, record.getId());
+        final Base64MD5PasswordDatabaseAuthenticationManager authenticationManager =
+                new Base64MD5PasswordDatabaseAuthenticationManager(getParent(Broker.class, parents),
+                                                                   Collections.<String, Object>emptyMap(),
+                                                                   attributes,
+                                                                   true);
+        return ResolvedObject.newInstance(authenticationManager);
+    }
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManager.java Fri Apr  4 22:34:26 2014
@@ -28,10 +28,12 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ManagedAttribute;
 import org.apache.qpid.server.model.ManagedAttributeField;
+import org.apache.qpid.server.model.ManagedObject;
 import org.apache.qpid.server.security.auth.AuthenticationResult;
 import org.apache.qpid.server.security.auth.UsernamePrincipal;
 import org.apache.qpid.server.security.auth.sasl.external.ExternalSaslServer;
 
+@ManagedObject( category = false, type = "External" )
 public class ExternalAuthenticationManager extends AbstractAuthenticationManager<ExternalAuthenticationManager>
 {
     private static final String EXTERNAL = "EXTERNAL";

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ExternalAuthenticationManagerFactory.java Fri Apr  4 22:34:26 2014
@@ -19,17 +19,17 @@
  */
 package org.apache.qpid.server.security.auth.manager;
 
+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.util.ResourceBundleLoader;
+
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
 
-import org.apache.qpid.server.model.AuthenticationProvider;
-import org.apache.qpid.server.model.Broker;
-import org.apache.qpid.server.plugin.AuthenticationManagerFactory;
-import org.apache.qpid.server.util.ResourceBundleLoader;
-
-public class ExternalAuthenticationManagerFactory implements AuthenticationManagerFactory
+public class ExternalAuthenticationManagerFactory extends AbstractAuthenticationManagerFactory<ExternalAuthenticationManager>
 {
     public static final String RESOURCE_BUNDLE = "org.apache.qpid.server.security.auth.manager.ExternalAuthenticationProviderAttributeDescriptions";
     public static final String PROVIDER_TYPE = "External";
@@ -39,16 +39,9 @@ public class ExternalAuthenticationManag
             AuthenticationProvider.TYPE,
             ATTRIBUTE_USE_FULL_DN));
 
-    @Override
-    public ExternalAuthenticationManager createInstance(Broker broker,
-                                                        Map<String, Object> attributes,
-                                                        final boolean recovering)
+    public ExternalAuthenticationManagerFactory()
     {
-        if (attributes != null && PROVIDER_TYPE.equals(attributes.get(AuthenticationProvider.TYPE)))
-        {
-            return new ExternalAuthenticationManager(broker, Collections.<String,Object>emptyMap(),attributes);
-        }
-        return null;
+        super(ExternalAuthenticationManager.class);
     }
 
     @Override
@@ -58,15 +51,16 @@ public class ExternalAuthenticationManag
     }
 
     @Override
-    public String getType()
+    public Map<String, String> getAttributeDescriptions()
     {
-        return PROVIDER_TYPE;
+        return ResourceBundleLoader.getResources(RESOURCE_BUNDLE);
     }
 
     @Override
-    public Map<String, String> getAttributeDescriptions()
+    public ExternalAuthenticationManager createInstance(final Map<String, Object> attributes,
+                                                        final ConfiguredObject<?>... parents)
     {
-        return ResourceBundleLoader.getResources(RESOURCE_BUNDLE);
+        return new ExternalAuthenticationManager(getParent(Broker.class, parents), Collections.<String,Object>emptyMap(),attributes);
     }
 
 }



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


Mime
View raw message