qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject svn commit: r1327003 [3/6] - in /qpid/trunk/qpid/java: ./ bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/ bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/entry/ bdbstore/src/main/java/org/apache/qpid/server/store/berkeley...
Date Tue, 17 Apr 2012 09:01:51 GMT
Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java Tue Apr 17 09:01:44 2012
@@ -33,6 +33,7 @@ import org.apache.qpid.server.logging.ac
 import org.apache.qpid.server.logging.actors.ManagementActor;
 import org.apache.qpid.server.management.AMQManagedObject;
 import org.apache.qpid.server.management.ManagedObject;
+import org.apache.qpid.server.model.UUIDGenerator;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.AMQQueueFactory;
 import org.apache.qpid.server.queue.AMQQueueMBean;
@@ -48,6 +49,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 
 /**
  * This MBean implements the broker management interface and exposes the
@@ -171,8 +173,8 @@ public class AMQBrokerManagerMBean exten
                 Exchange exchange = _exchangeRegistry.getExchange(new AMQShortString(exchangeName));
                 if (exchange == null)
                 {
-                    exchange = _exchangeFactory.createExchange(new AMQShortString(exchangeName), new AMQShortString(type),
-                                                               durable, false, 0);
+                    exchange = _exchangeFactory.createExchange(new AMQShortString(exchangeName),
+                                                               new AMQShortString(type), durable, false, 0);
                     _exchangeRegistry.registerExchange(exchange);
                     if (durable)
                     {
@@ -244,45 +246,42 @@ public class AMQBrokerManagerMBean exten
     public void createNewQueue(String queueName, String owner, boolean durable, Map<String,Object> arguments) throws JMException
     {
         final AMQShortString queueNameAsAMQShortString = new AMQShortString(queueName);
-        AMQQueue queue = _queueRegistry.getQueue(queueNameAsAMQShortString);
-        if (queue != null)
+        synchronized (_queueRegistry)
         {
-            throw new JMException("The queue \"" + queueName + "\" already exists.");
-        }
-
-        CurrentActor.set(new ManagementActor(getLogActor().getRootMessageLogger()));
-        try
-        {
-            AMQShortString ownerShortString = null;
-            if (owner != null)
+            AMQQueue queue = _queueRegistry.getQueue(queueNameAsAMQShortString);
+            if (queue != null)
             {
-                ownerShortString = new AMQShortString(owner);
+                throw new JMException("The queue \"" + queueName + "\" already exists.");
             }
 
-            FieldTable args = null;
-            if(arguments != null)
+            CurrentActor.set(new ManagementActor(getLogActor().getRootMessageLogger()));
+            try
             {
-                args = FieldTable.convertToFieldTable(arguments);
-            }
-            final VirtualHost virtualHost = getVirtualHost();
+                FieldTable args = null;
+                if(arguments != null)
+                {
+                    args = FieldTable.convertToFieldTable(arguments);
+                }
+                final VirtualHost virtualHost = getVirtualHost();
+
+                queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateUUID(), queueName, durable, owner,
+                                                           false, false, getVirtualHost(), arguments);
+                if (queue.isDurable() && !queue.isAutoDelete())
+                {
+                    getVirtualHost().getMessageStore().createQueue(queue, args);
+                }
 
-            queue = AMQQueueFactory.createAMQQueueImpl(queueNameAsAMQShortString, durable, ownerShortString,
-                                                       false, false, getVirtualHost(), args);
-            if (queue.isDurable() && !queue.isAutoDelete())
+                virtualHost.getBindingFactory().addBinding(queueName, queue, _exchangeRegistry.getDefaultExchange(), null);
+            }
+            catch (AMQException ex)
             {
-                getVirtualHost().getMessageStore().createQueue(queue, args);
+                JMException jme = new JMException(ex.toString());
+                throw new MBeanException(jme, "Error in creating queue " + queueName);
+            }
+            finally
+            {
+                CurrentActor.remove();
             }
-
-            virtualHost.getBindingFactory().addBinding(queueName, queue, _exchangeRegistry.getDefaultExchange(), null);
-        }
-        catch (AMQException ex)
-        {
-            JMException jme = new JMException(ex.toString());
-            throw new MBeanException(jme, "Error in creating queue " + queueName);
-        }
-        finally
-        {
-            CurrentActor.remove();
         }
     }
 

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/Binding.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/Binding.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/Binding.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/Binding.java Tue Apr 17 09:01:44 2012
@@ -117,7 +117,7 @@ public class Binding
 
     public String toString()
     {
-        return "Binding{bindingKey="+_bindingKey+", exchange="+_exchange+", queue="+_queue+"}";
+        return "Binding{bindingKey="+_bindingKey+", exchange="+_exchange+", queue="+_queue+", id= " + _id + " }";
     }
 
 }

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/BindingFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/BindingFactory.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/BindingFactory.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/binding/BindingFactory.java Tue Apr 17 09:01:44 2012
@@ -24,7 +24,6 @@ import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQInternalException;
 import org.apache.qpid.AMQSecurityException;
 import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.server.configuration.BindingConfig;
 import org.apache.qpid.server.configuration.BindingConfigType;
 import org.apache.qpid.server.configuration.ConfigStore;
@@ -33,11 +32,13 @@ import org.apache.qpid.server.exchange.E
 import org.apache.qpid.server.logging.actors.CurrentActor;
 import org.apache.qpid.server.logging.messages.BindingMessages;
 import org.apache.qpid.server.logging.subjects.BindingLogSubject;
+import org.apache.qpid.server.model.UUIDGenerator;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
 import java.util.Collections;
 import java.util.Map;
+import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 
 public class BindingFactory
@@ -57,9 +58,9 @@ public class BindingFactory
         //TODO : persist creation time
         private long _createTime = System.currentTimeMillis();
 
-        private BindingImpl(String bindingKey, final AMQQueue queue, final Exchange exchange, final Map<String, Object> arguments)
+        private BindingImpl(UUID id, String bindingKey, final AMQQueue queue, final Exchange exchange, final Map<String, Object> arguments)
         {
-            super(queue.getVirtualHost().getConfigStore().createId(), bindingKey, queue, exchange, arguments);
+            super(id, bindingKey, queue, exchange, arguments);
             _logSubject = new BindingLogSubject(bindingKey,exchange,queue);
 
         }
@@ -116,19 +117,19 @@ public class BindingFactory
 
     public boolean addBinding(String bindingKey, AMQQueue queue, Exchange exchange, Map<String, Object> arguments) throws AMQSecurityException, AMQInternalException 
     {
-        return makeBinding(bindingKey, queue, exchange, arguments, false, false);
+        return makeBinding(null, bindingKey, queue, exchange, arguments, false, false);
     }
 
 
-    public boolean replaceBinding(final String bindingKey,
+    public boolean replaceBinding(final UUID id, final String bindingKey,
                                final AMQQueue queue,
                                final Exchange exchange,
                                final Map<String, Object> arguments) throws AMQSecurityException, AMQInternalException
     {
-        return makeBinding(bindingKey, queue, exchange, arguments, false, true);
+        return makeBinding(id, bindingKey, queue, exchange, arguments, false, true);
     }
 
-    private boolean makeBinding(String bindingKey, AMQQueue queue, Exchange exchange, Map<String, Object> arguments, boolean restore, boolean force) throws AMQSecurityException, AMQInternalException
+    private boolean makeBinding(UUID id, String bindingKey, AMQQueue queue, Exchange exchange, Map<String, Object> arguments, boolean restore, boolean force) throws AMQSecurityException, AMQInternalException
     {
         assert queue != null;
         final Exchange defaultExchange = _virtualHost.getExchangeRegistry().getDefaultExchange();
@@ -163,9 +164,12 @@ public class BindingFactory
             }
         }
 
-        
-        BindingImpl b = new BindingImpl(bindingKey,queue,exchange,arguments);
-        BindingImpl existingMapping = _bindings.putIfAbsent(b,b);
+        if (id == null)
+        {
+            id = UUIDGenerator.generateUUID();
+        }
+        BindingImpl b = new BindingImpl(id, bindingKey, queue, exchange, arguments);
+        BindingImpl existingMapping = _bindings.putIfAbsent(b, b);
         if (existingMapping == null || force)
         {
             if (existingMapping != null)
@@ -175,7 +179,7 @@ public class BindingFactory
 
             if (b.isDurable() && !restore)
             {
-                _virtualHost.getMessageStore().bindQueue(exchange,new AMQShortString(bindingKey),queue,FieldTable.convertToFieldTable(arguments));
+                _virtualHost.getMessageStore().bindQueue(b);
             }
 
             queue.addQueueDeleteTask(b);
@@ -198,9 +202,9 @@ public class BindingFactory
         return _virtualHost.getConfigStore();
     }
 
-    public void restoreBinding(final String bindingKey, final AMQQueue queue, final Exchange exchange, final Map<String, Object> argumentMap) throws AMQSecurityException, AMQInternalException
+    public void restoreBinding(final UUID id, final String bindingKey, final AMQQueue queue, final Exchange exchange, final Map<String, Object> argumentMap) throws AMQSecurityException, AMQInternalException
     {
-        makeBinding(bindingKey,queue,exchange,argumentMap,true, false);
+        makeBinding(id, bindingKey,queue,exchange,argumentMap,true, false);
     }
 
     public void removeBinding(final Binding b) throws AMQSecurityException, AMQInternalException
@@ -239,7 +243,7 @@ public class BindingFactory
             }
         }
         
-        BindingImpl b = _bindings.remove(new BindingImpl(bindingKey,queue,exchange,arguments));
+        BindingImpl b = _bindings.remove(new BindingImpl(null, bindingKey,queue,exchange,arguments));
 
         if (b != null)
         {
@@ -250,10 +254,7 @@ public class BindingFactory
 
             if (b.isDurable())
             {
-                _virtualHost.getMessageStore().unbindQueue(exchange,
-                                         new AMQShortString(bindingKey),
-                                         queue,
-                                         FieldTable.convertToFieldTable(arguments));
+                _virtualHost.getMessageStore().unbindQueue(b);
             }
             b.logDestruction();
             getConfigStore().removeConfiguredObject(b);
@@ -280,7 +281,7 @@ public class BindingFactory
             arguments = Collections.emptyMap();
         }
 
-        BindingImpl b = new BindingImpl(bindingKey,queue,exchange,arguments);
+        BindingImpl b = new BindingImpl(null, bindingKey,queue,exchange,arguments);
         return _bindings.get(b);
     }
 }

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/AbstractExchange.java Tue Apr 17 09:01:44 2012
@@ -114,7 +114,7 @@ public abstract class AbstractExchange i
      */
     protected abstract AbstractExchangeMBean createMBean() throws JMException;
 
