qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1584365 [5/15] - in /qpid/branches/java-broker-config-store-changes/qpid/java: ./ bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/ bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/ bdbstore/src/main/jav...
Date Thu, 03 Apr 2014 19:59:01 GMT
Added: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContext.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContext.java?rev=1584365&view=auto
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContext.java (added)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/SystemContext.java Thu Apr  3 19:58:53 2014
@@ -0,0 +1,324 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.model;
+
+import org.apache.qpid.server.BrokerOptions;
+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.model.adapter.BrokerAdapter;
+import org.apache.qpid.server.store.ConfiguredObjectDependency;
+import org.apache.qpid.server.store.ConfiguredObjectIdDependency;
+import org.apache.qpid.server.store.ConfiguredObjectNameDependency;
+import org.apache.qpid.server.store.ConfiguredObjectRecord;
+import org.apache.qpid.server.store.UnresolvedConfiguredObject;
+import org.apache.qpid.server.util.ServerScopedRuntimeException;
+
+import java.security.AccessControlException;
+import java.util.*;
+
+@ManagedObject (creatable = false)
+public class SystemContext extends AbstractConfiguredObject<SystemContext>
+{
+    private static final UUID SYSTEM_ID = new UUID(0l, 0l);
+    private final ConfiguredObjectFactory _objectFactory;
+    private final EventLogger _eventLogger;
+    private final LogRecorder _logRecorder;
+    private final BrokerOptions _brokerOptions;
+
+    @ManagedAttributeField
+    private String _storePath;
+
+    @ManagedAttributeField
+    private String _storeType;
+    private Broker _broker;
+
+    public SystemContext(final TaskExecutor taskExecutor,
+                         final ConfiguredObjectFactory configuredObjectFactory,
+                         final EventLogger eventLogger,
+                         final LogRecorder logRecorder,
+                         final BrokerOptions brokerOptions)
+    {
+        super(SYSTEM_ID, Collections.<String,Object>emptyMap(), createAttributes(brokerOptions), taskExecutor);
+        _eventLogger = eventLogger;
+        getTaskExecutor().start();
+        _objectFactory = configuredObjectFactory;
+        _logRecorder = logRecorder;
+        _brokerOptions = brokerOptions;
+    }
+
+    public static Map<String, Object> createAttributes(final BrokerOptions brokerOptions)
+    {
+        Map<String,Object> attributes = new HashMap<String, Object>();
+        attributes.put(NAME, "System");
+        attributes.put("storePath", brokerOptions.getConfigurationStoreLocation());
+        attributes.put("storeTye", brokerOptions.getConfigurationStoreType());
+        return attributes;
+    }
+
+    public void resolveObjects(ConfiguredObjectRecord... records)
+    {
+
+        ConfiguredObjectFactory factory = getObjectFactory();
+
+        Map<UUID, ConfiguredObject<?>> resolvedObjects = new HashMap<UUID, ConfiguredObject<?>>();
+        resolvedObjects.put(getId(), this);
+
+        Collection<ConfiguredObjectRecord> recordsWithUnresolvedParents = new ArrayList<ConfiguredObjectRecord>(Arrays.asList(records));
+        Collection<UnresolvedConfiguredObject<? extends ConfiguredObject>> recordsWithUnresolvedDependencies =
+                new ArrayList<UnresolvedConfiguredObject<? extends ConfiguredObject>>();
+
+        boolean updatesMade;
+
+        do
+        {
+            updatesMade = false;
+            Iterator<ConfiguredObjectRecord> iter = recordsWithUnresolvedParents.iterator();
+            while (iter.hasNext())
+            {
+                ConfiguredObjectRecord record = iter.next();
+                Collection<ConfiguredObject<?>> parents = new ArrayList<ConfiguredObject<?>>();
+                boolean foundParents = true;
+                for (ConfiguredObjectRecord parent : record.getParents().values())
+                {
+                    if (!resolvedObjects.containsKey(parent.getId()))
+                    {
+                        foundParents = false;
+                        break;
+                    }
+                    else
+                    {
+                        parents.add(resolvedObjects.get(parent.getId()));
+                    }
+                }
+                if (foundParents)
+                {
+                    iter.remove();
+                    UnresolvedConfiguredObject<? extends ConfiguredObject> recovered =
+                            factory.recover(record, parents.toArray(new ConfiguredObject<?>[parents.size()]));
+                    Collection<ConfiguredObjectDependency<?>> dependencies =
+                            recovered.getUnresolvedDependencies();
+                    if (dependencies.isEmpty())
+                    {
+                        updatesMade = true;
+                        ConfiguredObject<?> resolved = recovered.resolve();
+                        resolvedObjects.put(resolved.getId(), resolved);
+                    }
+                    else
+                    {
+                        recordsWithUnresolvedDependencies.add(recovered);
+                    }
+                }
+
+            }
+
+            Iterator<UnresolvedConfiguredObject<? extends ConfiguredObject>> unresolvedIter =
+                    recordsWithUnresolvedDependencies.iterator();
+
+            while(unresolvedIter.hasNext())
+            {
+                UnresolvedConfiguredObject<? extends ConfiguredObject> unresolvedObject = unresolvedIter.next();
+                Collection<ConfiguredObjectDependency<?>> dependencies =
+                        new ArrayList<ConfiguredObjectDependency<?>>(unresolvedObject.getUnresolvedDependencies());
+
+                for(ConfiguredObjectDependency dependency : dependencies)
+                {
+                    if(dependency instanceof ConfiguredObjectIdDependency)
+                    {
+                        UUID id = ((ConfiguredObjectIdDependency)dependency).getId();
+                        if(resolvedObjects.containsKey(id))
+                        {
+                            dependency.resolve(resolvedObjects.get(id));
+                        }
+                    }
+                    else if(dependency instanceof ConfiguredObjectNameDependency)
+                    {
+                        ConfiguredObject<?> dependentObject = null;
+                        for(ConfiguredObject<?> parent : unresolvedObject.getParents())
+                        {
+                            dependentObject = parent.findConfiguredObject(dependency.getCategoryClass(), ((ConfiguredObjectNameDependency)dependency).getName());
+                            if(dependentObject != null)
+                            {
+                                break;
+                            }
+                        }
+                        if(dependentObject != null)
+                        {
+                            dependency.resolve(dependentObject);
+                        }
+                    }
+                    else
+                    {
+                        throw new ServerScopedRuntimeException("Unknown dependency type " + dependency.getClass().getSimpleName());
+                    }
+                }
+                if(unresolvedObject.getUnresolvedDependencies().isEmpty())
+                {
+                    updatesMade = true;
+                    unresolvedIter.remove();
+                    ConfiguredObject<?> resolved = unresolvedObject.resolve();
+                    resolvedObjects.put(resolved.getId(), resolved);
+                }
+            }
+
+        } while(updatesMade && !(recordsWithUnresolvedDependencies.isEmpty() && recordsWithUnresolvedParents.isEmpty()));
+
+        if(!recordsWithUnresolvedDependencies.isEmpty())
+        {
+            throw new IllegalArgumentException("Cannot resolve some objects: " + recordsWithUnresolvedDependencies);
+        }
+        if(!recordsWithUnresolvedParents.isEmpty())
+        {
+            throw new IllegalArgumentException("Cannot resolve object because their parents cannot be found" + recordsWithUnresolvedParents);
+        }
+    }
+
+    @Override
+    protected boolean setState(final State currentState, final State desiredState)
+    {
+        throw new IllegalArgumentException("Cannot change the state of the SystemContext object");
+    }
+
+    @Override
+    public String setName(final String currentName, final String desiredName)
+            throws IllegalStateException, AccessControlException
+    {
+        return null;
+    }
+
+    @Override
+    public State getState()
+    {
+        return State.ACTIVE;
+    }
+
+    @Override
+    public boolean isDurable()
+    {
+        return true;
+    }
+
+    @Override
+    public void setDurable(final boolean durable)
+            throws IllegalStateException, AccessControlException, IllegalArgumentException
+    {
+        throw new IllegalArgumentException("Cannot change the durability of the SystemContext object");
+    }
+
+    @Override
+    public LifetimePolicy getLifetimePolicy()
+    {
+        return LifetimePolicy.PERMANENT;
+    }
+
+    @Override
+    public LifetimePolicy setLifetimePolicy(final LifetimePolicy expected, final LifetimePolicy desired)
+            throws IllegalStateException, AccessControlException, IllegalArgumentException
+    {
+        throw new IllegalArgumentException("Cannot change the lifetime of the SystemContext object");
+    }
+
+    @Override
+    public <C extends ConfiguredObject> Collection<C> getChildren(final Class<C> clazz)
+    {
+        if(clazz == Broker.class)
+        {
+            return (Collection<C>) Collections.singleton(_broker);
+        }
+
+        return Collections.emptySet();
+    }
+
+    public ConfiguredObjectFactory getObjectFactory()
+    {
+        return _objectFactory;
+    }
+
+    public EventLogger getEventLogger()
+    {
+        return _eventLogger;
+    }
+
+    public LogRecorder getLogRecorder()
+    {
+        return _logRecorder;
+    }
+
+    public BrokerOptions getBrokerOptions()
+    {
+        return _brokerOptions;
+    }
+
+    @ManagedAttribute( automate = true )
+    public String getStorePath()
+    {
+        return _storePath;
+    }
+
+    @ManagedAttribute( automate = true )
+    public String getStoreType()
+    {
+        return _storeType;
+    }
+
+    public void close()
+    {
+        try
+        {
+
+
+            if (getTaskExecutor() != null)
+            {
+                getTaskExecutor().stop();
+            }
+
+            _eventLogger.message(BrokerMessages.STOPPED());
+
+            _logRecorder.closeLogRecorder();
+
+        }
+        finally
+        {
+            if (getTaskExecutor() != null)
+            {
+                getTaskExecutor().stopImmediately();
+            }
+        }
+
+    }
+
+    @Override
+    public Collection<String> getAttributeNames()
+    {
+        return getAttributeNames(getClass());
+    }
+
+    public void instantiateBroker(final Broker broker)
+    {
+        _broker = broker;
+    }
+
+    public Broker getBroker()
+    {
+        return _broker;
+    }
+}

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/TrustStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/TrustStore.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/TrustStore.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/TrustStore.java Thu Apr  3 19:58:53 2014
@@ -21,12 +21,9 @@
 package org.apache.qpid.server.model;
 
 import java.security.GeneralSecurityException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
 import javax.net.ssl.TrustManager;
 
