qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1588468 [2/3] - in /qpid/trunk/qpid/java: broker-core/src/main/java/org/apache/qpid/server/configuration/startup/ broker-core/src/main/java/org/apache/qpid/server/configuration/store/ broker-core/src/main/java/org/apache/qpid/server/model/...
Date Fri, 18 Apr 2014 13:37:34 GMT
Added: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueFactory.java?rev=1588468&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueFactory.java (added)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueFactory.java Fri Apr 18 13:37:32 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.queue;
+
+import java.util.Map;
+
+import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.virtualhost.VirtualHostImpl;
+
+public class StandardQueueFactory extends AbstractConfiguredObjectTypeFactory<StandardQueueImpl>
+{
+    public StandardQueueFactory()
+    {
+        super(StandardQueueImpl.class);
+    }
+
+    @Override
+    protected StandardQueueImpl createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents)
+    {
+        VirtualHost<?,?,?> virtualHost = getParent(VirtualHost.class, parents);
+        if (!(virtualHost instanceof VirtualHostImpl))
+        {
+            throw new IllegalArgumentException("Unexpected virtual host is set as a parent. Expected instance of " + VirtualHostImpl.class.getName());
+        }
+
+        return new StandardQueueImpl((VirtualHostImpl<?,?,?>)virtualHost,attributes);
+    }
+}

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueImpl.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueImpl.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/StandardQueueImpl.java Fri Apr 18 13:37:32 2014
@@ -26,9 +26,24 @@ import org.apache.qpid.server.virtualhos
 
 public class StandardQueueImpl extends AbstractQueue<StandardQueueImpl> implements StandardQueue<StandardQueueImpl>
 {
+    private StandardQueueEntryList _entries;
+
     public StandardQueueImpl(final VirtualHostImpl virtualHost,
                              final Map<String, Object> arguments)
     {
-        super(virtualHost, arguments, new StandardQueueEntryList.Factory());
+        super(virtualHost, arguments);
+    }
+
+    @Override
+    protected void onOpen()
+    {
+        super.onOpen();
+        _entries = new StandardQueueEntryList(this);
+    }
+
+    @Override
+    StandardQueueEntryList getEntries()
+    {
+        return _entries;
     }
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/PrincipalDatabaseAuthenticationManager.java Fri Apr 18 13:37:32 2014
@@ -31,6 +31,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 
 import javax.security.auth.login.AccountNotFoundException;
@@ -48,7 +49,6 @@ import org.apache.qpid.server.model.Ille
 import org.apache.qpid.server.model.ManagedAttributeField;
 import org.apache.qpid.server.model.PreferencesProvider;
 import org.apache.qpid.server.model.State;
-import org.apache.qpid.server.model.UUIDGenerator;
 import org.apache.qpid.server.model.User;
 import org.apache.qpid.server.security.access.Operation;
 import org.apache.qpid.server.security.auth.AuthenticationResult;
@@ -531,7 +531,7 @@ public abstract class PrincipalDatabaseA
     private static Map<String, Object> createPrincipalAttributes(PrincipalDatabaseAuthenticationManager manager, final Principal user)
     {
         final Map<String, Object> attributes = new HashMap<String, Object>();
-        attributes.put(ID, UUIDGenerator.generateUserUUID(manager.getName(), user.getName()));
+        attributes.put(ID, UUID.randomUUID());
         attributes.put(NAME, user.getName());
         return attributes;
     }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractDurableConfiguredObjectRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractDurableConfiguredObjectRecoverer.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractDurableConfiguredObjectRecoverer.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractDurableConfiguredObjectRecoverer.java Fri Apr 18 13:37:32 2014
@@ -22,44 +22,84 @@ package org.apache.qpid.server.store;
 
 import java.util.UUID;
 
-public abstract class AbstractDurableConfiguredObjectRecoverer<T> implements DurableConfiguredObjectRecoverer
+import org.apache.qpid.server.model.ConfiguredObject;
+
+public abstract class AbstractDurableConfiguredObjectRecoverer<T extends ConfiguredObject> implements DurableConfiguredObjectRecoverer
 {
     @Override
     public void load(final DurableConfigurationRecoverer durableConfigurationRecoverer,
                      final ConfiguredObjectRecord record)
     {
-        final UnresolvedObject obj = createUnresolvedObject(record);
+        final UnresolvedObject<T> obj = createUnresolvedObject(record);
         UnresolvedDependency[] dependencies = obj.getUnresolvedDependencies();
         for(final UnresolvedDependency dependency : dependencies)
         {
-            Object dep;
-            if((dep = durableConfigurationRecoverer.getResolvedObject(dependency.getType(), dependency.getId())) != null)
+            if(dependency.getId() != null)
             {
-                dependency.resolve(dep);
+                Object dep;
+                if ((dep = durableConfigurationRecoverer.getResolvedObject(dependency.getType(), dependency.getId()))
+                    != null)
+                {
+                    dependency.resolve(dep);
+                }
+                else
+                {
+                    durableConfigurationRecoverer.addResolutionListener(dependency.getType(), dependency.getId(),
+                                                                        null, new DependencyListener()
+                                                                        {
+
+                                                                            @Override
+                                                                            public void dependencyResolved(final String depType,
+                                                                                                           final UUID depId,
+                                                                                                           final ConfiguredObject o)
+                                                                            {
+                                                                                dependency.resolve(o);
+                                                                                if (obj.getUnresolvedDependencies().length
+                                                                                    == 0)
+                                                                                {
+                                                                                    durableConfigurationRecoverer.resolve(
+                                                                                            getType(),
+                                                                                            record.getId(),
+                                                                                            obj.resolve());
+                                                                                }
+                                                                            }
+                                                                        }
+                                                                       );
+                }
             }
             else
             {
-                durableConfigurationRecoverer.addResolutionListener(dependency.getType(), dependency.getId(),
-                                                                      new DependencyListener()
-                                                                      {
-
-                                                                          @Override
-                                                                          public void dependencyResolved(final String depType,
-                                                                                                         final UUID depId,
-                                                                                                         final Object o)
-                                                                          {
-                                                                              dependency.resolve(o);
-                                                                              if (obj.getUnresolvedDependencies().length
-                                                                                  == 0)
-                                                                              {
-                                                                                  durableConfigurationRecoverer.resolve(
-                                                                                          getType(),
-                                                                                          record.getId(),
-                                                                                          obj.resolve());
-                                                                              }
-                                                                          }
-                                                                      }
-                                                                     );
+                Object dep;
+
+                if ((dep = durableConfigurationRecoverer.getResolvedObject(dependency.getType(), dependency.getName()))
+                    != null)
+                {
+                    dependency.resolve(dep);
+                }
+                else
+                {
+                    durableConfigurationRecoverer.addResolutionListener(dependency.getType(), dependency.getId(),
+                                                                        dependency.getName(), new DependencyListener()
+                                                                        {
+
+                                                                            @Override
+                                                                            public void dependencyResolved(final String depType,
+                                                                                                           final UUID depId,
+                                                                                                           final ConfiguredObject o)
+                                                                            {
+                                                                                dependency.resolve(o);
+                                                                                if (obj.getUnresolvedDependencies().length
+                                                                                    == 0)
+                                                                                {
+                                                                                    durableConfigurationRecoverer.resolve(
+                                                                                            getType(),
+                                                                                            record.getId(),
+                                                                                            obj.resolve());
+                                                                                }
+                                                                            }
+                                                                        }
+                                                                       );
+                }
             }
         }
         if(obj.getUnresolvedDependencies().length == 0)

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DependencyListener.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DependencyListener.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DependencyListener.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DependencyListener.java Fri Apr 18 13:37:32 2014
@@ -22,7 +22,9 @@ package org.apache.qpid.server.store;
 
 import java.util.UUID;
 
+import org.apache.qpid.server.model.ConfiguredObject;
+
 interface DependencyListener
 {
-    void dependencyResolved(String type, UUID id, Object o);
+    void dependencyResolved(String type, UUID id, ConfiguredObject o);
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationRecoverer.java Fri Apr 18 13:37:32 2014
@@ -29,17 +29,19 @@ import java.util.Map;
 import java.util.UUID;
 
 import org.apache.log4j.Logger;
+
 import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.logging.EventLogger;
 import org.apache.qpid.server.logging.messages.ConfigStoreMessages;
 import org.apache.qpid.server.logging.subjects.MessageStoreLogSubject;
+import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.Model;
 
 public class DurableConfigurationRecoverer implements ConfigurationRecoveryHandler
 {
     private static final Logger _logger = Logger.getLogger(DurableConfigurationRecoverer.class);
 
-    private final Map<String, Map<UUID, Object>> _resolvedObjects = new HashMap<String, Map<UUID, Object>>();
+    private final Map<String, Map<UUID, ConfiguredObject>> _resolvedObjects = new HashMap<String, Map<UUID, ConfiguredObject>>();
 
     private final Map<String, Map<UUID, UnresolvedObject>> _unresolvedObjects =
             new HashMap<String, Map<UUID, UnresolvedObject>>();
@@ -47,6 +49,9 @@ public class DurableConfigurationRecover
 
     private final Map<String, Map<UUID, List<DependencyListener>>> _dependencyListeners =
             new HashMap<String, Map<UUID, List<DependencyListener>>>();
+    private final Map<String, Map<String, List<DependencyListener>>> _dependencyNameListeners =
+            new HashMap<String, Map<String, List<DependencyListener>>>();
+
     private final Map<String, DurableConfiguredObjectRecoverer> _recoverers;
     private final UpgraderProvider _upgraderProvider;
     private final EventLogger _eventLogger;
@@ -188,36 +193,72 @@ public class DurableConfigurationRecover
 
     void addResolutionListener(final String type,
                                final UUID id,
+                               final String name,
                                final DependencyListener dependencyListener)
     {
-        Map<UUID, List<DependencyListener>> typeListeners = _dependencyListeners.get(type);
-        if(typeListeners == null)
+        if(id != null)
         {
-            typeListeners = new HashMap<UUID, List<DependencyListener>>();
-            _dependencyListeners.put(type, typeListeners);
+            Map<UUID, List<DependencyListener>> typeListeners = _dependencyListeners.get(type);
+            if (typeListeners == null)
+            {
+                typeListeners = new HashMap<UUID, List<DependencyListener>>();
+                _dependencyListeners.put(type, typeListeners);
+            }
+            List<DependencyListener> objectListeners = typeListeners.get(id);
+            if (objectListeners == null)
+            {
+                objectListeners = new ArrayList<DependencyListener>();
+                typeListeners.put(id, objectListeners);
+            }
+            objectListeners.add(dependencyListener);
         }
-        List<DependencyListener> objectListeners = typeListeners.get(id);
-        if(objectListeners == null)
+        else
         {
-            objectListeners = new ArrayList<DependencyListener>();
-            typeListeners.put(id, objectListeners);
+            Map<String, List<DependencyListener>> typeListeners = _dependencyNameListeners.get(type);
+            if (typeListeners == null)
+            {
+                typeListeners = new HashMap<String, List<DependencyListener>>();
+                _dependencyNameListeners.put(type, typeListeners);
+            }
+            List<DependencyListener> objectListeners = typeListeners.get(name);
+            if (objectListeners == null)
+            {
+                objectListeners = new ArrayList<DependencyListener>();
+                typeListeners.put(name, objectListeners);
+            }
+            objectListeners.add(dependencyListener);
         }
-        objectListeners.add(dependencyListener);
-
     }
 
     Object getResolvedObject(final String type, final UUID id)
     {
-        Map<UUID, Object> objects = _resolvedObjects.get(type);
+        Map<UUID, ConfiguredObject> objects = _resolvedObjects.get(type);
         return objects == null ? null : objects.get(id);
     }
 
-    void resolve(final String type, final UUID id, final Object object)
+    Object getResolvedObject(final String type, final String name)
+    {
+        Map<UUID, ConfiguredObject> objects = _resolvedObjects.get(type);
+        if(objects != null)
+        {
+            for (ConfiguredObject object : objects.values())
+            {
+                if(object.getName().equals(name))
+                {
+                    return object;
+                }
+            }
+        }
+        return null;
+
+    }
+
+    void resolve(final String type, final UUID id, final ConfiguredObject object)
     {
-        Map<UUID, Object> typeObjects = _resolvedObjects.get(type);
+        Map<UUID, ConfiguredObject> typeObjects = _resolvedObjects.get(type);
         if(typeObjects == null)
         {
-            typeObjects = new HashMap<UUID, Object>();
+            typeObjects = new HashMap<UUID, ConfiguredObject>();
             _resolvedObjects.put(type, typeObjects);
         }
         typeObjects.put(id, object);
@@ -239,6 +280,19 @@ public class DurableConfigurationRecover
                 }
             }
         }
+
+        Map<String, List<DependencyListener>> typeNameListeners = _dependencyNameListeners.get(type);
+        if(typeNameListeners != null)
+        {
+            List<DependencyListener> listeners = typeNameListeners.remove(object.getName());
+            if(listeners != null)
+            {
+                for(DependencyListener listener : listeners)
+                {
+                    listener.dependencyResolved(type, id, object);
+                }
+            }
+        }
     }
 
     void addUnresolvedObject(final String type,

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/DurableConfigurationStoreHelper.java Fri Apr 18 13:37:32 2014
@@ -22,14 +22,11 @@ package org.apache.qpid.server.store;
 
 import java.util.Arrays;
 import java.util.HashSet;
-import java.util.Map;
-
 import java.util.Set;
 
 import org.apache.qpid.server.binding.BindingImpl;
 import org.apache.qpid.server.exchange.ExchangeImpl;
 import org.apache.qpid.server.model.Binding;
-import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.Exchange;
 import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.queue.AMQQueue;
@@ -44,26 +41,12 @@ public class DurableConfigurationStoreHe
 
     public static void updateQueue(DurableConfigurationStore store, AMQQueue queue)
     {
-        Map<String, Object> attributesMap = queue.getActualAttributes();
-        attributesMap.remove(ConfiguredObject.ID);
-        if(queue.getAlternateExchange() != null)
-        {
-            attributesMap.put(Queue.ALTERNATE_EXCHANGE, queue.getAlternateExchange().getId());
-        }
-        store.update(false, new ConfiguredObjectRecordImpl(queue.getId(), QUEUE, attributesMap));
+        store.update(false, queue.asObjectRecord());
     }
 
     public static void createQueue(DurableConfigurationStore store, AMQQueue<?> queue)
     {
-
-        Map<String, Object> attributesMap = queue.getActualAttributes();
-        attributesMap.remove(ConfiguredObject.ID);
-        if(queue.getAlternateExchange() != null)
-        {
-            attributesMap.put(Queue.ALTERNATE_EXCHANGE, queue.getAlternateExchange().getId());
-        }
-
-        store.create(new ConfiguredObjectRecordImpl(queue.getId(), QUEUE, attributesMap));
+        store.create(queue.asObjectRecord());
     }
 
     public static void removeQueue(DurableConfigurationStore store, AMQQueue queue)

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/UnresolvedDependency.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/UnresolvedDependency.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/UnresolvedDependency.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/UnresolvedDependency.java Fri Apr 18 13:37:32 2014
@@ -25,6 +25,7 @@ import java.util.UUID;
 public interface UnresolvedDependency<T>
 {
     public UUID getId();
+    public String getName();
     public String getType();
 
     public void resolve(final T dependency);

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java Fri Apr 18 13:37:32 2014
@@ -70,13 +70,6 @@ import org.apache.qpid.server.protocol.A
 import org.apache.qpid.server.protocol.AMQSessionModel;
 import org.apache.qpid.server.protocol.LinkRegistry;
 import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.LastValueQueue;
-import org.apache.qpid.server.queue.LastValueQueueImpl;
-import org.apache.qpid.server.queue.PriorityQueue;
-import org.apache.qpid.server.queue.PriorityQueueImpl;
-import org.apache.qpid.server.queue.SortedQueue;
-import org.apache.qpid.server.queue.SortedQueueImpl;
-import org.apache.qpid.server.queue.StandardQueueImpl;
 import org.apache.qpid.server.security.SecurityManager;
 import org.apache.qpid.server.security.access.Operation;
 import org.apache.qpid.server.stats.StatisticsCounter;
@@ -101,6 +94,7 @@ public abstract class AbstractVirtualHos
 {
     public static final String DEFAULT_DLQ_NAME_SUFFIX = "_DLQ";
     public static final String DLQ_ROUTING_KEY = "dlq";
+    public static final String CREATE_DLQ_ON_CREATION = "x-qpid-dlq-enabled"; // TODO - this value should change
     private static final int MAX_LENGTH = 255;
 
     private static final Logger _logger = Logger.getLogger(AbstractVirtualHost.class);
@@ -195,7 +189,7 @@ public abstract class AbstractVirtualHos
         if(attributes.get(ID) == null)
         {
             attributes = new HashMap<String, Object>(attributes);
-            attributes.put(ID, UUIDGenerator.generateVhostUUID((String)attributes.get(NAME)));
+            attributes.put(ID, UUID.randomUUID());
         }
         return attributes;
     }
@@ -608,6 +602,7 @@ public abstract class AbstractVirtualHos
     public AMQQueue<?> createQueue(Map<String, Object> attributes) throws QueueExistsException
     {
         checkVHostStateIsActive();
+
         AMQQueue<?> queue = addQueue(attributes);
         childAdded(queue);
         return queue;
@@ -615,51 +610,34 @@ public abstract class AbstractVirtualHos
 
     private AMQQueue<?> addQueue(Map<String, Object> attributes) throws QueueExistsException
     {
-
-        // make a copy as we may augment (with an ID for example)
-        attributes = new LinkedHashMap<String, Object>(attributes);
-        if (attributes.containsKey(Queue.TYPE))
+        if (shouldCreateDLQ(attributes))
         {
-            String typeAttribute = MapValueConverter.getStringAttribute(Queue.TYPE, attributes, null);
-            QueueType queueType = null;
-            try
-            {
-                queueType = QueueType.valueOf(typeAttribute.toUpperCase());
-            }
-            catch(Exception e)
-            {
-                throw new IllegalArgumentException("Unsupported queue type :" + typeAttribute);
-            }
-            if (queueType == QueueType.LVQ && attributes.get(LastValueQueue.LVQ_KEY) == null)
-            {
-                attributes.put(LastValueQueue.LVQ_KEY, LastValueQueueImpl.DEFAULT_LVQ_KEY);
-            }
-            else if (queueType == QueueType.PRIORITY && attributes.get(PriorityQueue.PRIORITIES) == null)
-            {
-                attributes.put(PriorityQueue.PRIORITIES, 10);
-            }
-            else if (queueType == QueueType.SORTED && attributes.get(SortedQueue.SORT_KEY) == null)
-            {
-                throw new IllegalArgumentException("Sort key is not specified for sorted queue");
-            }
+            // TODO - this isn't really correct - what if the name has ${foo} in it?
+            String queueName = String.valueOf(attributes.get(Queue.NAME));
+            validateDLNames(queueName);
+            String altExchangeName = createDLQ(queueName);
+            attributes = new LinkedHashMap<String, Object>(attributes);
+            attributes.put(Queue.ALTERNATE_EXCHANGE, altExchangeName);
         }
+        return addQueueWithoutDLQ(attributes);
+    }
+
+    private AMQQueue<?> addQueueWithoutDLQ(Map<String, Object> attributes) throws QueueExistsException
+    {
+        Broker<?> broker = getParent(Broker.class);
 
-        if(!attributes.containsKey(Queue.ID))
+        ConfiguredObjectTypeFactory<? extends Queue> factory =
+                broker.getObjectFactory().getConfiguredObjectTypeFactory(Queue.class, attributes);
+
+        try
         {
-            UUID id = UUID.randomUUID();
-            attributes.put(Queue.ID, id);
+            return (AMQQueue) factory.create(attributes, this);
         }
-
-        boolean createDLQ = shouldCreateDLQ(attributes, getDefaultDeadLetterQueueEnabled());
-        if (createDLQ)
+        catch (DuplicateNameException e)
         {
-            // TODO - this isn't really correct - what if the name has ${foo} in it?
-            validateDLNames(String.valueOf(attributes.get(Queue.NAME)));
+            throw new QueueExistsException(getQueue(e.getName()));
         }
 
-        return createOrRestoreQueue(attributes, true);
-
-
     }
 
 
@@ -1525,94 +1503,13 @@ public abstract class AbstractVirtualHos
     }
 
 
-    // TODO - remove
-    public AMQQueue restoreQueue(Map<String, Object> attributes)
-    {
-        return createOrRestoreQueue(attributes, false);
-
-    }
-
-
-    private AMQQueue createOrRestoreQueue(Map<String, Object> attributes, boolean createInStore)
-    {
-        String queueName = MapValueConverter.getStringAttribute(Queue.NAME,attributes);
-        boolean createDLQ = createInStore && shouldCreateDLQ(attributes, getDefaultDeadLetterQueueEnabled());
-        if (createDLQ)
-        {
-            validateDLNames(queueName);
-        }
-
-        AMQQueue queue;
-
-        try
-        {
-
-
-            if (attributes.containsKey(SortedQueue.SORT_KEY))
-            {
-                queue = new SortedQueueImpl(this, attributes);
-            }
-            else if (attributes.containsKey(LastValueQueue.LVQ_KEY))
-            {
-                queue = new LastValueQueueImpl(this, attributes);
-            }
-            else if (attributes.containsKey(PriorityQueue.PRIORITIES))
-            {
-                queue = new PriorityQueueImpl(this, attributes);
-            }
-            else
-            {
-                queue = new StandardQueueImpl(this, attributes);
-            }
-            queue.open();
-        }
-        catch(DuplicateNameException e)
-        {
-
-            throw new QueueExistsException(e.getName(), getQueue(e.getName()));
-        }
-
-        if(createDLQ)
-        {
-            createDLQ(queue);
-        }
-        else if(attributes != null && attributes.get(Queue.ALTERNATE_EXCHANGE) instanceof String)
-        {
-
-            final String altExchangeAttr = (String) attributes.get(Queue.ALTERNATE_EXCHANGE);
-            ExchangeImpl altExchange;
-            try
-            {
-                altExchange = getExchange(UUID.fromString(altExchangeAttr));
-            }
-            catch(IllegalArgumentException e)
-            {
-                altExchange = getExchange(altExchangeAttr);
-            }
-            queue.setAlternateExchange(altExchange);
-        }
-
-        if (createInStore && queue.isDurable() && !(queue.getLifetimePolicy()
-                                                    == LifetimePolicy.DELETE_ON_CONNECTION_CLOSE
-                                                    || queue.getLifetimePolicy()
-                                                       == LifetimePolicy.DELETE_ON_SESSION_END))
-        {
-            DurableConfigurationStoreHelper.createQueue(getDurableConfigurationStore(), queue);
-        }
-
-        return queue;
-    }
-
-
-
-    private void createDLQ(final AMQQueue queue)
+    private String createDLQ(final String queueName)
     {
-        final String queueName = queue.getName();
         final String dlExchangeName = getDeadLetterExchangeName(queueName);
         final String dlQueueName = getDeadLetterQueueName(queueName);
 
         ExchangeImpl dlExchange = null;
-        final UUID dlExchangeId = UUIDGenerator.generateExchangeUUID(dlExchangeName, getName());
+        final UUID dlExchangeId = UUID.randomUUID();
 
         try
         {
@@ -1654,7 +1551,7 @@ public abstract class AbstractVirtualHos
             {
                 //set args to disable DLQ-ing/MDC from the DLQ itself, preventing loops etc
                 final Map<String, Object> args = new HashMap<String, Object>();
-                args.put(Queue.CREATE_DLQ_ON_CREATION, false);
+                args.put(CREATE_DLQ_ON_CREATION, false);
                 args.put(Queue.MAXIMUM_DELIVERY_ATTEMPTS, 0);
 
                 try
@@ -1664,7 +1561,8 @@ public abstract class AbstractVirtualHos
                     args.put(Queue.ID, UUID.randomUUID());
                     args.put(Queue.NAME, dlQueueName);
                     args.put(Queue.DURABLE, true);
-                    dlQueue = createQueue(args);
+                    dlQueue = addQueueWithoutDLQ(args);
+                    childAdded(dlQueue);
                 }
                 catch (QueueExistsException e)
                 {
@@ -1681,7 +1579,7 @@ public abstract class AbstractVirtualHos
             //but we will make the key 'dlq' as it can be logged at creation.
             dlExchange.addBinding(AbstractVirtualHost.DLQ_ROUTING_KEY, dlQueue, null);
         }
-        queue.setAlternateExchange(dlExchange);
+        return dlExchangeName;
     }
 
     private static void validateDLNames(String name)
@@ -1701,8 +1599,9 @@ public abstract class AbstractVirtualHos
         }
     }
 
-    private static boolean shouldCreateDLQ(Map<String, Object> arguments, boolean virtualHostDefaultDeadLetterQueueEnabled)
+    private boolean shouldCreateDLQ(Map<String, Object> arguments)
     {
+
         boolean autoDelete = MapValueConverter.getEnumAttribute(LifetimePolicy.class,
                                                                 Queue.LIFETIME_POLICY,
                                                                 arguments,
@@ -1712,19 +1611,19 @@ public abstract class AbstractVirtualHos
         if (!(autoDelete || (arguments != null && arguments.containsKey(Queue.ALTERNATE_EXCHANGE))))
         {
             boolean dlqArgumentPresent = arguments != null
-                                         && arguments.containsKey(Queue.CREATE_DLQ_ON_CREATION);
+                                         && arguments.containsKey(CREATE_DLQ_ON_CREATION);
             if (dlqArgumentPresent)
             {
                 boolean dlqEnabled = true;
                 if (dlqArgumentPresent)
                 {
-                    Object argument = arguments.get(Queue.CREATE_DLQ_ON_CREATION);
+                    Object argument = arguments.get(CREATE_DLQ_ON_CREATION);
                     dlqEnabled = (argument instanceof Boolean && ((Boolean)argument).booleanValue())
                                  || (argument instanceof String && Boolean.parseBoolean(argument.toString()));
                 }
                 return dlqEnabled;
             }
-            return virtualHostDefaultDeadLetterQueueEnabled;
+            return isQueue_deadLetterQueueEnabled();
         }
         return false;
     }

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/BindingRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/BindingRecoverer.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/BindingRecoverer.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/BindingRecoverer.java Fri Apr 18 13:37:32 2014
@@ -123,6 +123,12 @@ public class BindingRecoverer extends Ab
             }
 
             @Override
+            public String getName()
+            {
+                return null;
+            }
+
+            @Override
             public String getType()
             {
                 return Queue.class.getSimpleName();
@@ -147,6 +153,12 @@ public class BindingRecoverer extends Ab
             }
 
             @Override
+            public String getName()
+            {
+                return null;
+            }
+
+            @Override
             public String getType()
             {
                 return org.apache.qpid.server.model.Exchange.class.getSimpleName();

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeRecoverer.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeRecoverer.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ExchangeRecoverer.java Fri Apr 18 13:37:32 2014
@@ -28,7 +28,6 @@ import org.apache.qpid.server.exchange.E
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ConfiguredObjectFactory;
 import org.apache.qpid.server.model.Exchange;
-import org.apache.qpid.server.model.SystemContext;
 import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory;
 import org.apache.qpid.server.store.AbstractDurableConfiguredObjectRecoverer;
 import org.apache.qpid.server.store.ConfiguredObjectRecord;
@@ -46,8 +45,7 @@ public class ExchangeRecoverer extends A
     {
         _vhost = vhost;
         Broker<?> broker = _vhost.getParent(Broker.class);
-        SystemContext<?> systemContext = broker.getParent(SystemContext.class);
-        _objectFactory = systemContext.getObjectFactory();
+        _objectFactory = broker.getObjectFactory();
     }
 
     @Override

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueExistsException.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueExistsException.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueExistsException.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueExistsException.java Fri Apr 18 13:37:32 2014
@@ -26,6 +26,11 @@ public class QueueExistsException extend
 {
     private final AMQQueue _existing;
 
+    public QueueExistsException(AMQQueue existing)
+    {
+        this(existing.getName(), existing);
+    }
+
     public QueueExistsException(String name, AMQQueue existing)
     {
         super(name);

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueRecoverer.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueRecoverer.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/QueueRecoverer.java Fri Apr 18 13:37:32 2014
@@ -21,7 +21,7 @@
 package org.apache.qpid.server.virtualhost;
 
 import java.util.ArrayList;
-import java.util.LinkedHashMap;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
@@ -29,21 +29,28 @@ import java.util.UUID;
 import org.apache.log4j.Logger;
 
 import org.apache.qpid.server.exchange.ExchangeImpl;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObjectFactory;
 import org.apache.qpid.server.model.Queue;
+import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.store.AbstractDurableConfiguredObjectRecoverer;
 import org.apache.qpid.server.store.ConfiguredObjectRecord;
+import org.apache.qpid.server.store.UnresolvedConfiguredObject;
 import org.apache.qpid.server.store.UnresolvedDependency;
 import org.apache.qpid.server.store.UnresolvedObject;
 
 public class QueueRecoverer extends AbstractDurableConfiguredObjectRecoverer<AMQQueue>
 {
     private static final Logger _logger = Logger.getLogger(QueueRecoverer.class);
-    private final VirtualHostImpl _virtualHost;
+    private final VirtualHostImpl<?,?,?> _virtualHost;
+    private final ConfiguredObjectFactory _objectFactory;
 
     public QueueRecoverer(final VirtualHostImpl virtualHost)
     {
         _virtualHost = virtualHost;
+        Broker<?> broker = _virtualHost.getParent(Broker.class);
+        _objectFactory = broker.getObjectFactory();
     }
 
     @Override
@@ -55,33 +62,42 @@ public class QueueRecoverer extends Abst
     @Override
     public UnresolvedObject<AMQQueue> createUnresolvedObject(final ConfiguredObjectRecord record)
     {
-        return new UnresolvedQueue(record.getId(), record.getAttributes());
+        return new UnresolvedQueue(record);
     }
 
     private class UnresolvedQueue implements UnresolvedObject<AMQQueue>
     {
-        private final Map<String, Object> _attributes;
-        private final UUID _alternateExchangeId;
-        private final UUID _id;
+
+      //  private final UUID _alternateExchangeId;
+        private final ConfiguredObjectRecord _record;
         private AMQQueue _queue;
         private List<UnresolvedDependency> _dependencies = new ArrayList<UnresolvedDependency>();
         private ExchangeImpl _alternateExchange;
+        private UUID _alternateExchangeId;
+        private String _alternateExchangeName;
 
-        public UnresolvedQueue(final UUID id,
-                               final Map<String, Object> attributes)
+        public UnresolvedQueue(ConfiguredObjectRecord record)
         {
-            _attributes = attributes;
-            _alternateExchangeId = _attributes.get(Queue.ALTERNATE_EXCHANGE) == null ? null : UUID.fromString((String) _attributes
-                    .get(Queue.ALTERNATE_EXCHANGE));
-            _id = id;
-            if (_alternateExchangeId != null)
+            _record = record;
+            Object altExchObj = record.getAttributes().get(Queue.ALTERNATE_EXCHANGE);
+            if(altExchObj instanceof UUID)
+            {
+                _alternateExchangeId = (UUID) altExchObj;
+                _dependencies.add(new AlternateExchangeDependency());
+            }
+            else if (altExchObj instanceof String)
             {
-                _alternateExchange = _virtualHost.getExchange(_alternateExchangeId);
-                if(_alternateExchange == null)
+                try
+                {
+                    _alternateExchangeId = UUID.fromString((String)altExchObj);
+                }
+                catch (IllegalArgumentException e)
                 {
-                    _dependencies.add(new AlternateExchangeDependency());
+                    _alternateExchangeName = (String) altExchObj;
                 }
+                _dependencies.add(new AlternateExchangeDependency());
             }
+
         }
 
         @Override
@@ -93,9 +109,9 @@ public class QueueRecoverer extends Abst
         @Override
         public AMQQueue resolve()
         {
-            String queueName = (String) _attributes.get(Queue.NAME);
+            String queueName = (String) _record.getAttributes().get(Queue.NAME);
 
-            _queue = _virtualHost.getQueue(_id);
+            _queue = _virtualHost.getQueue(_record.getId());
             if(_queue == null)
             {
                 _queue = _virtualHost.getQueue(queueName);
@@ -103,11 +119,17 @@ public class QueueRecoverer extends Abst
 
             if (_queue == null)
             {
-                Map<String, Object> attributes = new LinkedHashMap<String, Object>(_attributes);
-                attributes.put(Queue.ID, _id);
-                attributes.put(Queue.DURABLE, true);
-                _queue = _virtualHost.restoreQueue(attributes);
+                Map<String,Object> attributesWithId = new HashMap<String,Object>(_record.getAttributes());
+                attributesWithId.put(Queue.ID,_record.getId());
+                attributesWithId.put(Queue.DURABLE,true);
+
+                ConfiguredObjectTypeFactory<? extends Queue> configuredObjectTypeFactory =
+                        _objectFactory.getConfiguredObjectTypeFactory(Queue.class, attributesWithId);
+                UnresolvedConfiguredObject<? extends Queue> unresolvedConfiguredObject =
+                        configuredObjectTypeFactory.recover(_record, _virtualHost);
+                _queue = (AMQQueue<?>) unresolvedConfiguredObject.resolve();
             }
+            _queue.open();
             return _queue;
         }
 
@@ -120,6 +142,12 @@ public class QueueRecoverer extends Abst
             }
 
             @Override
+            public String getName()
+            {
+                return _alternateExchangeName;
+            }
+
+            @Override
             public String getType()
             {
                 return "Exchange";

Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java Fri Apr 18 13:37:32 2014
@@ -128,6 +128,4 @@ public interface VirtualHostImpl< X exte
 
     EventLogger getEventLogger();
 
-    // TODO - remove
-    public AMQQueue restoreQueue(Map<String, Object> attributes);
 }

Modified: qpid/trunk/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory Fri Apr 18 13:37:32 2014
@@ -35,6 +35,11 @@ org.apache.qpid.server.model.adapter.Bro
 org.apache.qpid.server.model.adapter.StandardVirtualHostFactory
 org.apache.qpid.server.model.adapter.FileBasedGroupProviderFactory
 org.apache.qpid.server.model.adapter.FileSystemPreferencesProviderFactory
+org.apache.qpid.server.queue.LastValueQueueFactory
+org.apache.qpid.server.queue.PriorityQueueFactory
+org.apache.qpid.server.queue.QueueFactory
+org.apache.qpid.server.queue.SortedQueueFactory
+org.apache.qpid.server.queue.StandardQueueFactory
 org.apache.qpid.server.exchange.DirectExchangeFactory
 org.apache.qpid.server.exchange.FanoutExchangeFactory
 org.apache.qpid.server.exchange.HeadersExchangeFactory

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AbstractQueueTestBase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AbstractQueueTestBase.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AbstractQueueTestBase.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/AbstractQueueTestBase.java Fri Apr 18 13:37:32 2014
@@ -709,8 +709,7 @@ abstract class AbstractQueueTestBase ext
 
     private AbstractQueue createNonAsyncDeliverQueue()
     {
-        TestSimpleQueueEntryListFactory factory = new TestSimpleQueueEntryListFactory();
-        return new NonAsyncDeliverQueue(factory, getVirtualHost());
+        return new NonAsyncDeliverQueue(getVirtualHost());
     }
 
     /**
@@ -830,7 +829,8 @@ abstract class AbstractQueueTestBase ext
         QueueNotificationListener listener = mock(QueueNotificationListener .class);
 
         _queue.setNotificationListener(listener);
-        _queue.setAlertThresholdQueueDepthMessages(2);
+        _queue.setAttributes(Collections.<String, Object>singletonMap(Queue.ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES,
+                                                                      Integer.valueOf(2)));
 
         _queue.enqueue(createMessage(new Long(24)), null);
         verifyZeroInteractions(listener);
@@ -849,7 +849,8 @@ abstract class AbstractQueueTestBase ext
         _queue.enqueue(createMessage(new Long(26)), null);
 
         _queue.setNotificationListener(listener);
-        _queue.setAlertThresholdQueueDepthMessages(2);
+        _queue.setAttributes(Collections.<String, Object>singletonMap(Queue.ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES,
+                                                                      Integer.valueOf(2)));
 
         verifyZeroInteractions(listener);
 
@@ -1046,17 +1047,6 @@ abstract class AbstractQueueTestBase ext
         return _consumerTarget;
     }
 
-
-    static class TestSimpleQueueEntryListFactory implements QueueEntryListFactory
-    {
-
-        @Override
-        public NonAsyncDeliverList createQueueEntryList(final AMQQueue<?> queue)
-        {
-            return new NonAsyncDeliverList((NonAsyncDeliverQueue) queue);
-        }
-    }
-
     private static class NonAsyncDeliverEntry extends OrderedQueueEntry
     {
 
@@ -1107,9 +1097,23 @@ abstract class AbstractQueueTestBase ext
 
     private static class NonAsyncDeliverQueue extends AbstractQueue<NonAsyncDeliverQueue>
     {
-        public NonAsyncDeliverQueue(final TestSimpleQueueEntryListFactory factory, VirtualHostImpl vhost)
+        private QueueEntryList _entries = new NonAsyncDeliverList(this);
+
+        public NonAsyncDeliverQueue(VirtualHostImpl vhost)
+        {
+            super(vhost, attributes());
+        }
+
+        @Override
+        protected void onOpen()
+        {
+            super.onOpen();
+        }
+
+        @Override
+        QueueEntryList getEntries()
         {
-            super(vhost, attributes(), factory);
+            return _entries;
         }
 
         private static Map<String,Object> attributes()

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/LastValueQueueListTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/LastValueQueueListTest.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/LastValueQueueListTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/LastValueQueueListTest.java Fri Apr 18 13:37:32 2014
@@ -59,7 +59,8 @@ public class LastValueQueueListTest exte
         when(virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class));
         when(virtualHost.getEventLogger()).thenReturn(new EventLogger());
         _queue = new LastValueQueueImpl(virtualHost, queueAttributes);
-        _list = (LastValueQueueList) _queue.getEntries();
+        _queue.open();
+        _list = _queue.getEntries();
     }
 
     public void testListHasNoEntries()

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/PriorityQueueListTest.java Fri Apr 18 13:37:32 2014
@@ -59,7 +59,8 @@ public class PriorityQueueListTest exten
         when(virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class));
         when(virtualHost.getEventLogger()).thenReturn(new EventLogger());
         PriorityQueueImpl queue = new PriorityQueueImpl(virtualHost, queueAttributes);
-        _list = (PriorityQueueList) queue.getEntries();
+        queue.open();
+        _list = queue.getEntries();
 
         for (int i = 0; i < PRIORITIES.length; i++)
         {

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/QueueEntryImplTestBase.java Fri Apr 18 13:37:32 2014
@@ -18,24 +18,24 @@
  */
 package org.apache.qpid.server.queue;
 
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
 import junit.framework.TestCase;
 
 import org.apache.qpid.server.logging.EventLogger;
 import org.apache.qpid.server.message.MessageInstance;
+import org.apache.qpid.server.message.MessageInstance.EntryState;
 import org.apache.qpid.server.message.MessageReference;
 import org.apache.qpid.server.message.ServerMessage;
-import org.apache.qpid.server.message.MessageInstance.EntryState;
 import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.virtualhost.VirtualHostImpl;
 
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
 /**
  * Tests for {@link QueueEntryImpl}
  */
@@ -200,7 +200,8 @@ public abstract class QueueEntryImplTest
         when(virtualHost.getEventLogger()).thenReturn(new EventLogger());
 
         StandardQueueImpl queue = new StandardQueueImpl(virtualHost, queueAttributes);
-        OrderedQueueEntryList queueEntryList = (OrderedQueueEntryList) queue.getEntries();
+        queue.open();
+        OrderedQueueEntryList queueEntryList = queue.getEntries();
 
         // create test entries
         for(int i = 0; i < numberOfEntries ; i++)

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SelfValidatingSortedQueueEntryList.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SelfValidatingSortedQueueEntryList.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SelfValidatingSortedQueueEntryList.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SelfValidatingSortedQueueEntryList.java Fri Apr 18 13:37:32 2014
@@ -30,9 +30,9 @@ import org.apache.qpid.server.queue.Sort
  */
 public class SelfValidatingSortedQueueEntryList extends SortedQueueEntryList
 {
-    public SelfValidatingSortedQueueEntryList(SortedQueueImpl queue, String propertyName)
+    public SelfValidatingSortedQueueEntryList(SortedQueueImpl queue)
     {
-        super(queue, propertyName);
+        super(queue);
     }
 
     @Override

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryImplTest.java Fri Apr 18 13:37:32 2014
@@ -20,18 +20,18 @@
  */
 package org.apache.qpid.server.queue;
 
-import org.apache.qpid.server.logging.EventLogger;
-import org.apache.qpid.server.message.MessageReference;
-import org.apache.qpid.server.message.ServerMessage;
-import org.apache.qpid.server.model.Queue;
-import org.apache.qpid.server.virtualhost.VirtualHostImpl;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import org.apache.qpid.server.logging.EventLogger;
+import org.apache.qpid.server.message.MessageReference;
+import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.server.model.Queue;
+import org.apache.qpid.server.virtualhost.VirtualHostImpl;
 
 public class SimpleQueueEntryImplTest extends QueueEntryImplTestBase
 {
@@ -48,8 +48,8 @@ public class SimpleQueueEntryImplTest ex
         when(virtualHost.getSecurityManager()).thenReturn(mock(org.apache.qpid.server.security.SecurityManager.class));
         when(virtualHost.getEventLogger()).thenReturn(new EventLogger());
         StandardQueueImpl queue = new StandardQueueImpl(virtualHost, queueAttributes);
-
-        queueEntryList = (OrderedQueueEntryList) queue.getEntries();
+        queue.open();
+        queueEntryList = queue.getEntries();
 
         super.setUp();
     }

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryListTest.java Fri Apr 18 13:37:32 2014
@@ -86,15 +86,23 @@ public class SortedQueueEntryListTest ex
         final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class);
         when(virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class));
         when(virtualHost.getEventLogger()).thenReturn(new EventLogger());
-        _testQueue = new SortedQueueImpl(virtualHost, attributes, new QueueEntryListFactory()
+        _testQueue = new SortedQueueImpl(virtualHost, attributes)
         {
+            SelfValidatingSortedQueueEntryList _entries;
+            @Override
+            protected void onOpen()
+            {
+                super.onOpen();
+                _entries = new SelfValidatingSortedQueueEntryList(this);
+            }
 
             @Override
-            public SortedQueueEntryList createQueueEntryList(final AMQQueue queue)
+            SelfValidatingSortedQueueEntryList getEntries()
             {
-                return new SelfValidatingSortedQueueEntryList((SortedQueueImpl) queue, "KEY");
+                return _entries;
             }
-        });
+        };
+        _testQueue.open();
         _sqel = (SelfValidatingSortedQueueEntryList) _testQueue.getEntries();
 
         super.setUp();
@@ -124,7 +132,7 @@ public class SortedQueueEntryListTest ex
     {
         if(newList)
         {
-            return new SelfValidatingSortedQueueEntryList(_testQueue, "KEY");
+            return new SelfValidatingSortedQueueEntryList(_testQueue);
         }
         else
         {
@@ -195,7 +203,7 @@ public class SortedQueueEntryListTest ex
 
     public void testNonUniqueSortKeys() throws Exception
     {
-        _sqel = new SelfValidatingSortedQueueEntryList(_testQueue, "KEY");
+        _sqel = new SelfValidatingSortedQueueEntryList(_testQueue);
 
         // Build test list
         long messageId = 0L;
@@ -216,7 +224,7 @@ public class SortedQueueEntryListTest ex
 
     public void testNullSortKeys() throws Exception
     {
-        _sqel = new SelfValidatingSortedQueueEntryList(_testQueue, "KEY");
+        _sqel = new SelfValidatingSortedQueueEntryList(_testQueue);
 
         // Build test list
         long messageId = 0L;
@@ -237,7 +245,7 @@ public class SortedQueueEntryListTest ex
 
     public void testAscendingSortKeys() throws Exception
     {
-        _sqel = new SelfValidatingSortedQueueEntryList(_testQueue, "KEY");
+        _sqel = new SelfValidatingSortedQueueEntryList(_testQueue);
 
         // Build test list
         long messageId = 0L;
@@ -260,7 +268,7 @@ public class SortedQueueEntryListTest ex
 
     public void testDescendingSortKeys() throws Exception
     {
-        _sqel = new SelfValidatingSortedQueueEntryList(_testQueue, "KEY");
+        _sqel = new SelfValidatingSortedQueueEntryList(_testQueue);
 
         // Build test list
         long messageId = 0L;
@@ -283,7 +291,7 @@ public class SortedQueueEntryListTest ex
 
     public void testInsertAfter() throws Exception
     {
-        _sqel = new SelfValidatingSortedQueueEntryList(_testQueue, "KEY");
+        _sqel = new SelfValidatingSortedQueueEntryList(_testQueue);
 
         ServerMessage msg = generateTestMessage(1, "A");
         _sqel.add(msg);
@@ -303,7 +311,7 @@ public class SortedQueueEntryListTest ex
 
     public void testInsertBefore() throws Exception
     {
-        _sqel = new SelfValidatingSortedQueueEntryList(_testQueue, "KEY");
+        _sqel = new SelfValidatingSortedQueueEntryList(_testQueue);
 
         ServerMessage msg = generateTestMessage(1, "B");
         _sqel.add(msg);
@@ -323,7 +331,7 @@ public class SortedQueueEntryListTest ex
 
     public void testInsertInbetween() throws Exception
     {
-        _sqel = new SelfValidatingSortedQueueEntryList(_testQueue, "KEY");
+        _sqel = new SelfValidatingSortedQueueEntryList(_testQueue);
 
         ServerMessage msg = generateTestMessage(1, "A");
         _sqel.add(msg);
@@ -354,7 +362,7 @@ public class SortedQueueEntryListTest ex
 
     public void testInsertAtHead() throws Exception
     {
-        _sqel = new SelfValidatingSortedQueueEntryList(_testQueue, "KEY");
+        _sqel = new SelfValidatingSortedQueueEntryList(_testQueue);
 
         ServerMessage msg = generateTestMessage(1, "B");
         _sqel.add(msg);

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/SortedQueueEntryTest.java Fri Apr 18 13:37:32 2014
@@ -56,15 +56,23 @@ public class SortedQueueEntryTest extend
         final VirtualHostImpl virtualHost = mock(VirtualHostImpl.class);
         when(virtualHost.getSecurityManager()).thenReturn(mock(org.apache.qpid.server.security.SecurityManager.class));
         when(virtualHost.getEventLogger()).thenReturn(new EventLogger());
-        SortedQueueImpl queue = new SortedQueueImpl(virtualHost, attributes, new QueueEntryListFactory()
+        SortedQueueImpl queue = new SortedQueueImpl(virtualHost, attributes)
         {
+            SelfValidatingSortedQueueEntryList _entries;
+            @Override
+            protected void onOpen()
+            {
+                super.onOpen();
+                _entries = new SelfValidatingSortedQueueEntryList(this);
+            }
 
             @Override
-            public SortedQueueEntryList createQueueEntryList(final AMQQueue queue)
+            SelfValidatingSortedQueueEntryList getEntries()
             {
-                return new SelfValidatingSortedQueueEntryList((SortedQueueImpl) queue, "KEY");
+                return _entries;
             }
-        });
+        };
+        queue.open();
         _queueEntryList = (SelfValidatingSortedQueueEntryList) queue.getEntries();
         super.setUp();
     }

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueEntryListTest.java Fri Apr 18 13:37:32 2014
@@ -20,20 +20,20 @@
 */
 package org.apache.qpid.server.queue;
 
-import org.apache.qpid.server.logging.EventLogger;
-import org.apache.qpid.server.message.MessageReference;
-import org.apache.qpid.server.message.ServerMessage;
-import org.apache.qpid.server.model.Queue;
-import org.apache.qpid.server.security.SecurityManager;
-import org.apache.qpid.server.virtualhost.VirtualHostImpl;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import org.apache.qpid.server.logging.EventLogger;
+import org.apache.qpid.server.message.MessageReference;
+import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.server.model.Queue;
+import org.apache.qpid.server.security.SecurityManager;
+import org.apache.qpid.server.virtualhost.VirtualHostImpl;
 
 public class StandardQueueEntryListTest extends QueueEntryListTestBase
 {
@@ -56,8 +56,8 @@ public class StandardQueueEntryListTest 
         when(virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class));
         when(virtualHost.getEventLogger()).thenReturn(new EventLogger());
         _testQueue = new StandardQueueImpl(virtualHost, queueAttributes);
-
-        _sqel = (StandardQueueEntryList) _testQueue.getEntries();
+        _testQueue.open();
+        _sqel = _testQueue.getEntries();
         for(int i = 1; i <= 100; i++)
         {
             final ServerMessage message = mock(ServerMessage.class);
@@ -102,8 +102,8 @@ public class StandardQueueEntryListTest 
             when(virtualHost.getSecurityManager()).thenReturn(mock(SecurityManager.class));
             when(virtualHost.getEventLogger()).thenReturn(new EventLogger());
             StandardQueueImpl queue = new StandardQueueImpl(virtualHost, queueAttributes);
-
-            return (StandardQueueEntryList) queue.getEntries();
+            queue.open();
+            return queue.getEntries();
         }
         else
         {

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java Fri Apr 18 13:37:32 2014
@@ -249,9 +249,17 @@ public class StandardQueueTest extends A
     private static class DequeuedQueue extends AbstractQueue
     {
 
+        private QueueEntryList _entries = new DequeuedQueueEntryList(this);
+
         public DequeuedQueue(VirtualHostImpl virtualHost)
         {
-            super(virtualHost, attributes(), new DequeuedQueueEntryListFactory());
+            super(virtualHost, attributes());
+        }
+
+        @Override
+        QueueEntryList getEntries()
+        {
+            return _entries;
         }
 
         private static Map<String,Object> attributes()
@@ -264,19 +272,6 @@ public class StandardQueueTest extends A
             return attributes;
         }
     }
-    private static class DequeuedQueueEntryListFactory implements QueueEntryListFactory
-    {
-        public DequeuedQueueEntryList createQueueEntryList(AMQQueue queue)
-        {
-            /**
-             * Override SimpleQueueEntryList to create a dequeued
-             * entries for messages with even id
-             */
-            return new DequeuedQueueEntryList((DequeuedQueue) queue);
-        }
-
-
-    }
 
     private static class DequeuedQueueEntryList extends OrderedQueueEntryList
     {

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java Fri Apr 18 13:37:32 2014
@@ -53,6 +53,7 @@ import org.apache.qpid.server.plugin.Exc
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.security.SecurityManager;
 import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler;
+import org.apache.qpid.server.virtualhost.AbstractVirtualHost;
 import org.apache.qpid.server.virtualhost.VirtualHostImpl;
 import org.apache.qpid.test.utils.QpidTestCase;
 import org.apache.qpid.util.FileUtils;
@@ -286,7 +287,7 @@ public abstract class AbstractDurableCon
     public void testCreateQueueAMQQueueFieldTable() throws Exception
     {
         Map<String, Object> attributes = new HashMap<String, Object>();
-        attributes.put(Queue.CREATE_DLQ_ON_CREATION, Boolean.TRUE);
+        attributes.put(AbstractVirtualHost.CREATE_DLQ_ON_CREATION, Boolean.TRUE);
         attributes.put(Queue.MAXIMUM_DELIVERY_ATTEMPTS, 10);
         AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true, attributes);
 
@@ -335,7 +336,7 @@ public abstract class AbstractDurableCon
     {
         // create queue
         Map<String, Object> attributes = new HashMap<String, Object>();
-        attributes.put(Queue.CREATE_DLQ_ON_CREATION, Boolean.TRUE);
+        attributes.put(AbstractVirtualHost.CREATE_DLQ_ON_CREATION, Boolean.TRUE);
         attributes.put(Queue.MAXIMUM_DELIVERY_ATTEMPTS, 10);
         AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true, attributes);
 
@@ -361,7 +362,7 @@ public abstract class AbstractDurableCon
     {
         // create queue
         Map<String, Object> attributes = new HashMap<String, Object>();
-        attributes.put(Queue.CREATE_DLQ_ON_CREATION, Boolean.TRUE);
+        attributes.put(AbstractVirtualHost.CREATE_DLQ_ON_CREATION, Boolean.TRUE);
         attributes.put(Queue.MAXIMUM_DELIVERY_ATTEMPTS, 10);
         AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true, attributes);
         DurableConfigurationStoreHelper.createQueue(_configStore, queue);
@@ -387,7 +388,7 @@ public abstract class AbstractDurableCon
     {
         // create queue
         Map<String, Object> attributes = new HashMap<String, Object>();
-        attributes.put(Queue.CREATE_DLQ_ON_CREATION, Boolean.TRUE);
+        attributes.put(AbstractVirtualHost.CREATE_DLQ_ON_CREATION, Boolean.TRUE);
         attributes.put(Queue.MAXIMUM_DELIVERY_ATTEMPTS, 10);
         AMQQueue queue = createTestQueue(getName(), getName() + "Owner", true, attributes);
         DurableConfigurationStoreHelper.createQueue(_configStore, queue);

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java Fri Apr 18 13:37:32 2014
@@ -67,7 +67,6 @@ import org.apache.qpid.server.store.Dura
 import org.apache.qpid.server.store.DurableConfiguredObjectRecoverer;
 import org.apache.qpid.server.store.StoreException;
 import org.apache.qpid.server.store.UnresolvedConfiguredObject;
-import org.apache.qpid.server.util.MapValueConverter;
 import org.apache.qpid.test.utils.QpidTestCase;
 
 public class DurableConfigurationRecovererTest extends QpidTestCase
@@ -84,6 +83,7 @@ public class DurableConfigurationRecover
     private DurableConfigurationStore _store;
     private ConfiguredObjectFactory _configuredObjectFactory;
     private ConfiguredObjectTypeFactory _exchangeFactory;
+    private ConfiguredObjectTypeFactory _queueFactory;
 
     @Override
     public void setUp() throws Exception
@@ -91,6 +91,8 @@ public class DurableConfigurationRecover
         super.setUp();
         _configuredObjectFactory = mock(ConfiguredObjectFactory.class);
         _exchangeFactory = mock(ConfiguredObjectTypeFactory.class);
+        _queueFactory = mock(ConfiguredObjectTypeFactory.class);
+
 
         AMQQueue<?> queue = mock(AMQQueue.class);
 
@@ -106,6 +108,8 @@ public class DurableConfigurationRecover
         when(_vhost.getQueue(eq(QUEUE_ID))).thenReturn(queue);
 
         when(_configuredObjectFactory.getConfiguredObjectTypeFactory(eq(Exchange.class), anyMap())).thenReturn(_exchangeFactory);
+        when(_configuredObjectFactory.getConfiguredObjectTypeFactory(eq(Queue.class), anyMap())).thenReturn(_queueFactory);
+
 
         final ArgumentCaptor<ConfiguredObjectRecord> recoveredExchange = ArgumentCaptor.forClass(ConfiguredObjectRecord.class);
         doAnswer(new Answer()
@@ -131,52 +135,38 @@ public class DurableConfigurationRecover
 
 
 
-        final ArgumentCaptor<Map> attributesArg = ArgumentCaptor.forClass(Map.class);
 
-        when(_vhost.restoreQueue(attributesArg.capture())).then(
-                new Answer()
-                {
+        final ArgumentCaptor<ConfiguredObjectRecord> recoveredQueue = ArgumentCaptor.forClass(ConfiguredObjectRecord.class);
+        doAnswer(new Answer()
+        {
 
-                    @Override
-                    public Object answer(final InvocationOnMock invocation) throws Throwable
-                    {
-                        final AMQQueue queue = mock(AMQQueue.class);
-
-                        final Map attributes = attributesArg.getValue();
-                        final String queueName = (String) attributes.get(Queue.NAME);
-                        final UUID queueId = MapValueConverter.getUUIDAttribute(Queue.ID, attributes);
-
-                        when(queue.getName()).thenReturn(queueName);
-                        when(queue.getId()).thenReturn(queueId);
-                        when(_vhost.getQueue(eq(queueName))).thenReturn(queue);
-                        when(_vhost.getQueue(eq(queueId))).thenReturn(queue);
-
-                        final ArgumentCaptor<ExchangeImpl> altExchangeArg = ArgumentCaptor.forClass(ExchangeImpl.class);
-                        doAnswer(
-                                new Answer()
-                                {
-                                    @Override
-                                    public Object answer(InvocationOnMock invocation) throws Throwable
-                                    {
-                                        final ExchangeImpl value = altExchangeArg.getValue();
-                                        when(queue.getAlternateExchange()).thenReturn(value);
-                                        return null;
-                                    }
-                                }
-                                ).when(queue).setAlternateExchange(altExchangeArg.capture());
-
-                        Map args = attributes;
-                        if (args.containsKey(Queue.ALTERNATE_EXCHANGE))
-                        {
-                            final UUID exchangeId = UUID.fromString(args.get(Queue.ALTERNATE_EXCHANGE).toString());
-                            final ExchangeImpl exchange =
-                                    (ExchangeImpl) _vhost.getExchange(exchangeId);
-                            queue.setAlternateExchange(exchange);
-                        }
-                        return queue;
-                    }
-                });
+            @Override
+            public Object answer(final InvocationOnMock invocation) throws Throwable
+            {
+                ConfiguredObjectRecord queueRecord = recoveredQueue.getValue();
+                AMQQueue queue = mock(AMQQueue.class);
+                UUID id = queueRecord.getId();
+                String name = (String) queueRecord.getAttributes().get("name");
+                when(queue.getId()).thenReturn(id);
+                when(queue.getName()).thenReturn(name);
+                when(_vhost.getQueue(eq(id))).thenReturn(queue);
+                when(_vhost.getQueue(eq(name))).thenReturn(queue);
 
+                UnresolvedConfiguredObject unresolved = mock(UnresolvedConfiguredObject.class);
+                when(unresolved.resolve()).thenReturn(queue);
+
+                Map args = queueRecord.getAttributes();
+                if (args.containsKey(Queue.ALTERNATE_EXCHANGE))
+                {
+                    final UUID exchangeId = UUID.fromString(args.get(Queue.ALTERNATE_EXCHANGE).toString());
+                    final ExchangeImpl exchange =
+                            _vhost.getExchange(exchangeId);
+                    when(queue.getAlternateExchange()).thenReturn(exchange);
+                }
+
+                return unresolved;
+            }
+        }).when(_queueFactory).recover(recoveredQueue.capture(), any(ConfiguredObject.class));
 
 
         DurableConfiguredObjectRecoverer[] recoverers = {

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java Fri Apr 18 13:37:32 2014
@@ -652,12 +652,6 @@ public class MockVirtualHost implements 
     }
 
     @Override
-    public AMQQueue restoreQueue(final Map<String, Object> attributes)
-    {
-        return null;
-    }
-
-    @Override
     public boolean getDefaultDeadLetterQueueEnabled()
     {
         return false;

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/VirtualHostQueueCreationTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/VirtualHostQueueCreationTest.java?rev=1588468&r1=1588467&r2=1588468&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/VirtualHostQueueCreationTest.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/VirtualHostQueueCreationTest.java Fri Apr 18 13:37:32 2014
@@ -33,6 +33,7 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.exchange.ExchangeImpl;
 import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.Exchange;
 import org.apache.qpid.server.model.LifetimePolicy;
 import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.model.VirtualHost;
@@ -153,21 +154,21 @@ public class VirtualHostQueueCreationTes
 
         attributes.put(Queue.ID, UUID.randomUUID());
         attributes.put(Queue.NAME, queueName);
-        attributes.put(Queue.CREATE_DLQ_ON_CREATION, true);
+        attributes.put(AbstractVirtualHost.CREATE_DLQ_ON_CREATION, true);
 
         AMQQueue queue = _virtualHost.createQueue(attributes);
 
-        ExchangeImpl altExchange = queue.getAlternateExchange();
+        Exchange altExchange = queue.getAlternateExchange();
         assertNotNull("Queue should have an alternate exchange as DLQ is enabled", altExchange);
         assertEquals("Alternate exchange name was not as expected", dlExchangeName, altExchange.getName());
-        assertEquals("Alternate exchange type was not as expected", ExchangeDefaults.FANOUT_EXCHANGE_CLASS, altExchange.getTypeName());
+        assertEquals("Alternate exchange type was not as expected", ExchangeDefaults.FANOUT_EXCHANGE_CLASS, altExchange.getType());
 
         assertNotNull("The alternate exchange was not registered as expected", _virtualHost.getExchange(dlExchangeName));
         assertEquals("The registered exchange was not the expected exchange instance", altExchange, _virtualHost.getExchange(dlExchangeName));
 
         AMQQueue dlQueue = _virtualHost.getQueue(dlQueueName);
         assertNotNull("The DLQ was not registered as expected", dlQueue);
-        assertTrue("DLQ should have been bound to the alternate exchange", altExchange.isBound(dlQueue));
+        assertTrue("DLQ should have been bound to the alternate exchange", ((ExchangeImpl)altExchange).isBound(dlQueue));
         assertNull("DLQ should have no alternate exchange", dlQueue.getAlternateExchange());
         assertEquals("DLQ should have a zero maximum delivery count", 0, dlQueue.getMaximumDeliveryAttempts());
 
@@ -192,23 +193,23 @@ public class VirtualHostQueueCreationTes
         Map<String,Object> attributes = new HashMap<String, Object>();
         attributes.put(Queue.ID, UUID.randomUUID());
         attributes.put(Queue.NAME, queueName);
-        attributes.put(Queue.CREATE_DLQ_ON_CREATION, true);
+        attributes.put(AbstractVirtualHost.CREATE_DLQ_ON_CREATION, true);
         attributes.put(Queue.MAXIMUM_DELIVERY_ATTEMPTS, 5);
 
         AMQQueue queue = _virtualHost.createQueue(attributes);
 
         assertEquals("Unexpected maximum delivery count", 5, queue.getMaximumDeliveryAttempts());
-        ExchangeImpl altExchange = queue.getAlternateExchange();
+        Exchange altExchange = queue.getAlternateExchange();
         assertNotNull("Queue should have an alternate exchange as DLQ is enabled", altExchange);
         assertEquals("Alternate exchange name was not as expected", dlExchangeName, altExchange.getName());
-        assertEquals("Alternate exchange type was not as expected", ExchangeDefaults.FANOUT_EXCHANGE_CLASS, altExchange.getTypeName());
+        assertEquals("Alternate exchange type was not as expected", ExchangeDefaults.FANOUT_EXCHANGE_CLASS, altExchange.getType());
 
         assertNotNull("The alternate exchange was not registered as expected", _virtualHost.getExchange(dlExchangeName));
         assertEquals("The registered exchange was not the expected exchange instance", altExchange, _virtualHost.getExchange(dlExchangeName));
 
         AMQQueue dlQueue = _virtualHost.getQueue(dlQueueName);
         assertNotNull("The DLQ was not registered as expected", dlQueue);
-        assertTrue("DLQ should have been bound to the alternate exchange", altExchange.isBound(dlQueue));
+        assertTrue("DLQ should have been bound to the alternate exchange", ((ExchangeImpl)altExchange).isBound(dlQueue));
         assertNull("DLQ should have no alternate exchange", dlQueue.getAlternateExchange());
         assertEquals("DLQ should have a zero maximum delivery count", 0, dlQueue.getMaximumDeliveryAttempts());
 
@@ -234,7 +235,7 @@ public class VirtualHostQueueCreationTes
 
         attributes.put(Queue.ID, UUID.randomUUID());
         attributes.put(Queue.NAME, queueName);
-        attributes.put(Queue.CREATE_DLQ_ON_CREATION, false);
+        attributes.put(AbstractVirtualHost.CREATE_DLQ_ON_CREATION, false);
 
         AMQQueue queue = _virtualHost.createQueue(attributes);
 
@@ -266,7 +267,7 @@ public class VirtualHostQueueCreationTes
         attributes.put(Queue.ID, UUID.randomUUID());
         attributes.put(Queue.NAME, queueName);
 
-        attributes.put(Queue.CREATE_DLQ_ON_CREATION, true);
+        attributes.put(AbstractVirtualHost.CREATE_DLQ_ON_CREATION, true);
         attributes.put(Queue.LIFETIME_POLICY, LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS);
 
         //create an autodelete queue
@@ -338,7 +339,7 @@ public class VirtualHostQueueCreationTes
         catch (Exception e)
         {
             assertTrue(e instanceof IllegalArgumentException);
-            assertEquals("Value for attribute name is not found", e.getMessage());
+            assertTrue(e.getMessage().startsWith("The name attribute is mandatory"));
         }
     }
 
@@ -359,7 +360,7 @@ public class VirtualHostQueueCreationTes
             attributes.put(Queue.ID, UUID.randomUUID());
             attributes.put(Queue.NAME, queueName);
 
-            attributes.put(Queue.CREATE_DLQ_ON_CREATION, true);
+            attributes.put(AbstractVirtualHost.CREATE_DLQ_ON_CREATION, true);
 
             _virtualHost.createQueue(attributes);
             fail("queue with DLQ name having more than 255 characters can not be created!");
@@ -389,7 +390,7 @@ public class VirtualHostQueueCreationTes
             attributes.put(Queue.ID, UUID.randomUUID());
             attributes.put(Queue.NAME, queueName);
 
-            attributes.put(Queue.CREATE_DLQ_ON_CREATION, (Object) true);
+            attributes.put(AbstractVirtualHost.CREATE_DLQ_ON_CREATION, (Object) true);
 
             _virtualHost.createQueue(attributes);
             fail("queue with DLE name having more than 255 characters can not be created!");



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


Mime
View raw message