[rhmessaging-commits] rhmessaging commits: r3800 - store/branches/java/0.5-release/src/tools/java/org/apache/qpid/server/store/berkeleydb.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Thu Jan 14 12:20:50 EST 2010


Author: rgemmell
Date: 2010-01-14 12:20:50 -0500 (Thu, 14 Jan 2010)
New Revision: 3800

Modified:
   store/branches/java/0.5-release/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreBindingsWorkaround.java
Log:
Updates to aid unit testing of the process


Modified: store/branches/java/0.5-release/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreBindingsWorkaround.java
===================================================================
--- store/branches/java/0.5-release/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreBindingsWorkaround.java	2010-01-14 17:19:57 UTC (rev 3799)
+++ store/branches/java/0.5-release/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreBindingsWorkaround.java	2010-01-14 17:20:50 UTC (rev 3800)
@@ -145,7 +145,9 @@
         
         loadVirtualHosts();
         
-        addDurableExchangesToStoreIfRequired();
+        addDurableExchangesToStoreIfRequired(
+                ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHosts());
+        
         _logger.info("Workaround process complete");
     }
 
@@ -228,7 +230,7 @@
         }
     }
 
-    private static List<AMQShortString> getBDBStoreExchangeNames(final VirtualHost vhost, final BDBMessageStore store) throws AMQException, DatabaseException
+    protected static List<AMQShortString> getBDBStoreExchangeNames(final VirtualHost vhost, final BDBMessageStore store) throws AMQException, DatabaseException
     {
         final List<AMQShortString> exchanges = new ArrayList<AMQShortString>();
 
@@ -273,10 +275,24 @@
         return exchanges;
     }
     
-    private static void addDurableExchangesToStoreIfRequired() throws AMQException, DatabaseException
+    protected List<Exchange> getVhostExchanges(VirtualHost vhost)
     {
-        Collection<VirtualHost> vhosts = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHosts();
+        ExchangeRegistry registry = vhost.getExchangeRegistry();
+        Collection<AMQShortString> exchangeNames = registry.getExchangeNames();
         
+        List<Exchange> exchangeList = new ArrayList<Exchange>();
+        
+        for(AMQShortString exchangeName : exchangeNames)
+        {
+            Exchange ex = registry.getExchange(exchangeName);
+            exchangeList.add(ex);
+        }
+        
+        return exchangeList;
+    }
+    
+    protected void addDurableExchangesToStoreIfRequired(Collection<VirtualHost> vhosts) throws AMQException, DatabaseException
+    {
         //For each active VHost, add all durable exchanges in the ExchangeRegistry to the store if they arent already in it.
         for(VirtualHost vhost : vhosts)
         {
@@ -295,13 +311,12 @@
             }
             
             List<AMQShortString> bdbExchangeNames = getBDBStoreExchangeNames(vhost, store);
+            List<Exchange> vhostExchanges = getVhostExchanges(vhost);
             
-            ExchangeRegistry registry = vhost.getExchangeRegistry();
-            Collection<AMQShortString> exchangeNames = registry.getExchangeNames();
-            
-            for(AMQShortString exchangeName : exchangeNames)
+            for(Exchange exchange : vhostExchanges)
             {
-                Exchange exchange = registry.getExchange(exchangeName);
+                AMQShortString exchangeName = exchange.getName();
+                
                 if(exchange.isDurable())
                 {
                     if(bdbExchangeNames.contains(exchangeName))



More information about the rhmessaging-commits mailing list