-@ManagedObject
+@ManagedObject( defaultType = "FileTrustStore" )
 public interface TrustStore<X extends TrustStore<X>> extends ConfiguredObject<X>
 {
     String DURABLE = "durable";

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/VirtualHost.java Thu Apr  3 19:58:53 2014
@@ -29,7 +29,7 @@ import java.util.Collection;
 import java.util.Map;
 import java.util.UUID;
 
-@ManagedObject( managesChildren = true )
+@ManagedObject( managesChildren = true, defaultType = "STANDARD")
 public interface VirtualHost<X extends VirtualHost<X>> extends ConfiguredObject<X>
 {
 
@@ -48,19 +48,16 @@ public interface VirtualHost<X extends V
     String STORE_TRANSACTION_IDLE_TIMEOUT_WARN  = "storeTransactionIdleTimeoutWarn";
     String STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE = "storeTransactionOpenTimeoutClose";
     String STORE_TRANSACTION_OPEN_TIMEOUT_WARN  = "storeTransactionOpenTimeoutWarn";
-    String STORE_TYPE                           = "storeType";
-    String STORE_PATH                           = "storePath";
-    String CONFIG_STORE_TYPE                    = "configStoreType";
-    String CONFIG_STORE_PATH                    = "configStorePath";
     String SUPPORTED_EXCHANGE_TYPES             = "supportedExchangeTypes";
     String SUPPORTED_QUEUE_TYPES                = "supportedQueueTypes";
     String DURABLE                              = "durable";
     String LIFETIME_POLICY                      = "lifetimePolicy";
-    String CONFIG_PATH                          = "configPath";
+    String SECURITY_ACL                         = "securityAcl";
+    String HOUSE_KEEPING_THREAD_COUNT           = "houseKeepingThreadCount";
+    String CONFIGURATION_STORE_SETTINGS         = "configurationStoreSettings";
+    String MESSAGE_STORE_SETTINGS               = "messageStoreSettings";
 
-    // Attributes
-
-    int CURRENT_CONFIG_VERSION = 4;
+    int CURRENT_CONFIG_VERSION = 5;
 
     @ManagedAttribute
     Collection<String> getSupportedExchangeTypes();
@@ -84,18 +81,6 @@ public interface VirtualHost<X extends V
     long getQueue_flowResumeSizeBytes();
 
     @ManagedAttribute
-    String getConfigStoreType();
-
-    @ManagedAttribute
-    String getConfigStorePath();
-
-    @ManagedAttribute
-    String getStoreType();
-
-    @ManagedAttribute
-    String getStorePath();
-
-    @ManagedAttribute
     long getStoreTransactionIdleTimeoutClose();
 
     @ManagedAttribute
@@ -123,7 +108,16 @@ public interface VirtualHost<X extends V
     long getQueue_alertThresholdQueueDepthMessages();
 
     @ManagedAttribute
-    String getConfigPath();
+    String getSecurityAcl();
+
+    @ManagedAttribute
+    int getHouseKeepingThreadCount();
+
+    @ManagedAttribute
+    Map<String, Object> getMessageStoreSettings();
+
+    @ManagedAttribute
+    Map<String, Object> getConfigurationStoreSettings();
 
     @ManagedStatistic
     long getQueueCount();

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AbstractPluginAdapter.java Thu Apr  3 19:58:53 2014
@@ -20,12 +20,7 @@
  */
 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.AbstractConfiguredObject;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.LifetimePolicy;
@@ -33,17 +28,23 @@ import org.apache.qpid.server.model.Plug
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.security.access.Operation;
 
+import java.security.AccessControlException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+
 public abstract class AbstractPluginAdapter<X extends Plugin<X>> extends AbstractConfiguredObject<X> implements Plugin<X>
 {
     private Broker _broker;
 
     protected AbstractPluginAdapter(UUID id, Map<String, Object> defaults, Map<String, Object> attributes, Broker broker)
     {
-        super(id, defaults, attributes, broker.getTaskExecutor());
+        super(Collections.<Class<? extends ConfiguredObject>, ConfiguredObject<?>>singletonMap(Broker.class, broker), defaults, combineIdWithAttributes(id, attributes), broker.getTaskExecutor());
         _broker = broker;
-        addParent(Broker.class, broker);
     }
 
+
     @Override
     public String setName(String currentName, String desiredName) throws IllegalStateException, AccessControlException
     {
@@ -116,13 +117,6 @@ public abstract class AbstractPluginAdap
     }
 
     @Override
-    public <C extends ConfiguredObject> C createChild(Class<C> childClass, Map<String, Object> attributes,
-            ConfiguredObject... otherParents)
-    {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
     protected void authoriseSetDesiredState(State currentState, State desiredState) throws AccessControlException
     {
         if(desiredState == State.DELETED)

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java Thu Apr  3 19:58:53 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.plugin.PreferencesProviderFactory;
+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.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.store.MessageStoreCreator;
 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 = new MessageStoreCreator().getStoreTypes();
-        _supportedBrokerStoreTypes = new BrokerConfigurationStoreCreator().getStoreTypes();
-        _brokerStore = brokerStore;
+        _supportedVirtualHostStoreTypes = MessageStoreFactory.FACTORY_LOADER.getSupportedTypes();
         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.FACTORIES.getDescriptiveTypes();
+        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.FACTORIES.getDescriptiveTypes();
+            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);
+            }
+        }
+    }
+
+
 }