-    public void initialise(VirtualHost host, AMQShortString name, boolean durable, int ticket, boolean autoDelete)
+    public void initialise(UUID id, VirtualHost host, AMQShortString name, boolean durable, int ticket, boolean autoDelete)
             throws AMQException
     {
         _virtualHost = host;
@@ -123,7 +123,7 @@ public abstract class AbstractExchange i
         _autoDelete = autoDelete;
         _ticket = ticket;
 
-        _id = getConfigStore().createId();
+        _id = id;
 
         getConfigStore().addConfiguredObject(this);
         createAndRegisterMBean();

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeFactory.java Tue Apr 17 09:01:44 2012
@@ -25,9 +25,11 @@ import org.apache.log4j.Logger;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQSecurityException;
 import org.apache.qpid.AMQUnknownExchangeType;
+import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.qmf.ManagementExchange;
 import org.apache.qpid.server.configuration.VirtualHostConfiguration;
+import org.apache.qpid.server.model.UUIDGenerator;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
@@ -35,6 +37,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.UUID;
 
 public class DefaultExchangeFactory implements ExchangeFactory
 {
@@ -76,17 +79,29 @@ public class DefaultExchangeFactory impl
         
         return publicTypes;
     }
-    
-    
 
     public Exchange createExchange(String exchange, String type, boolean durable, boolean autoDelete)
-            throws AMQException
+    throws AMQException
     {
         return createExchange(new AMQShortString(exchange), new AMQShortString(type), durable, autoDelete, 0);
     }
 
-    public Exchange createExchange(AMQShortString exchange, AMQShortString type, boolean durable, boolean autoDelete,
-                                   int ticket)
+    public Exchange createExchange(UUID id, String exchange, String type, boolean durable, boolean autoDelete)
+            throws AMQException
+    {
+        return createExchange(id, new AMQShortString(exchange), new AMQShortString(type), durable, autoDelete, 0);
+    }
+
+    public Exchange createExchange(AMQShortString exchange, AMQShortString type, boolean durable,
+                                   boolean autoDelete, int ticket)
+            throws AMQException
+    {
+        UUID id = UUIDGenerator.generateExchangeUUID(exchange.asString(), _host.getName());
+        return createExchange(id, exchange, type, durable, autoDelete, ticket);
+    }
+
+    public Exchange createExchange(UUID id, AMQShortString exchange, AMQShortString type, boolean durable,
+                                   boolean autoDelete, int ticket)
             throws AMQException
     {
         // Check access
@@ -102,7 +117,7 @@ public class DefaultExchangeFactory impl
             throw new AMQUnknownExchangeType("Unknown exchange type: " + type,null);
         }
         
-        Exchange e = exchType.newInstance(_host, exchange, durable, ticket, autoDelete);
+        Exchange e = exchType.newInstance(id, _host, exchange, durable, ticket, autoDelete);
         return e;
     }
 

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java Tue Apr 17 09:01:44 2012
@@ -30,6 +30,7 @@ import org.apache.qpid.server.store.Dura
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
 import java.util.Collection;
+import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
@@ -174,4 +175,25 @@ public class DefaultExchangeRegistry imp
         _exchangeMapStr.clear();
     }
 
+    @Override
+    public synchronized Exchange getExchange(UUID exchangeId)
+    {
+        if (exchangeId == null)
+        {
+            return getDefaultExchange();
+        }
+        else
+        {
+            Collection<Exchange> exchanges = _exchangeMap.values();
+            for (Exchange exchange : exchanges)
+            {
+                if (exchange.getId().equals(exchangeId))
+                {
+                    return exchange;
+                }
+            }
+            return null;
+        }
+    }
+
 }

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/DirectExchange.java Tue Apr 17 09:01:44 2012
@@ -36,6 +36,7 @@ import javax.management.JMException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArraySet;
 
@@ -103,14 +104,14 @@ public class DirectExchange extends Abst
             return DirectExchange.class;
         }
 