Added: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapterFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapterFactory.java?rev=1584365&view=auto
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapterFactory.java (added)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapterFactory.java Thu Apr  3 19:58:53 2014
@@ -0,0 +1,48 @@
+/*
+ *
+ * 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 org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.SystemContext;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public class BrokerAdapterFactory  extends AbstractConfiguredObjectTypeFactory<BrokerAdapter>
+{
+    public BrokerAdapterFactory()
+    {
+        super(BrokerAdapter.class);
+    }
+
+    @Override
+    public BrokerAdapter createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents)
+    {
+        SystemContext context = getParent(SystemContext.class, parents);
+        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 BrokerAdapter(id, attributesWithoutId, context);
+    }
+
+}

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/ConnectionAdapter.java Thu Apr  3 19:58:53 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

Copied: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java (from r1582544, qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java?p2=qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java&p1=qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java&r1=1582544&r2=1584365&rev=1584365&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/GroupProviderAdapter.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProvider.java Thu Apr  3 19:58:53 2014
@@ -19,65 +19,85 @@
  */
 package org.apache.qpid.server.model.adapter;
 
+import java.io.File;
+import java.io.IOException;
 import java.security.AccessControlException;
 import java.security.Principal;
 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.model.*;
 import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.security.access.Operation;
+import org.apache.qpid.server.security.group.FileGroupManager;
 import org.apache.qpid.server.security.group.GroupManager;
 import org.apache.qpid.server.security.SecurityManager;
 import org.apache.qpid.server.util.MapValueConverter;
 