-        public DirectExchange newInstance(VirtualHost host,
+        public DirectExchange newInstance(UUID id, VirtualHost host,
                                             AMQShortString name,
                                             boolean durable,
                                             int ticket,
                                             boolean autoDelete) throws AMQException
         {
             DirectExchange exch = new DirectExchange();
-            exch.initialise(host,name,durable,ticket,autoDelete);
+            exch.initialise(id, host,name,durable,ticket,autoDelete);
             return exch;
         }
 

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/Exchange.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/Exchange.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/Exchange.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/Exchange.java Tue Apr 17 09:01:44 2012
@@ -36,6 +36,7 @@ import javax.management.JMException;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 
 public interface Exchange extends ExchangeReferrer, ExchangeConfig
 {
@@ -50,7 +51,7 @@ public interface Exchange extends Exchan
 
     AMQShortString getTypeShortString();
 
-    void initialise(VirtualHost host, AMQShortString name, boolean durable, int ticket, boolean autoDelete)
+    void initialise(UUID id, VirtualHost host, AMQShortString name, boolean durable, int ticket, boolean autoDelete)
             throws AMQException, JMException;
 
     boolean isDurable();

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java Tue Apr 17 09:01:44 2012
@@ -25,6 +25,7 @@ import org.apache.qpid.framing.AMQShortS
 import org.apache.qpid.server.configuration.VirtualHostConfiguration;
 
 import java.util.Collection;
+import java.util.UUID;
 
 
 public interface ExchangeFactory
@@ -40,4 +41,10 @@ public interface ExchangeFactory
     Collection<ExchangeType<? extends Exchange>> getPublicCreatableTypes();
 
     Exchange createExchange(String exchange, String type, boolean durable, boolean autoDelete) throws AMQException;
+
+    Exchange createExchange(UUID id, String exchange, String type, boolean durable, boolean autoDelete) throws AMQException;
+
+    Exchange createExchange(UUID id, AMQShortString exchange, AMQShortString type, boolean durable,
+                            boolean autoDelete, int ticket)
+            throws AMQException;
 }

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeInitialiser.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeInitialiser.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeInitialiser.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeInitialiser.java Tue Apr 17 09:01:44 2012
@@ -20,6 +20,7 @@
  */
 package org.apache.qpid.server.exchange;
 
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java Tue Apr 17 09:01:44 2012
@@ -24,6 +24,7 @@ import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 
 import java.util.Collection;
+import java.util.UUID;
 
 
 public interface ExchangeRegistry
@@ -54,4 +55,6 @@ public interface ExchangeRegistry
     void unregisterExchange(String exchange, boolean ifUnused)  throws ExchangeInUseException, AMQException;
 
     void clearAndUnregisterMbeans();
+
+    Exchange getExchange(UUID exchangeId);
 }

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeType.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeType.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeType.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/ExchangeType.java Tue Apr 17 09:01:44 2012
@@ -20,6 +20,8 @@
  */
 package org.apache.qpid.server.exchange;
 
+import java.util.UUID;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -29,7 +31,7 @@ public interface ExchangeType<T extends 
 {
     public AMQShortString getName();
     public Class<T> getExchangeClass();
-    public T newInstance(VirtualHost host, AMQShortString name,
+    public T newInstance(UUID id, VirtualHost host, AMQShortString name,
                          boolean durable, int ticket, boolean autoDelete) throws AMQException;
     public AMQShortString getDefaultExchangeName();
 }

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/FanoutExchange.java Tue Apr 17 09:01:44 2012
@@ -34,6 +34,7 @@ import org.apache.qpid.server.virtualhos
 
 import javax.management.JMException;
 import java.util.ArrayList;
+import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 
 public class FanoutExchange extends AbstractExchange
@@ -65,14 +66,14 @@ public class FanoutExchange extends Abst
     		return FanoutExchange.class;
     	}
 
-    	public FanoutExchange newInstance(VirtualHost host,
+        public FanoutExchange newInstance(UUID id, VirtualHost host,
     									  AMQShortString name,
     									  boolean durable,
     									  int ticket,
     									  boolean autoDelete) throws AMQException
     	{
     		FanoutExchange exch = new FanoutExchange();
-    		exch.initialise(host, name, durable, ticket, autoDelete);
+            exch.initialise(id, host, name, durable, ticket, autoDelete);
     		return exch;
     	}
 

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java Tue Apr 17 09:01:44 2012
@@ -37,6 +37,7 @@ import javax.management.JMException;
 import java.util.ArrayList;
 import java.util.LinkedHashSet;
 import java.util.Map;
+import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.CopyOnWriteArraySet;
@@ -93,12 +94,12 @@ public class HeadersExchange extends Abs
             return HeadersExchange.class;
         }
 
-        public HeadersExchange newInstance(VirtualHost host, AMQShortString name, boolean durable, int ticket,
+        public HeadersExchange newInstance(UUID id, VirtualHost host, AMQShortString name, boolean durable, int ticket,
                 boolean autoDelete) throws AMQException
         {
             HeadersExchange exch = new HeadersExchange();
 
-            exch.initialise(host, name, durable, ticket, autoDelete);
+            exch.initialise(id, host, name, durable, ticket, autoDelete);
             return exch;
         }
 

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java Tue Apr 17 09:01:44 2012
@@ -27,6 +27,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
+import java.util.UUID;
 import java.util.WeakHashMap;
 import java.util.concurrent.ConcurrentHashMap;
 import javax.management.JMException;
@@ -70,14 +71,14 @@ public class TopicExchange extends Abstr
             return TopicExchange.class;
         }
 
-        public TopicExchange newInstance(VirtualHost host,
+        public TopicExchange newInstance(UUID id, VirtualHost host,
                                             AMQShortString name,
                                             boolean durable,
                                             int ticket,
                                             boolean autoDelete) throws AMQException
         {
             TopicExchange exch = new TopicExchange();
-            exch.initialise(host, name, durable, ticket, autoDelete);
+            exch.initialise(id, host, name, durable, ticket, autoDelete);
             return exch;
         }
 

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/federation/Bridge.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/federation/Bridge.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/federation/Bridge.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/federation/Bridge.java Tue Apr 17 09:01:44 2012
@@ -767,13 +767,13 @@ public class Bridge implements BridgeCon
 
             try
             {
-                _queue = AMQQueueFactory.createAMQQueueImpl(_tmpQueueName,
+                _queue = AMQQueueFactory.createAMQQueueImpl(null,
+                                                        _tmpQueueName,
                                                         isDurable(),
                                                         _link.getFederationTag(),
                                                         false,
                                                         false,
-                                                        getVirtualHost(),
-                                                        options);
+                                                        getVirtualHost(), options);
             }
             catch (AMQException e)
             {

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueBindHandler.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueBindHandler.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueBindHandler.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueBindHandler.java Tue Apr 17 09:01:44 2012
@@ -134,7 +134,7 @@ public class QueueBindHandler implements
                     Map<String, Object> oldArgs = oldBinding.getArguments();
                     if((oldArgs == null && !arguments.isEmpty()) || (oldArgs != null && !oldArgs.equals(arguments)))
                     {
-                        virtualHost.getBindingFactory().replaceBinding(bindingKey, queue, exch, arguments);    
+                        virtualHost.getBindingFactory().replaceBinding(oldBinding.getId(), bindingKey, queue, exch, arguments);
                     }
                 }
             }

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/handler/QueueDeclareHandler.java Tue Apr 17 09:01:44 2012
@@ -24,6 +24,7 @@ import org.apache.log4j.Logger;
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.FieldTable;
 import org.apache.qpid.framing.MethodRegistry;
 import org.apache.qpid.framing.QueueDeclareBody;
 import org.apache.qpid.framing.QueueDeclareOkBody;
@@ -31,6 +32,7 @@ import org.apache.qpid.protocol.AMQConst
 import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.exchange.ExchangeRegistry;
+import org.apache.qpid.server.model.UUIDGenerator;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 import org.apache.qpid.server.protocol.AMQSessionModel;
 import org.apache.qpid.server.queue.AMQQueue;
@@ -43,6 +45,7 @@ import org.apache.qpid.server.store.Dura
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
 import java.util.Collections;
+import java.util.Map;
 import java.util.UUID;
 
 public class QueueDeclareHandler implements StateAwareMethodListener<QueueDeclareBody>
@@ -219,10 +222,11 @@ public class QueueDeclareHandler impleme
             throws AMQException
     {
         final QueueRegistry registry = virtualHost.getQueueRegistry();
-        AMQShortString owner = body.getExclusive() ? session.getContextKey() : null;
+        String owner = body.getExclusive() ? AMQShortString.toString(session.getContextKey()) : null;
 
-        final AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(queueName, body.getDurable(), owner, body.getAutoDelete(),
-                                                                  body.getExclusive(),virtualHost, body.getArguments());
+        Map<String, Object> arguments = FieldTable.convertToMap(body.getArguments());
+        final AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateUUID(), AMQShortString.toString(queueName), body.getDurable(), owner, body.getAutoDelete(),
+                                                                  body.getExclusive(),virtualHost, arguments);
 
         if (body.getExclusive() && !body.getDurable())
         {

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Binding.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Binding.java?rev=1327003&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Binding.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Binding.java Tue Apr 17 09:01:44 2012
@@ -0,0 +1,75 @@
+/*
+ *
+ * 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 java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+public interface Binding extends ConfiguredObject
+{
+
+    public String MATCHED_BYTES = "matchedBytes";
+    public String MATCHED_MESSAGES = "matchedMessages";
+    public String STATE_CHANGED = "stateChanged";
+
+    public static final Collection<String> AVAILABLE_STATISTICS =
+            Collections.unmodifiableCollection(
+                    Arrays.asList(
+            MATCHED_BYTES,
+            MATCHED_MESSAGES,
+            STATE_CHANGED));
+
+
+    public String ARGUMENTS = "arguments";
+    public String CREATED = "created";
+    public String DURABLE = "durable";
+    public String ID = "id";
+    public String LIFETIME_POLICY = "lifetimePolicy";
+    public String NAME = "name";
+    public String STATE = "state";
+    public String TIME_TO_LIVE = "timeToLive";
+    public String UPDATED = "updated";
+    public String QUEUE = "queue";
+    public String EXCHANGE = "exchange";
+
+    public static final Collection<String> AVAILABLE_ATTRIBUTES =
+            Collections.unmodifiableCollection(
+                    Arrays.asList(ID,
+                                  NAME,
+                                  STATE,
+                                  DURABLE,
+                                  LIFETIME_POLICY,
+                                  TIME_TO_LIVE,
+                                  CREATED,
+                                  UPDATED,
+                                  EXCHANGE,
+                                  QUEUE,
+                                  ARGUMENTS)
+            );
+
+
+
+    Map<String,Object> getArguments();
+
+    void delete();
+}

Copied: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfigurationChangeListener.java (from r1327000, qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/entry/QueueEntryKey.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfigurationChangeListener.java?p2=qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfigurationChangeListener.java&p1=qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/entry/QueueEntryKey.java&r1=1327000&r2=1327003&rev=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/entry/QueueEntryKey.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfigurationChangeListener.java Tue Apr 17 09:01:44 2012
@@ -18,28 +18,21 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.store.berkeleydb.entry;
+package org.apache.qpid.server.model;
 
-import org.apache.qpid.framing.AMQShortString;
-
-public class QueueEntryKey
+public interface ConfigurationChangeListener
 {
-    private AMQShortString _queueName;
-    private long _messageId;
+    /**
+     * Inform the listener that the passed object has changed state
+     *
+     * @param object the object whose state has changed
+     * @param oldState the state prior to the change
+     * @param newState the state after the change
+     */
+    void stateChanged(ConfiguredObject object, State oldState, State newState);
 
-    public QueueEntryKey(AMQShortString queueName, long messageId)
-    {
-        _queueName = queueName;
-        _messageId = messageId;
-    }
+    void childAdded(ConfiguredObject object, ConfiguredObject child);
 
-    public AMQShortString getQueueName()
-    {
-        return _queueName;
-    }
+    void childRemoved(ConfiguredObject object, ConfiguredObject child);
 
-    public long getMessageId()
-    {
-        return _messageId;
-    }
 }

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java?rev=1327003&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java Tue Apr 17 09:01:44 2012
@@ -0,0 +1,229 @@
+/*
+ *
+ * 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 java.security.AccessControlException;
+import java.util.Collection;
+import java.util.UUID;
+
+public interface ConfiguredObject
+{
+
+    /**
+     * Get the universally unique identifier for the object
+     *
+     * @return the objects id
+     */
+    UUID getId();
+
+    /**
+     * Get the name of the object
+     *
+     * @return the name of the object
+     */
+    String getName();
+
+
+    /**
+     * Attempt to change the name of the object
+     *
+     * Request a change to the name of the object.  The caller must pass in the name it believes the object currently
+     * has. If the current name differes from this expected value, then no name change will occur
+     *
+     * @param currentName the name the caller believes the object to have
+     * @param desiredName the name the caller would like the object to have
+     * @return the new name for the object
+     * @throws IllegalStateException if the name of the object may not be changed in in the current state
+     * @throws AccessControlException if the current context does not have permission to change the name
+     * @throws IllegalArgumentException if the provided name is not legal
+     * @throws NullPointerException if the desired name is null
+     */
+    String setName(String currentName, String desiredName) throws IllegalStateException,
+                                                                  AccessControlException;
+
+
+    /**
+     * Get the desired state of the object.
+     *
+     * This is the state set at the object itself, however the object
+     * may not be able attain this state if one of its ancestors is in a different state (in particular a descendant
+     * object may not be ACTIVE if all of its ancestors are not also ACTIVE).
+     *
+     * @return the desired state of the object
+     */
+    State getDesiredState();
+
+    /**
+     * Change the desired state of the object
+     *
+     * Request a change to the current state. The caller must pass in the state it believe the object to be in, if
+     * this differs from the current desired state when the object evalues the request, then no state change will occur.
+     *
+     * @param currentState the state the caller believes the object to be in
+     * @param desiredState the state the caller wishes the object to attain
+     * @return the new current state
+     * @throws IllegalStateTransitionException  the requested state tranisition is invalid
+     * @throws AccessControlException the current context does not have sufficeint permissions to change the state
+     */
+    State setDesiredState(State currentState, State desiredState) throws IllegalStateTransitionException,
+                                                                         AccessControlException;
+
+    /**
+     * Get the actual state of the object.
+     *
+     * This state is derived fromt the desired state of the object itself and
+     * the actual state of its parents. If an object "desires" to be ACTIVE, but one of its parents is STOPPED, then
+     * the actual state of the object will be STOPPED
+     *
+     * @return the actual state of the object
+     */
+    State getActualState();
+
+
+    /**
+     * Add a listener which will be informed of all changes to this configuration object
+     *
+     * @param listener the listener to add
+     */
+    void addChangeListener(ConfigurationChangeListener listener);
+
+    /**
+     * Remove a change listener
+     *
+     *
+     * @param listener the listener to remove
+     * @return true iff a listener was removed
+     */
+    boolean removeChangeListener(ConfigurationChangeListener listener);
+
+    /**
+     * Get the parent of the given type for this object
+     *
+     * @param clazz the class of parent being asked for
+     * @return the objects parent
+     */
+    <T extends ConfiguredObject> T getParent(Class<T> clazz);
+
+
+    /**
+     * Returns whether the the object configuration is durably stored
+     *
+     * @return the durablity
+     */
+    boolean isDurable();
+
+    /**
+     * Sets the durability of the object
+     *
+     * @param durable true iff the caller wishes the object to store its configuration durably
+     *
+     * @throws IllegalStateException if the durability cannot be changed in the current state
+     * @throws AccessControlException if the current context does not have sufficient permission to change the durability
+     * @throws IllegalArgumentException if the object does not support the requested durability
+     */
+    void setDurable(boolean durable) throws IllegalStateException,
+                                            AccessControlException,
+                                            IllegalArgumentException;
+
+    /**
+     * Return the lifetime policy for the object
+     *
+     * @return the lifetime policy
+     */
+    LifetimePolicy getLifetimePolicy();
+
+    /**
+     * Set the lifetime policy of the object
+     *
+     * @param expected The lifetime policy the caller believes the object currently has
+     * @param desired The lifetime policy the caller desires the object to have
+     * @return the new lifetime policy
+     * @throws IllegalStateException if the lifetime policy cannot be changed in the current state
+     * @throws AccessControlException if the caller does not have permission to change the lifetime policy
+     * @throws IllegalArgumentException if the object does not support the requested lifetime policy
+     */
+    LifetimePolicy setLifetimePolicy(LifetimePolicy expected, LifetimePolicy desired) throws IllegalStateException,
+                                                                                             AccessControlException,
+                                                                                             IllegalArgumentException;
+
+    /**
+     * Get the time the object will live once the lifetime policy conditions are no longer fulfilled
+     *
+     * @return the time to live
+     */
+    long getTimeToLive();
+
+    /**
+     * Set the ttl value
+     *
+     * @param expected the ttl the caller believes the object currently has
+     * @param desired the ttl value the caller
+     * @return the new ttl value
+     * @throws IllegalStateException if the ttl cannot be set in the current state
+     * @throws AccessControlException if the caller does not have permission to change the ttl
+     * @throws IllegalArgumentException if the object does not support the requested ttl value
+     */
+    long setTimeToLive(long expected, long desired) throws IllegalStateException,
+                                                           AccessControlException,
+                                                           IllegalArgumentException;
+
+    /**
+     * Get the names of attributes that are set on this object
+     *
+     * Not that the returned collection is correct at the time the method is called, but will not reflect future
+     * additions or removals when they occur
+     *
+     * @return the collection of attribute names
+     */
+    Collection<String> getAttributeNames();
+
+
+    /**
+     * Return the value for the given attribute
+     *
+     * @param name the name of the attribute
+     * @return the value of the attribute at the object (or null if the attribute is not set
+     */
+    Object getAttribute(String name);
+
+    /**
+     * Set the value of an attribute
+     *
+     * @param name the name of the attribute to be set
+     * @param expected the value the caller believes the attribute currently has (or null if it is expected to be unset)
+     * @param desired the desired value for the attribute (or null to unset the attribute)
+     * @return the new value for the given attribute
+     * @throws IllegalStateException if the attribute cannot be set while the object is in its current state
+     * @throws AccessControlException if the caller does not have permission to alter the value of the attribute
+     * @throws IllegalArgumentException if the provided value is not valid for the given argument
+     */
+    Object setAttribute(String name, Object expected, Object desired) throws IllegalStateException,
+                                                                             AccessControlException,
+                                                                             IllegalArgumentException;
+
+
+    /**
+     * Return the Statistics holder for the ConfiguredObject
+     *
+     * @return the Statistics holder for the ConfiguredObject (or null if none exists)
+     */
+    Statistics getStatistics();
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Consumer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Consumer.java?rev=1327003&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Consumer.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Consumer.java Tue Apr 17 09:01:44 2012
@@ -0,0 +1,73 @@
+/*
+ *
+ * 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 java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+public interface Consumer extends ConfiguredObject
+{
+    public String DISTRIBUTION_MODE = "distributionMode";
+    public String EXCLUSIVE = "exclusive";
+    public String NO_LOCAL = "noLocal";
+    public String SELECTOR = "selector";
+    public String SETTLEMENT_MODE = "settlementMode";
+    public String CREATED = "created";
+    public String DURABLE = "durable";
+    public String ID = "id";
+    public String LIFETIME_POLICY = "lifetimePolicy";
+    public String NAME = "name";
+    public String STATE = "state";
+    public String TIME_TO_LIVE = "timeToLive";
+    public String UPDATED = "updated";
+
+    public Collection<String> AVAILABLE_ATTRIBUTES =
+            Collections.unmodifiableCollection(
+                    Arrays.asList(ID,
+                                  NAME,
+                                  STATE,
+                                  DURABLE,
+                                  LIFETIME_POLICY,
+                                  TIME_TO_LIVE,
+                                  CREATED,
+                                  UPDATED,
+                                  DISTRIBUTION_MODE,
+                                  SETTLEMENT_MODE,
+                                  EXCLUSIVE,
+                                  NO_LOCAL,
+                                  SELECTOR));
+
+    public String BYTES_OUT = "bytesOut";
+    public String MESSAGES_OUT = "messagesOut";
+    public String STATE_CHANGED = "stateChanged";
+    public String UNACKNOWLEDGED_BYTES = "unacknowledgedBytes";
+    public String UNACKNOWLEDGED_MESSAGES = "unacknowledgedMessages";
+
+    public Collection<String> AVAILABLE_STATISTICS =
+            Collections.unmodifiableCollection(
+                    Arrays.asList(BYTES_OUT,
+                                  MESSAGES_OUT,
+                                  STATE_CHANGED,
+                                  UNACKNOWLEDGED_BYTES,
+                                  UNACKNOWLEDGED_MESSAGES)
+            );
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Exchange.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Exchange.java?rev=1327003&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Exchange.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Exchange.java Tue Apr 17 09:01:44 2012
@@ -0,0 +1,91 @@
+/*
+ *
+ * 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 java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+public interface Exchange extends ConfiguredObject
+{
+    String BINDING_COUNT = "bindingCount";
+    String BYTES_DROPPED = "bytesDropped";
+    String BYTES_IN      = "bytesIn";
+    String MESSAGES_DROPPED = "messagesDropped";
+    String MESSAGES_IN      = "messagesIn";
+    String PRODUCER_COUNT   = "producerCount";
+    String STATE_CHANGED    = "stateChanged";
+
+    public static final Collection<String> AVAILABLE_STATISTICS =
+            Collections.unmodifiableList(
+                    Arrays.asList(BINDING_COUNT,
+                                  BYTES_DROPPED,
+                                  BYTES_IN,
+                                  MESSAGES_DROPPED,
+                                  MESSAGES_IN,
+                                  PRODUCER_COUNT,
+                                  STATE_CHANGED));
+
+    String CREATED                              = "created";
+    String DURABLE                              = "durable";
+    String ID                                   = "id";
+    String LIFETIME_POLICY                      = "lifetimePolicy";
+    String NAME                                 = "name";
+    String STATE                                = "state";
+    String TIME_TO_LIVE                         = "timeToLive";
+    String UPDATED                              = "updated";
+    String ALTERNATE_EXCHANGE                   = "alternateExchange";
+    String TYPE                                 = "type";
+
+    // Attributes
+    public static final Collection<String> AVAILABLE_ATTRIBUTES =
+            Collections.unmodifiableList(
+                    Arrays.asList(
+                            ID,
+                            NAME,
+                            STATE,
+                            DURABLE,
+                            LIFETIME_POLICY,
+                            TIME_TO_LIVE,
+                            CREATED,
+                            UPDATED,
+                            ALTERNATE_EXCHANGE,
+                            TYPE
+                    ));
+
+    String getExchangeType();
+
+    //children
+    Collection<Binding> getBindings();
+    Collection<Publisher> getPublishers();
+
+    //operations
+    Binding createBinding(String bindingKey,
+                          Queue queue,
+                          Map<String,Object> bindingArguments,
+                          Map<String, Object> attributes);
+
+
+    // Statistics
+
+    void delete();
+}

Copied: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/IllegalStateTransitionException.java (from r1327000, qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/entry/QueueEntryKey.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/IllegalStateTransitionException.java?p2=qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/IllegalStateTransitionException.java&p1=qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/entry/QueueEntryKey.java&r1=1327000&r2=1327003&rev=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/entry/QueueEntryKey.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/IllegalStateTransitionException.java Tue Apr 17 09:01:44 2012
@@ -18,28 +18,26 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.store.berkeleydb.entry;
+package org.apache.qpid.server.model;
 
-import org.apache.qpid.framing.AMQShortString;
-
-public class QueueEntryKey
+public class IllegalStateTransitionException extends RuntimeException
 {
-    private AMQShortString _queueName;
-    private long _messageId;
+    public IllegalStateTransitionException()
+    {
+    }
 
-    public QueueEntryKey(AMQShortString queueName, long messageId)
+    public IllegalStateTransitionException(final String message)
     {
-        _queueName = queueName;
-        _messageId = messageId;
+        super(message);
     }
 
-    public AMQShortString getQueueName()
+    public IllegalStateTransitionException(final String message, final Throwable cause)
     {
-        return _queueName;
+        super(message, cause);
     }
 
-    public long getMessageId()
+    public IllegalStateTransitionException(final Throwable cause)
     {
-        return _messageId;
+        super(cause);
     }
 }

Copied: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/LifetimePolicy.java (from r1327000, qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/StoreUpgrade.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/LifetimePolicy.java?p2=qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/LifetimePolicy.java&p1=qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/StoreUpgrade.java&r1=1327000&r2=1327003&rev=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/StoreUpgrade.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/LifetimePolicy.java Tue Apr 17 09:01:44 2012
@@ -18,14 +18,10 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.store.berkeleydb.upgrade;
+package org.apache.qpid.server.model;
 
-import com.sleepycat.je.DatabaseException;
-import com.sleepycat.je.Environment;
-import org.apache.qpid.AMQStoreException;
-
-public interface StoreUpgrade
+public enum LifetimePolicy
 {
-    void performUpgrade(Environment environment, UpgradeInteractionHandler handler)
-            throws DatabaseException, AMQStoreException;
+    PERMANENT,
+    AUTO_DELETE
 }

Copied: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Publisher.java (from r1327000, qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/StoreUpgrade.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Publisher.java?p2=qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Publisher.java&p1=qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/StoreUpgrade.java&r1=1327000&r2=1327003&rev=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/StoreUpgrade.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Publisher.java Tue Apr 17 09:01:44 2012
@@ -18,14 +18,8 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.store.berkeleydb.upgrade;
+package org.apache.qpid.server.model;
 
-import com.sleepycat.je.DatabaseException;
-import com.sleepycat.je.Environment;
-import org.apache.qpid.AMQStoreException;
-
-public interface StoreUpgrade
+public interface Publisher extends ConfiguredObject
 {
-    void performUpgrade(Environment environment, UpgradeInteractionHandler handler)
-            throws DatabaseException, AMQStoreException;
 }

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Queue.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Queue.java?rev=1327003&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Queue.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Queue.java Tue Apr 17 09:01:44 2012
@@ -0,0 +1,146 @@
+/*
+ *
+ * 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 java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import org.apache.qpid.server.queue.QueueEntryVisitor;
+
+
+public interface Queue extends ConfiguredObject
+{
+    public static final String BINDING_COUNT = "bindingCount";
+    public static final String CONSUMER_COUNT = "consumerCount";
+    public static final String CONSUMER_COUNT_WITH_CREDIT = "consumerCountWithCredit";
+    public static final String DISCARDS_TTL_BYTES = "discardsTtlBytes";
+    public static final String DISCARDS_TTL_MESSAGES = "discardsTtlMessages";
+    public static final String PERSISTENT_DEQUEUED_BYTES = "persistentDequeuedBytes";
+    public static final String PERSISTENT_DEQUEUED_MESSAGES = "persistentDequeuedMessages";
+    public static final String PERSISTENT_ENQUEUED_BYTES = "persistentEnqueuedBytes";
+    public static final String PERSISTENT_ENQUEUED_MESSAGES = "persistentEnqueuedMessages";
+    public static final String QUEUE_DEPTH_BYTES = "queueDepthBytes";
+    public static final String QUEUE_DEPTH_MESSAGES = "queueDepthMessages";
+    public static final String STATE_CHANGED = "stateChanged";
+    public static final String TOTAL_DEQUEUED_BYTES = "totalDequeuedBytes";
+    public static final String TOTAL_DEQUEUED_MESSAGES = "totalDequeuedMessages";
+    public static final String TOTAL_ENQUEUED_BYTES = "totalEnqueuedBytes";
+    public static final String TOTAL_ENQUEUED_MESSAGES = "totalEnqueuedMessages";
+    public static final String UNACKNOWLEDGED_BYTES = "unacknowledgedBytes";
+    public static final String UNACKNOWLEDGED_MESSAGES = "unacknowledgedMessages";
+
+    public static final Collection<String> AVAILABLE_STATISTICS =
+            Collections.unmodifiableList(
+                    Arrays.asList(BINDING_COUNT,
+                                  CONSUMER_COUNT,
+                                  CONSUMER_COUNT_WITH_CREDIT,
+                                  DISCARDS_TTL_BYTES,
+                                  DISCARDS_TTL_MESSAGES,
+                                  PERSISTENT_DEQUEUED_BYTES,
+                                  PERSISTENT_DEQUEUED_MESSAGES,
+                                  PERSISTENT_ENQUEUED_BYTES,
+                                  PERSISTENT_ENQUEUED_MESSAGES,
+                                  QUEUE_DEPTH_BYTES,
+                                  QUEUE_DEPTH_MESSAGES,
+                                  STATE_CHANGED,
+                                  TOTAL_DEQUEUED_BYTES,
+                                  TOTAL_DEQUEUED_MESSAGES,
+                                  TOTAL_ENQUEUED_BYTES,
+                                  TOTAL_ENQUEUED_MESSAGES,
+                                  UNACKNOWLEDGED_BYTES,
+                                  UNACKNOWLEDGED_MESSAGES));
+
+
+
+    public static final String ID = "id";
+    public static final String NAME = "name";
+    public static final String STATE = "state";
+    public static final String DURABLE = "durable";
+    public static final String LIFETIME_POLICY = "lifetimePolicy";
+    public static final String TIME_TO_LIVE = "timeToLive";
+    public static final String CREATED = "created";
+    public static final String UPDATED = "updated";
+
+    public static final String ALERT_REPEAT_GAP = "alertRepeatGap";
+    public static final String ALERT_THRESHOLD_MESSAGE_AGE = "alertThresholdMessageAge";
+    public static final String ALERT_THRESHOLD_MESSAGE_SIZE = "alertThresholdMessageSize";
+    public static final String ALERT_THRESHOLD_QUEUE_DEPTH_BYTES = "alertThresholdQueueDepthBytes";
+    public static final String ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES = "alertThresholdQueueDepthMessages";
+    public static final String ALTERNATE_EXCHANGE = "alternateExchange";
+    public static final String EXCLUSIVE = "exclusive";
+    public static final String MESSAGE_GROUP_KEY = "messageGroupKey";
+    public static final String MESSAGE_GROUP_DEFAULT_GROUP = "messageGroupDefaultGroup";
+    public static final String MESSAGE_GROUP_SHARED_GROUPS = "messageGroupSharedGroups";
+    public static final String LVQ_KEY = "lvqKey";
+    public static final String MAXIMUM_DELIVERY_ATTEMPTS = "maximumDeliveryAttempts";
+    public static final String NO_LOCAL = "noLocal";
+    public static final String OWNER = "owner";
+    public static final String QUEUE_FLOW_CONTROL_SIZE_BYTES = "queueFlowControlSizeBytes";
+    public static final String QUEUE_FLOW_RESUME_SIZE_BYTES = "queueFlowResumeSizeBytes";
+    public static final String QUEUE_FLOW_STOPPED = "queueFlowStopped";
+    public static final String SORT_KEY = "sortKey";
+    public static final String TYPE = "type";
+
+
+
+
+    public static final Collection<String> AVAILABLE_ATTRIBUTES =
+            Collections.unmodifiableList(
+                    Arrays.asList(ID,
+                                  NAME,
+                                  STATE,
+                                  DURABLE,
+                                  LIFETIME_POLICY,
+                                  TIME_TO_LIVE,
+                                  CREATED,
+                                  UPDATED,
+                                  TYPE,
+                                  ALTERNATE_EXCHANGE,
+                                  EXCLUSIVE,
+                                  OWNER,
+                                  NO_LOCAL,
+                                  LVQ_KEY,
+                                  SORT_KEY,
+                                  MESSAGE_GROUP_KEY,
+                                  MESSAGE_GROUP_DEFAULT_GROUP,
+                                  MESSAGE_GROUP_SHARED_GROUPS,
+                                  MAXIMUM_DELIVERY_ATTEMPTS,
+                                  QUEUE_FLOW_CONTROL_SIZE_BYTES,
+                                  QUEUE_FLOW_RESUME_SIZE_BYTES,
+                                  QUEUE_FLOW_STOPPED,
+                                  ALERT_THRESHOLD_MESSAGE_AGE,
+                                  ALERT_THRESHOLD_MESSAGE_SIZE,
+                                  ALERT_THRESHOLD_QUEUE_DEPTH_BYTES,
+                                  ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES,
+                                  ALERT_REPEAT_GAP
+                    ));
+
+    //children
+    Collection<Binding> getBindings();
+    Collection<Consumer> getConsumers();
+
+
+    //operations
+
+    void visit(QueueEntryVisitor visitor);
+
+    void delete();
+}

Copied: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/State.java (from r1327000, qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/StoreUpgrade.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/State.java?p2=qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/State.java&p1=qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/StoreUpgrade.java&r1=1327000&r2=1327003&rev=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/upgrade/StoreUpgrade.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/State.java Tue Apr 17 09:01:44 2012
@@ -18,14 +18,13 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.store.berkeleydb.upgrade;
+package org.apache.qpid.server.model;
 
-import com.sleepycat.je.DatabaseException;
-import com.sleepycat.je.Environment;
-import org.apache.qpid.AMQStoreException;
-
-public interface StoreUpgrade
+public enum State
 {
-    void performUpgrade(Environment environment, UpgradeInteractionHandler handler)
-            throws DatabaseException, AMQStoreException;
+    INITIALISING,
+    QUIESCED,
+    STOPPED,
+    ACTIVE,
+    DELETED
 }

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Statistics.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Statistics.java?rev=1327003&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Statistics.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Statistics.java Tue Apr 17 09:01:44 2012
@@ -0,0 +1,25 @@
+package org.apache.qpid.server.model;
+
+import java.util.Collection;
+
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ */
+public interface Statistics
+{
+    Collection<String> getStatisticNames();
+    public Object getStatistic(String name);
+}