-public class GroupProviderAdapter extends AbstractConfiguredObject<GroupProviderAdapter> implements GroupProvider<GroupProviderAdapter>
+@ManagedObject( category = false, type = "GroupFile" )
+public class FileBasedGroupProvider
+        extends AbstractConfiguredObject<FileBasedGroupProvider> implements GroupProvider<FileBasedGroupProvider>
 {
-    private static Logger LOGGER = Logger.getLogger(GroupProviderAdapter.class);
+    private static Logger LOGGER = Logger.getLogger(FileBasedGroupProvider.class);
 
     private final GroupManager _groupManager;
-    private final Broker _broker;
-    private Collection<String> _supportedAttributes;
+    private final Broker<?> _broker;
     private AtomicReference<State> _state;
 
-    public GroupProviderAdapter(UUID id, Broker broker, GroupManager groupManager, Map<String, Object> attributes, Collection<String> attributeNames)
+    @ManagedAttributeField
+    private String _path;
+
+    public FileBasedGroupProvider(UUID id,
+                                  Broker broker,
+                                  Map<String, Object> attributes)
     {
-        super(id, Collections.singletonMap(NAME, attributes.get(NAME)), Collections.<String,Object>emptyMap(), broker.getTaskExecutor());
+        super(Collections.<Class<? extends ConfiguredObject>,ConfiguredObject<?>>singletonMap(Broker.class, broker),
+              Collections.<String,Object>emptyMap(), combineIdWithAttributes(id, attributes), broker.getTaskExecutor());
 
-        if (groupManager == null)
-        {
-            throw new IllegalArgumentException("GroupManager must not be null");
-        }
-        _groupManager = groupManager;
+        _groupManager = new FileGroupManager(getPath());
         _broker = broker;
-        _supportedAttributes = createSupportedAttributes(attributeNames);
+
         State state = MapValueConverter.getEnumAttribute(State.class, STATE, attributes, State.INITIALISING);
         _state = new AtomicReference<State>(state);
-       addParent(Broker.class, broker);
-
-       // set attributes now after all attribute names are known
-       if (attributes != null)
-       {
-           for (String name : _supportedAttributes)
-           {
-               if (attributes.containsKey(name))
-               {
-                   changeAttribute(name, null, attributes.get(name));
-               }
-           }
-       }
+        validateUniqueFile();
     }
 
-    protected Collection<String> createSupportedAttributes(Collection<String> factoryAttributes)
+    private void validateUniqueFile()
     {
-        List<String> attributesNames = new ArrayList<String>(getAttributeNames(GroupProvider.class));
-        if (factoryAttributes != null)
+        Collection<GroupProvider<?>> groupProviders = _broker.getGroupProviders();
+        for(GroupProvider<?> provider : groupProviders)
         {
-            attributesNames.addAll(factoryAttributes);
+            if(provider instanceof FileBasedGroupProvider && provider != this)
+            {
+                try
+                {
+                    if(new File(getPath()).getCanonicalPath().equals(new File(((FileBasedGroupProvider)provider).getPath()).getCanonicalPath()))
+                    {
+                        throw new IllegalConfigurationException("Cannot have two group providers using the same file: " + getPath());
+                    }
+                }
+                catch (IOException e)
+                {
+                    throw new IllegalArgumentException("Invalid path", e);
+                }
+            }
         }
+    }
+
 
-        return Collections.unmodifiableCollection(attributesNames);
+    @Override
+    protected void create()
+    {
+        _groupManager.onCreate();
+        super.create();
+    }
+
+    @ManagedAttribute( automate = true, mandatory = true)
+    public String getPath()
+    {
+        return _path;
     }
 
     @Override
@@ -122,7 +142,7 @@ public class GroupProviderAdapter extend
     @Override
     public Collection<String> getAttributeNames()
     {
-        return _supportedAttributes;
+        return getAttributeNames(getClass());
     }
 
     @Override
@@ -132,10 +152,6 @@ public class GroupProviderAdapter extend
         {
             return true;
         }
-        else if (ID.equals(name))
-        {
-            return getId();
-        }
         else if (LIFETIME_POLICY.equals(name))
         {
             return LifetimePolicy.PERMANENT;
@@ -388,7 +404,7 @@ public class GroupProviderAdapter extend
                 Collection<GroupMember> members = new ArrayList<GroupMember>();
                 for (Principal principal : usersInGroup)
                 {
-                    UUID id = UUIDGenerator.generateGroupMemberUUID(GroupProviderAdapter.this.getName(), getName(), principal.getName());
+                    UUID id = UUIDGenerator.generateGroupMemberUUID(FileBasedGroupProvider.this.getName(), getName(), principal.getName());
                     Map<String,Object> attrMap = new HashMap<String, Object>();
                     attrMap.put(GroupMember.ID,id);
                     attrMap.put(GroupMember.NAME, principal.getName());
@@ -416,7 +432,7 @@ public class GroupProviderAdapter extend
                 getSecurityManager().authoriseGroupOperation(Operation.UPDATE, getName());
 
                 _groupManager.addUserToGroup(memberName, getName());
-                UUID id = UUIDGenerator.generateGroupMemberUUID(GroupProviderAdapter.this.getName(), getName(), memberName);
+                UUID id = UUIDGenerator.generateGroupMemberUUID(FileBasedGroupProvider.this.getName(), getName(), memberName);
                 Map<String,Object> attrMap = new HashMap<String, Object>();
                 attrMap.put(GroupMember.ID,id);
                 attrMap.put(GroupMember.NAME, memberName);
@@ -541,14 +557,6 @@ public class GroupProviderAdapter extend
             }
 
             @Override
-            public <C extends ConfiguredObject> C createChild(
-                    Class<C> childClass, Map<String, Object> attributes,
-                    ConfiguredObject... otherParents)
-            {
-                return null;
-            }
-
-            @Override
             protected boolean setState(State currentState, State desiredState)
                     throws IllegalStateTransitionException,
                     AccessControlException

Added: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderFactory.java?rev=1584365&view=auto
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderFactory.java (added)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileBasedGroupProviderFactory.java Thu Apr  3 19:58:53 2014
@@ -0,0 +1,48 @@
+/*
+ *
+ * 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 org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public class FileBasedGroupProviderFactory extends AbstractConfiguredObjectTypeFactory<FileBasedGroupProvider>
+{
+    public FileBasedGroupProviderFactory()
+    {
+        super(FileBasedGroupProvider.class);
+    }
+
+    @Override
+    public FileBasedGroupProvider createInstance(final Map<String, Object> attributes,
+                                                 final ConfiguredObject<?>... parents)
+    {
+        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 FileBasedGroupProvider(id, getParent(Broker.class, parents), attributesWithoutId);
+    }
+
+}

Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProvider.java Thu Apr  3 19:58:53 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/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactory.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactory.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderFactory.java Thu Apr  3 19:58:53 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/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/SessionAdapter.java Thu Apr  3 19:58:53 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();

Added: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/StandardVirtualHostAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/StandardVirtualHostAdapter.java?rev=1584365&view=auto
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/StandardVirtualHostAdapter.java (added)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/StandardVirtualHostAdapter.java Thu Apr  3 19:58:53 2014
@@ -0,0 +1,38 @@
+/*
+ *
+ * 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 org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ManagedObject;
+
+import java.util.Map;
+import java.util.UUID;
+
+@ManagedObject( category = false, type = "STANDARD")
+public class StandardVirtualHostAdapter extends VirtualHostAdapter<StandardVirtualHostAdapter>
+{
+    public StandardVirtualHostAdapter(final UUID id,
+                                      final Map<String, Object> attributes,
+                                      final Broker<?> broker)
+    {
+        super(id, attributes, broker);
+    }
+}

Added: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/StandardVirtualHostAdapterFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/StandardVirtualHostAdapterFactory.java?rev=1584365&view=auto
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/StandardVirtualHostAdapterFactory.java (added)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/StandardVirtualHostAdapterFactory.java Thu Apr  3 19:58:53 2014
@@ -0,0 +1,51 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.model.adapter;
+
+import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public class StandardVirtualHostAdapterFactory extends AbstractConfiguredObjectTypeFactory<StandardVirtualHostAdapter>
+{
+
+    public StandardVirtualHostAdapterFactory()
+    {
+        super(StandardVirtualHostAdapter.class);
+    }
+
+    @Override
+    public StandardVirtualHostAdapter createInstance(final Map<String, Object> attributes,
+                                                 final ConfiguredObject<?>... parents)
+    {
+        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());
+        final Broker broker = getParent(Broker.class, parents);
+        return new StandardVirtualHostAdapter(id, attributesWithoutId, broker);
+    }
+
+
+}



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


Mime
View raw message