Copied: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/UUIDGenerator.java (from r1327000, qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/entry/ExchangeRecord.java)
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/UUIDGenerator.java?p2=qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/UUIDGenerator.java&p1=qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/entry/ExchangeRecord.java&r1=1327000&r2=1327003&rev=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/entry/ExchangeRecord.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/model/UUIDGenerator.java Tue Apr 17 09:01:44 2012
@@ -18,36 +18,37 @@
  * under the License.
  *
  */
-package org.apache.qpid.server.store.berkeleydb.entry;
+package org.apache.qpid.server.model;
 
-import org.apache.qpid.framing.AMQShortString;
+import java.util.UUID;
 
-public class ExchangeRecord extends Object
-{
-    private final AMQShortString _exchangeName;
-    private final AMQShortString _exchangeType;
-    private final boolean _autoDelete;
+import org.apache.qpid.exchange.ExchangeDefaults;
 
-    public ExchangeRecord(AMQShortString exchangeName, AMQShortString exchangeType, boolean autoDelete)
-    {
-        _exchangeName = exchangeName;
-        _exchangeType = exchangeType;
-        _autoDelete = autoDelete;
-    }
 
-    public AMQShortString getNameShortString()
+public class UUIDGenerator
+{
+
+    public static UUID generateUUID()
     {
-        return _exchangeName;
+        return UUID.randomUUID();
     }
 
-    public AMQShortString getType()
+    public static UUID generateUUID(String objectName, String virtualHostName)
     {
-        return _exchangeType;
+        StringBuilder sb = new StringBuilder();
+        sb.append(virtualHostName).append(objectName);
+        return UUID.nameUUIDFromBytes(sb.toString().getBytes());
     }
 
-    public boolean isAutoDelete()
+    public static UUID generateExchangeUUID(String echangeName, String virtualHostName)
     {
-        return _autoDelete;
+        if(ExchangeDefaults.DEFAULT_EXCHANGE_NAME.asString().equals(echangeName) || echangeName.startsWith("amq.") || echangeName.startsWith("qpid."))
+        {
+            return generateUUID(echangeName, virtualHostName);
+        }
+        else
+        {
+            return generateUUID();
+        }
     }
-
 }

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/SendingLink_1_0.java Tue Apr 17 09:01:44 2012
@@ -62,6 +62,7 @@ import org.apache.qpid.server.exchange.E
 import org.apache.qpid.server.exchange.TopicExchange;
 import org.apache.qpid.server.filter.JMSSelectorFilter;
 import org.apache.qpid.server.filter.SimpleFilterManager;
+import org.apache.qpid.server.model.UUIDGenerator;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.AMQQueueFactory;
 import org.apache.qpid.server.queue.QueueEntry;
@@ -199,6 +200,7 @@ public class SendingLink_1_0 implements 
                 if(queue == null)
                 {
                     queue = AMQQueueFactory.createAMQQueueImpl(
+                                UUIDGenerator.generateUUID(),
                                 name,
                                 isDurable,
                                 null,

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/v1_0/Session_1_0.java Tue Apr 17 09:01:44 2012
@@ -37,6 +37,7 @@ import org.apache.qpid.amqp_1_0.type.tra
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQSecurityException;
 import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.model.UUIDGenerator;
 import org.apache.qpid.server.queue.AMQQueue;
 import org.apache.qpid.server.queue.AMQQueueFactory;
 import org.apache.qpid.server.registry.IApplicationRegistry;
@@ -314,7 +315,8 @@ public class Session_1_0 implements Sess
                                             ? null
                                             : (LifetimePolicy) properties.get(LIFETIME_POLICY);
 
-            final AMQQueue tempQueue = queue = AMQQueueFactory.createAMQQueueImpl(queueName,
+            final AMQQueue tempQueue = queue = AMQQueueFactory.createAMQQueueImpl( UUIDGenerator.generateUUID(),
+                                                                                   queueName,
                                                                                    false, // durable
                                                                                    null, // owner
                                                                                    false, // autodelete

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQPriorityQueue.java Tue Apr 17 09:01:44 2012
@@ -23,19 +23,20 @@ package org.apache.qpid.server.queue;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
 import java.util.Map;
+import java.util.UUID;
 
 public class AMQPriorityQueue extends OutOfOrderQueue
 {
-    protected AMQPriorityQueue(final String name,
+    protected AMQPriorityQueue(UUID id,
+                                final String name,
                                 final boolean durable,
                                 final String owner,
                                 final boolean autoDelete,
                                 boolean exclusive,
                                 final VirtualHost virtualHost,
-                                Map<String, Object> arguments,
-                                int priorities)
+                                Map<String, Object> arguments, int priorities)
     {
-        super(name, durable, owner, autoDelete, exclusive, virtualHost, new PriorityQueueList.Factory(priorities), arguments);
+        super(id, name, durable, owner, autoDelete, exclusive, virtualHost, new PriorityQueueList.Factory(priorities), arguments);
     }
 
     public int getPriorities()

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java?rev=1327003&r1=1327002&r2=1327003&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/AMQQueueFactory.java Tue Apr 17 09:01:44 2012
@@ -20,6 +20,10 @@
  */
 package org.apache.qpid.server.queue;
 
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
 import org.apache.qpid.AMQException;
 import org.apache.qpid.AMQSecurityException;
 import org.apache.qpid.exchange.ExchangeDefaults;
@@ -30,12 +34,10 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.exchange.Exchange;
 import org.apache.qpid.server.exchange.ExchangeFactory;
 import org.apache.qpid.server.exchange.ExchangeRegistry;
+import org.apache.qpid.server.model.UUIDGenerator;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 
-import java.util.HashMap;
-import java.util.Map;
-
 public class AMQQueueFactory
 {
     public static final String X_QPID_PRIORITIES = "x-qpid-priorities";
@@ -166,8 +168,13 @@ public class AMQQueueFactory
             }
     };
 
-
-    /** @see #createAMQQueueImpl(String, boolean, String, boolean, boolean, VirtualHost, Map) */
+    /**
+     * Creates a new queue with a random id.
+     *
+     * @see #createAMQQueueImpl(UUID, String, boolean, String, boolean, boolean, VirtualHost, Map)
+     * @deprecated because only called from unit tests
+     * */
+    @Deprecated
     public static AMQQueue createAMQQueueImpl(AMQShortString name,
                                               boolean durable,
                                               AMQShortString owner,
@@ -175,22 +182,28 @@ public class AMQQueueFactory
                                               boolean exclusive,
                                               VirtualHost virtualHost, final FieldTable arguments) throws AMQException
     {
-        return createAMQQueueImpl(name == null ? null : name.toString(),
+        return createAMQQueueImpl(UUIDGenerator.generateUUID(),
+                                  name == null ? null : name.toString(),
                                   durable,
                                   owner == null ? null : owner.toString(),
                                   autoDelete,
-                                  exclusive,
-                                  virtualHost, FieldTable.convertToMap(arguments));
+                                  exclusive, virtualHost, FieldTable.convertToMap(arguments));
     }
 
-
-    public static AMQQueue createAMQQueueImpl(String queueName,
+    /**
+     * @param id the id to use. If default then one is generated from queueName. TODO check correctness of calls that pass a null value.
+     */
+    public static AMQQueue createAMQQueueImpl(UUID id,
+                                              String queueName,
                                               boolean durable,
                                               String owner,
                                               boolean autoDelete,
-                                              boolean exclusive,
-                                              VirtualHost virtualHost, Map<String, Object> arguments) throws AMQSecurityException, AMQException
+                                              boolean exclusive, VirtualHost virtualHost, Map<String, Object> arguments) throws AMQSecurityException, AMQException
     {
+        if (id == null)
+        {
+            throw new IllegalArgumentException("Queue id must not be null");
+        }
         if (queueName == null)
         {
             throw new IllegalArgumentException("Queue name must not be null");
@@ -241,19 +254,19 @@ public class AMQQueueFactory
         AMQQueue q;
         if(sortingKey != null)
         {
-            q = new SortedQueue(queueName, durable, owner, autoDelete, exclusive, virtualHost, arguments, sortingKey);
+            q = new SortedQueue(id, queueName, durable, owner, autoDelete, exclusive, virtualHost, arguments, sortingKey);
         }
         else if(conflationKey != null)
         {
-            q = new ConflationQueue(queueName, durable, owner, autoDelete, exclusive, virtualHost, arguments, conflationKey);
+            q = new ConflationQueue(id, queueName, durable, owner, autoDelete, exclusive, virtualHost, arguments, conflationKey);
         }
         else if(priorities > 1)
         {
-            q = new AMQPriorityQueue(queueName, durable, owner, autoDelete, exclusive, virtualHost, arguments, priorities);
+            q = new AMQPriorityQueue(id, queueName, durable, owner, autoDelete, exclusive, virtualHost, arguments, priorities);
         }
         else
         {
-            q = new SimpleAMQQueue(queueName, durable, owner, autoDelete, exclusive, virtualHost, arguments);
+            q = new SimpleAMQQueue(id, queueName, durable, owner, autoDelete, exclusive, virtualHost, arguments);
         }
 
         //Register the new queue
@@ -287,7 +300,7 @@ public class AMQQueueFactory
 
                 if(dlExchange == null)
                 {
-                    dlExchange = exchangeFactory.createExchange(new AMQShortString(dlExchangeName), ExchangeDefaults.FANOUT_EXCHANGE_CLASS, true, false, 0);
+                    dlExchange = exchangeFactory.createExchange(UUIDGenerator.generateUUID(dlExchangeName, virtualHost.getName()), new AMQShortString(dlExchangeName), ExchangeDefaults.FANOUT_EXCHANGE_CLASS, true, false, 0);
 
                     exchangeRegistry.registerExchange(dlExchange);
 
@@ -309,7 +322,7 @@ public class AMQQueueFactory
                     args.put(X_QPID_DLQ_ENABLED, false);
                     args.put(X_QPID_MAXIMUM_DELIVERY_COUNT, 0);
 
-                    dlQueue = createAMQQueueImpl(dlQueueName, true, owner, false, exclusive, virtualHost, args);
+                    dlQueue = createAMQQueueImpl(UUIDGenerator.generateUUID(dlQueueName, virtualHost.getName()), dlQueueName, true, owner, false, exclusive, virtualHost, args);
 
                     //enter the dlq in the persistent store
                     virtualHost.getMessageStore().createQueue(dlQueue, FieldTable.convertToFieldTable(args));
@@ -364,7 +377,10 @@ public class AMQQueueFactory
             arguments.put(X_QPID_DLQ_ENABLED, true);
         }
 
-        AMQQueue q = createAMQQueueImpl(queueName, durable, owner, autodelete, exclusive, host, arguments);
+        // we need queues that are defined in config to have deterministic ids.
+        UUID id = UUIDGenerator.generateUUID(queueName, host.getName());
+
+        AMQQueue q = createAMQQueueImpl(id, queueName, durable, owner, autodelete, exclusive, host, arguments);
         q.configure(config);
         return q;
     }



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


Mime
View raw message