[jboss-cvs] JBoss Messaging SVN: r5564 - in trunk: src/main/org/jboss/messaging/core/management/impl and 33 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Dec 31 09:10:26 EST 2008


Author: timfox
Date: 2008-12-31 09:10:26 -0500 (Wed, 31 Dec 2008)
New Revision: 5564

Added:
   trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalLargeServerMessage.java
   trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageLargeServerMessage.java
   trunk/src/main/org/jboss/messaging/core/postoffice/BindingType.java
   trunk/src/main/org/jboss/messaging/core/server/Bindable.java
   trunk/src/main/org/jboss/messaging/core/server/BindableFactory.java
   trunk/src/main/org/jboss/messaging/core/server/LargeServerMessage.java
   trunk/src/main/org/jboss/messaging/core/server/Link.java
   trunk/src/main/org/jboss/messaging/core/server/impl/BindableFactoryImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/LinkImpl.java
   trunk/src/main/org/jboss/messaging/core/transaction/TransactionOperation.java
Removed:
   trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalLargeMessageImpl.java
   trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageLargeMessageImpl.java
   trunk/src/main/org/jboss/messaging/core/server/QueueFactory.java
   trunk/src/main/org/jboss/messaging/core/server/ReferenceHandler.java
   trunk/src/main/org/jboss/messaging/core/server/ServerLargeMessage.java
   trunk/src/main/org/jboss/messaging/core/server/impl/QueueFactoryImpl.java
   trunk/src/main/org/jboss/messaging/core/transaction/TransactionSynchronization.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/BindingsImplTest.java
Modified:
   trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
   trunk/src/main/org/jboss/messaging/core/management/impl/AddressControl.java
   trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java
   trunk/src/main/org/jboss/messaging/core/paging/impl/LastPageRecordImpl.java
   trunk/src/main/org/jboss/messaging/core/paging/impl/PagedMessageImpl.java
   trunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java
   trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreFactoryNIO.java
   trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java
   trunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java
   trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
   trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java
   trunk/src/main/org/jboss/messaging/core/postoffice/Binding.java
   trunk/src/main/org/jboss/messaging/core/postoffice/Bindings.java
   trunk/src/main/org/jboss/messaging/core/postoffice/PostOffice.java
   trunk/src/main/org/jboss/messaging/core/postoffice/impl/BindingImpl.java
   trunk/src/main/org/jboss/messaging/core/postoffice/impl/BindingsImpl.java
   trunk/src/main/org/jboss/messaging/core/postoffice/impl/DuplicateIDCacheImpl.java
   trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
   trunk/src/main/org/jboss/messaging/core/postoffice/impl/SimpleAddressManager.java
   trunk/src/main/org/jboss/messaging/core/postoffice/impl/WildcardAddressManager.java
   trunk/src/main/org/jboss/messaging/core/server/MessageReference.java
   trunk/src/main/org/jboss/messaging/core/server/Queue.java
   trunk/src/main/org/jboss/messaging/core/server/ServerMessage.java
   trunk/src/main/org/jboss/messaging/core/server/cluster/impl/ForwarderImpl.java
   trunk/src/main/org/jboss/messaging/core/server/cluster/impl/MessageFlowImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/MessageReferenceImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
   trunk/src/main/org/jboss/messaging/core/transaction/Transaction.java
   trunk/src/main/org/jboss/messaging/core/transaction/impl/ResourceManagerImpl.java
   trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java
   trunk/src/main/org/jboss/messaging/jms/client/JBossSession.java
   trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
   trunk/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java
   trunk/src/main/org/jboss/messaging/util/SimpleString.java
   trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ConsumerClosedTest.java
   trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java
   trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/MiscellaneousTest.java
   trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
   trunk/tests/src/org/jboss/messaging/tests/concurrent/server/impl/QueueTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java
   trunk/tests/src/org/jboss/messaging/tests/integration/consumer/ConsumerTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/jms/consumer/ConsumerTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/queue/DeadLetterAddressTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/queue/ExpiryRunnerTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java
   trunk/tests/src/org/jboss/messaging/tests/performance/persistence/FakeBinding.java
   trunk/tests/src/org/jboss/messaging/tests/performance/persistence/FakePostOffice.java
   trunk/tests/src/org/jboss/messaging/tests/timing/core/server/impl/QueueImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerControlTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplWildcardManagerTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/SimpleAddressManagerTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessagingServerImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueFactoryImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/fakes/FakeQueueFactory.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/TransactionImplTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/util/SimpleStringTest.java
   trunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java
Log:
Transaction and paging reworking part I


Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -436,7 +436,7 @@
       {
          throw new IllegalStateException("Journal must be loaded first");
       }
-
+      
       int recordLength = record.getEncodeSize();
 
       int size = SIZE_ADD_RECORD_TX + recordLength;

Modified: trunk/src/main/org/jboss/messaging/core/management/impl/AddressControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/AddressControl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/AddressControl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -87,7 +87,7 @@
          for (int i = 0; i < bindings.getBindings().size(); i++)
          {
             Binding binding = bindings.getBindings().get(i);
-            queueNames[i] = binding.getQueue().getName().toString();
+            queueNames[i] = binding.getBindable().getName().toString();
          }
          return queueNames;
       }

Modified: trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -53,6 +53,7 @@
 import org.jboss.messaging.core.messagecounter.MessageCounterManager;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.Binding;
+import org.jboss.messaging.core.postoffice.BindingType;
 import org.jboss.messaging.core.postoffice.PostOffice;
 import org.jboss.messaging.core.remoting.RemotingConnection;
 import org.jboss.messaging.core.remoting.RemotingService;
@@ -145,16 +146,16 @@
       postOffice.removeDestination(simpleAddress, false);
    }
 
-   public Queue getQueue(final String address) throws Exception
+   public Queue getQueue(final String name) throws Exception
    {
-      SimpleString sAddress = new SimpleString(address);
-      Binding binding = postOffice.getBinding(sAddress);
-      if (binding == null)
+      SimpleString sName = new SimpleString(name);
+      Binding binding = postOffice.getBinding(sName);
+      if (binding == null || binding.getType() != BindingType.QUEUE)
       {
-         throw new IllegalArgumentException("No queue with name " + sAddress);
+         throw new IllegalArgumentException("No queue with name " + sName);
       }
 
-      return binding.getQueue();
+      return (Queue)binding.getBindable();
    }
 
    public Configuration getConfiguration()
@@ -290,13 +291,14 @@
    }
 
    // TODO - do we really need this method?
+     
    public void createQueue(final String address, final String name) throws Exception
    {
       SimpleString sAddress = new SimpleString(address);
       SimpleString sName = new SimpleString(name);
-      if (postOffice.getBinding(sAddress) == null)
+      if (postOffice.getBinding(sName) == null)
       {
-         postOffice.addBinding(sAddress, sName, null, true, false, false);
+         postOffice.addQueueBinding(sName, sAddress, null, true, false, false);
       }
    }
 
@@ -310,9 +312,9 @@
       {
          filter = new FilterImpl(sFilter);
       }
-      if (postOffice.getBinding(sAddress) == null)
+      if (postOffice.getBinding(sName) == null)
       {
-         postOffice.addBinding(sAddress, sName, filter, durable, false, false);
+         postOffice.addQueueBinding(sName, sAddress, filter, durable, false, false);
       }
    }
 
@@ -323,11 +325,14 @@
 
       if (binding != null)
       {
-         Queue queue = binding.getQueue();
+         if (binding.getType() == BindingType.QUEUE)
+         {
+            Queue queue = (Queue)binding.getBindable();
+   
+            queue.deleteAllReferences(storageManager);
+         }
 
-         queue.deleteAllReferences(storageManager);
-
-         postOffice.removeBinding(queue.getName());
+         postOffice.removeBinding(sName);
       }
    }
 

Modified: trunk/src/main/org/jboss/messaging/core/paging/impl/LastPageRecordImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/impl/LastPageRecordImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/paging/impl/LastPageRecordImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -24,6 +24,7 @@
 
 import static org.jboss.messaging.util.DataConstants.SIZE_LONG;
 
+import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.paging.LastPageRecord;
 import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
 import org.jboss.messaging.util.SimpleString;
@@ -37,6 +38,9 @@
 {
    // Constants -----------------------------------------------------
 
+   private static final Logger log = Logger.getLogger(LastPageRecordImpl.class);
+
+   
    // Attributes ----------------------------------------------------
 
    private volatile long recordId = 0;
@@ -67,7 +71,7 @@
    }
 
    public void setRecordId(final long recordId)
-   {
+   {      
       this.recordId = recordId;
    }
 

Modified: trunk/src/main/org/jboss/messaging/core/paging/impl/PagedMessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/impl/PagedMessageImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/paging/impl/PagedMessageImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -32,7 +32,7 @@
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
 import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
-import org.jboss.messaging.core.server.ServerLargeMessage;
+import org.jboss.messaging.core.server.LargeServerMessage;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.server.impl.ServerMessageImpl;
 
@@ -127,7 +127,7 @@
    {
       buffer.putLong(transactionID);
       
-      buffer.putBoolean(message instanceof ServerLargeMessage);
+      buffer.putBoolean(message instanceof LargeServerMessage);
       
       buffer.putInt(message.getEncodeSize());
       

Modified: trunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -69,7 +69,7 @@
 
    private final HierarchicalRepository<QueueSettings> queueSettingsRepository;
 
-   private final PagingStoreFactory pagingSPI;
+   private final PagingStoreFactory pagingStoreFactory;
 
    private final StorageManager storageManager;
 
@@ -103,7 +103,7 @@
                             final long defaultPageSize,
                             final boolean syncNonTransactional)
    {
-      this.pagingSPI = pagingSPI;
+      this.pagingStoreFactory = pagingSPI;
       this.queueSettingsRepository = queueSettingsRepository;
       this.storageManager = storageManager;
       this.defaultPageSize = defaultPageSize;
@@ -133,7 +133,8 @@
     */
    public void reloadStores() throws Exception
    {
-      List<SimpleString> destinations = pagingSPI.getStoredDestinations();
+      List<SimpleString> destinations = pagingStoreFactory.getStoredDestinations();
+      
       for (SimpleString dest: destinations)
       {
          createPageStore(dest);
@@ -184,7 +185,7 @@
     *  (There is a one-to-one relationship here) */
    public void setPostOffice(final PostOffice postOffice)
    {
-      pagingSPI.setPostOffice(postOffice);
+      pagingStoreFactory.setPostOffice(postOffice);
    }
 
    public long getDefaultPageSize()
@@ -276,9 +277,9 @@
          return;
       }
 
-      pagingSPI.setPagingManager(this);
+      pagingStoreFactory.setPagingManager(this);
 
-      pagingSPI.setStorageManager(storageManager);
+      pagingStoreFactory.setStorageManager(storageManager);
 
       started = true;
    }
@@ -297,7 +298,7 @@
          store.stop();
       }
 
-      pagingSPI.stop();
+      pagingStoreFactory.stop();
    }
 
    public synchronized void startGlobalDepage()
@@ -305,7 +306,7 @@
       setGlobalPageMode(true);
       for (PagingStore store : stores.values())
       {
-         store.startDepaging(pagingSPI.getGlobalDepagerExecutor());
+         store.startDepaging(pagingStoreFactory.getGlobalDepagerExecutor());
       }
    }
 
@@ -321,7 +322,7 @@
     * @see org.jboss.messaging.core.paging.PagingManager#addGlobalSize(long)
     */
    public long addGlobalSize(final long size)
-   {
+   {      
       return globalSize.addAndGet(size);
    }
 
@@ -341,7 +342,7 @@
 
    private PagingStore newStore(final SimpleString destinationName)
    {
-      return pagingSPI.newStore(destinationName, queueSettingsRepository.getMatch(destinationName.toString()));
+      return pagingStoreFactory.newStore(destinationName, queueSettingsRepository.getMatch(destinationName.toString()));
    }
 
    // Inner classes -------------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreFactoryNIO.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreFactoryNIO.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreFactoryNIO.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -107,8 +107,7 @@
    }
 
    public PagingStore newStore(final SimpleString destinationName, final QueueSettings settings)
-   {
-      
+   {      
       final String destinationDirectory = directory + "/" + Base64.encodeBytes(destinationName.getData(), Base64.URL_SAFE);
 
       return new PagingStoreImpl(pagingManager,

Modified: trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -23,7 +23,6 @@
 package org.jboss.messaging.core.paging.impl;
 
 import java.text.DecimalFormat;
-import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.concurrent.Executor;
@@ -45,7 +44,6 @@
 import org.jboss.messaging.core.paging.PagingStore;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.PostOffice;
-import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.settings.impl.QueueSettings;
 import org.jboss.messaging.core.transaction.Transaction;
@@ -126,7 +124,7 @@
       if (isTrace)
       {
          log.trace(message);
-      }      
+      }
    }
 
    // Constructors --------------------------------------------------
@@ -243,7 +241,7 @@
          else
          {
             addAddressSize(size);
-            
+
             return true;
          }
       }
@@ -427,7 +425,7 @@
    }
 
    public boolean startDepaging(final Executor executor)
-   {
+   {     
       currentPageLock.readLock().lock();
       try
       {
@@ -504,7 +502,7 @@
    }
 
    public void start() throws Exception
-   {
+   {      
       writeLock.lock();
 
       try
@@ -708,7 +706,7 @@
     *     
     * If persistent messages are also used, it will update eventual PageTransactions
     */
-   
+
    private void onDepage(final int pageId, final SimpleString destination, final List<PagedMessage> pagedMessages) throws Exception
    {
       trace("Depaging....");
@@ -740,13 +738,13 @@
       storageManager.storeLastPage(depageTransaction.getID(), lastPageRecord);
 
       HashSet<PageTransactionInfo> pageTransactionsToUpdate = new HashSet<PageTransactionInfo>();
-
+            
       for (PagedMessage pagedMessage : pagedMessages)
       {
          ServerMessage message = null;
 
          message = pagedMessage.getMessage(storageManager);
-
+         
          final long transactionIdDuringPaging = pagedMessage.getTransactionID();
 
          if (transactionIdDuringPaging >= 0)
@@ -778,10 +776,10 @@
             {
                pageTransactionInfo.decrement();
                pageTransactionsToUpdate.add(pageTransactionInfo);
-            }                        
+            }
          }
          
-         depageTransaction.addMessage(message);
+         postOffice.route(message, depageTransaction);
       }
 
       for (PageTransactionInfo pageWithTransaction : pageTransactionsToUpdate)
@@ -800,7 +798,7 @@
       }
 
       depageTransaction.commit();
-
+      
       trace("Depage committed");
    }
 
@@ -853,8 +851,6 @@
    private void openNewPage() throws Exception
    {
       currentPageLock.writeLock().lock();
-      
-   //   log.info("Opening new page");
 
       try
       {
@@ -886,8 +882,6 @@
 
    public void clearLastPageRecord(final LastPageRecord lastRecord) throws Exception
    {
-      trace("Clearing lastRecord information " + lastRecord.getLastId());
-
       storageManager.deleteLastPage(lastRecord.getRecordId());
    }
 
@@ -938,7 +932,7 @@
    private void readPage() throws Exception
    {
       Page page = depage();
-
+      
       if (page == null)
       {
          if (lastPageRecord != null)

Modified: trunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/persistence/StorageManager.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -31,11 +31,11 @@
 import org.jboss.messaging.core.paging.PageTransactionInfo;
 import org.jboss.messaging.core.postoffice.Binding;
 import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.BindableFactory;
+import org.jboss.messaging.core.server.LargeServerMessage;
 import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.MessagingComponent;
 import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.QueueFactory;
-import org.jboss.messaging.core.server.ServerLargeMessage;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.transaction.ResourceManager;
 import org.jboss.messaging.util.Pair;
@@ -85,7 +85,7 @@
    
    void deleteDuplicateIDTransactional(long txID, long recordID) throws Exception;
 
-   ServerLargeMessage createLargeMessage();
+   LargeServerMessage createLargeMessage();
 
    void prepare(long txID, Xid xid) throws Exception;
 
@@ -116,5 +116,5 @@
 
    boolean deleteDestination(SimpleString destination) throws Exception;
 
-   void loadBindings(QueueFactory queueFactory, List<Binding> bindings, List<SimpleString> destinations) throws Exception;
+   void loadBindings(BindableFactory queueFactory, List<Binding> bindings, List<SimpleString> destinations) throws Exception;
 }

Deleted: trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalLargeMessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalLargeMessageImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalLargeMessageImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -1,253 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.messaging.core.persistence.impl.journal;
-
-import java.nio.ByteBuffer;
-
-import org.jboss.messaging.core.exception.MessagingException;
-import org.jboss.messaging.core.journal.SequentialFile;
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
-import org.jboss.messaging.core.server.ServerLargeMessage;
-import org.jboss.messaging.core.server.impl.ServerMessageImpl;
-
-/**
- * A ServerLargeMessageImpl
- *
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * 
- * Created 30-Sep-08 12:02:45 PM
- *
- *
- */
-public class JournalLargeMessageImpl extends ServerMessageImpl implements ServerLargeMessage
-{
-
-   // Constants -----------------------------------------------------
-
-   private static final Logger log = Logger.getLogger(JournalLargeMessageImpl.class);
-
-   private static boolean isTrace = log.isTraceEnabled();
-
-   // Attributes ----------------------------------------------------
-
-   private final JournalStorageManager storageManager;
-
-   // We should only use the NIO implementation on the Journal
-   private SequentialFile file;
-
-   private boolean complete = false;
-   
-   private long bodySize = -1;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   public JournalLargeMessageImpl(final JournalStorageManager storageManager)
-   {
-      this.storageManager = storageManager;
-   }
-
-   // Public --------------------------------------------------------
-
-   /* (non-Javadoc)
-    * @see org.jboss.messaging.core.server.ServerLargeMessage#addBytes(byte[])
-    */
-   public synchronized void addBytes(final byte[] bytes) throws Exception
-   {
-      validateFile();
-
-      if (!file.isOpen())
-      {
-         file.open();
-      }
-
-      file.position(file.size());
-
-      file.write(ByteBuffer.wrap(bytes), false);
-      
-      bodySize += bytes.length;
-   }
-
-   @Override
-   public synchronized void encodeBody(final MessagingBuffer bufferOut, final long start, final int size)
-   {
-      try
-      {
-         validateFile();
-
-         // This could maybe be optimized (maybe reading directly into bufferOut)
-         ByteBuffer bufferRead = ByteBuffer.allocate(size);
-         if (!file.isOpen())
-         {
-            file.open();
-         }
-
-         int bytesRead = 0;
-         file.position(start);
-
-         bytesRead = file.read(bufferRead);
-
-         bufferRead.flip();
-
-         if (bytesRead > 0)
-         {
-            bufferOut.putBytes(bufferRead.array(), 0, bytesRead);
-         }
-
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e.getMessage(), e);
-      }
-   }
-
-   @Override
-   public synchronized int getBodySize()
-   {
-      try
-      {
-         validateFile();
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e.getMessage(), e);
-      }
-      // FIXME: The file could be bigger than MAX_INT
-      return (int)bodySize;
-   }
-
-   @Override
-   public synchronized int getEncodeSize()
-   {
-      return getPropertiesEncodeSize();
-   }
-
-   @Override
-   public void encode(final MessagingBuffer buffer)
-   {
-      encodeProperties(buffer);
-   }
-
-   @Override
-   public void decode(final MessagingBuffer buffer)
-   {
-      file = null;
-      complete = true;
-      decodeProperties(buffer);
-   }
-
-   @Override
-   public int decrementRefCount()
-   {
-      int currentRefCount = super.decrementRefCount();
-
-      if (currentRefCount == 0)
-      {
-         if (isTrace)
-         {
-            log.trace("Deleting file " + file + " as the usage was complete");
-         }
-
-         try
-         {
-            deleteFile();
-         }
-         catch (Exception e)
-         {
-            log.error(e.getMessage(), e);
-         }
-      }
-
-      return currentRefCount;
-   }
-
-   public void deleteFile() throws MessagingException
-   {
-      if (file != null)
-      {
-         storageManager.deleteFile(file);
-      }
-   }
-
-   @Override
-   public synchronized int getMemoryEstimate()
-   {
-      // The body won't be on memory (aways on-file), so we don't consider this for paging
-      return super.getPropertiesEncodeSize();
-   }
-
-   public synchronized void complete() throws Exception
-   {
-      releaseResources();
-
-      if (!complete)
-      {
-         SequentialFile fileToRename = storageManager.createFileForLargeMessage(getMessageID(), true);
-         file.renameTo(fileToRename.getFileName());
-      }
-   }
-
-   public synchronized void releaseResources()
-   {
-      if (file != null && file.isOpen())
-      {
-         try
-         {
-            file.close();
-         }
-         catch (Exception e)
-         {
-            log.error(e.getMessage(), e);
-         }
-      }
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   private synchronized void validateFile() throws Exception
-   {
-      if (file == null)
-      {
-         if (messageID <= 0)
-         {
-            throw new RuntimeException("MessageID not set on LargeMessage");
-         }
-
-         file = storageManager.createFileForLargeMessage(getMessageID(), complete);
-         
-         file.open();
-         
-         bodySize = file.size();
-
-      }
-   }
-
-   // Inner classes -------------------------------------------------
-
-}

Copied: trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalLargeServerMessage.java (from rev 5550, trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalLargeMessageImpl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalLargeServerMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalLargeServerMessage.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -0,0 +1,252 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.persistence.impl.journal;
+
+import java.nio.ByteBuffer;
+
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.journal.SequentialFile;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.core.server.LargeServerMessage;
+import org.jboss.messaging.core.server.impl.ServerMessageImpl;
+
+/**
+ * A JournalLargeServerMessage
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * 
+ * Created 30-Sep-08 12:02:45 PM
+ *
+ *
+ */
+public class JournalLargeServerMessage extends ServerMessageImpl implements LargeServerMessage
+{
+   // Constants -----------------------------------------------------
+
+   private static final Logger log = Logger.getLogger(JournalLargeServerMessage.class);
+
+   private static boolean isTrace = log.isTraceEnabled();
+
+   // Attributes ----------------------------------------------------
+
+   private final JournalStorageManager storageManager;
+
+   // We should only use the NIO implementation on the Journal
+   private SequentialFile file;
+
+   private boolean complete = false;
+   
+   private long bodySize = -1;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public JournalLargeServerMessage(final JournalStorageManager storageManager)
+   {
+      this.storageManager = storageManager;
+   }
+
+   // Public --------------------------------------------------------
+
+   /* (non-Javadoc)
+    * @see org.jboss.messaging.core.server.LargeServerMessage#addBytes(byte[])
+    */
+   public synchronized void addBytes(final byte[] bytes) throws Exception
+   {
+      validateFile();
+
+      if (!file.isOpen())
+      {
+         file.open();
+      }
+
+      file.position(file.size());
+
+      file.write(ByteBuffer.wrap(bytes), false);
+      
+      bodySize += bytes.length;
+   }
+
+   @Override
+   public synchronized void encodeBody(final MessagingBuffer bufferOut, final long start, final int size)
+   {
+      try
+      {
+         validateFile();
+
+         // This could maybe be optimized (maybe reading directly into bufferOut)
+         ByteBuffer bufferRead = ByteBuffer.allocate(size);
+         if (!file.isOpen())
+         {
+            file.open();
+         }
+
+         int bytesRead = 0;
+         file.position(start);
+
+         bytesRead = file.read(bufferRead);
+
+         bufferRead.flip();
+
+         if (bytesRead > 0)
+         {
+            bufferOut.putBytes(bufferRead.array(), 0, bytesRead);
+         }
+
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e.getMessage(), e);
+      }
+   }
+
+   @Override
+   public synchronized int getBodySize()
+   {
+      try
+      {
+         validateFile();
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e.getMessage(), e);
+      }
+      // FIXME: The file could be bigger than MAX_INT
+      return (int)bodySize;
+   }
+
+   @Override
+   public synchronized int getEncodeSize()
+   {
+      return getPropertiesEncodeSize();
+   }
+
+   @Override
+   public void encode(final MessagingBuffer buffer)
+   {
+      encodeProperties(buffer);
+   }
+
+   @Override
+   public void decode(final MessagingBuffer buffer)
+   {
+      file = null;
+      complete = true;
+      decodeProperties(buffer);
+   }
+
+   @Override
+   public int decrementRefCount()
+   {      
+      int currentRefCount = super.decrementRefCount();
+      
+      if (currentRefCount == 0)
+      {
+         if (isTrace)
+         {
+            log.trace("Deleting file " + file + " as the usage was complete");
+         }
+
+         try
+         {
+            deleteFile();
+         }
+         catch (Exception e)
+         {
+            log.error(e.getMessage(), e);
+         }
+      }
+
+      return currentRefCount;
+   }
+
+   public void deleteFile() throws MessagingException
+   {
+      if (file != null)
+      {
+         storageManager.deleteFile(file);
+      }
+   }
+
+   @Override
+   public synchronized int getMemoryEstimate()
+   {
+      // The body won't be on memory (aways on-file), so we don't consider this for paging
+      return super.getPropertiesEncodeSize();
+   }
+
+   public synchronized void complete() throws Exception
+   {
+      releaseResources();
+
+      if (!complete)
+      {
+         SequentialFile fileToRename = storageManager.createFileForLargeMessage(getMessageID(), true);
+         file.renameTo(fileToRename.getFileName());
+      }
+   }
+
+   public synchronized void releaseResources()
+   {
+      if (file != null && file.isOpen())
+      {
+         try
+         {
+            file.close();
+         }
+         catch (Exception e)
+         {
+            log.error(e.getMessage(), e);
+         }
+      }
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   private synchronized void validateFile() throws Exception
+   {
+      if (file == null)
+      {
+         if (messageID <= 0)
+         {
+            throw new RuntimeException("MessageID not set on LargeMessage");
+         }
+
+         file = storageManager.createFileForLargeMessage(getMessageID(), complete);
+         
+         file.open();
+         
+         bodySize = file.size();
+
+      }
+   }
+
+   // Inner classes -------------------------------------------------
+
+}

Modified: trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -61,16 +61,19 @@
 import org.jboss.messaging.core.paging.impl.PageTransactionInfoImpl;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.Binding;
+import org.jboss.messaging.core.postoffice.BindingType;
 import org.jboss.messaging.core.postoffice.PostOffice;
 import org.jboss.messaging.core.postoffice.impl.BindingImpl;
 import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
 import org.jboss.messaging.core.remoting.impl.wireformat.XidCodecSupport;
 import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.core.server.Bindable;
+import org.jboss.messaging.core.server.BindableFactory;
 import org.jboss.messaging.core.server.JournalType;
+import org.jboss.messaging.core.server.Link;
 import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.QueueFactory;
-import org.jboss.messaging.core.server.ServerLargeMessage;
+import org.jboss.messaging.core.server.LargeServerMessage;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.server.impl.ServerMessageImpl;
 import org.jboss.messaging.core.transaction.ResourceManager;
@@ -227,9 +230,9 @@
       return idGenerator.generateID();
    }
 
-   public ServerLargeMessage createLargeMessage()
+   public LargeServerMessage createLargeMessage()
    {
-      return new JournalLargeMessageImpl(this);
+      return new JournalLargeServerMessage(this);
    }
 
    // Non transactional operations
@@ -241,11 +244,11 @@
          throw new MessagingException(MessagingException.ILLEGAL_STATE, "MessageId was not assigned to Message");
       }
 
-      if (message instanceof ServerLargeMessage)
+      if (message instanceof LargeServerMessage)
       {
          messageJournal.appendAddRecord(message.getMessageID(),
                                         ADD_LARGE_MESSAGE,
-                                        new LargeMessageEncoding((ServerLargeMessage)message));
+                                        new LargeMessageEncoding((LargeServerMessage)message));
       }
       else
       {
@@ -284,7 +287,7 @@
 
       messageJournal.appendUpdateRecord(recordID, DUPLICATE_ID, encoding);
    }
-   
+
    public void deleteDuplicateID(long recordID) throws Exception
    {
       messageJournal.appendDeleteRecord(recordID);
@@ -299,12 +302,12 @@
          throw new MessagingException(MessagingException.ILLEGAL_STATE, "MessageId was not assigned to Message");
       }
 
-      if (message instanceof ServerLargeMessage)
+      if (message instanceof LargeServerMessage)
       {
          messageJournal.appendAddRecordTransactional(txID,
                                                      message.getMessageID(),
                                                      ADD_LARGE_MESSAGE,
-                                                     new LargeMessageEncoding(((ServerLargeMessage)message)));
+                                                     new LargeMessageEncoding(((LargeServerMessage)message)));
       }
       else
       {
@@ -331,7 +334,7 @@
    }
 
    public void storeLastPage(final long txID, final LastPageRecord lastPage) throws Exception
-   {
+   {      
       if (lastPage.getRecordId() != 0)
       {
          // To avoid linked list effect on reclaiming, we delete and add a new
@@ -343,12 +346,11 @@
 
       messageJournal.appendAddRecordTransactional(txID, lastPage.getRecordId(), LAST_PAGE, lastPage);
    }
-   
+
    public void deleteLastPage(final long recordID) throws Exception
    {
       messageJournal.appendDeleteRecord(recordID);
    }
-   
 
    public void storeAcknowledgeTransactional(final long txID, final long queueID, final long messageID) throws Exception
    {
@@ -382,7 +384,7 @@
    }
 
    public void commit(final long txID) throws Exception
-   {    
+   {
       messageJournal.appendCommitRecord(txID);
    }
 
@@ -410,7 +412,7 @@
 
       messageJournal.appendUpdateRecordTransactional(txID, recordID, DUPLICATE_ID, encoding);
    }
-   
+
    public void deleteDuplicateIDTransactional(long txID, long recordID) throws Exception
    {
       messageJournal.appendDeleteRecordTransactional(txID, recordID);
@@ -451,15 +453,15 @@
          {
             case ADD_LARGE_MESSAGE:
             {
-               ServerLargeMessage largeMessage = this.createLargeMessage();
+               LargeServerMessage largeMessage = createLargeMessage();
 
                LargeMessageEncoding messageEncoding = new LargeMessageEncoding(largeMessage);
 
                messageEncoding.decode(buff);
 
-               List<MessageReference> refs = postOffice.reroute(largeMessage);
+               largeMessage.setReload();
 
-               postOffice.deliver(refs);
+               postOffice.route(largeMessage, null);
 
                break;
             }
@@ -469,10 +471,10 @@
 
                message.decode(buff);
 
-               List<MessageReference> refs = postOffice.reroute(message);
+               message.setReload();
+               
+               postOffice.route(message, null);
 
-               postOffice.deliver(refs);
-
                break;
             }
             case ACKNOWLEDGE_REF:
@@ -583,12 +585,12 @@
                if (ids == null)
                {
                   ids = new ArrayList<Pair<SimpleString, Long>>();
-                  
+
                   duplicateIDMap.put(encoding.address, ids);
                }
 
                ids.add(new Pair<SimpleString, Long>(encoding.duplID, record.id));
-               
+
                break;
             }
             default:
@@ -605,17 +607,17 @@
 
    public void addBinding(final Binding binding) throws Exception
    {
-      Queue queue = binding.getQueue();
-
       // We generate the queue id here
 
-      long queueID = idGenerator.generateID();
+      Bindable bindable = binding.getBindable();
 
-      queue.setPersistenceID(queueID);
+      long bindingID = idGenerator.generateID();
 
+      bindable.setPersistenceID(bindingID);
+
       final SimpleString filterString;
 
-      final Filter filter = queue.getFilter();
+      final Filter filter = bindable.getFilter();
 
       if (filter != null)
       {
@@ -626,21 +628,34 @@
          filterString = null;
       }
 
-      BindingEncoding bindingEncoding = new BindingEncoding(binding.getQueue().getName(),
+      SimpleString linkAddress;
+
+      if (binding.getType() == BindingType.LINK)
+      {
+         linkAddress = ((Link)bindable).getLinkAddress();
+      }
+      else
+      {
+         linkAddress = null;
+      }
+
+      BindingEncoding bindingEncoding = new BindingEncoding(binding.getType(),
+                                                            bindable.getName(),
                                                             binding.getAddress(),
                                                             filterString,
-                                                            binding.isExclusive());
+                                                            binding.isExclusive(),
+                                                            linkAddress);
 
-      bindingsJournal.appendAddRecord(queueID, BINDING_RECORD, bindingEncoding);
+      bindingsJournal.appendAddRecord(bindingID, BINDING_RECORD, bindingEncoding);
    }
 
    public void deleteBinding(final Binding binding) throws Exception
    {
-      long id = binding.getQueue().getPersistenceID();
+      long id = binding.getBindable().getPersistenceID();
 
       if (id == -1)
       {
-         throw new IllegalArgumentException("Cannot delete binding, id is " + id);
+         throw new IllegalArgumentException("Cannot delete binding, id is -1");
       }
 
       bindingsJournal.appendDeleteRecord(id);
@@ -681,7 +696,7 @@
       }
    }
 
-   public void loadBindings(final QueueFactory queueFactory,
+   public void loadBindings(final BindableFactory bindableFactory,
                             final List<Binding> bindings,
                             final List<SimpleString> destinations) throws Exception
    {
@@ -701,32 +716,50 @@
 
          if (rec == BINDING_RECORD)
          {
-            BindingEncoding encodeBinding = new BindingEncoding();
+            BindingEncoding bindingEncoding = new BindingEncoding();
 
-            encodeBinding.decode(buffer);
+            bindingEncoding.decode(buffer);
 
             Filter filter = null;
 
-            if (encodeBinding.filter != null)
+            if (bindingEncoding.filter != null)
             {
-               filter = new FilterImpl(encodeBinding.filter);
+               filter = new FilterImpl(bindingEncoding.filter);
             }
 
-            Queue queue = queueFactory.createQueue(id, encodeBinding.queueName, filter, true, false);
+            Bindable bindable;
 
-            Binding binding = new BindingImpl(encodeBinding.address, queue, encodeBinding.exclusive);
+            if (bindingEncoding.type == BindingType.QUEUE)
+            {
 
+               bindable = bindableFactory.createQueue(id, bindingEncoding.name, filter, true, false);
+            }
+            else
+            {
+               bindable = bindableFactory.createLink(id,
+                                                     bindingEncoding.name,
+                                                     filter,
+                                                     true,
+                                                     false,
+                                                     bindingEncoding.linkAddress);
+            }
+
+            Binding binding = new BindingImpl(bindingEncoding.type,
+                                              bindingEncoding.address,
+                                              bindable,
+                                              bindingEncoding.exclusive);
+
             bindings.add(binding);
          }
          else if (rec == DESTINATION_RECORD)
          {
-            DestinationEncoding destEnc = new DestinationEncoding();
+            DestinationEncoding destinationEncoding = new DestinationEncoding();
 
-            destEnc.decode(buffer);
+            destinationEncoding.decode(buffer);
 
-            destinationIDMap.put(destEnc.destination, id);
+            destinationIDMap.put(destinationEncoding.destination, id);
 
-            destinations.add(destEnc.destination);
+            destinations.add(destinationEncoding.destination);
          }
          else
          {
@@ -845,12 +878,8 @@
 
          Transaction tx = new TransactionImpl(preparedTransaction.id, xid, this, postOffice);
 
-         List<MessageReference> references = new ArrayList<MessageReference>();
-
          List<MessageReference> referencesToAck = new ArrayList<MessageReference>();
 
-         PageTransactionInfoImpl pageTransactionInfo = null;
-
          // first get any sent messages for this tx and recreate
          for (RecordInfo record : preparedTransaction.records)
          {
@@ -870,9 +899,9 @@
 
                   message.decode(buff);
 
-                  List<MessageReference> refs = postOffice.reroute(message);
+                  message.setReload();
 
-                  references.addAll(refs);
+                  postOffice.route(message, tx);
 
                   break;
                }
@@ -899,63 +928,46 @@
                   {
                      throw new IllegalStateException("Failed to remove reference for " + messageID);
                   }
-
+                  
                   break;
                }
                case PAGE_TRANSACTION:
                {
-                  pageTransactionInfo = new PageTransactionInfoImpl();
+                  PageTransactionInfo pageTransactionInfo = new PageTransactionInfoImpl();
 
                   pageTransactionInfo.decode(buff);
 
                   pageTransactionInfo.markIncomplete();
+                  
+                  tx.setPageTransaction(pageTransactionInfo);
 
                   break;
                }
                case SET_SCHEDULED_DELIVERY_TIME:
-               {
-                  long messageID = record.id;
-
-                  ScheduledDeliveryEncoding encoding = new ScheduledDeliveryEncoding();
-
-                  encoding.decode(buff);
-
-                  Queue queue = queues.get(encoding.queueID);
-
-                  if (queue == null)
-                  {
-                     throw new IllegalStateException("Cannot find queue with id " + encoding.queueID);
-                  }
-
-                  //FIXME - this involves a scan --- SLOW!!
-                  for (MessageReference ref : references)
-                  {
-                     if (ref.getQueue().getPersistenceID() == encoding.queueID && ref.getMessage().getMessageID() == messageID)
-                     {
-                        ref.setScheduledDeliveryTime(encoding.scheduledDeliveryTime);
-                     }
-                  }
-
+               {                  
+                  //Do nothing - for prepared txs, the set scheduled delivery time will only occur in a send in which
+                  //case the message will already have the header for the scheduled delivery time, so no need to do anything.
+               
                   break;
                }
                case DUPLICATE_ID:
                {
-                  //We need load the duplicate ids at prepare time too
+                  // We need load the duplicate ids at prepare time too
                   DuplicateIDEncoding encoding = new DuplicateIDEncoding();
-                  
+
                   encoding.decode(buff);
-                  
+
                   List<Pair<SimpleString, Long>> ids = duplicateIDMap.get(encoding.address);
 
                   if (ids == null)
                   {
                      ids = new ArrayList<Pair<SimpleString, Long>>();
-                     
+
                      duplicateIDMap.put(encoding.address, ids);
                   }
 
                   ids.add(new Pair<SimpleString, Long>(encoding.duplID, record.id));
-                  
+
                   break;
                }
                default:
@@ -997,9 +1009,13 @@
             }
          }
 
-         // now we recreate the state of the tx and add to the resource manager
-         tx.replay(references, referencesToAck, pageTransactionInfo);
-
+         for (MessageReference ack: referencesToAck)
+         {
+            tx.addAckTempUntilNextRefactoring(ack);
+         }
+                  
+         tx.setState(Transaction.State.PREPARED);
+         
          resourceManager.putTransaction(xid, tx);
       }
    }
@@ -1045,7 +1061,7 @@
          for (String tmpFile : tmpFiles)
          {
             SequentialFile file = largeMessagesFactory.createSequentialFile(tmpFile, -1);
-            log.info("cleaning up file " + file);
+            log.info("Deleting file " + file);
             file.delete();
          }
       }
@@ -1086,51 +1102,90 @@
 
    private static class BindingEncoding implements EncodingSupport
    {
-      SimpleString queueName;
+      BindingType type;
 
+      SimpleString name;
+
       SimpleString address;
 
       SimpleString filter;
 
       boolean exclusive;
 
+      SimpleString linkAddress;
+
       public BindingEncoding()
       {
       }
 
-      public BindingEncoding(final SimpleString queueName,
+      public BindingEncoding(final BindingType type,
+                             final SimpleString name,
                              final SimpleString address,
                              final SimpleString filter,
-                             final boolean exclusive)
+                             final boolean exclusive,
+                             final SimpleString linkAddress)
       {
          super();
-         this.queueName = queueName;
+         this.type = type;
+         this.name = name;
          this.address = address;
          this.filter = filter;
          this.exclusive = exclusive;
+         this.linkAddress = linkAddress;
       }
 
       public void decode(final MessagingBuffer buffer)
       {
-         queueName = buffer.getSimpleString();
+         int itype = buffer.getInt();
+         switch (itype)
+         {
+            case 0:
+            {
+               type = BindingType.LINK;
+               break;
+            }
+            case 1:
+            {
+               type = BindingType.QUEUE;
+               break;
+            }
+            default:
+            {
+               throw new IllegalArgumentException("Invalid binding type " + itype);
+            }
+         }
+         name = buffer.getSimpleString();
          address = buffer.getSimpleString();
          filter = buffer.getNullableSimpleString();
          exclusive = buffer.getBoolean();
+         linkAddress = buffer.getNullableSimpleString();
       }
 
       public void encode(final MessagingBuffer buffer)
       {
-         buffer.putSimpleString(queueName);
+         if (type == BindingType.LINK)
+         {
+            buffer.putInt(0);
+         }
+         else
+         {
+            buffer.putInt(1);
+         }
+         buffer.putSimpleString(name);
          buffer.putSimpleString(address);
          buffer.putNullableSimpleString(filter);
          buffer.putBoolean(exclusive);
+         buffer.putNullableSimpleString(linkAddress);
       }
-
+      
       public int getEncodeSize()
       {
-         return SimpleString.sizeofString(queueName) + SimpleString.sizeofString(address) + 1 + // HasFilter?
-                ((filter != null) ? SimpleString.sizeofString(filter) : 0) +
-                SIZE_BOOLEAN;
+         return SIZE_INT +
+                SimpleString.sizeofString(name) +
+                SimpleString.sizeofString(address) +
+                SimpleString.sizeofNullableString(filter) + 
+                SIZE_BOOLEAN +
+                SimpleString.sizeofNullableString(linkAddress);
       }
    }
 
@@ -1166,9 +1221,9 @@
 
    private static class LargeMessageEncoding implements EncodingSupport
    {
-      private final ServerLargeMessage message;
+      private final LargeServerMessage message;
 
-      public LargeMessageEncoding(ServerLargeMessage message)
+      public LargeMessageEncoding(LargeServerMessage message)
       {
          this.message = message;
       }

Deleted: trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageLargeMessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageLargeMessageImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageLargeMessageImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -1,114 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.messaging.core.persistence.impl.nullpm;
-
-import java.nio.ByteBuffer;
-
-import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
-import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
-import org.jboss.messaging.core.server.ServerLargeMessage;
-import org.jboss.messaging.core.server.impl.ServerMessageImpl;
-
-/**
- * A NullStorageLargeMessageImpl
- *
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * 
- * Created 30-Sep-08 1:51:42 PM
- *
- *
- */
-public class NullStorageLargeMessageImpl extends ServerMessageImpl implements ServerLargeMessage
-{
-
-   // Constants -----------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   // Public --------------------------------------------------------
-
-   public NullStorageLargeMessageImpl()
-   {
-      super();
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.messaging.core.server.ServerLargeMessage#release()
-    */
-   public void releaseResources()
-   {
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.messaging.core.server.ServerLargeMessage#addBytes(byte[])
-    */
-   public synchronized void addBytes(final byte[] bytes)
-   {
-      MessagingBuffer buffer = this.getBody();
-      
-      if (buffer != null)
-      {
-         ByteBuffer newBuffer = ByteBuffer.allocate(buffer.limit() + bytes.length);
-         newBuffer.put(buffer.array());
-         buffer = new ByteBufferWrapper(newBuffer);
-         this.setBody(buffer);
-      }
-      else
-      {
-         buffer = new ByteBufferWrapper(ByteBuffer.allocate(bytes.length));
-         this.setBody(buffer);
-      }
-      
-      buffer.putBytes(bytes);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.messaging.core.server.ServerLargeMessage#deleteFile()
-    */
-   public void deleteFile() throws Exception
-   {
-      // nothing to be done here.. we don really have a file on this Storage
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.messaging.core.server.ServerLargeMessage#complete()
-    */
-   public void complete() throws Exception
-   {
-      // nothing to be done here.. we don really have a file on this Storage
-      
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-
-}

Copied: trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageLargeServerMessage.java (from rev 5550, trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageLargeMessageImpl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageLargeServerMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageLargeServerMessage.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.persistence.impl.nullpm;
+
+import java.nio.ByteBuffer;
+
+import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
+import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
+import org.jboss.messaging.core.server.LargeServerMessage;
+import org.jboss.messaging.core.server.impl.ServerMessageImpl;
+
+/**
+ * A NullStorageLargeServerMessage
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * 
+ * Created 30-Sep-08 1:51:42 PM
+ *
+ *
+ */
+public class NullStorageLargeServerMessage extends ServerMessageImpl implements LargeServerMessage
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public NullStorageLargeServerMessage()
+   {
+      super();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.messaging.core.server.LargeServerMessage#release()
+    */
+   public void releaseResources()
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.messaging.core.server.LargeServerMessage#addBytes(byte[])
+    */
+   public synchronized void addBytes(final byte[] bytes)
+   {
+      MessagingBuffer buffer = this.getBody();
+      
+      if (buffer != null)
+      {
+         ByteBuffer newBuffer = ByteBuffer.allocate(buffer.limit() + bytes.length);
+         newBuffer.put(buffer.array());
+         buffer = new ByteBufferWrapper(newBuffer);
+         this.setBody(buffer);
+      }
+      else
+      {
+         buffer = new ByteBufferWrapper(ByteBuffer.allocate(bytes.length));
+         this.setBody(buffer);
+      }
+      
+      buffer.putBytes(bytes);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.messaging.core.server.LargeServerMessage#deleteFile()
+    */
+   public void deleteFile() throws Exception
+   {
+      // nothing to be done here.. we don really have a file on this Storage
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.messaging.core.server.LargeServerMessage#complete()
+    */
+   public void complete() throws Exception
+   {
+      // nothing to be done here.. we don really have a file on this Storage
+      
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Modified: trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/nullpm/NullStorageManager.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -34,8 +34,8 @@
 import org.jboss.messaging.core.postoffice.PostOffice;
 import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.QueueFactory;
-import org.jboss.messaging.core.server.ServerLargeMessage;
+import org.jboss.messaging.core.server.BindableFactory;
+import org.jboss.messaging.core.server.LargeServerMessage;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.transaction.ResourceManager;
 import org.jboss.messaging.util.IDGenerator;
@@ -79,7 +79,7 @@
       return true;
    }
 
-   public void loadBindings(final QueueFactory queueFactory,
+   public void loadBindings(final BindableFactory queueFactory,
                             final List<Binding> bindings,
                             final List<SimpleString> destinations) throws Exception
    {
@@ -166,9 +166,9 @@
    /* (non-Javadoc)
     * @see org.jboss.messaging.core.persistence.StorageManager#createLargeMessageStorage(long, int, int)
     */
-   public ServerLargeMessage createLargeMessage()
+   public LargeServerMessage createLargeMessage()
    {
-      return new NullStorageLargeMessageImpl();
+      return new NullStorageLargeServerMessage();
    }
 
    public long generateUniqueID()

Modified: trunk/src/main/org/jboss/messaging/core/postoffice/Binding.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/Binding.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/Binding.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -22,7 +22,7 @@
 
 package org.jboss.messaging.core.postoffice;
 
-import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.Bindable;
 import org.jboss.messaging.util.SimpleString;
 
 
@@ -35,9 +35,11 @@
  */
 public interface Binding
 {
+   BindingType getType();
+   
    SimpleString getAddress();
    
-   Queue getQueue();
+   Bindable getBindable();
    
    int getWeight();
    

Added: trunk/src/main/org/jboss/messaging/core/postoffice/BindingType.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/BindingType.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/BindingType.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.jboss.messaging.core.postoffice;
+
+/**
+ * A BindingType
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * 
+ * Created 22 Dec 2008 13:37:23
+ *
+ *
+ */
+public enum BindingType
+{
+   QUEUE, LINK;
+}

Modified: trunk/src/main/org/jboss/messaging/core/postoffice/Bindings.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/Bindings.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/Bindings.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -24,7 +24,6 @@
 
 import java.util.List;
 
-import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.transaction.Transaction;
 
@@ -41,9 +40,9 @@
 {
    List<Binding> getBindings();
    
-   List<MessageReference> route(final ServerMessage message);
+   void route(final ServerMessage message) throws Exception;
    
-   List<MessageReference> route(ServerMessage message, Transaction tx);
+   void route(ServerMessage message, Transaction tx) throws Exception;
    
    void addBinding(Binding binding);
    

Modified: trunk/src/main/org/jboss/messaging/core/postoffice/PostOffice.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/PostOffice.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/PostOffice.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -27,7 +27,6 @@
 
 import org.jboss.messaging.core.filter.Filter;
 import org.jboss.messaging.core.paging.PagingManager;
-import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.MessagingComponent;
 import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.core.server.SendLock;
@@ -61,19 +60,28 @@
 
    boolean containsDestination(SimpleString address);
 
-   Binding addBinding(SimpleString address, SimpleString queueName, Filter filter, boolean durable, boolean temporary, boolean exclusive) throws Exception;
+   Binding addLinkBinding(SimpleString name,
+                          SimpleString address,
+                          Filter filter,
+                          boolean durable,
+                          boolean temporary,
+                          boolean exclusive,
+                          SimpleString linkAddress) throws Exception;
 
-   Binding removeBinding(SimpleString queueName) throws Exception;
+   Binding addQueueBinding(SimpleString name,
+                           SimpleString address,
+                           Filter filter,
+                           boolean durable,
+                           boolean temporary,
+                           boolean exclusive) throws Exception;
 
+   Binding removeBinding(SimpleString name) throws Exception;
+
    Bindings getBindingsForAddress(SimpleString address) throws Exception;
 
-   Binding getBinding(SimpleString queueName);
+   Binding getBinding(SimpleString name);
 
    void route(ServerMessage message, Transaction tx) throws Exception;
-   
-   List<MessageReference> route(ServerMessage message, Transaction tx, boolean deliver) throws Exception;
-   
-   List<MessageReference> reroute(ServerMessage message) throws Exception;
 
    Set<SimpleString> listAllDestinations();
 
@@ -86,6 +94,4 @@
    DuplicateIDCache getDuplicateIDCache(SimpleString address);
 
    int numMappings();
-
-   void deliver(final List<MessageReference> references);
 }

Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/BindingImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/BindingImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/BindingImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -23,7 +23,8 @@
 package org.jboss.messaging.core.postoffice.impl;
 
 import org.jboss.messaging.core.postoffice.Binding;
-import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.postoffice.BindingType;
+import org.jboss.messaging.core.server.Bindable;
 import org.jboss.messaging.util.SimpleString;
 
 /**
@@ -35,9 +36,11 @@
  */
 public class BindingImpl implements Binding
 {  
+   private final BindingType type;
+   
    private final SimpleString address;
    
-   private final Queue queue;
+   private final Bindable bindable;
    
    private final boolean exclusive;
    
@@ -47,23 +50,30 @@
    
    private int hash;
                 
-   public BindingImpl(final SimpleString address, final Queue queue, final boolean exclusive)
+   public BindingImpl(final BindingType type, final SimpleString address, final Bindable bindable, final boolean exclusive)
    {
+      this.type = type;
+       
       this.address = address;
       
-      this.queue = queue;
+      this.bindable = bindable;
       
       this.exclusive = exclusive;
    }
    
+   public BindingType getType()
+   {
+      return type;
+   }
+    
    public SimpleString getAddress()
    {
       return address;
    }
    
-   public Queue getQueue()
+   public Bindable getBindable()
    {
-      return queue;
+      return bindable;
    }
    
    public boolean isExclusive()
@@ -87,10 +97,11 @@
       {
          return true;
       }
+      
       Binding bother = (Binding)other;
       
       return (this.address.equals(bother.getAddress()) &&
-              this.queue.equals(bother.getQueue()));
+              this.bindable.equals(bother.getBindable()));
    }
    
    public int hashCode()
@@ -99,7 +110,7 @@
       {
          hash = 17;
          hash = 37 * hash + address.hashCode();
-         hash = 37 * hash + queue.hashCode();
+         hash = 37 * hash + bindable.hashCode();
                 
          hashAssigned = true;
       }

Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/BindingsImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/BindingsImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/BindingsImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -23,7 +23,6 @@
 package org.jboss.messaging.core.postoffice.impl;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -32,8 +31,8 @@
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.postoffice.Binding;
 import org.jboss.messaging.core.postoffice.Bindings;
+import org.jboss.messaging.core.server.Bindable;
 import org.jboss.messaging.core.server.MessageReference;
-import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.transaction.Transaction;
 
@@ -85,31 +84,25 @@
       }
    }
    
-   public List<MessageReference> route(final ServerMessage message)
+   public void route(final ServerMessage message) throws Exception
    {
-      return route(message, null);
+      route(message, null);
    }
    
-   public List<MessageReference> route(final ServerMessage message, final Transaction tx)
+   public void route(final ServerMessage message, final Transaction tx) throws Exception
    {
       if (numberExclusive.get() > 0)
       {
          // We need to round robin
          
-         List<MessageReference> refs = new ArrayList<MessageReference>(1);
-
          Binding binding = getNext(message);
             
          if (binding != null)
          {        
-            Queue queue = binding.getQueue();
-            
-            MessageReference reference = message.createReference(queue);
-   
-            refs.add(reference);             
-         }
-         
-         return refs;
+            Bindable bindable = binding.getBindable();
+                 
+            bindable.route(message, tx);
+         }         
       }
       else
       {
@@ -119,30 +112,20 @@
          
          if (!bindings.isEmpty())
          {   
-            List<MessageReference> refs = new ArrayList<MessageReference>();
-   
             for (Binding binding : bindings)
             {
-               Queue queue = binding.getQueue();
+               Bindable bindable = binding.getBindable();
    
-               Filter filter = queue.getFilter();
+               Filter filter = bindable.getFilter();
    
                //Note we ignore any exclusive - this structure is concurrent so one could have been added
                //since the initial check on number of exclusive
                if (!binding.isExclusive() && (filter == null || filter.match(message)))
                {
-                  MessageReference reference = message.createReference(queue);
-   
-                  refs.add(reference);
+                  bindable.route(message, tx);
                }
             }
-            
-            return refs;
          }
-         else
-         {
-            return Collections.<MessageReference>emptyList();
-         }
       }
    }
    
@@ -169,7 +152,7 @@
                weightCount.set(binding.getWeight());
             }
             
-            Filter filter = binding.getQueue().getFilter();
+            Filter filter = binding.getBindable().getFilter();
             
             if ((filter != null && !filter.match(message)) || weightCount.get() == 0)
             {

Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/DuplicateIDCacheImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/DuplicateIDCacheImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/DuplicateIDCacheImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -30,7 +30,7 @@
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.DuplicateIDCache;
 import org.jboss.messaging.core.transaction.Transaction;
-import org.jboss.messaging.core.transaction.TransactionSynchronization;
+import org.jboss.messaging.core.transaction.TransactionOperation;
 import org.jboss.messaging.util.ConcurrentHashSet;
 import org.jboss.messaging.util.Pair;
 import org.jboss.messaging.util.SimpleString;
@@ -183,7 +183,7 @@
 
       // For a tx, it's important that the entry is not added to the cache until commit (or prepare)
       // since if the client fails then resends them tx we don't want it to get rejected
-      tx.addSynchronization(new Sync(duplID, recordID));      
+      tx.addOperation(new AddDuplicateIDOperation(duplID, recordID));      
    }
 
    private void addToCacheInMemory(final SimpleString duplID, final long recordID) throws Exception
@@ -221,15 +221,15 @@
       }
    }
 
-   private class Sync implements TransactionSynchronization
-   {
+   private class AddDuplicateIDOperation implements TransactionOperation
+   {      
       final SimpleString duplID;
 
       final long recordID;
 
       volatile boolean done;
 
-      Sync(final SimpleString duplID, final long recordID)
+      AddDuplicateIDOperation(final SimpleString duplID, final long recordID)
       {
          this.duplID = duplID;
 
@@ -245,7 +245,19 @@
             done = true;
          }
       }
+      
+      public void beforeCommit() throws Exception
+      {
+      }
 
+      public void beforePrepare() throws Exception
+      {
+      }
+
+      public void beforeRollback() throws Exception
+      {
+      }
+
       public void afterCommit() throws Exception
       {
          process();

Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -37,18 +37,18 @@
 import org.jboss.messaging.core.filter.Filter;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.management.ManagementService;
-import org.jboss.messaging.core.message.impl.MessageImpl;
 import org.jboss.messaging.core.paging.PagingManager;
-import org.jboss.messaging.core.paging.PagingStore;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.AddressManager;
 import org.jboss.messaging.core.postoffice.Binding;
+import org.jboss.messaging.core.postoffice.BindingType;
 import org.jboss.messaging.core.postoffice.Bindings;
 import org.jboss.messaging.core.postoffice.DuplicateIDCache;
 import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.Bindable;
+import org.jboss.messaging.core.server.BindableFactory;
 import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.QueueFactory;
 import org.jboss.messaging.core.server.SendLock;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.server.impl.SendLockImpl;
@@ -70,12 +70,12 @@
 public class PostOfficeImpl implements PostOffice
 {
    private static final Logger log = Logger.getLogger(PostOfficeImpl.class);
-   
-   private static final List<MessageReference> emptyList = Collections.<MessageReference>emptyList();
-   
+
+   private static final List<MessageReference> emptyList = Collections.<MessageReference> emptyList();
+
    private final AddressManager addressManager;
 
-   private final QueueFactory queueFactory;
+   private final BindableFactory bindableFactory;
 
    private final boolean checkAllowable;
 
@@ -106,10 +106,10 @@
    private final int idCacheSize;
 
    private final boolean persistIDCache;
-   
+
    public PostOfficeImpl(final StorageManager storageManager,
                          final PagingManager pagingManager,
-                         final QueueFactory queueFactory,
+                         final BindableFactory bindableFactory,
                          final ManagementService managementService,
                          final HierarchicalRepository<QueueSettings> queueSettingsRepository,
                          final long messageExpiryScanPeriod,
@@ -123,7 +123,7 @@
    {
       this.storageManager = storageManager;
 
-      this.queueFactory = queueFactory;
+      this.bindableFactory = bindableFactory;
 
       this.managementService = managementService;
 
@@ -167,7 +167,7 @@
       }
 
       // Injecting the postoffice (itself) on queueFactory for paging-control
-      queueFactory.setPostOffice(this);
+      bindableFactory.setPostOffice(this);
 
       load();
 
@@ -265,14 +265,14 @@
    // and post office is activated but queue remains unactivated after failover so delivery never occurs
    // even though failover is complete
    // TODO - more subtle locking could be used -this is a bit heavy handed
-   public synchronized Binding addBinding(final SimpleString address,
-                                          final SimpleString queueName,
-                                          final Filter filter,
-                                          final boolean durable,
-                                          final boolean temporary,
-                                          final boolean exclusive) throws Exception
+   public synchronized Binding addQueueBinding(final SimpleString name,
+                                               final SimpleString address,
+                                               final Filter filter,
+                                               final boolean durable,
+                                               final boolean temporary,
+                                               final boolean exclusive) throws Exception
    {
-      Binding binding = createBinding(address, queueName, filter, durable, temporary, exclusive);
+      Binding binding = createQueueBinding(name, address, filter, durable, temporary, exclusive);
 
       addBindingInMemory(binding);
 
@@ -284,16 +284,39 @@
       return binding;
    }
 
-   public synchronized Binding removeBinding(final SimpleString queueName) throws Exception
+   public synchronized Binding addLinkBinding(final SimpleString name,
+                                              final SimpleString address,
+                                              final Filter filter,
+                                              final boolean durable,
+                                              final boolean temporary,
+                                              final boolean exclusive,
+                                              final SimpleString linkAddress) throws Exception
    {
-      Binding binding = removeQueueInMemory(queueName);
+      Binding binding = createLinkBinding(name, address, filter, durable, temporary, exclusive, linkAddress);
 
-      if (binding.getQueue().isDurable())
+      addBindingInMemory(binding);
+
+      if (durable)
       {
+         storageManager.addBinding(binding);
+      }
+
+      return binding;
+   }
+
+   public synchronized Binding removeBinding(final SimpleString bindableName) throws Exception
+   {
+      Binding binding = removeBindingInMemory(bindableName);
+
+      if (binding.getBindable().isDurable())
+      {
          storageManager.deleteBinding(binding);
       }
 
-      managementService.unregisterQueue(queueName, binding.getAddress());
+      if (binding.getType() == BindingType.QUEUE)
+      {
+         managementService.unregisterQueue(bindableName, binding.getAddress());
+      }
 
       return binding;
    }
@@ -301,12 +324,12 @@
    public Bindings getBindingsForAddress(final SimpleString address)
    {
       Bindings bindings = addressManager.getBindings(address);
-      
+
       if (bindings == null)
       {
          bindings = new BindingsImpl();
       }
-      
+
       return bindings;
    }
 
@@ -315,36 +338,10 @@
       return addressManager.getBinding(queueName);
    }
 
-   public void deliver(final List<MessageReference> references)
+   public void route(final ServerMessage message, final Transaction tx) throws Exception
    {
-      for (MessageReference ref : references)
-      {
-         ref.getQueue().add(ref);
-      }
-   }
-
-   public List<MessageReference> reroute(final ServerMessage message) throws Exception
-   {
       SimpleString address = message.getDestination();
 
-      Bindings bindings = addressManager.getBindings(address);
-
-      List<MessageReference> references = null;
-      
-      if (bindings != null)
-      {
-         references = bindings.route(message, null);
-
-         computePaging(address, message, references);
-      }
-      
-      return references;
-   }
-   
-   public List<MessageReference> route(final ServerMessage message, final Transaction tx, final boolean deliver) throws Exception
-   {      
-      SimpleString address = message.getDestination();
-
       if (checkAllowable)
       {
          if (!addressManager.containsDestination(address))
@@ -356,84 +353,35 @@
 
       Bindings bindings = addressManager.getBindings(address);
 
-      List<MessageReference> references = null;
-      
       if (bindings != null)
       {
-         references = bindings.route(message, tx);
-
-         computePaging(address, message, references);
+         bindings.route(message, tx);
       }
+   }
 
-      if (message.getDurableRefCount() != 0)
+   public void route(final ServerMessage message) throws Exception
+   {
+      SimpleString address = message.getDestination();
+
+      if (checkAllowable)
       {
-         if (tx == null)
+         if (!addressManager.containsDestination(address))
          {
-            storageManager.storeMessage(message);
+            throw new MessagingException(MessagingException.ADDRESS_DOES_NOT_EXIST,
+                                         "Cannot route to address " + address);
          }
-         else
-         {
-            storageManager.storeMessageTransactional(tx.getID(), message);
-         }
       }
 
-      if (references != null)
-      {         
-         Long scheduledDeliveryTime = (Long)message.getProperty(MessageImpl.HDR_SCHEDULED_DELIVERY_TIME);
+      if (!pagingManager.page(message))
+      {
+         Bindings bindings = addressManager.getBindings(address);
 
-         if (scheduledDeliveryTime != null)
+         if (bindings != null)
          {
-            for (MessageReference ref : references)
-            {
-               ref.setScheduledDeliveryTime(scheduledDeliveryTime);
-
-               if (ref.getMessage().isDurable() && ref.getQueue().isDurable())
-               {
-                  if (tx != null)
-                  {
-                     storageManager.updateScheduledDeliveryTimeTransactional(tx.getID(), ref);
-                  }
-                  else
-                  {
-                     storageManager.updateScheduledDeliveryTime(ref);
-                  }
-               }
-            }
+            bindings.route(message, null);
          }
-         
-//         TODO - bindings.route does not need to return a messagereference list, instead bindings route should actually create the refs and send them to the queues
-//         then we can get rid of the deliver call too
-//                          
-//         for a transaction bindings.route
-//          
-      
-         if (deliver)
-         {
-            deliver(references);
-         }
-                  
-         return references;
       }
-      else
-      {
-         return emptyList;
-      }
    }
-   
-   public void route(final ServerMessage message, final Transaction tx) throws Exception
-   {
-      if (tx == null)
-      {
-         if (!pagingManager.page(message))
-         {
-            route(message, null, true);
-         }
-      }
-      else
-      {
-         tx.addMessage(message);
-      }
-   }
 
    public PagingManager getPagingManager()
    {
@@ -450,13 +398,16 @@
 
       for (Binding binding : nameMap.values())
       {
-         Queue queue = binding.getQueue();
+         if (binding.getType() == BindingType.QUEUE)
+         {
+            Queue queue = (Queue)binding.getBindable();
 
-         boolean activated = queue.activate();
+            boolean activated = queue.activate();
 
-         if (!activated)
-         {
-            queues.add(queue);
+            if (!activated)
+            {
+               queues.add(queue);
+            }
          }
       }
 
@@ -502,66 +453,65 @@
    }
 
    // Private -----------------------------------------------------------------
- 
-   /**
-    * Add sizes on Paging
-    * @param address
-    * @param message
-    * @param references
-    * @throws Exception
-    */
-   private void computePaging(SimpleString address, final ServerMessage message, List<MessageReference> references) throws Exception
-   {
-      if (!references.isEmpty())
-      {
-         PagingStore store = pagingManager.getPageStore(address);
 
-         store.addSize(message.getMemoryEstimate());
-
-         for (MessageReference ref : references)
-         {
-            store.addSize(ref.getMemoryEstimate());
-         }
-      }
-   }
-
-   private Binding createBinding(final SimpleString address,
-                                 final SimpleString name,
-                                 final Filter filter,
-                                 final boolean durable,
-                                 final boolean temporary,
-                                 final boolean exclusive) throws Exception
+   private Binding createQueueBinding(final SimpleString name,
+                                      final SimpleString address,
+                                      final Filter filter,
+                                      final boolean durable,
+                                      final boolean temporary,
+                                      final boolean exclusive) throws Exception
    {
-      Queue queue = queueFactory.createQueue(-1, name, filter, durable, false);
+      Bindable bindable = bindableFactory.createQueue(-1, name, filter, durable, temporary);
 
       if (backup)
       {
+         Queue queue = (Queue)bindable;
+
          queue.setBackup();
       }
 
-      Binding binding = new BindingImpl(address, queue, exclusive);
+      Binding binding = new BindingImpl(BindingType.QUEUE, address, bindable, exclusive);
 
       return binding;
    }
 
+   private Binding createLinkBinding(final SimpleString name,
+                                     final SimpleString address,
+                                     final Filter filter,
+                                     final boolean durable,
+                                     final boolean temporary,
+                                     final boolean exclusive,
+                                     final SimpleString linkAddress) throws Exception
+   {
+      Bindable bindable = bindableFactory.createLink(-1, name, filter, durable, temporary, linkAddress);
+
+      Binding binding = new BindingImpl(BindingType.LINK, address, bindable, exclusive);
+
+      return binding;
+   }
+
    private void addBindingInMemory(final Binding binding) throws Exception
    {
       boolean exists = addressManager.addMapping(binding.getAddress(), binding);
+
       if (!exists)
       {
          managementService.registerAddress(binding.getAddress());
       }
 
-      managementService.registerQueue(binding.getQueue(), binding.getAddress(), storageManager);
+      if (binding.getType() == BindingType.QUEUE)
+      {
+         managementService.registerQueue((Queue)binding.getBindable(), binding.getAddress(), storageManager);
+      }
 
       addressManager.addBinding(binding);
    }
 
-   private Binding removeQueueInMemory(final SimpleString queueName) throws Exception
+   private Binding removeBindingInMemory(final SimpleString bindingName) throws Exception
    {
-      Binding binding = addressManager.removeBinding(queueName);
+      Binding binding = addressManager.removeBinding(bindingName);
 
-      if (addressManager.removeMapping(binding.getAddress(), queueName))
+      if (addressManager.removeMapping(binding.getAddress(), bindingName))
       {
          managementService.unregisterAddress(binding.getAddress());
       }
@@ -575,7 +525,7 @@
 
       List<SimpleString> dests = new ArrayList<SimpleString>();
 
-      storageManager.loadBindings(queueFactory, bindings, dests);
+      storageManager.loadBindings(bindableFactory, bindings, dests);
 
       // Destinations must be added first to ensure flow controllers exist
       // before queues are created
@@ -590,7 +540,10 @@
       {
          addBindingInMemory(binding);
 
-         queues.put(binding.getQueue().getPersistenceID(), binding.getQueue());
+         if (binding.getType() == BindingType.QUEUE)
+         {
+            queues.put(binding.getBindable().getPersistenceID(), (Queue)binding.getBindable());
+         }
       }
 
       Map<SimpleString, List<Pair<SimpleString, Long>>> duplicateIDMap = new HashMap<SimpleString, List<Pair<SimpleString, Long>>>();
@@ -626,9 +579,14 @@
 
          for (Binding binding : nameMap.values())
          {
-            Queue queue = binding.getQueue();
-            queues.add(queue);
+            if (binding.getType() == BindingType.QUEUE)
+            {
+               Queue queue = (Queue)binding.getBindable();
+
+               queues.add(queue);
+            }
          }
+
          for (Queue queue : queues)
          {
             try

Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/SimpleAddressManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/SimpleAddressManager.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/SimpleAddressManager.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -48,9 +48,9 @@
 
    private final ConcurrentMap<SimpleString, Binding> nameMap = new ConcurrentHashMap<SimpleString, Binding>();
 
-   public void addBinding(Binding binding)
+   public void addBinding(final Binding binding)
    {
-      if (nameMap.putIfAbsent(binding.getQueue().getName(), binding) != null)
+      if (nameMap.putIfAbsent(binding.getBindable().getName(), binding) != null)
       {
          throw new IllegalStateException("Binding already exists " + binding);
       }
@@ -106,9 +106,9 @@
       return destinations;
    }
 
-   public Binding getBinding(final SimpleString queueName)
+   public Binding getBinding(final SimpleString bindableName)
    {
-      return nameMap.get(queueName);
+      return nameMap.get(bindableName);
    }
 
    public Map<SimpleString, Binding> getBindings()
@@ -128,24 +128,24 @@
       return mappings.size();
    }
    
-   public Binding removeBinding(final SimpleString queueName)
+   public Binding removeBinding(final SimpleString bindableName)
    {
-      Binding binding = nameMap.remove(queueName);
+      Binding binding = nameMap.remove(bindableName);
 
       if (binding == null)
       {
-         throw new IllegalStateException("Queue is not bound " + queueName);
+         throw new IllegalStateException("Queue is not bound " + bindableName);
       }
       return binding;
    }
 
-   public boolean removeMapping(final SimpleString address, final SimpleString queueName)
+   public boolean removeMapping(final SimpleString address, final SimpleString bindableName)
    {
       Bindings bindings = mappings.get(address);
       
       if (bindings != null)
       {
-         removeMapping(queueName, bindings);
+         removeMapping(bindableName, bindings);
          
          if (bindings.getBindings().isEmpty())
          {
@@ -158,13 +158,13 @@
       return false;
    }
 
-   protected Binding removeMapping(final SimpleString queueName, final Bindings bindings)
+   protected Binding removeMapping(final SimpleString bindableName, final Bindings bindings)
    {
       Binding theBinding = null;
       
       for (Binding binding: bindings.getBindings())
       {
-         if (binding.getQueue().getName().equals(queueName))
+         if (binding.getBindable().getName().equals(bindableName))
          {
             theBinding = binding;
 
@@ -174,7 +174,7 @@
 
       if (theBinding == null)
       {
-         throw new IllegalStateException("Cannot find binding " + queueName);
+         throw new IllegalStateException("Cannot find binding " + bindableName);
       }
 
       bindings.removeBinding(theBinding);

Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/WildcardAddressManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/WildcardAddressManager.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/WildcardAddressManager.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -87,7 +87,7 @@
       {
          for (Address destination : add.getLinkedAddresses())
          {
-            BindingImpl binding1 = new BindingImpl(destination.getAddress(), binding.getQueue(), binding.isExclusive());
+            BindingImpl binding1 = new BindingImpl(binding.getType(), destination.getAddress(), binding.getBindable(), binding.isExclusive());
             super.addMapping(destination.getAddress(), binding1);
          }
          return super.addMapping(address, binding);
@@ -99,15 +99,15 @@
     * otherwise it will be removed as normal.
     *
     * @param address   the address to remove the binding from
-    * @param queueName the name of the queue for the binding to remove
+    * @param bindableName the name of the queue for the binding to remove
     * @return true if this was the last mapping for a specific address
     */
-   public boolean removeMapping(final SimpleString address, final SimpleString queueName)
+   public boolean removeMapping(final SimpleString address, final SimpleString bindableName)
    {
       Address add = removeAndUpdateAddressMap(address);
       if (!add.containsWildCard())
       {
-         boolean removed = super.removeMapping(address, queueName);
+         boolean removed = super.removeMapping(address, bindableName);
          for (Address destination : add.getLinkedAddresses())
          {
             Bindings bindings = getBindings(destination.getAddress());
@@ -115,7 +115,7 @@
             {
                for (Binding b : bindings.getBindings())
                {
-                  super.removeMapping(address, b.getQueue().getName());
+                  super.removeMapping(address, b.getBindable().getName());
                }
             }
          }
@@ -125,9 +125,9 @@
       {
          for (Address destination : add.getLinkedAddresses())
          {
-            super.removeMapping(destination.getAddress(), queueName);
+            super.removeMapping(destination.getAddress(), bindableName);
          }
-         return super.removeMapping(address, queueName);
+         return super.removeMapping(address, bindableName);
       }
    }
 

Added: trunk/src/main/org/jboss/messaging/core/server/Bindable.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/Bindable.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/server/Bindable.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.jboss.messaging.core.server;
+
+import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.transaction.Transaction;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * A Bindable
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * 
+ * Created 21 Dec 2008 09:10:18
+ *
+ *
+ */
+public interface Bindable
+{
+   Filter getFilter();
+   
+   SimpleString getName();
+   
+   long getPersistenceID();
+   
+   void setPersistenceID(long id);
+   
+   void route(ServerMessage message, Transaction tx) throws Exception;
+   
+   boolean isDurable();
+}

Copied: trunk/src/main/org/jboss/messaging/core/server/BindableFactory.java (from rev 5550, trunk/src/main/org/jboss/messaging/core/server/QueueFactory.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/BindableFactory.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/server/BindableFactory.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.server;
+
+import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * 
+ * A BindableFactory
+ * 
+ * Implementations of this class know how to create queues with the correct attribute values
+ * based on default and overrides
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface BindableFactory
+{
+   Queue createQueue(long persistenceID, SimpleString name, Filter filter, boolean durable, boolean temporary);
+
+   Link createLink(long persistenceID,
+                   SimpleString name,
+                   Filter filter,
+                   boolean durable,
+                   boolean temporary,
+                   SimpleString linkAddress);
+
+   // TODO - these injectors should not be here!!
+
+   /**
+    * This is required for delete-all-reference to work correctly with paging
+    * @param postOffice
+    */
+   void setPostOffice(PostOffice postOffice);
+}

Copied: trunk/src/main/org/jboss/messaging/core/server/LargeServerMessage.java (from rev 5550, trunk/src/main/org/jboss/messaging/core/server/ServerLargeMessage.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/LargeServerMessage.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/server/LargeServerMessage.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.server;
+
+/**
+ * A LargeMessage
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * 
+ * Created 30-Sep-08 10:58:04 AM
+ *
+ *
+ */
+public interface LargeServerMessage extends ServerMessage
+{
+   void addBytes(byte[] bytes) throws Exception;
+
+   /** Close the files if opened */
+   void releaseResources();
+   
+   void complete() throws Exception;
+   
+   void deleteFile() throws Exception;
+}

Added: trunk/src/main/org/jboss/messaging/core/server/Link.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/Link.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/server/Link.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.jboss.messaging.core.server;
+
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * A Link
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * 
+ * Created 24 Dec 2008 09:58:04
+ *
+ *
+ */
+public interface Link extends Bindable
+{
+   SimpleString getLinkAddress();
+}

Modified: trunk/src/main/org/jboss/messaging/core/server/MessageReference.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/MessageReference.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/server/MessageReference.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -81,7 +81,7 @@
 
    void move(SimpleString toAddress, StorageManager persistenceManager, PostOffice postOffice) throws Exception;
 
-   void move(SimpleString toAddress, Transaction tx, StorageManager persistenceManager, boolean expiry) throws Exception;
+   void move(SimpleString toAddress, Transaction tx, StorageManager persistenceManager, PostOffice postOffice, boolean expiry) throws Exception;
 
 }
 

Modified: trunk/src/main/org/jboss/messaging/core/server/Queue.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/Queue.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/server/Queue.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -43,10 +43,12 @@
  * @author <a href="clebert.suconic at jboss.com">Clebert Suconic</a>
  *
  */
-public interface Queue extends ReferenceHandler
+public interface Queue extends Bindable
 {     
-   HandleStatus addFirst(MessageReference ref);
+   void addLast(MessageReference ref);
    
+   void addFirst(MessageReference ref);
+   
    /**
     * This method is used to add a List of MessageReferences atomically at the head of the list.
     * Useful when cancelling messages and guaranteeing ordering
@@ -64,12 +66,6 @@
    
    List<MessageReference> list(Filter filter);
    
-   long getPersistenceID();
-   
-   void setPersistenceID(long id);
-   
-   Filter getFilter();
-   
    int getMessageCount();
    
    int getDeliveringCount();

Deleted: trunk/src/main/org/jboss/messaging/core/server/QueueFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/QueueFactory.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/server/QueueFactory.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
-
-package org.jboss.messaging.core.server;
-
-import org.jboss.messaging.core.filter.Filter;
-import org.jboss.messaging.core.postoffice.PostOffice;
-import org.jboss.messaging.util.SimpleString;
-
-/**
- * 
- * A QueueFactory
- * 
- * Implementations of this class know how to create queues with the correct attribute values
- * based on default and overrides
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface QueueFactory
-{
-   Queue createQueue(long persistenceID, SimpleString name, Filter filter,
-                     boolean durable, boolean temporary);
-   
-   /**
-    * This is required for delete-all-reference to work correctly with paging
-    * @param postOffice
-    */
-   void setPostOffice(PostOffice postOffice);
-}

Deleted: trunk/src/main/org/jboss/messaging/core/server/ReferenceHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/ReferenceHandler.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/server/ReferenceHandler.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-
-package org.jboss.messaging.core.server;
-
-/**
- * A ReferenceHandler
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * 
- * Created 10 Dec 2008 19:14:20
- *
- *
- */
-
-//TODO - can this be combined with consumer??
-public interface ReferenceHandler
-{
-   HandleStatus add(MessageReference ref);   
-}

Deleted: trunk/src/main/org/jboss/messaging/core/server/ServerLargeMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/ServerLargeMessage.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/server/ServerLargeMessage.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.messaging.core.server;
-
-/**
- * A LargeMessage
- *
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * 
- * Created 30-Sep-08 10:58:04 AM
- *
- *
- */
-public interface ServerLargeMessage extends ServerMessage
-{
-   void addBytes(byte[] bytes) throws Exception;
-
-   /** Close the files if opened */
-   void releaseResources();
-   
-   void complete() throws Exception;
-   
-   void deleteFile() throws Exception;
-
-}

Modified: trunk/src/main/org/jboss/messaging/core/server/ServerMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/ServerMessage.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/server/ServerMessage.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -37,10 +37,12 @@
 {      
    void setMessageID(long id);
 
-   MessageReference createReference(Queue queue);   
+   MessageReference createReference(Queue queue);
 
    int decrementDurableRefCount();
    
+   int getRefCount();
+   
    int getDurableRefCount();
    
    int decrementRefCount();
@@ -50,5 +52,9 @@
    ServerMessage copy();
    
    int getMemoryEstimate();
+   
+   void setReload();
+   
+   boolean isReload();
 }
 

Modified: trunk/src/main/org/jboss/messaging/core/server/cluster/impl/ForwarderImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/cluster/impl/ForwarderImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/server/cluster/impl/ForwarderImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -36,6 +36,7 @@
 import org.jboss.messaging.core.config.TransportConfiguration;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.message.impl.MessageImpl;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.PostOffice;
 import org.jboss.messaging.core.remoting.FailureListener;
@@ -52,6 +53,7 @@
 import org.jboss.messaging.core.transaction.impl.TransactionImpl;
 import org.jboss.messaging.util.Future;
 import org.jboss.messaging.util.Pair;
+import org.jboss.messaging.util.SimpleString;
 
 /**
  * A ForwarderImpl
@@ -330,7 +332,7 @@
             return;
          }
          
-         // TODO - duplicate detection on sendee and if batch size = 1 then don't need tx
+         // TODO - if batch size = 1 then don't need tx
 
          while (true)
          {
@@ -349,8 +351,10 @@
             {
                message = transformer.transform(message);
             }
+          
+            SimpleString forwardingDestination = (SimpleString)message.getProperty(MessageImpl.HDR_ORIGIN_QUEUE);
 
-            producer.send(message.getDestination(), message);
+            producer.send(forwardingDestination, message);
          }
 
          session.commit();

Modified: trunk/src/main/org/jboss/messaging/core/server/cluster/impl/MessageFlowImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/cluster/impl/MessageFlowImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/server/cluster/impl/MessageFlowImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -38,7 +38,9 @@
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.Binding;
+import org.jboss.messaging.core.postoffice.BindingType;
 import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.core.server.cluster.Forwarder;
 import org.jboss.messaging.core.server.cluster.MessageFlow;
 import org.jboss.messaging.core.server.cluster.Transformer;
@@ -323,6 +325,8 @@
             SimpleString queueName = new SimpleString("outflow." + name +
                                                       "." +
                                                       UUIDGenerator.getInstance().generateSimpleStringUUID());
+            
+            SimpleString linkName = new SimpleString("link." + queueName.toString());
 
             Binding binding = postOffice.getBinding(queueName);
 
@@ -332,10 +336,18 @@
             {
                Filter filter = filterString == null ? null : new FilterImpl(filterString);
 
-               binding = postOffice.addBinding(address, queueName, filter, true, false, exclusive);
+               //Create the queue
+               
+               binding = postOffice.addQueueBinding(queueName, queueName, filter, true, false, exclusive);
+               
+               //Create the link
+               
+               postOffice.addLinkBinding(linkName, address, filter, true, false, exclusive, queueName);
             }
+            
+            Queue queue = (Queue)binding.getBindable();
 
-            Forwarder forwarder = new ForwarderImpl(binding.getQueue(),
+            Forwarder forwarder = new ForwarderImpl(queue,
                                                     connectorPair,
                                                     executorFactory.getExecutor(),
                                                     maxBatchSize,
@@ -352,7 +364,7 @@
 
             forwarders.put(connectorPair, forwarder);
 
-            binding.getQueue().addConsumer(forwarder);
+            queue.addConsumer(forwarder);
 
             forwarder.start();
          }

Copied: trunk/src/main/org/jboss/messaging/core/server/impl/BindableFactoryImpl.java (from rev 5550, trunk/src/main/org/jboss/messaging/core/server/impl/QueueFactoryImpl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/BindableFactoryImpl.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/BindableFactoryImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.server.impl;
+
+import java.util.concurrent.ScheduledExecutorService;
+
+import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.BindingType;
+import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.Bindable;
+import org.jboss.messaging.core.server.BindableFactory;
+import org.jboss.messaging.core.server.Link;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.settings.HierarchicalRepository;
+import org.jboss.messaging.core.settings.impl.QueueSettings;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ *
+ * A BindableFactoryImpl
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ *
+ */
+public class BindableFactoryImpl implements BindableFactory
+{
+   private final HierarchicalRepository<QueueSettings> queueSettingsRepository;
+
+   private final ScheduledExecutorService scheduledExecutor;
+
+   /** This is required for delete-all-reference to work correctly with paging, and controlling global-size */
+   private PostOffice postOffice;
+
+   private final StorageManager storageManager;
+
+   public BindableFactoryImpl(final ScheduledExecutorService scheduledExecutor,
+                              final HierarchicalRepository<QueueSettings> queueSettingsRepository,
+                              final StorageManager storageManager)
+   {
+      this.queueSettingsRepository = queueSettingsRepository;
+
+      this.scheduledExecutor = scheduledExecutor;
+
+      this.storageManager = storageManager;
+   }
+
+   public void setPostOffice(final PostOffice postOffice)
+   {
+      this.postOffice = postOffice;
+   }
+
+   public Queue createQueue(final long persistenceID,
+                            final SimpleString name,
+                            final Filter filter,
+                            final boolean durable,
+                            final boolean temporary)
+   {
+      QueueSettings queueSettings = queueSettingsRepository.getMatch(name.toString());
+
+      Queue queue = new QueueImpl(persistenceID,
+                                  name,
+                                  filter,
+                                  queueSettings.isClustered(),
+                                  durable,
+                                  temporary,
+                                  scheduledExecutor,
+                                  postOffice,
+                                  storageManager);
+
+      queue.setDistributionPolicy(queueSettings.getDistributionPolicy());
+
+      return queue;
+   }
+
+   public Link createLink(final long persistenceID,
+                          final SimpleString name,
+                          final Filter filter,
+                          final boolean durable,
+                          final boolean temporary,
+                          final SimpleString linkAddress)
+   {
+
+      Link link = new LinkImpl(name, durable, filter, linkAddress, postOffice, storageManager);
+
+      link.setPersistenceID(persistenceID);
+
+      return link;
+   }
+}

Added: trunk/src/main/org/jboss/messaging/core/server/impl/LinkImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/LinkImpl.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/LinkImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.server.impl;
+
+import static org.jboss.messaging.core.message.impl.MessageImpl.HDR_ORIGIN_QUEUE;
+
+import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.message.impl.MessageImpl;
+import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.Link;
+import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.core.transaction.Transaction;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ * A LinkImpl simply makes a copy of a message and redirects it to another address
+ * 
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * 
+ * Created 19 Dec 2008 10:57:49
+ *
+ *
+ */
+public class LinkImpl implements Link
+{
+   private static final Logger log = Logger.getLogger(LinkImpl.class);
+
+   
+   private final PostOffice postOffice;
+
+   private final SimpleString address;
+
+   private final StorageManager storageManager;
+
+   private volatile long id;
+
+   private final Filter filter;
+
+   private final boolean durable;
+
+   private final SimpleString name;
+
+   public LinkImpl(final SimpleString name,
+                   final boolean durable,
+                   final Filter filter,
+                   final SimpleString address,
+                   final PostOffice postOffice,
+                   final StorageManager storageManager)
+   {
+      this.name = name;
+
+      this.durable = durable;
+
+      this.filter = filter;
+
+      this.address = address;
+
+      this.postOffice = postOffice;
+
+      this.storageManager = storageManager;
+   }
+
+   public void route(final ServerMessage message, final Transaction tx) throws Exception
+   {     
+      ServerMessage copy = message.copy();
+
+      copy.setMessageID(storageManager.generateUniqueID());
+
+      SimpleString originalDestination = copy.getDestination();
+      
+      copy.setDestination(address);
+      
+      copy.putStringProperty(HDR_ORIGIN_QUEUE, originalDestination);
+      
+      postOffice.route(copy, tx);
+   }
+
+   public Filter getFilter()
+   {
+      return filter;
+   }
+
+   public long getPersistenceID()
+   {
+      return id;
+   }
+
+   public SimpleString getName()
+   {
+      return name;
+   }
+
+   public boolean isDurable()
+   {
+      return durable;
+   }
+
+   public void setPersistenceID(long id)
+   {
+      this.id = id;
+   }
+
+   public SimpleString getLinkAddress()
+   {
+      return address;
+   }
+
+}

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessageReferenceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessageReferenceImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessageReferenceImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -67,8 +67,6 @@
    
    // Static --------------------------------------------------------
    
-
-
    // Constructors --------------------------------------------------
 
    public MessageReferenceImpl(final MessageReferenceImpl other, final Queue queue)
@@ -100,6 +98,8 @@
       // from few tests I have done, deliveryCount and scheduledDelivery will use  two longs (because of alignment)
       // and each of the references (messages and queue) will use the equivalent to two longs (because of long pointers).
       // Anyway.. this is just an estimate
+      
+      //TODO - doesn't the object itself have an overhead? - I thought was usually one Long per Object?
       return DataConstants.SIZE_LONG * 4;
    }
    
@@ -251,7 +251,7 @@
          }
          else
          {
-            move(expiryAddress, tx, storageManager, true);
+            move(expiryAddress, tx, storageManager, postOffice, true);
          }
       }
       else
@@ -267,13 +267,13 @@
       move(toAddress, persistenceManager, postOffice, false);
    }
    
-   public void move(final SimpleString toAddress, final Transaction tx, final StorageManager persistenceManager, final boolean expiry) throws Exception
+   public void move(final SimpleString toAddress, final Transaction tx, final StorageManager persistenceManager, final PostOffice postOffice, final boolean expiry) throws Exception
    {
       ServerMessage copyMessage = makeCopy(expiry, persistenceManager);
 
       copyMessage.setDestination(toAddress);
 
-      tx.addMessage(copyMessage);
+      postOffice.route(copyMessage, tx);
 
       tx.addAcknowledgement(this);
    }
@@ -305,7 +305,9 @@
 
       copyMessage.setDestination(address);
 
-      tx.addMessage(copyMessage);
+      //tx.addMessage(copyMessage);
+      
+      postOffice.route(copyMessage, tx);
 
       tx.addAcknowledgement(this);
 

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -54,7 +54,7 @@
 import org.jboss.messaging.core.security.impl.SecurityStoreImpl;
 import org.jboss.messaging.core.server.MessagingServer;
 import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.QueueFactory;
+import org.jboss.messaging.core.server.BindableFactory;
 import org.jboss.messaging.core.server.ServerSession;
 import org.jboss.messaging.core.server.cluster.ClusterManager;
 import org.jboss.messaging.core.server.cluster.impl.ClusterManagerImpl;
@@ -101,7 +101,7 @@
 
    private ScheduledExecutorService scheduledExecutor;
 
-   private QueueFactory queueFactory;
+   private BindableFactory queueFactory;
 
    private PagingManager pagingManager;
 
@@ -210,7 +210,7 @@
       queueSettingsRepository.setDefault(new QueueSettings());
       scheduledExecutor = new ScheduledThreadPoolExecutor(configuration.getScheduledThreadPoolMaxSize(),
                                                           new JBMThreadFactory("JBM-scheduled-threads"));
-      queueFactory = new QueueFactoryImpl(scheduledExecutor, queueSettingsRepository);
+      queueFactory = new BindableFactoryImpl(scheduledExecutor, queueSettingsRepository, storageManager);
 
       pagingManager = new PagingManagerImpl(new PagingStoreFactoryNIO(configuration.getPagingDirectory(),
                                                                       configuration.getPagingMaxThreads()),

Deleted: trunk/src/main/org/jboss/messaging/core/server/impl/QueueFactoryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/QueueFactoryImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/QueueFactoryImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
-
-package org.jboss.messaging.core.server.impl;
-
-import java.util.concurrent.ScheduledExecutorService;
-
-import org.jboss.messaging.core.filter.Filter;
-import org.jboss.messaging.core.postoffice.PostOffice;
-import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.QueueFactory;
-import org.jboss.messaging.core.settings.HierarchicalRepository;
-import org.jboss.messaging.core.settings.impl.QueueSettings;
-import org.jboss.messaging.util.SimpleString;
-
-/**
- *
- * A QueueFactoryImpl
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- *
- */
-public class QueueFactoryImpl implements QueueFactory
-{
-   private final HierarchicalRepository<QueueSettings> queueSettingsRepository;
-
-   private final ScheduledExecutorService scheduledExecutor;
-   
-   /** This is required for delete-all-reference to work correctly with paging, and controlling global-size */
-   private PostOffice postOffice;
-   
-   public QueueFactoryImpl(final ScheduledExecutorService scheduledExecutor,
-   	                   	final HierarchicalRepository<QueueSettings> queueSettingsRepository)
-   {
-      this.queueSettingsRepository = queueSettingsRepository;
-      
-      this.scheduledExecutor = scheduledExecutor;
-   }
-   
-   public void setPostOffice(PostOffice postOffice)
-   {
-      this.postOffice = postOffice;
-   }
-   
-   public Queue createQueue(final long persistenceID, final SimpleString name, final Filter filter,
-                            final boolean durable, final boolean temporary)
-   {
-      QueueSettings queueSettings = queueSettingsRepository.getMatch(name.toString());
-            
-      Queue queue = new QueueImpl(persistenceID, name, filter, queueSettings.isClustered(), durable,
-      		temporary, scheduledExecutor, postOffice);
-
-      queue.setDistributionPolicy(queueSettings.getDistributionPolicy());
-
-      return queue;
-   }
-}

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -26,6 +26,7 @@
 import org.jboss.messaging.core.list.PriorityLinkedList;
 import org.jboss.messaging.core.list.impl.PriorityLinkedListImpl;
 import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.message.impl.MessageImpl;
 import org.jboss.messaging.core.paging.PagingManager;
 import org.jboss.messaging.core.paging.PagingStore;
 import org.jboss.messaging.core.persistence.StorageManager;
@@ -40,10 +41,11 @@
 import org.jboss.messaging.core.settings.HierarchicalRepository;
 import org.jboss.messaging.core.settings.impl.QueueSettings;
 import org.jboss.messaging.core.transaction.Transaction;
+import org.jboss.messaging.core.transaction.TransactionOperation;
 import org.jboss.messaging.core.transaction.impl.TransactionImpl;
 import org.jboss.messaging.util.ConcurrentHashSet;
+import org.jboss.messaging.util.ConcurrentSet;
 import org.jboss.messaging.util.SimpleString;
-import org.jboss.messaging.util.ConcurrentSet;
 
 /**
  * Implementation of a Queue TODO use Java 5 concurrent queue
@@ -97,6 +99,8 @@
 
    private final PagingManager pagingManager;
 
+   private final StorageManager storageManager;
+
    private volatile boolean backup;
 
    private int consumersToFailover = -1;
@@ -108,7 +112,8 @@
                     final boolean durable,
                     final boolean temporary,
                     final ScheduledExecutorService scheduledExecutor,
-                    final PostOffice postOffice)
+                    final PostOffice postOffice,
+                    final StorageManager storageManager)
    {
       this.persistenceID = persistenceID;
 
@@ -124,6 +129,8 @@
 
       this.postOffice = postOffice;
 
+      this.storageManager = storageManager;
+
       if (postOffice == null)
       {
          this.pagingManager = null;
@@ -138,9 +145,155 @@
       scheduledDeliveryHandler = new ScheduledDeliveryHandlerImpl(scheduledExecutor);
    }
 
-   // Queue implementation
-   // -------------------------------------------------------------------
+   // Bindable implementation -------------------------------------------------------------------------------------
 
+   public void route(final ServerMessage message, final Transaction tx) throws Exception
+   {     
+      // TODO we can avoid these lookups in the Queue since all messsages in the Queue will be for the same store
+      PagingStore store = pagingManager.getPageStore(message.getDestination());
+
+      if (tx == null)
+      {
+         // If durable, must be persisted before anything is routed
+         MessageReference ref = message.createReference(this);
+
+         if (!message.isReload())
+         {
+            if (message.getDurableRefCount() == 1)
+            {
+               storageManager.storeMessage(message);
+            }
+
+            Long scheduledDeliveryTime = (Long)message.getProperty(MessageImpl.HDR_SCHEDULED_DELIVERY_TIME);
+
+            if (scheduledDeliveryTime != null)
+            {
+               ref.setScheduledDeliveryTime(scheduledDeliveryTime);
+
+               if (ref.getMessage().isDurable() && durable)
+               {
+                  storageManager.updateScheduledDeliveryTime(ref);
+               }
+            }
+         }
+
+         if (message.getRefCount() == 1)
+         {
+            store.addSize(message.getMemoryEstimate());
+         }
+
+         store.addSize(ref.getMemoryEstimate());
+
+         // TODO addLast never currently returns anything other than STATUS_HANDLED
+
+         addLast(ref);
+      }
+      else
+      {
+         // TODO combine this similar logic with the non transactional case
+
+         SimpleString destination = message.getDestination();
+
+         if (!tx.isDepage() && (tx.getPagingAddresses().contains(destination) || pagingManager.isPaging(destination)))
+         {
+            tx.addPagingAddress(destination);
+
+            tx.addPagingMessage(message);
+         }
+         else
+         {
+            MessageReference ref = message.createReference(this);
+
+            boolean first = message.getDurableRefCount() == 1;
+            
+            if (first)
+            {
+               storageManager.storeMessageTransactional(tx.getID(), message);
+            }
+
+            Long scheduledDeliveryTime = (Long)message.getProperty(MessageImpl.HDR_SCHEDULED_DELIVERY_TIME);
+
+            boolean durableRef = ref.getMessage().isDurable() && durable;
+
+            if (scheduledDeliveryTime != null)
+            {
+               ref.setScheduledDeliveryTime(scheduledDeliveryTime);
+
+               if (durableRef)
+               {
+                  storageManager.updateScheduledDeliveryTimeTransactional(tx.getID(), ref);
+               }
+            }
+
+            if (message.getRefCount() == 1)
+            {
+               store.addSize(message.getMemoryEstimate());
+            }
+
+            store.addSize(ref.getMemoryEstimate());
+            
+            tx.addOperation(new AddMessageOperation(ref, first));
+
+            if (durableRef)
+            {
+               tx.setContainsPersistent(true);
+            }
+         }
+      }
+   }
+
+   private class AddMessageOperation implements TransactionOperation
+   {
+      private final MessageReference ref;
+      
+      private final boolean first;
+
+      AddMessageOperation(final MessageReference ref, final boolean first)
+      {
+         this.ref = ref;
+         
+         this.first = first;
+      }
+
+      public void afterCommit() throws Exception
+      {
+      }
+
+      public void afterPrepare() throws Exception
+      {
+      }
+
+      public void afterRollback() throws Exception
+      {
+      }
+
+      public void beforeCommit() throws Exception
+      {
+         addLast(ref);
+      }
+
+      public void beforePrepare() throws Exception
+      {
+      }
+
+      public void beforeRollback() throws Exception
+      {
+         ServerMessage msg = ref.getMessage();
+         
+         PagingStore store = pagingManager.getPageStore(msg.getDestination());
+         
+         store.addSize(-ref.getMemoryEstimate());
+         
+         if (first)
+         {
+            store.addSize(-msg.getMemoryEstimate());
+         }
+      }
+
+   }
+
+   // Queue implementation ----------------------------------------------------------------------------------------
+
    public boolean isClustered()
    {
       return clustered;
@@ -161,16 +314,14 @@
       return name;
    }
 
-   public HandleStatus add(final MessageReference ref)
-   {
-      HandleStatus status = add(ref, false);
-
-      return status;
+   public void addLast(final MessageReference ref)
+   {      
+      add(ref, false);
    }
 
-   public HandleStatus addFirst(final MessageReference ref)
+   public void addFirst(final MessageReference ref)
    {
-      return add(ref, true);
+      add(ref, true);
    }
 
    public synchronized void addListFirst(final LinkedList<MessageReference> list)
@@ -284,7 +435,7 @@
    }
 
    // Remove message from queue, add it to the scheduled delivery list without affect reference counting
-   public void rescheduleDelivery(final long id, final long scheduledDeliveryTime)
+   public synchronized void rescheduleDelivery(final long id, final long scheduledDeliveryTime)
    {
       Iterator<MessageReference> iterator = messageReferences.iterator();
       while (iterator.hasNext())
@@ -323,7 +474,7 @@
 
       return null;
    }
-
+   
    public long getPersistenceID()
    {
       return persistenceID;
@@ -579,7 +730,7 @@
          if (filter == null || filter.match(ref.getMessage()))
          {
             deliveringCount.incrementAndGet();
-            ref.move(toAddress, tx, storageManager, false);
+            ref.move(toAddress, tx, storageManager, postOffice, false);
             iter.remove();
             count++;
          }
@@ -591,7 +742,7 @@
          if (filter == null || filter.match(ref.getMessage()))
          {
             deliveringCount.incrementAndGet();
-            ref.move(toAddress, tx, storageManager, false);
+            ref.move(toAddress, tx, storageManager, postOffice, false);
             tx.addAcknowledgement(ref);
             count++;
          }
@@ -617,8 +768,11 @@
             message.setPriority(newPriority);
             // delete and add the reference so that it
             // goes to the right queues for the new priority
+
+            // FIXME - why deleting the reference?? This will delete it from storage!!
+
             deleteReference(messageID, storageManager);
-            add(ref);
+            addLast(ref);
             return true;
          }
       }
@@ -793,7 +947,7 @@
       }
    }
 
-   private synchronized HandleStatus add(final MessageReference ref, final boolean first)
+   private synchronized void add(final MessageReference ref, final boolean first)
    {
       if (!first)
       {
@@ -802,7 +956,7 @@
 
       if (scheduledDeliveryHandler.checkAndSchedule(ref, backup))
       {
-         return HandleStatus.HANDLED;
+         return;
       }
 
       boolean add = false;
@@ -862,8 +1016,6 @@
             deliver();
          }
       }
-
-      return HandleStatus.HANDLED;
    }
 
    private HandleStatus deliver(final MessageReference reference)

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerConsumerImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -49,7 +49,7 @@
 import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.core.server.ServerConsumer;
-import org.jboss.messaging.core.server.ServerLargeMessage;
+import org.jboss.messaging.core.server.LargeServerMessage;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.server.ServerSession;
 import org.jboss.messaging.core.settings.HierarchicalRepository;
@@ -544,7 +544,7 @@
          }
                   
          // TODO: get rid of the instanceof by something like message.isLargeMessage()
-         if (message instanceof ServerLargeMessage)
+         if (message instanceof LargeServerMessage)
          {            
             //FIXME - please put the replication logic in the sendLargeMessage method
             
@@ -583,7 +583,7 @@
 
    private void sendLargeMessage(final MessageReference ref, final ServerMessage message)
    {
-      largeMessageSender = new LargeMessageSender((ServerLargeMessage)message, ref);
+      largeMessageSender = new LargeMessageSender((LargeServerMessage)message, ref);
 
       largeMessageSender.sendLargeMessage();
    }
@@ -632,7 +632,7 @@
       private final long sizePendingLargeMessage;
 
       /** The current message being processed */
-      private final ServerLargeMessage pendingLargeMessage;
+      private final LargeServerMessage pendingLargeMessage;
 
       private final MessageReference ref;
 
@@ -643,7 +643,7 @@
 
       private volatile SessionReceiveContinuationMessage readAheadChunk;
 
-      public LargeMessageSender(final ServerLargeMessage message, final MessageReference ref)
+      public LargeMessageSender(final LargeServerMessage message, final MessageReference ref)
       {
          pendingLargeMessage = message;
 

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -46,6 +46,8 @@
    /** Global reference counts for paging control */
    private final AtomicInteger refCount = new AtomicInteger(0);
 
+   private volatile boolean reload;
+
    /*
     * Constructor for when reading from network
     */
@@ -92,12 +94,17 @@
       {
          durableRefCount.incrementAndGet();
       }
-
+      
       refCount.incrementAndGet();
-      
+    
       return ref;
    }
 
+   public int getRefCount()
+   {
+      return refCount.get();
+   }
+
    public int getDurableRefCount()
    {
       return durableRefCount.get();
@@ -112,7 +119,7 @@
    {
       return durableRefCount.incrementAndGet();
    }
-   
+
    public int decrementRefCount()
    {
       return refCount.decrementAndGet();
@@ -123,10 +130,19 @@
       // This is just an estimate...
       // due to memory alignments and JVM implementation this could be very
       // different from reality
-      return getEncodeSize() + (16 + 4) * 2;
+      return getEncodeSize() + (16 + 4) * 2 + 1;
+   }
 
+   public boolean isReload()
+   {
+      return reload;
    }
 
+   public void setReload()
+   {
+      this.reload = true;
+   }
+
    public ServerMessage copy()
    {
       return new ServerMessageImpl(this);

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -34,9 +34,9 @@
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.management.ManagementService;
 import org.jboss.messaging.core.message.impl.MessageImpl;
-import org.jboss.messaging.core.paging.PagingManager;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.Binding;
+import org.jboss.messaging.core.postoffice.BindingType;
 import org.jboss.messaging.core.postoffice.Bindings;
 import org.jboss.messaging.core.postoffice.DuplicateIDCache;
 import org.jboss.messaging.core.postoffice.PostOffice;
@@ -86,7 +86,7 @@
 import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.core.server.SendLock;
 import org.jboss.messaging.core.server.ServerConsumer;
-import org.jboss.messaging.core.server.ServerLargeMessage;
+import org.jboss.messaging.core.server.LargeServerMessage;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.server.ServerSession;
 import org.jboss.messaging.core.settings.HierarchicalRepository;
@@ -200,7 +200,7 @@
 
    private final SimpleString managementAddress;
 
-   private volatile ServerLargeMessage largeMessage;
+   private volatile LargeServerMessage largeMessage;
 
    // Constructors ---------------------------------------------------------------------------------
 
@@ -311,7 +311,12 @@
 
    public void close() throws Exception
    {
-      rollback();
+      if (tx != null && tx.getXid() == null)
+      {
+         //We only rollback local txs on close, not XA tx branches
+         
+         rollback();
+      }
 
       Set<ServerConsumer> consumersClone = new HashSet<ServerConsumer>(consumers.values());
 
@@ -357,7 +362,7 @@
       {
          Binding binding = postOffice.getBinding(queueName);
 
-         if (binding == null)
+         if (binding == null || binding.getType() != BindingType.QUEUE)
          {
             throw new MessagingException(MessagingException.QUEUE_DOES_NOT_EXIST);
          }
@@ -377,19 +382,19 @@
             // We consume a copy of the queue - TODO - this is a temporary measure
             // and will disappear once we can provide a proper iterator on the queue
 
-            theQueue = new QueueImpl(-1, queueName, filter, false, false, false, null, postOffice);
+            theQueue = new QueueImpl(-1, queueName, filter, false, false, false, null, postOffice, storageManager);
 
             // There's no need for any special locking since the list method is synchronized
-            List<MessageReference> refs = binding.getQueue().list(filter);
+            List<MessageReference> refs = ((Queue)binding.getBindable()).list(filter);
 
             for (MessageReference ref : refs)
             {
-               theQueue.add(ref);
+               theQueue.addLast(ref);
             }
          }
          else
          {
-            theQueue = binding.getQueue();
+            theQueue = (Queue)binding.getBindable();
          }
 
          ServerConsumer consumer = new ServerConsumerImpl(idGenerator.generateID(),
@@ -484,7 +489,7 @@
             filter = new FilterImpl(filterString);
          }
 
-         binding = postOffice.addBinding(address, queueName, filter, durable, temporary, false);
+         binding = postOffice.addQueueBinding(queueName, address, filter, durable, temporary, false);
 
          if (temporary)
          {
@@ -494,7 +499,7 @@
             // session is closed.
             // It is up to the user to delete the queue when finished with it
 
-            final Queue queue = binding.getQueue();
+            final Queue queue = (Queue)binding.getBindable();
 
             failureRunners.add(new Runnable()
             {
@@ -615,12 +620,12 @@
       {
          Binding binding = postOffice.removeBinding(queueName);
 
-         if (binding == null)
+         if (binding == null || binding.getType() != BindingType.QUEUE)
          {
             throw new MessagingException(MessagingException.QUEUE_DOES_NOT_EXIST);
          }
 
-         Queue queue = binding.getQueue();
+         Queue queue = (Queue)binding.getBindable();
 
          if (queue.getConsumerCount() != 0)
          {
@@ -629,7 +634,7 @@
 
          if (queue.isDurable())
          {
-            binding.getQueue().deleteAllReferences(storageManager);
+            queue.deleteAllReferences(storageManager);
          }
 
          response = new NullResponseMessage();
@@ -689,9 +694,9 @@
 
          Binding binding = postOffice.getBinding(queueName);
 
-         if (binding != null)
+         if (binding != null && binding.getType() == BindingType.QUEUE)
          {
-            Queue queue = binding.getQueue();
+            Queue queue = (Queue)binding.getBindable();
 
             Filter filter = queue.getFilter();
 
@@ -771,7 +776,10 @@
 
             for (Binding binding : bindings.getBindings())
             {
-               queueNames.add(binding.getQueue().getName());
+               if (binding.getType() == BindingType.QUEUE)
+               {
+                  queueNames.add(binding.getBindable().getName());
+               }
             }
          }
 
@@ -1597,7 +1605,6 @@
 
    public void handleXAPrepare(final SessionXAPrepareMessage packet)
    {
-      log.info("handling xa prepare");
       DelayedResult result = channel.replicatePacket(packet);
 
       if (result == null)
@@ -2480,7 +2487,7 @@
 
          if (!packet.isContinues())
          {
-            final ServerLargeMessage message = largeMessage;
+            final LargeServerMessage message = largeMessage;
 
             largeMessage = null;
 
@@ -2533,9 +2540,9 @@
       }
    }
 
-   private ServerLargeMessage createLargeMessageStorage(final long messageID, final byte[] header) throws Exception
+   private LargeServerMessage createLargeMessageStorage(final long messageID, final byte[] header) throws Exception
    {
-      ServerLargeMessage largeMessage = storageManager.createLargeMessage();
+      LargeServerMessage largeMessage = storageManager.createLargeMessage();
 
       MessagingBuffer headerBuffer = new ByteBufferWrapper(ByteBuffer.wrap(header));
 

Modified: trunk/src/main/org/jboss/messaging/core/transaction/Transaction.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/transaction/Transaction.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/transaction/Transaction.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -23,6 +23,7 @@
 package org.jboss.messaging.core.transaction;
 
 import java.util.List;
+import java.util.Set;
 
 import javax.transaction.xa.Xid;
 
@@ -50,9 +51,19 @@
 
    void addDuplicateID(SimpleString address, SimpleString duplID, long recordID) throws Exception;
 
-   void addMessage(ServerMessage message) throws Exception;
+   Set<SimpleString> getPagingAddresses();
+   
+   void addPagingAddress(SimpleString address);
+   
+   void addPagingMessage(ServerMessage message);
 
    void addAcknowledgement(MessageReference acknowledgement) throws Exception;
+   
+   void addAckTempUntilNextRefactoring(MessageReference ref);
+   
+   boolean isDepage();
+   
+   void setContainsPersistent(boolean containsPersistent);
 
    int getAcknowledgementsCount();
 
@@ -65,22 +76,22 @@
    void resume();
 
    State getState();
+   
+   void setState(State state);
 
    boolean isContainsPersistent();
 
    void markAsRollbackOnly(MessagingException messagingException);
 
-   void replay(List<MessageReference> messages,
-               List<MessageReference> acknowledgements,
-               PageTransactionInfo pageTransaction) throws Exception;
+   void setPageTransaction(PageTransactionInfo pageTransaction);
 
    List<MessageReference> timeout() throws Exception;
 
    long getCreateTime();
 
-   void addSynchronization(TransactionSynchronization sync);
+   void addOperation(TransactionOperation sync);
 
-   void removeSynchronization(TransactionSynchronization sync);
+   void removeOperation(TransactionOperation sync);
 
    static enum State
    {

Copied: trunk/src/main/org/jboss/messaging/core/transaction/TransactionOperation.java (from rev 5550, trunk/src/main/org/jboss/messaging/core/transaction/TransactionSynchronization.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/transaction/TransactionOperation.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/transaction/TransactionOperation.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+
+package org.jboss.messaging.core.transaction;
+
+/**
+ * 
+ * A TransactionOperation
+ * 
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public interface TransactionOperation
+{
+   void beforePrepare() throws Exception;
+   
+   void beforeCommit() throws Exception;
+   
+   void beforeRollback() throws Exception;
+   
+   void afterPrepare() throws Exception;
+      
+   void afterCommit() throws Exception;
+   
+   void afterRollback() throws Exception;   
+}

Deleted: trunk/src/main/org/jboss/messaging/core/transaction/TransactionSynchronization.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/transaction/TransactionSynchronization.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/transaction/TransactionSynchronization.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
-
-package org.jboss.messaging.core.transaction;
-
-/**
- * 
- * A TransactionSynchronization
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public interface TransactionSynchronization
-{
-   void afterCommit() throws Exception;
-   
-   void afterRollback() throws Exception;
-   
-   void afterPrepare() throws Exception;
-}

Modified: trunk/src/main/org/jboss/messaging/core/transaction/impl/ResourceManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/transaction/impl/ResourceManagerImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/transaction/impl/ResourceManagerImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -169,7 +169,7 @@
    }
 
    public List<Xid> getPreparedTransactions()
-   {
+   {           
       List<Xid> xids = new ArrayList<Xid>();
 
       for (Xid xid : transactions.keySet())

Modified: trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -34,7 +34,8 @@
 import org.jboss.messaging.core.settings.HierarchicalRepository;
 import org.jboss.messaging.core.settings.impl.QueueSettings;
 import org.jboss.messaging.core.transaction.Transaction;
-import org.jboss.messaging.core.transaction.TransactionSynchronization;
+import org.jboss.messaging.core.transaction.TransactionOperation;
+import org.jboss.messaging.core.transaction.Transaction.State;
 import org.jboss.messaging.util.SimpleString;
 
 /**
@@ -47,7 +48,7 @@
  */
 public class TransactionImpl implements Transaction
 {
-   private List<TransactionSynchronization> syncs;
+   private List<TransactionOperation> operations;
 
    private static final Logger log = Logger.getLogger(TransactionImpl.class);
 
@@ -57,8 +58,6 @@
 
    private final PagingManager pagingManager;
 
-   private final List<MessageReference> refsToAdd = new ArrayList<MessageReference>();
-
    private final List<MessageReference> acknowledgements = new ArrayList<MessageReference>();
 
    /** List of destinations in page mode.
@@ -69,7 +68,7 @@
    // FIXME: As part of https://jira.jboss.org/jira/browse/JBMESSAGING-1313
    private final List<ServerMessage> pagedMessages = new ArrayList<ServerMessage>();
 
-   private PageTransactionInfo pageTransaction;
+   private volatile PageTransactionInfo pageTransaction;
 
    private final Xid xid;
 
@@ -134,6 +133,12 @@
       createTime = System.currentTimeMillis();
       
       this.depage = depage;
+      
+      if (depage)
+      {
+         //Need to force to true, since other last page record won't be committed
+         this.containsPersistent = true;
+      }
    }
 
    public TransactionImpl(final Xid xid, final StorageManager storageManager, final PostOffice postOffice)
@@ -199,26 +204,6 @@
       containsPersistent = true;
    }
 
-   public void addMessage(final ServerMessage message) throws Exception
-   {
-      if (state != State.ACTIVE)
-      {
-         throw new IllegalStateException("Transaction is in invalid state " + state);
-      }
-
-      SimpleString destination = message.getDestination();
-
-      if (!depage && (destinationsInPageMode.contains(destination) || pagingManager.isPaging(destination)))
-      {
-         destinationsInPageMode.add(destination);
-         pagedMessages.add(message);
-      }
-      else
-      {
-         route(message);
-      }
-   }
-
    public List<MessageReference> timeout() throws Exception
    {
       // we need to synchronize with commit and rollback just in case they get called atthesame time
@@ -281,6 +266,16 @@
          }
       }
    }
+   
+   public void addAckTempUntilNextRefactoring(final MessageReference ref)
+   {
+      this.acknowledgements.add(ref);
+      
+      if (ref.getQueue().isDurable() && ref.getMessage().isDurable())
+      {
+         containsPersistent = true;
+      }
+   }
 
    public void prepare() throws Exception
    {
@@ -295,6 +290,14 @@
          {
             throw new IllegalStateException("Cannot prepare non XA transaction");
          }
+         
+         if (operations != null)
+         {
+            for (TransactionOperation operation : operations)
+            {
+               operation.beforePrepare();
+            }
+         }
 
          pageMessages();
 
@@ -302,18 +305,19 @@
 
          state = State.PREPARED;
 
-         if (syncs != null)
+         if (operations != null)
          {
-            for (TransactionSynchronization sync : syncs)
+            for (TransactionOperation operation : operations)
             {
-               sync.afterPrepare();
+               operation.afterPrepare();
             }
          }
+                  
       }
    }
 
    public void commit() throws Exception
-   {      
+   {           
       synchronized (timeoutLock)
       {
          if (state == State.ROLLBACK_ONLY)
@@ -342,6 +346,14 @@
                throw new IllegalStateException("Transaction is in invalid state " + state);
             }
          }
+         
+         if (operations != null)
+         {
+            for (TransactionOperation operation : operations)
+            {
+               operation.beforeCommit();
+            }
+         }
 
          if (state != State.PREPARED)
          {
@@ -353,7 +365,7 @@
             storageManager.commit(id);
          }
 
-         postOffice.deliver(refsToAdd);
+         //postOffice.deliver(refsToAdd);
 
          // If part of the transaction goes to the queue, and part goes to paging, we can't let depage start for the
          // transaction until all the messages were added to the queue
@@ -372,13 +384,14 @@
 
          state = State.COMMITTED;
 
-         if (syncs != null)
+         if (operations != null)
          {
-            for (TransactionSynchronization sync : syncs)
+            for (TransactionOperation operation : operations)
             {
-               sync.afterCommit();
+               operation.afterCommit();
             }
          }
+                  
       }
    }
 
@@ -402,18 +415,27 @@
                throw new IllegalStateException("Transaction is in invalid state " + state);
             }
          }
+         
+         if (operations != null)
+         {
+            for (TransactionOperation operation : operations)
+            {
+               operation.beforeRollback();
+            }
+         }
 
          toCancel = doRollback();
 
          state = State.ROLLEDBACK;
 
-         if (syncs != null)
+         if (operations != null)
          {
-            for (TransactionSynchronization sync : syncs)
+            for (TransactionOperation operation : operations)
             {
-               sync.afterRollback();
+               operation.afterRollback();
             }
          }
+                  
       }
 
       return toCancel;
@@ -446,6 +468,11 @@
    {
       return state;
    }
+   
+   public void setState(final State state)
+   {
+      this.state = state;
+   }
 
    public Xid getXid()
    {
@@ -464,42 +491,49 @@
       this.messagingException = messagingException;
    }
 
-   public void replay(final List<MessageReference> messages,
-                      final List<MessageReference> acknowledgements,
-                      final PageTransactionInfo pageTransaction) throws Exception
-   {
-      containsPersistent = true;
-      refsToAdd.addAll(messages);
-
-      this.acknowledgements.addAll(acknowledgements);
-      this.pageTransaction = pageTransaction;
-
-      if (this.pageTransaction != null)
-      {
-         pagingManager.addTransaction(this.pageTransaction);
-      }
-
-      state = State.PREPARED;
-   }
-
    public void setContainsPersistent(final boolean containsPersistent)
    {
       this.containsPersistent = containsPersistent;
    }
 
-   public void addSynchronization(final TransactionSynchronization sync)
+   public void addOperation(final TransactionOperation operation)
    {
-      checkCreateSyncs();
+      checkCreateOperations();
 
-      syncs.add(sync);
+      operations.add(operation);
    }
 
-   public void removeSynchronization(final TransactionSynchronization sync)
+   public void removeOperation(final TransactionOperation operation)
    {
-      checkCreateSyncs();
+      checkCreateOperations();
 
-      syncs.remove(sync);
+      operations.remove(operation);
    }
+   
+   public void setPageTransaction(PageTransactionInfo pageTransaction)
+   {
+      this.pageTransaction = pageTransaction;      
+   }
+   
+   public Set<SimpleString> getPagingAddresses()
+   {
+      return destinationsInPageMode;
+   }
+   
+   public void addPagingMessage(final ServerMessage message)
+   {
+      this.pagedMessages.add(message);
+   }
+   
+   public boolean isDepage()
+   {
+      return depage;
+   }
+   
+   public void addPagingAddress(final SimpleString address)
+   {
+      this.destinationsInPageMode.add(address);
+   }
 
    // Private
    // -------------------------------------------------------------------
@@ -527,50 +561,24 @@
          if (message.isDurable() && queue.isDurable())
          {
             message.incrementDurableRefCount();
-
          }
+         
          toCancel.add(ref);
       }
 
-      HashSet<ServerMessage> messagesAdded = new HashSet<ServerMessage>();
-
-      // We need to remove the sizes added on paging manager, for the messages that only exist here on the Transaction
-      for (MessageReference ref : this.refsToAdd)
-      {
-         messagesAdded.add(ref.getMessage());
-         pagingManager.getPageStore(ref.getMessage().getDestination()).addSize(-ref.getMemoryEstimate());
-      }
-
-      for (ServerMessage msg : messagesAdded)
-      {
-         pagingManager.removeSize(msg);
-      }
-
       clear();
 
       return toCancel;
    }
 
-   private void checkCreateSyncs()
+   private void checkCreateOperations()
    {
-      if (syncs == null)
+      if (operations == null)
       {
-         syncs = new ArrayList<TransactionSynchronization>();
+         operations = new ArrayList<TransactionOperation>();
       }
    }
 
-   private void route(final ServerMessage message) throws Exception
-   {
-      List<MessageReference> refs = postOffice.route(message, this, false);
-            
-      refsToAdd.addAll(refs);
-
-      if (message.getDurableRefCount() != 0)
-      {
-         containsPersistent = true;
-      }
-   }
-
    private void pageMessages() throws Exception
    {
       if (!pagedMessages.isEmpty())
@@ -604,14 +612,16 @@
             else
             {
                // This could happen when the PageStore left the pageState
-               route(message);
+                                  
+               //TODO is this correct - don't we lose transactionality here???
+               postOffice.route(message, null);
             }
          }
 
          if (pagingPersistent)
          {
             containsPersistent = true;
-            if (pagedDestinationsToSync.size() > 0)
+            if (!pagedDestinationsToSync.isEmpty())
             {
                pagingManager.sync(pagedDestinationsToSync);
                storageManager.storePageTransaction(id, pageTransaction);
@@ -622,8 +632,6 @@
 
    private void clear()
    {
-      refsToAdd.clear();
-
       acknowledgements.clear();
 
       pagedMessages.clear();

Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossSession.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossSession.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossSession.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -533,7 +533,7 @@
             else
             {
                // Durable sub
-
+               
                if (connection.getClientID() == null)
                {
                   throw new InvalidClientIDException("Cannot create durable subscription - client ID has not been set");
@@ -546,7 +546,7 @@
 
                queueName = new SimpleString(JBossTopic.createQueueNameForDurableSubscription(connection.getClientID(),
                                                                                              subscriptionName));
-
+               
                SessionQueueQueryResponseMessage subResponse = session.queueQuery(queueName);
 
                if (!subResponse.isExists())
@@ -576,9 +576,9 @@
                                             (oldFilterString != null && coreFilterString != null && !oldFilterString.equals(coreFilterString));
 
                   SimpleString oldTopicName = subResponse.getAddress();
-
+                  
                   boolean topicChanged = !oldTopicName.equals(dest.getSimpleAddress());
-
+                  
                   if (selectorChanged || topicChanged)
                   {
                      // Delete the old durable sub

Modified: trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -42,6 +42,7 @@
 import org.jboss.messaging.core.postoffice.Binding;
 import org.jboss.messaging.core.postoffice.PostOffice;
 import org.jboss.messaging.core.server.MessagingServer;
+import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.core.settings.HierarchicalRepository;
 import org.jboss.messaging.core.settings.impl.QueueSettings;
 import org.jboss.messaging.jms.JBossQueue;
@@ -154,7 +155,7 @@
       }
       Binding binding = postOffice.getBinding(jBossQueue.getSimpleAddress());
       managementService.registerQueue(jBossQueue,
-                                      binding.getQueue(),
+                                      (Queue)binding.getBindable(),
                                       jndiBinding,
                                       postOffice,
                                       storageManager,

Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/TopicControl.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -33,6 +33,7 @@
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.postoffice.Binding;
+import org.jboss.messaging.core.postoffice.BindingType;
 import org.jboss.messaging.core.postoffice.Bindings;
 import org.jboss.messaging.core.postoffice.PostOffice;
 import org.jboss.messaging.core.server.MessageReference;
@@ -168,11 +169,11 @@
    {
       SimpleString sAddress = new SimpleString(queueName);
       Binding binding = postOffice.getBinding(sAddress);
-      if (binding == null)
+      if (binding == null || binding.getType() != BindingType.QUEUE)
       {
          throw new IllegalArgumentException("No queue with name " + sAddress);
       }
-      Queue queue = binding.getQueue();
+      Queue queue = (Queue)binding.getBindable();
       List<MessageReference> messageRefs = queue.list(null);
       List<JMSMessageInfo> infos = new ArrayList<JMSMessageInfo>(messageRefs.size());
 
@@ -184,17 +185,17 @@
       }
       return JMSMessageInfo.toTabularData(infos);
    }
-   
+
    public int countMessagesForSubscription(final String clientID, final String subscriptionName, final String filterStr) throws Exception
    {
       String queueName = JBossTopic.createQueueNameForDurableSubscription(clientID, subscriptionName);
       SimpleString sAddress = new SimpleString(queueName);
       Binding binding = postOffice.getBinding(sAddress);
-      if (binding == null)
+      if (binding == null || binding.getType() != BindingType.QUEUE)
       {
          throw new IllegalArgumentException("No queue with name " + sAddress);
       }
-      Queue queue = binding.getQueue();
+      Queue queue = (Queue)binding.getBindable();
       Filter filter = FilterImpl.createFilter(filterStr);
       List<MessageReference> messageRefs = queue.list(filter);
       return messageRefs.size();
@@ -207,8 +208,11 @@
 
       for (Binding binding : bindings.getBindings())
       {
-         Queue queue = binding.getQueue();
-         count += queue.deleteAllReferences(storageManager);
+         if (binding.getType() == BindingType.QUEUE)
+         {
+            Queue queue = (Queue)binding.getBindable();
+            count += queue.deleteAllReferences(storageManager);
+         }
       }
 
       return count;
@@ -219,14 +223,14 @@
       String queueName = JBossTopic.createQueueNameForDurableSubscription(clientID, subscriptionName);
       Binding binding = postOffice.getBinding(new SimpleString(queueName));
 
-      if (binding == null)
+      if (binding == null || binding.getType() != BindingType.QUEUE)
       {
          throw new IllegalArgumentException("No durable subscription for clientID=" + clientID +
                                             ", subcription=" +
                                             subscriptionName);
       }
 
-      Queue queue = binding.getQueue();
+      Queue queue = (Queue)binding.getBindable();
 
       queue.deleteAllReferences(storageManager);
 
@@ -239,9 +243,12 @@
 
       for (Binding binding : bindings.getBindings())
       {
-         Queue queue = binding.getQueue();
-         queue.deleteAllReferences(storageManager);
-         postOffice.removeBinding(queue.getName());
+         if (binding.getType() == BindingType.QUEUE)
+         {
+            Queue queue = (Queue)binding.getBindable();
+            queue.deleteAllReferences(storageManager);
+            postOffice.removeBinding(queue.getName());
+         }
       }
    }
 
@@ -300,11 +307,14 @@
 
          for (Binding binding : bindings.getBindings())
          {
-            Queue queue = binding.getQueue();
-            if (durability == DurabilityType.ALL || (durability == DurabilityType.DURABLE && queue.isDurable()) ||
-                (durability == DurabilityType.NON_DURABLE && !queue.isDurable()))
+            if (binding.getType() == BindingType.QUEUE)
             {
-               matchingQueues.add(queue);
+               Queue queue = (Queue)binding.getBindable();
+               if (durability == DurabilityType.ALL || (durability == DurabilityType.DURABLE && queue.isDurable()) ||
+                   (durability == DurabilityType.NON_DURABLE && !queue.isDurable()))
+               {
+                  matchingQueues.add(queue);
+               }
             }
          }
          return matchingQueues;

Modified: trunk/src/main/org/jboss/messaging/util/SimpleString.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/SimpleString.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/src/main/org/jboss/messaging/util/SimpleString.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -291,12 +291,20 @@
 
    public static int sizeofString(final SimpleString str)
 	{
-	   if (str == null)
-	   {
-	      return SIZE_INT;
-	   }
 		return SIZE_INT + str.data.length;
 	}
+   
+   public static int sizeofNullableString(final SimpleString str)
+   {
+      if (str == null)
+      {
+         return 1;
+      }
+      else
+      {
+         return 1 + sizeofString(str);
+      }
+   }
 
    public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) {
       if (srcBegin < 0) {

Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ConsumerClosedTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ConsumerClosedTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ConsumerClosedTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -75,7 +75,7 @@
       		c.close();
       	}
       	
-      	//removeAllMessages(queue1.getQueueName(), true, 0);      	
+      	removeAllMessages(queue1.getQueueName(), true, 0);      	
       }
    }
 

Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -83,13 +83,18 @@
                                                     jndiBindings);
       
       cf = (JBossConnectionFactory)getInitialContext().lookup("/testsuitecf");
+      
+      assertRemainingMessages(0);
    }
+   
 
    protected void tearDown() throws Exception
    {
       super.tearDown();
       getJmsServerManager().destroyConnectionFactory("testsuitecf");
       cf = null;
+      
+      assertRemainingMessages(0);
    }
 
    public JMSTestCase(String name)

Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/MiscellaneousTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/MiscellaneousTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/MiscellaneousTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -55,6 +55,13 @@
    {
       super(name);
    }
+   
+   protected void tearDown() throws Exception
+   {
+      removeAllMessages(queue1.getQueueName(), true, 0);
+      
+      super.tearDown();
+   }
 
    // Public --------------------------------------------------------
 

Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -53,8 +53,10 @@
 import org.jboss.messaging.core.config.TransportConfiguration;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.postoffice.Binding;
+import org.jboss.messaging.core.postoffice.BindingType;
 import org.jboss.messaging.core.security.Role;
 import org.jboss.messaging.core.server.MessagingServer;
+import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.core.settings.impl.QueueSettings;
 import org.jboss.messaging.integration.bootstrap.JBMBootstrapServer;
 import org.jboss.messaging.jms.JBossDestination;
@@ -713,9 +715,9 @@
    public void removeAllMessages(JBossDestination destination) throws Exception
    {
       Binding binding = getMessagingServer().getPostOffice().getBinding(destination.getSimpleAddress());
-      if (binding != null)
+      if (binding != null && binding.getType() == BindingType.QUEUE)
       {
-         binding.getQueue().deleteAllReferences(getMessagingServer().getStorageManager());
+         ((Queue)binding.getBindable()).deleteAllReferences(getMessagingServer().getStorageManager());
       }
    }
 

Modified: trunk/tests/src/org/jboss/messaging/tests/concurrent/server/impl/QueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/concurrent/server/impl/QueueTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/concurrent/server/impl/QueueTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -29,7 +29,7 @@
 import org.jboss.messaging.core.server.HandleStatus;
 import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.QueueFactory;
+import org.jboss.messaging.core.server.BindableFactory;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.tests.unit.core.server.impl.fakes.FakeConsumer;
 import org.jboss.messaging.tests.unit.core.server.impl.fakes.FakeQueueFactory;
@@ -48,9 +48,8 @@
 public class QueueTest extends UnitTestCase
 {
    private static final Logger log = Logger.getLogger(QueueTest.class);
-
    
-   private QueueFactory queueFactory = new FakeQueueFactory();
+   private BindableFactory queueFactory = new FakeQueueFactory();
    
    /*
     * Concurrent set consumer not busy, busy then, call deliver while messages are being added and consumed
@@ -140,7 +139,7 @@
             
             MessageReference ref = message.createReference(queue);
             
-            queue.add(ref);
+            queue.addLast(ref);
             
             refs.add(ref);
             

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/chunkmessage/ChunkTestBase.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -30,17 +30,18 @@
 import java.nio.channels.FileChannel;
 
 import org.jboss.messaging.core.client.ClientConsumer;
+import org.jboss.messaging.core.client.ClientFileMessage;
 import org.jboss.messaging.core.client.ClientMessage;
 import org.jboss.messaging.core.client.ClientProducer;
 import org.jboss.messaging.core.client.ClientSession;
 import org.jboss.messaging.core.client.ClientSessionFactory;
-import org.jboss.messaging.core.client.ClientFileMessage;
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.message.impl.MessageImpl;
 import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
 import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
 import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.tests.util.ServiceTestBase;
 import org.jboss.messaging.util.DataConstants;
 import org.jboss.messaging.util.SimpleString;
@@ -61,10 +62,9 @@
    private static final Logger log = Logger.getLogger(ChunkTestBase.class);
 
    protected final SimpleString ADDRESS = new SimpleString("SimpleAddress");
-   
+
    protected MessagingService messagingService;
 
-
    // Attributes ----------------------------------------------------
 
    // Static --------------------------------------------------------
@@ -131,7 +131,7 @@
             sf.setBlockOnPersistentSend(true);
             sf.setBlockOnAcknowledge(true);
          }
-         
+
          if (producerWindow > 0)
          {
             sf.setSendWindowSize(producerWindow);
@@ -185,7 +185,7 @@
                   long time = System.currentTimeMillis();
                   message.putLongProperty(new SimpleString("original-time"), time);
                   message.putLongProperty(MessageImpl.HDR_SCHEDULED_DELIVERY_TIME, time + delayDelivery);
-                  
+
                   producer.send(message);
                }
                else
@@ -233,10 +233,10 @@
             ClientMessage message = consumer.receive(waitOnConsumer + delayDelivery);
 
             assertNotNull(message);
-            
+
             if (realFiles)
             {
-               assertTrue (message instanceof ClientFileMessage);
+               assertTrue(message instanceof ClientFileMessage);
             }
 
             if (testTime)
@@ -260,7 +260,9 @@
             assertNotNull(message);
 
             if (delayDelivery <= 0)
-            { // right now there is no guarantee of ordered delivered on multiple scheduledMessages
+            {
+               // right now there is no guarantee of ordered delivered on multiple scheduledMessages with the same
+               // scheduled delivery time
                assertEquals(i, ((Integer)message.getProperty(new SimpleString("counter-message"))).intValue());
             }
 
@@ -287,11 +289,12 @@
 
          long globalSize = messagingService.getServer().getPostOffice().getPagingManager().getGlobalSize();
          assertEquals(0l, globalSize);
-         assertEquals(0, messagingService.getServer().getPostOffice().getBinding(ADDRESS).getQueue().getDeliveringCount());
-         assertEquals(0, messagingService.getServer().getPostOffice().getBinding(ADDRESS).getQueue().getMessageCount());
+         assertEquals(0,
+                      ((Queue)messagingService.getServer().getPostOffice().getBinding(ADDRESS).getBindable()).getDeliveringCount());
+         assertEquals(0,
+                      ((Queue)messagingService.getServer().getPostOffice().getBinding(ADDRESS).getBindable()).getMessageCount());
 
          validateNoFilesOnLargeDir();
-         
 
       }
       finally
@@ -396,28 +399,27 @@
       ClientMessage clientMessage = consumer.receive(5000);
 
       assertNotNull(clientMessage);
-      
+
       if (!(clientMessage instanceof ClientFileMessage))
       {
          System.out.println("Size = " + clientMessage.getBodySize());
       }
 
-      
       if (clientMessage instanceof ClientFileMessage)
       {
          assertTrue(clientMessage instanceof ClientFileMessage);
-   
+
          ClientFileMessage fileClientMessage = (ClientFileMessage)clientMessage;
-   
+
          assertNotNull(fileClientMessage);
          File receivedFile = fileClientMessage.getFile();
-   
+
          checkFileRead(receivedFile, numberOfIntegers);
 
       }
-      
+
       clientMessage.acknowledge();
-      
+
       session.commit();
 
       consumer.close();

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/consumer/ConsumerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/consumer/ConsumerTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/consumer/ConsumerTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -33,6 +33,7 @@
 import org.jboss.messaging.core.config.impl.ConfigurationImpl;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
 import org.jboss.messaging.jms.client.JBossTextMessage;
 import org.jboss.messaging.tests.util.UnitTestCase;
@@ -310,8 +311,8 @@
          assertEquals("m" + i, message2.getBody().getString());
       }
       // assert that all the messages are there and none have been acked
-      assertEquals(messagingService.getServer().getPostOffice().getBinding(QUEUE).getQueue().getDeliveringCount(), 0);
-      assertEquals(messagingService.getServer().getPostOffice().getBinding(QUEUE).getQueue().getMessageCount(), 100);
+      assertEquals(((Queue)messagingService.getServer().getPostOffice().getBinding(QUEUE).getBindable()).getDeliveringCount(), 0);
+      assertEquals(((Queue)messagingService.getServer().getPostOffice().getBinding(QUEUE).getBindable()).getMessageCount(), 100);
 
       session.close();
    }
@@ -345,8 +346,8 @@
          assertEquals("m" + i, message2.getBody().getString());
       }
       // assert that all the messages are there and none have been acked
-      assertEquals(messagingService.getServer().getPostOffice().getBinding(QUEUE).getQueue().getDeliveringCount(), 0);
-      assertEquals(messagingService.getServer().getPostOffice().getBinding(QUEUE).getQueue().getMessageCount(), 100);
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(QUEUE).getBindable()).getDeliveringCount());
+      assertEquals(100, ((Queue)messagingService.getServer().getPostOffice().getBinding(QUEUE).getBindable()).getMessageCount());
 
       session.close();
    }
@@ -439,8 +440,8 @@
          assertEquals("m" + i, message2.getBody().getString());
       }
       // assert that all the messages are there and none have been acked
-      assertEquals(0, messagingService.getServer().getPostOffice().getBinding(QUEUE).getQueue().getDeliveringCount());
-      assertEquals(0, messagingService.getServer().getPostOffice().getBinding(QUEUE).getQueue().getMessageCount());
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(QUEUE).getBindable()).getDeliveringCount());
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(QUEUE).getBindable()).getMessageCount());
 
       session.close();
    }
@@ -473,8 +474,8 @@
          assertEquals("m" + i, message2.getBody().getString());
       }
       // assert that all the messages are there and none have been acked
-      assertEquals(messagingService.getServer().getPostOffice().getBinding(QUEUE).getQueue().getDeliveringCount(), 0);
-      assertEquals(messagingService.getServer().getPostOffice().getBinding(QUEUE).getQueue().getMessageCount(), 0);
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(QUEUE).getBindable()).getDeliveringCount());
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(QUEUE).getBindable()).getMessageCount());
 
       session.close();
    }
@@ -511,8 +512,8 @@
          }
       }
       // assert that all the messages are there and none have been acked
-      assertEquals(messagingService.getServer().getPostOffice().getBinding(QUEUE).getQueue().getDeliveringCount(), 0);
-      assertEquals(messagingService.getServer().getPostOffice().getBinding(QUEUE).getQueue().getMessageCount(), 0);
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(QUEUE).getBindable()).getDeliveringCount());
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(QUEUE).getBindable()).getMessageCount());
 
       session.close();
    }
@@ -549,13 +550,13 @@
          }
       }
       // assert that all the messages are there and none have been acked
-      assertEquals(messagingService.getServer().getPostOffice().getBinding(QUEUE).getQueue().getDeliveringCount(), 0);
-      assertEquals(messagingService.getServer().getPostOffice().getBinding(QUEUE).getQueue().getMessageCount(), 0);
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(QUEUE).getBindable()).getDeliveringCount());
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(QUEUE).getBindable()).getMessageCount());
 
       session.close();
 
-      assertEquals(messagingService.getServer().getPostOffice().getBinding(QUEUE).getQueue().getDeliveringCount(), 0);
-      assertEquals(messagingService.getServer().getPostOffice().getBinding(QUEUE).getQueue().getMessageCount(), 0);
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(QUEUE).getBindable()).getDeliveringCount());
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(QUEUE).getBindable()).getMessageCount());
    }
 
    private ClientMessage createMessage(final ClientSession session, final String msg)

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/consumer/ConsumerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/consumer/ConsumerTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/consumer/ConsumerTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -52,6 +52,7 @@
 import org.jboss.messaging.core.config.TransportConfiguration;
 import org.jboss.messaging.core.config.impl.ConfigurationImpl;
 import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
 import org.jboss.messaging.jms.JBossQueue;
 import org.jboss.messaging.jms.client.JBossConnectionFactory;
@@ -155,8 +156,8 @@
       }
       // assert that all the messages are there and none have been acked
       SimpleString queueName = new SimpleString(JBossQueue.JMS_QUEUE_ADDRESS_PREFIX + Q_NAME);
-      assertEquals(0, service.getServer().getPostOffice().getBinding(queueName).getQueue().getDeliveringCount());
-      assertEquals(0, service.getServer().getPostOffice().getBinding(queueName).getQueue().getMessageCount());
+      assertEquals(0, ((Queue)service.getServer().getPostOffice().getBinding(queueName).getBindable()).getDeliveringCount());
+      assertEquals(0, ((Queue)service.getServer().getPostOffice().getBinding(queueName).getBindable()).getMessageCount());
       session.close();
    }
 }

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/queue/DeadLetterAddressTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/queue/DeadLetterAddressTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/queue/DeadLetterAddressTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -38,6 +38,7 @@
 import org.jboss.messaging.core.exception.MessagingException;
 import org.jboss.messaging.core.message.impl.MessageImpl;
 import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
 import org.jboss.messaging.core.settings.impl.QueueSettings;
 import org.jboss.messaging.core.transaction.impl.XidImpl;
@@ -201,8 +202,8 @@
          clientSession.end(xid, XAResource.TMSUCCESS);
          clientSession.rollback(xid);
       }
-
-      assertEquals(messagingService.getServer().getPostOffice().getBinding(qName).getQueue().getMessageCount(), 0);
+      
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(qName).getBindable()).getMessageCount());
       ClientMessage m = clientConsumer.receive(1000);
       assertNull(m);
       //All the messages should now be in the DLQ

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/queue/ExpiryRunnerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/queue/ExpiryRunnerTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/queue/ExpiryRunnerTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -23,6 +23,7 @@
 
 import org.jboss.messaging.tests.util.UnitTestCase;
 import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.Queue;
 import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
 import org.jboss.messaging.core.client.ClientSession;
 import org.jboss.messaging.core.client.ClientSessionFactory;
@@ -76,8 +77,8 @@
          producer.send(m);
       }
       Thread.sleep(1600);
-      assertEquals(0, messagingService.getServer().getPostOffice().getBinding(qName).getQueue().getMessageCount());
-      assertEquals(0, messagingService.getServer().getPostOffice().getBinding(qName).getQueue().getDeliveringCount());
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(qName).getBindable()).getMessageCount());
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(qName).getBindable()).getDeliveringCount());
 
       ClientConsumer consumer = clientSession.createConsumer(expiryQueue);
       clientSession.start();
@@ -110,8 +111,8 @@
          producer2.send(m);
       }
       Thread.sleep(1600);
-      assertEquals(0, messagingService.getServer().getPostOffice().getBinding(qName).getQueue().getMessageCount());
-      assertEquals(0, messagingService.getServer().getPostOffice().getBinding(qName).getQueue().getDeliveringCount());
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(qName).getBindable()).getMessageCount());
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(qName).getBindable()).getDeliveringCount());
 
       ClientConsumer consumer = clientSession.createConsumer(expiryQueue);
       clientSession.start();
@@ -139,8 +140,8 @@
          producer.send(m);
       }
       Thread.sleep(1600);
-      assertEquals(50, messagingService.getServer().getPostOffice().getBinding(qName).getQueue().getMessageCount());
-      assertEquals(0, messagingService.getServer().getPostOffice().getBinding(qName).getQueue().getDeliveringCount());
+      assertEquals(numMessages / 2, ((Queue)messagingService.getServer().getPostOffice().getBinding(qName).getBindable()).getMessageCount());
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(qName).getBindable()).getDeliveringCount());
 
       ClientConsumer consumer = clientSession.createConsumer(expiryQueue);
       clientSession.start();
@@ -175,8 +176,8 @@
       }
       consumer.close();
       Thread.sleep(2100);
-      assertEquals(0, messagingService.getServer().getPostOffice().getBinding(qName).getQueue().getMessageCount());
-      assertEquals(0, messagingService.getServer().getPostOffice().getBinding(qName).getQueue().getDeliveringCount());
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(qName).getBindable()).getMessageCount());
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(qName).getBindable()).getDeliveringCount());
 
       consumer = clientSession.createConsumer(expiryQueue);
       clientSession.start();
@@ -205,8 +206,8 @@
          producer.send(m);
       }
       Thread.sleep(1600);
-      assertEquals(0, messagingService.getServer().getPostOffice().getBinding(qName).getQueue().getMessageCount());
-      assertEquals(0, messagingService.getServer().getPostOffice().getBinding(qName).getQueue().getDeliveringCount());
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(qName).getBindable()).getMessageCount());
+      assertEquals(0, ((Queue)messagingService.getServer().getPostOffice().getBinding(qName).getBindable()).getDeliveringCount());
 
       ClientConsumer consumer = clientSession.createConsumer(expiryQueue);
       clientSession.start();

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/xa/BasicXaRecoveryTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -230,10 +230,11 @@
       testMultipleTxReceiveWithRollback(true);
    }
 
-   public void testPagingServerRestarted() throws Exception
-   {
-      testPaging(true);
-   }
+// Uncomment when https://jira.jboss.org/jira/browse/JBMESSAGING-1473 is complete   
+//   public void testPagingServerRestarted() throws Exception
+//   {
+//      testPaging(true);
+//   }
 
    public void testPaging() throws Exception
    {
@@ -271,6 +272,8 @@
       clientSession.end(xid, XAResource.TMSUCCESS);
       clientSession.prepare(xid);
 
+      log.info("*** stopping and restarting");
+      
       if (restartServer)
       {
          stopAndRestartServer();
@@ -279,6 +282,8 @@
       {
          recreateClients();
       }
+      
+      
 
       Xid[] xids = clientSession.recover(XAResource.TMSTARTRSCAN);
       assertEquals(xids.length, 1);
@@ -300,6 +305,8 @@
       {
          ClientMessage m = pageConsumer.receive(10000);
          
+         log.info("got message " + i);
+         
          assertNotNull(m);
          m.acknowledge();
          clientSession.commit();
@@ -373,6 +380,9 @@
       
       long globalSize = this.messagingService.getServer().getPostOffice().getPagingManager().getGlobalSize();
       // Management message (from createQueue) will not be taken into account again as it is nonPersistent
+      
+      log.info("global size is " + globalSize +  " initial page size is " + initialPageSize);
+      
       assertTrue(globalSize == initialPageSize || globalSize == 0l);
 
    }
@@ -523,6 +533,8 @@
       clientSession.end(xid, XAResource.TMSUCCESS);
       clientSession.prepare(xid);
 
+      log.info("shutting down server");
+      
       if (stopServer)
       {
          stopAndRestartServer();
@@ -531,6 +543,8 @@
       {
          recreateClients();
       }
+      
+      log.info("restarted");
 
       Xid[] xids = clientSession.recover(XAResource.TMSTARTRSCAN);
 
@@ -543,6 +557,7 @@
       clientSession.rollback(xid);
       clientSession.start();
       ClientMessage m = clientConsumer.receive(1000);
+      log.info("m is " + m);
       assertNull(m);
    }
 
@@ -961,6 +976,8 @@
       clientSession.end(xid, XAResource.TMSUCCESS);
       clientSession.prepare(xid);
 
+      log.info("stopping and restarting");
+      
       if (stopServer)
       {
          stopAndRestartServer();
@@ -969,10 +986,12 @@
       {
          recreateClients();
       }
+      
+      log.info("Restarted");
 
       Xid[] xids = clientSession.recover(XAResource.TMSTARTRSCAN);
 
-      assertEquals(xids.length, 1);
+      assertEquals(1, xids.length);
       assertEquals(xids[0].getFormatId(), xid.getFormatId());
       assertEqualsByteArrays(xids[0].getBranchQualifier(), xid.getBranchQualifier());
       assertEqualsByteArrays(xids[0].getGlobalTransactionId(), xid.getGlobalTransactionId());

Modified: trunk/tests/src/org/jboss/messaging/tests/performance/persistence/FakeBinding.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/persistence/FakeBinding.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/persistence/FakeBinding.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -18,12 +18,13 @@
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
+ */
 
 package org.jboss.messaging.tests.performance.persistence;
 
 import org.jboss.messaging.core.postoffice.Binding;
-import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.postoffice.BindingType;
+import org.jboss.messaging.core.server.Bindable;
 import org.jboss.messaging.util.SimpleString;
 
 /**
@@ -32,39 +33,44 @@
  *
  */
 public class FakeBinding implements Binding
-{   
+{
    private SimpleString address;
-   private Queue queue;
 
-   public FakeBinding(final SimpleString address, final Queue queue)
+   private Bindable bindable;
+
+   public FakeBinding(final SimpleString address, final Bindable bindable)
    {
       this.address = address;
-      this.queue = queue;
+      this.bindable = bindable;
    }
 
+   public Bindable getBindable()
+   {
+      return bindable;
+   }
+
+   public BindingType getType()
+   {
+      return BindingType.QUEUE;
+   }
+
    public SimpleString getAddress()
    {
       return address;
    }
 
-   public Queue getQueue()
-   {
-      return queue;
-   }
-   
    public int getWeight()
    {
       return 0;
    }
 
    public boolean isExclusive()
-   {      
+   {
       return false;
    }
 
    public void setWeight(int weight)
-   {      
+   {
    }
 
-   
 }

Modified: trunk/tests/src/org/jboss/messaging/tests/performance/persistence/FakePostOffice.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/performance/persistence/FakePostOffice.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/performance/persistence/FakePostOffice.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -33,9 +33,10 @@
 import org.jboss.messaging.core.postoffice.Bindings;
 import org.jboss.messaging.core.postoffice.DuplicateIDCache;
 import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.BindableFactory;
+import org.jboss.messaging.core.server.Link;
 import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.QueueFactory;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.server.impl.SendLockImpl;
 import org.jboss.messaging.core.transaction.Transaction;
@@ -51,28 +52,42 @@
  *
  */
 public class FakePostOffice implements PostOffice
-{   
+{
    private ConcurrentHashMap<SimpleString, Binding> bindings = new ConcurrentHashMap<SimpleString, Binding>();
 
-   private QueueFactory queueFactory = new FakeQueueFactory();
+   private BindableFactory queueFactory = new FakeQueueFactory();
 
    private ConcurrentHashSet<SimpleString> addresses = new ConcurrentHashSet<SimpleString>();
 
    private volatile boolean started;
 
-   public Binding addBinding(SimpleString address,
-                             SimpleString queueName,
-                             Filter filter,
-                             boolean durable,
-                             boolean temporary,
-                             boolean exclusive) throws Exception
+   public Binding addQueueBinding(SimpleString address,
+                                  SimpleString queueName,
+                                  Filter filter,
+                                  boolean durable,
+                                  boolean temporary,
+                                  boolean exclusive) throws Exception
    {
       Queue queue = queueFactory.createQueue(-1, queueName, filter, durable, false);
       Binding binding = new FakeBinding(address, queue);
       bindings.put(address, binding);
       return binding;
    }
-   
+
+   public Binding addLinkBinding(SimpleString address,
+                                 SimpleString queueName,
+                                 Filter filter,
+                                 boolean durable,
+                                 boolean temporary,
+                                 boolean exclusive,
+                                 SimpleString linkAddress) throws Exception
+   {
+      Link link = queueFactory.createLink(-1, queueName, filter, durable, false, linkAddress);
+      Binding binding = new FakeBinding(address, link);
+      bindings.put(address, binding);
+      return binding;
+   }
+
    public List<MessageReference> reroute(ServerMessage message) throws Exception
    {
       return null;
@@ -166,19 +181,18 @@
    {
       return null;
    }
-   
+
    public int numMappings()
    {
       return 0;
    }
 
-
    /* (non-Javadoc)
     * @see org.jboss.messaging.core.postoffice.PostOffice#deliver(java.util.List)
     */
    public void deliver(List<MessageReference> references)
    {
-      
+
    }
 
    /* (non-Javadoc)
@@ -195,5 +209,4 @@
    {
    }
 
-
 }

Modified: trunk/tests/src/org/jboss/messaging/tests/timing/core/server/impl/QueueImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/timing/core/server/impl/QueueImplTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/timing/core/server/impl/QueueImplTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -30,8 +30,10 @@
 
 import org.easymock.EasyMock;
 import org.easymock.IAnswer;
+import org.jboss.messaging.core.filter.Filter;
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.persistence.StorageManager;
+import org.jboss.messaging.core.postoffice.PostOffice;
 import org.jboss.messaging.core.server.Consumer;
 import org.jboss.messaging.core.server.HandleStatus;
 import org.jboss.messaging.core.server.MessageReference;
@@ -82,7 +84,7 @@
 
    public void testScheduledNoConsumer() throws Exception
    {
-      Queue queue = new QueueImpl(1, new SimpleString("queue1"), null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, new SimpleString("queue1"), null, false, true, false, scheduledExecutor, null, null);
 
       //Send one scheduled
 
@@ -90,35 +92,35 @@
 
       MessageReference ref1 = generateReference(queue, 1);
       ref1.setScheduledDeliveryTime(now + 7000);
-      queue.add(ref1);
+      queue.addLast(ref1);
 
       //Send some non scheduled messages
 
       MessageReference ref2 = generateReference(queue, 2);
-      queue.add(ref2);
+      queue.addLast(ref2);
       MessageReference ref3 = generateReference(queue, 3);
-      queue.add(ref3);
+      queue.addLast(ref3);
       MessageReference ref4 = generateReference(queue, 4);
-      queue.add(ref4);
+      queue.addLast(ref4);
 
 
       //Now send some more scheduled messages
 
       MessageReference ref5 = generateReference(queue, 5);
       ref5.setScheduledDeliveryTime(now + 5000);
-      queue.add(ref5);
+      queue.addLast(ref5);
 
       MessageReference ref6 = generateReference(queue, 6);
       ref6.setScheduledDeliveryTime(now + 4000);
-      queue.add(ref6);
+      queue.addLast(ref6);
 
       MessageReference ref7 = generateReference(queue, 7);
       ref7.setScheduledDeliveryTime(now + 3000);
-      queue.add(ref7);
+      queue.addLast(ref7);
 
       MessageReference ref8 = generateReference(queue, 8);
       ref8.setScheduledDeliveryTime(now + 6000);
-      queue.add(ref8);
+      queue.addLast(ref8);
 
       List<MessageReference> refs = new ArrayList<MessageReference>();
 
@@ -148,7 +150,7 @@
 
    private void testScheduled(boolean direct)
    {
-      Queue queue = new QueueImpl(1, new SimpleString("queue1"), null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, new SimpleString("queue1"), null, false, true, false, scheduledExecutor, null, null);
 
       FakeConsumer consumer = null;
 
@@ -165,35 +167,35 @@
 
       MessageReference ref1 = generateReference(queue, 1);
       ref1.setScheduledDeliveryTime(now + 7000);
-      queue.add(ref1);
+      queue.addLast(ref1);
 
       //Send some non scheduled messages
 
       MessageReference ref2 = generateReference(queue, 2);
-      queue.add(ref2);
+      queue.addLast(ref2);
       MessageReference ref3 = generateReference(queue, 3);
-      queue.add(ref3);
+      queue.addLast(ref3);
       MessageReference ref4 = generateReference(queue, 4);
-      queue.add(ref4);
+      queue.addLast(ref4);
 
 
       //Now send some more scheduled messages
 
       MessageReference ref5 = generateReference(queue, 5);
       ref5.setScheduledDeliveryTime(now + 5000);
-      queue.add(ref5);
+      queue.addLast(ref5);
 
       MessageReference ref6 = generateReference(queue, 6);
       ref6.setScheduledDeliveryTime(now + 4000);
-      queue.add(ref6);
+      queue.addLast(ref6);
 
       MessageReference ref7 = generateReference(queue, 7);
       ref7.setScheduledDeliveryTime(now + 3000);
-      queue.add(ref7);
+      queue.addLast(ref7);
 
       MessageReference ref8 = generateReference(queue, 8);
       ref8.setScheduledDeliveryTime(now + 6000);
-      queue.add(ref8);
+      queue.addLast(ref8);
 
       if (!direct)
       {
@@ -246,7 +248,7 @@
    public void testDeliveryScheduled() throws Exception
    {
       Consumer consumer = EasyMock.createStrictMock(Consumer.class);
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
       MessageReference messageReference = generateReference(queue, 1);
       final CountDownLatch countDownLatch = new CountDownLatch(1);
       EasyMock.expect(consumer.handle(messageReference)).andAnswer(new IAnswer<HandleStatus>()

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerControlTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/MessagingServerControlTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -79,13 +79,21 @@
 public class MessagingServerControlTest extends TestCase
 {
    private PostOffice postOffice;
+
    private StorageManager storageManager;
+
    private Configuration configuration;
+
    private HierarchicalRepository<Set<Role>> securityRepository;
+
    private HierarchicalRepository<QueueSettings> queueSettingsRepository;
+
    private ResourceManager resourceManager;
+
    private MessagingServer server;
+
    private MessageCounterManager messageCounterManager;
+
    private RemotingService remotingService;
 
    // Constants -----------------------------------------------------
@@ -235,8 +243,7 @@
    {
       long interval = randomLong();
 
-      expect(configuration.getSecurityInvalidationInterval()).andReturn(
-            interval);
+      expect(configuration.getSecurityInvalidationInterval()).andReturn(interval);
       replayMockedAttributes();
 
       MessagingServerControl control = createControl();
@@ -288,13 +295,11 @@
    {
       boolean journalSyncNonTransactional = randomBoolean();
 
-      expect(configuration.isJournalSyncNonTransactional()).andReturn(
-            journalSyncNonTransactional);
+      expect(configuration.isJournalSyncNonTransactional()).andReturn(journalSyncNonTransactional);
       replayMockedAttributes();
 
       MessagingServerControl control = createControl();
-      assertEquals(journalSyncNonTransactional, control
-            .isJournalSyncNonTransactional());
+      assertEquals(journalSyncNonTransactional, control.isJournalSyncNonTransactional());
 
       verifyMockedAttributes();
    }
@@ -303,13 +308,11 @@
    {
       boolean journalSyncTransactional = randomBoolean();
 
-      expect(configuration.isJournalSyncTransactional()).andReturn(
-            journalSyncTransactional);
+      expect(configuration.isJournalSyncTransactional()).andReturn(journalSyncTransactional);
       replayMockedAttributes();
 
       MessagingServerControl control = createControl();
-      assertEquals(journalSyncTransactional, control
-            .isJournalSyncTransactional());
+      assertEquals(journalSyncTransactional, control.isJournalSyncTransactional());
 
       verifyMockedAttributes();
    }
@@ -318,8 +321,7 @@
    {
       boolean requireDestinations = randomBoolean();
 
-      expect(configuration.isRequireDestinations()).andReturn(
-            requireDestinations);
+      expect(configuration.isRequireDestinations()).andReturn(requireDestinations);
       replayMockedAttributes();
 
       MessagingServerControl control = createControl();
@@ -346,8 +348,7 @@
       String address = randomString();
       boolean added = randomBoolean();
 
-      expect(postOffice.addDestination(new SimpleString(address), false))
-            .andReturn(added);
+      expect(postOffice.addDestination(new SimpleString(address), false)).andReturn(added);
       replayMockedAttributes();
 
       MessagingServerControl control = createControl();
@@ -362,8 +363,7 @@
       String address = randomString();
       boolean removed = randomBoolean();
 
-      expect(postOffice.removeDestination(new SimpleString(address), false))
-            .andReturn(removed);
+      expect(postOffice.removeDestination(new SimpleString(address), false)).andReturn(removed);
       replayMockedAttributes();
 
       MessagingServerControl control = createControl();
@@ -372,119 +372,124 @@
       verifyMockedAttributes();
    }
 
-   public void testCreateQueue() throws Exception
-   {
-      String address = randomString();
-      String name = randomString();
+//   public void testCreateQueue() throws Exception
+//   {
+//      String address = randomString();
+//      String name = randomString();
+//
+//      expect(postOffice.getBinding(new SimpleString(address))).andReturn(null);
+//      Binding newBinding = createMock(Binding.class);
+//      expect(postOffice.addQueueBinding(new SimpleString(address), new SimpleString(name), null, true, false, false)).andReturn(newBinding);
+//      replayMockedAttributes();
+//      replay(newBinding);
+//
+//      MessagingServerControl control = createControl();
+//      control.createQueue(address, name);
+//
+//      verifyMockedAttributes();
+//      verify(newBinding);
+//   }
+//
+//   public void testCreateQueueWithAllParameters() throws Exception
+//   {
+//      String address = randomString();
+//      String name = randomString();
+//      String filter = "color = 'green'";
+//      boolean durable = true;
+//      boolean temporary = false;
+//      boolean exclusive = false;
+//
+//      expect(postOffice.getBinding(new SimpleString(address))).andReturn(null);
+//      Binding newBinding = createMock(Binding.class);
+//      expect(postOffice.addQueueBinding(eq(new SimpleString(address)),
+//                                        eq(new SimpleString(name)),
+//                                        isA(Filter.class),
+//                                        eq(durable),
+//                                        eq(temporary),
+//                                        eq(exclusive))).andReturn(newBinding);
+//      replayMockedAttributes();
+//      replay(newBinding);
+//
+//      MessagingServerControl control = createControl();
+//      control.createQueue(address, name, filter, durable);
+//
+//      verify(newBinding);
+//      verifyMockedAttributes();
+//   }
+//
+//   public void testCreateQueueWithEmptyFilter() throws Exception
+//   {
+//      String address = randomString();
+//      String name = randomString();
+//      String filter = "";
+//      boolean durable = true;
+//      boolean temporary = false;
+//
+//      expect(postOffice.getBinding(new SimpleString(address))).andReturn(null);
+//      Binding newBinding = createMock(Binding.class);
+//      expect(postOffice.addQueueBinding(new SimpleString(address),
+//                                        new SimpleString(name),
+//                                        null,
+//                                        durable,
+//                                        temporary,
+//                                        false)).andReturn(newBinding);
+//      replay(newBinding);
+//      replayMockedAttributes();
+//
+//      MessagingServerControl control = createControl();
+//      control.createQueue(address, name, filter, durable);
+//
+//      verify(newBinding);
+//      verifyMockedAttributes();
+//   }
+//
+//   public void testCreateQueueWithNullFilter() throws Exception
+//   {
+//      String address = randomString();
+//      String name = randomString();
+//      String filter = null;
+//      boolean durable = true;
+//      boolean temporary = false;
+//
+//      expect(postOffice.getBinding(new SimpleString(address))).andReturn(null);
+//      Binding newBinding = createMock(Binding.class);
+//      expect(postOffice.addQueueBinding(new SimpleString(address),
+//                                        new SimpleString(name),
+//                                        null,
+//                                        durable,
+//                                        temporary,
+//                                        false)).andReturn(newBinding);
+//      replay(newBinding);
+//      replayMockedAttributes();
+//
+//      MessagingServerControl control = createControl();
+//      control.createQueue(address, name, filter, durable);
+//
+//      verify(newBinding);
+//      verifyMockedAttributes();
+//   }
+//
+//   public void testDestroyQueueAndReceiveNotification() throws Exception
+//   {
+//      String name = randomString();
+//
+//      Binding binding = createMock(Binding.class);
+//      Queue queue = createMock(Queue.class);
+//      expect(queue.getName()).andReturn(new SimpleString(name));
+//      expect(binding.getBindable()).andReturn(queue);
+//      expect(postOffice.getBinding(new SimpleString(name))).andReturn(binding);
+//      expect(queue.deleteAllReferences(storageManager)).andReturn(randomPositiveInt());
+//      expect(postOffice.removeBinding(new SimpleString(name))).andReturn(binding);
+//      replayMockedAttributes();
+//      replay(binding, queue);
+//
+//      MessagingServerControl control = createControl();
+//      control.destroyQueue(name);
+//
+//      verify(binding, queue);
+//      verifyMockedAttributes();
+//   }
 
-      expect(postOffice.getBinding(new SimpleString(address))).andReturn(null);
-      Binding newBinding = createMock(Binding.class);
-      expect(
-            postOffice.addBinding(new SimpleString(address), new SimpleString(
-                  name), null, true, false, false)).andReturn(newBinding);
-      replayMockedAttributes();
-      replay(newBinding);
-
-      MessagingServerControl control = createControl();
-      control.createQueue(address, name);
-
-      verifyMockedAttributes();
-      verify(newBinding);
-   }
-
-   public void testCreateQueueWithAllParameters() throws Exception
-   {
-      String address = randomString();
-      String name = randomString();
-      String filter = "color = 'green'";
-      boolean durable = true;
-      boolean temporary = false;
-      boolean exclusive = false;
-
-      expect(postOffice.getBinding(new SimpleString(address))).andReturn(null);
-      Binding newBinding = createMock(Binding.class);
-      expect(
-            postOffice.addBinding(eq(new SimpleString(address)),
-                  eq(new SimpleString(name)), isA(Filter.class), eq(durable)
-                  , eq(temporary), eq(exclusive))).andReturn(newBinding);
-      replayMockedAttributes();
-      replay(newBinding);
-
-      MessagingServerControl control = createControl();
-      control.createQueue(address, name, filter, durable);
-
-      verify(newBinding);
-      verifyMockedAttributes();
-   }
-
-   public void testCreateQueueWithEmptyFilter() throws Exception
-   {
-      String address = randomString();
-      String name = randomString();
-      String filter = "";
-      boolean durable = true;
-      boolean temporary = false;
- 
-      expect(postOffice.getBinding(new SimpleString(address))).andReturn(null);
-      Binding newBinding = createMock(Binding.class);
-      expect(
-            postOffice.addBinding(new SimpleString(address), new SimpleString(
-                  name), null, durable, temporary, false)).andReturn(newBinding);
-      replay(newBinding);
-      replayMockedAttributes();
-
-      MessagingServerControl control = createControl();
-      control.createQueue(address, name, filter, durable);
-
-      verify(newBinding);
-      verifyMockedAttributes();
-   }
-
-   public void testCreateQueueWithNullFilter() throws Exception
-   {
-      String address = randomString();
-      String name = randomString();
-      String filter = null;
-      boolean durable = true;
-      boolean temporary = false;
-
-      expect(postOffice.getBinding(new SimpleString(address))).andReturn(null);
-      Binding newBinding = createMock(Binding.class);
-      expect(
-            postOffice.addBinding(new SimpleString(address), new SimpleString(
-                  name), null, durable, temporary, false)).andReturn(newBinding);
-      replay(newBinding);
-      replayMockedAttributes();
-
-      MessagingServerControl control = createControl();
-      control.createQueue(address, name, filter, durable);
-
-      verify(newBinding);
-      verifyMockedAttributes();
-   }
-
-   public void testDestroyQueueAndReceiveNotification() throws Exception
-   {
-      String name = randomString();
-
-      Binding binding = createMock(Binding.class);
-      Queue queue = createMock(Queue.class);
-      expect(queue.getName()).andReturn(new SimpleString(name));
-      expect(binding.getQueue()).andReturn(queue);
-      expect(postOffice.getBinding(new SimpleString(name))).andReturn(binding);
-      expect(queue.deleteAllReferences(storageManager)).andReturn(randomPositiveInt());
-      expect(postOffice.removeBinding(new SimpleString(name))).andReturn(
-            binding);
-      replayMockedAttributes();
-      replay(binding, queue);
-
-      MessagingServerControl control = createControl();
-      control.destroyQueue(name);
-
-      verify(binding, queue);
-      verifyMockedAttributes();
-   }
-
    public void testGetConnectionCount() throws Exception
    {
       int count = randomInt();
@@ -515,9 +520,9 @@
       expect(resourceManager.getPreparedTransactionsWithCreationTime()).andStubReturn(xids);
 
       replayMockedAttributes();
-      
+
       MessagingServerControl control = createControl();
-      
+
       String[] preparedTransactions = control.listPreparedTransactions();
 
       assertEquals(3, preparedTransactions.length);
@@ -537,16 +542,16 @@
       Xid xid = randomXid();
       String transactionAsBase64 = XidImpl.toBase64String(xid);
       Transaction tx = createMock(Transaction.class);
-      
-      expect(resourceManager.getPreparedTransactions()).andReturn(Arrays.asList(xid));      
+
+      expect(resourceManager.getPreparedTransactions()).andReturn(Arrays.asList(xid));
       expect(resourceManager.removeTransaction(xid)).andReturn(tx);
       tx.commit();
-      
+
       replayMockedAttributes();
       replay(tx);
-      
+
       MessagingServerControl control = createControl();
-      
+
       assertTrue(control.commitPreparedTransaction(transactionAsBase64));
 
       verifyMockedAttributes();
@@ -557,33 +562,33 @@
    {
       Xid xid = randomXid();
       String transactionAsBase64 = XidImpl.toBase64String(xid);
-      
-      expect(resourceManager.getPreparedTransactions()).andStubReturn(Collections.emptyList());      
 
+      expect(resourceManager.getPreparedTransactions()).andStubReturn(Collections.emptyList());
+
       replayMockedAttributes();
-      
+
       MessagingServerControl control = createControl();
-      
+
       assertFalse(control.commitPreparedTransaction(transactionAsBase64));
 
       verifyMockedAttributes();
    }
-   
+
    public void testRollbackPreparedTransactionWithKnownPreparedTransaction() throws Exception
    {
       Xid xid = randomXid();
       String transactionAsBase64 = XidImpl.toBase64String(xid);
       Transaction tx = createMock(Transaction.class);
-      
-      expect(resourceManager.getPreparedTransactions()).andReturn(Arrays.asList(xid));      
+
+      expect(resourceManager.getPreparedTransactions()).andReturn(Arrays.asList(xid));
       expect(resourceManager.removeTransaction(xid)).andReturn(tx);
       expect(tx.rollback(queueSettingsRepository)).andStubReturn(Collections.emptyList());
-      
+
       replayMockedAttributes();
       replay(tx);
-      
+
       MessagingServerControl control = createControl();
-      
+
       assertTrue(control.rollbackPreparedTransaction(transactionAsBase64));
 
       verifyMockedAttributes();
@@ -594,18 +599,18 @@
    {
       Xid xid = randomXid();
       String transactionAsBase64 = XidImpl.toBase64String(xid);
-      
-      expect(resourceManager.getPreparedTransactions()).andStubReturn(Collections.emptyList());      
 
+      expect(resourceManager.getPreparedTransactions()).andStubReturn(Collections.emptyList());
+
       replayMockedAttributes();
-      
+
       MessagingServerControl control = createControl();
-      
+
       assertFalse(control.rollbackPreparedTransaction(transactionAsBase64));
 
       verifyMockedAttributes();
    }
-   
+
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------
@@ -648,21 +653,41 @@
    private MessagingServerControl createControl() throws Exception
    {
       MessagingServerControl control = new MessagingServerControl(postOffice,
-            storageManager, configuration, 
-            queueSettingsRepository, resourceManager, remotingService, server, messageCounterManager, new NotificationBroadcasterSupport());
+                                                                  storageManager,
+                                                                  configuration,
+                                                                  queueSettingsRepository,
+                                                                  resourceManager,
+                                                                  remotingService,
+                                                                  server,
+                                                                  messageCounterManager,
+                                                                  new NotificationBroadcasterSupport());
       return control;
    }
 
    private void replayMockedAttributes()
    {
-      replay(postOffice, storageManager, configuration, securityRepository,
-            queueSettingsRepository, resourceManager, remotingService, server, messageCounterManager);
+      replay(postOffice,
+             storageManager,
+             configuration,
+             securityRepository,
+             queueSettingsRepository,
+             resourceManager,
+             remotingService,
+             server,
+             messageCounterManager);
    }
 
    private void verifyMockedAttributes()
    {
-      verify(postOffice, storageManager, configuration, securityRepository,
-            queueSettingsRepository, resourceManager, remotingService, server, messageCounterManager);
+      verify(postOffice,
+             storageManager,
+             configuration,
+             securityRepository,
+             queueSettingsRepository,
+             resourceManager,
+             remotingService,
+             server,
+             messageCounterManager);
    }
 
    // Inner classes -------------------------------------------------

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/persistence/impl/journal/JournalStorageManagerTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -52,7 +52,7 @@
 import org.jboss.messaging.core.server.HandleStatus;
 import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.QueueFactory;
+import org.jboss.messaging.core.server.BindableFactory;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.server.impl.ServerMessageImpl;
 import org.jboss.messaging.core.transaction.impl.XidImpl;
@@ -409,139 +409,139 @@
 //      EasyMock.verify(refs2.toArray());
 //      EasyMock.verify(queue1, queue2, queue3);
 //   }
+//
+//   public void testAddBindingWithFilter() throws Exception
+//   {
+//      testAddBindingWithFilter(true);
+//   }
+//
+//   public void testAddBindingWithoutFilter() throws Exception
+//   {
+//      testAddBindingWithFilter(false);
+//   }
+//
+//   private void testAddBindingWithFilter(final boolean useFilter) throws Exception
+//   {
+//      Journal messageJournal = EasyMock.createStrictMock(Journal.class);
+//      Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
+//
+//      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
+//
+//      Queue queue = EasyMock.createStrictMock(Queue.class);
+//      SimpleString queueName = new SimpleString("saiohsiudh");
+//      EasyMock.expect(queue.getName()).andStubReturn(queueName);
+//      Filter filter = null;
+//      SimpleString queueFilter = new SimpleString("ihjuhyg");
+//      if (useFilter)
+//      {
+//         filter = EasyMock.createStrictMock(Filter.class);
+//         EasyMock.expect(filter.getFilterString()).andStubReturn(queueFilter);
+//      }
+//      EasyMock.expect(queue.getFilter()).andStubReturn(filter);
+//
+//      SimpleString address = new SimpleString("aijsiajs");
+//      Binding binding = new BindingImpl(address, queue, true);
+//
+//      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+//      DataOutputStream daos = new DataOutputStream(baos);
+//
+//      queue.setPersistenceID(EasyMock.anyLong());
+//
+//      byte[] nameBytes = queueName.getData();
+//      daos.writeInt(nameBytes.length);
+//      daos.write(nameBytes);
+//      byte[] addressBytes = binding.getAddress().getData();
+//      daos.writeInt(addressBytes.length);
+//      daos.write(addressBytes);
+//      daos.writeBoolean(filter != null);      
+//      if (filter != null)
+//      {
+//         byte[] filterBytes = queueFilter.getData();
+//         daos.writeInt(filterBytes.length);
+//         daos.write(filterBytes);
+//      }
+//      daos.writeBoolean(true);
+//      daos.flush();
+//      byte[] data = baos.toByteArray();
+//
+//      log.debug("** data length is " + data.length);
+//      log.debug(UnitTestCase.dumpBytes(data));
+//
+//      bindingsJournal.appendAddRecord(EasyMock.anyLong(),
+//                                      EasyMock.eq(JournalStorageManager.BINDING_RECORD),
+//                                      compareEncodingSupport(data));
+//
+//      if (useFilter)
+//      {
+//         EasyMock.replay(queue, filter, messageJournal, bindingsJournal);
+//      }
+//      else
+//      {
+//         EasyMock.replay(queue, messageJournal, bindingsJournal);
+//      }
+//
+//      jsm.addBinding(binding);
+//
+//      if (useFilter)
+//      {
+//         EasyMock.verify(queue, filter, messageJournal, bindingsJournal);
+//      }
+//      else
+//      {
+//         EasyMock.verify(queue, messageJournal, bindingsJournal);
+//      }
+//   }
+//
+//   public void testDeleteBinding() throws Exception
+//   {
+//      Journal messageJournal = EasyMock.createStrictMock(Journal.class);
+//      Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
+//
+//      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
+//
+//      Binding binding = EasyMock.createStrictMock(Binding.class);
+//      Queue queue = EasyMock.createStrictMock(Queue.class);
+//      EasyMock.expect(binding.getQueue()).andStubReturn(queue);
+//      long queueID = 1209129;
+//      EasyMock.expect(queue.getPersistenceID()).andStubReturn(queueID);
+//
+//      bindingsJournal.appendDeleteRecord(queueID);
+//
+//      EasyMock.replay(messageJournal, bindingsJournal, binding, queue);
+//
+//      jsm.deleteBinding(binding);
+//
+//      EasyMock.verify(messageJournal, bindingsJournal, binding, queue);
+//   }
+//
+//   public void testDeleteBindingUnPersistedQueue() throws Exception
+//   {
+//      Journal messageJournal = EasyMock.createStrictMock(Journal.class);
+//      Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
+//
+//      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
+//
+//      Binding binding = EasyMock.createStrictMock(Binding.class);
+//      Queue queue = EasyMock.createStrictMock(Queue.class);
+//      EasyMock.expect(binding.getQueue()).andStubReturn(queue);
+//      long queueID = -1;
+//      EasyMock.expect(queue.getPersistenceID()).andStubReturn(queueID);
+//
+//      EasyMock.replay(messageJournal, bindingsJournal, binding, queue);
+//
+//      try
+//      {
+//         jsm.deleteBinding(binding);
+//         fail("Should throw exception");
+//      }
+//      catch (IllegalArgumentException e)
+//      {
+//         // OK
+//      }
+//
+//      EasyMock.verify(messageJournal, bindingsJournal, binding, queue);
+//   }
 
-   public void testAddBindingWithFilter() throws Exception
-   {
-      testAddBindingWithFilter(true);
-   }
-
-   public void testAddBindingWithoutFilter() throws Exception
-   {
-      testAddBindingWithFilter(false);
-   }
-
-   private void testAddBindingWithFilter(final boolean useFilter) throws Exception
-   {
-      Journal messageJournal = EasyMock.createStrictMock(Journal.class);
-      Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
-
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
-
-      Queue queue = EasyMock.createStrictMock(Queue.class);
-      SimpleString queueName = new SimpleString("saiohsiudh");
-      EasyMock.expect(queue.getName()).andStubReturn(queueName);
-      Filter filter = null;
-      SimpleString queueFilter = new SimpleString("ihjuhyg");
-      if (useFilter)
-      {
-         filter = EasyMock.createStrictMock(Filter.class);
-         EasyMock.expect(filter.getFilterString()).andStubReturn(queueFilter);
-      }
-      EasyMock.expect(queue.getFilter()).andStubReturn(filter);
-
-      SimpleString address = new SimpleString("aijsiajs");
-      Binding binding = new BindingImpl(address, queue, true);
-
-      ByteArrayOutputStream baos = new ByteArrayOutputStream();
-      DataOutputStream daos = new DataOutputStream(baos);
-
-      queue.setPersistenceID(EasyMock.anyLong());
-
-      byte[] nameBytes = queueName.getData();
-      daos.writeInt(nameBytes.length);
-      daos.write(nameBytes);
-      byte[] addressBytes = binding.getAddress().getData();
-      daos.writeInt(addressBytes.length);
-      daos.write(addressBytes);
-      daos.writeBoolean(filter != null);      
-      if (filter != null)
-      {
-         byte[] filterBytes = queueFilter.getData();
-         daos.writeInt(filterBytes.length);
-         daos.write(filterBytes);
-      }
-      daos.writeBoolean(true);
-      daos.flush();
-      byte[] data = baos.toByteArray();
-
-      log.debug("** data length is " + data.length);
-      log.debug(UnitTestCase.dumpBytes(data));
-
-      bindingsJournal.appendAddRecord(EasyMock.anyLong(),
-                                      EasyMock.eq(JournalStorageManager.BINDING_RECORD),
-                                      compareEncodingSupport(data));
-
-      if (useFilter)
-      {
-         EasyMock.replay(queue, filter, messageJournal, bindingsJournal);
-      }
-      else
-      {
-         EasyMock.replay(queue, messageJournal, bindingsJournal);
-      }
-
-      jsm.addBinding(binding);
-
-      if (useFilter)
-      {
-         EasyMock.verify(queue, filter, messageJournal, bindingsJournal);
-      }
-      else
-      {
-         EasyMock.verify(queue, messageJournal, bindingsJournal);
-      }
-   }
-
-   public void testDeleteBinding() throws Exception
-   {
-      Journal messageJournal = EasyMock.createStrictMock(Journal.class);
-      Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
-
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
-
-      Binding binding = EasyMock.createStrictMock(Binding.class);
-      Queue queue = EasyMock.createStrictMock(Queue.class);
-      EasyMock.expect(binding.getQueue()).andStubReturn(queue);
-      long queueID = 1209129;
-      EasyMock.expect(queue.getPersistenceID()).andStubReturn(queueID);
-
-      bindingsJournal.appendDeleteRecord(queueID);
-
-      EasyMock.replay(messageJournal, bindingsJournal, binding, queue);
-
-      jsm.deleteBinding(binding);
-
-      EasyMock.verify(messageJournal, bindingsJournal, binding, queue);
-   }
-
-   public void testDeleteBindingUnPersistedQueue() throws Exception
-   {
-      Journal messageJournal = EasyMock.createStrictMock(Journal.class);
-      Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
-
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
-
-      Binding binding = EasyMock.createStrictMock(Binding.class);
-      Queue queue = EasyMock.createStrictMock(Queue.class);
-      EasyMock.expect(binding.getQueue()).andStubReturn(queue);
-      long queueID = -1;
-      EasyMock.expect(queue.getPersistenceID()).andStubReturn(queueID);
-
-      EasyMock.replay(messageJournal, bindingsJournal, binding, queue);
-
-      try
-      {
-         jsm.deleteBinding(binding);
-         fail("Should throw exception");
-      }
-      catch (IllegalArgumentException e)
-      {
-         // OK
-      }
-
-      EasyMock.verify(messageJournal, bindingsJournal, binding, queue);
-   }
-
    public void testAddDeleteDestination() throws Exception
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);
@@ -667,73 +667,73 @@
       return record;
    }
 
-   public void testLoadBindings() throws Exception
-   {
-      Journal messageJournal = EasyMock.createStrictMock(Journal.class);
-      Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
+//   public void testLoadBindings() throws Exception
+//   {
+//      Journal messageJournal = EasyMock.createStrictMock(Journal.class);
+//      Journal bindingsJournal = EasyMock.createStrictMock(Journal.class);
+//
+//      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
+//
+//      bindingsJournal.load((List<RecordInfo>)EasyMock.anyObject(), (List<PreparedTransactionInfo>)EasyMock.anyObject());
+//
+//      List<RecordInfo> records = new ArrayList<RecordInfo>();
+//
+//      SimpleString squeue1 = new SimpleString("queue1");
+//      SimpleString squeue2 = new SimpleString("queue2");
+//      SimpleString squeue3 = new SimpleString("queue3");
+//      SimpleString saddress1 = new SimpleString("address1");
+//      SimpleString saddress2 = new SimpleString("address2");
+//      SimpleString saddress3 = new SimpleString("address3");
+//      SimpleString sfilter1 = new SimpleString("JBMMessageID=123");
+//
+//      records.add(createBindingRecord(0, squeue1, saddress1, sfilter1));
+//      records.add(createBindingRecord(1, squeue2, saddress2, null));
+//      records.add(createBindingRecord(2, squeue3, saddress3, null));
+//
+//      SimpleString sdest1 = new SimpleString("dest1");
+//      SimpleString sdest2 = new SimpleString("dest2");
+//      SimpleString sdest3 = new SimpleString("dest3");
+//
+//      records.add(createDestinationRecord(10, sdest1));
+//      records.add(createDestinationRecord(11, sdest2));
+//      records.add(createDestinationRecord(12, sdest3));
+//
+//      EasyMock.expectLastCall().andAnswer(new LoadRecordsIAnswer(12, records, null));
+//
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
+//
+//      Queue queue1 = EasyMock.createStrictMock(Queue.class);
+//      Queue queue2 = EasyMock.createStrictMock(Queue.class);
+//      Queue queue3 = EasyMock.createStrictMock(Queue.class);
+//      EasyMock.expect(qf.createQueue(EasyMock.eq(0L),
+//                                     EasyMock.eq(squeue1),
+//                                     EasyMock.isA(Filter.class),
+//                                     EasyMock.eq(true),
+//                                     EasyMock.eq(false))).andReturn(queue1);
+//      EasyMock.expect(qf.createQueue(1L, squeue2, null, true, false)).andReturn(queue1);
+//      EasyMock.expect(qf.createQueue(2L, squeue3, null, true, false)).andReturn(queue1);
+//
+//      EasyMock.replay(messageJournal, bindingsJournal, queue1, queue2, queue3, qf);
+//
+//      List<Binding> bindings = new ArrayList<Binding>();
+//      List<SimpleString> destinations = new ArrayList<SimpleString>();
+//
+//      jsm.loadBindings(qf, bindings, destinations);
+//
+//      EasyMock.verify(messageJournal, bindingsJournal, queue1, queue2, queue3, qf);
+//
+//      assertEquals(3, bindings.size());
+//      assertEquals(3, destinations.size());
+//
+//      assertEquals(saddress1, bindings.get(0).getAddress());
+//      assertEquals(saddress2, bindings.get(1).getAddress());
+//      assertEquals(saddress3, bindings.get(2).getAddress());
+//
+//      assertEquals(sdest1, destinations.get(0));
+//      assertEquals(sdest2, destinations.get(1));
+//      assertEquals(sdest3, destinations.get(2));
+//   }
 
-      JournalStorageManager jsm = new JournalStorageManager(messageJournal, bindingsJournal, null);
-
-      bindingsJournal.load((List<RecordInfo>)EasyMock.anyObject(), (List<PreparedTransactionInfo>)EasyMock.anyObject());
-
-      List<RecordInfo> records = new ArrayList<RecordInfo>();
-
-      SimpleString squeue1 = new SimpleString("queue1");
-      SimpleString squeue2 = new SimpleString("queue2");
-      SimpleString squeue3 = new SimpleString("queue3");
-      SimpleString saddress1 = new SimpleString("address1");
-      SimpleString saddress2 = new SimpleString("address2");
-      SimpleString saddress3 = new SimpleString("address3");
-      SimpleString sfilter1 = new SimpleString("JBMMessageID=123");
-
-      records.add(createBindingRecord(0, squeue1, saddress1, sfilter1));
-      records.add(createBindingRecord(1, squeue2, saddress2, null));
-      records.add(createBindingRecord(2, squeue3, saddress3, null));
-
-      SimpleString sdest1 = new SimpleString("dest1");
-      SimpleString sdest2 = new SimpleString("dest2");
-      SimpleString sdest3 = new SimpleString("dest3");
-
-      records.add(createDestinationRecord(10, sdest1));
-      records.add(createDestinationRecord(11, sdest2));
-      records.add(createDestinationRecord(12, sdest3));
-
-      EasyMock.expectLastCall().andAnswer(new LoadRecordsIAnswer(12, records, null));
-
-      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
-
-      Queue queue1 = EasyMock.createStrictMock(Queue.class);
-      Queue queue2 = EasyMock.createStrictMock(Queue.class);
-      Queue queue3 = EasyMock.createStrictMock(Queue.class);
-      EasyMock.expect(qf.createQueue(EasyMock.eq(0L),
-                                     EasyMock.eq(squeue1),
-                                     EasyMock.isA(Filter.class),
-                                     EasyMock.eq(true),
-                                     EasyMock.eq(false))).andReturn(queue1);
-      EasyMock.expect(qf.createQueue(1L, squeue2, null, true, false)).andReturn(queue1);
-      EasyMock.expect(qf.createQueue(2L, squeue3, null, true, false)).andReturn(queue1);
-
-      EasyMock.replay(messageJournal, bindingsJournal, queue1, queue2, queue3, qf);
-
-      List<Binding> bindings = new ArrayList<Binding>();
-      List<SimpleString> destinations = new ArrayList<SimpleString>();
-
-      jsm.loadBindings(qf, bindings, destinations);
-
-      EasyMock.verify(messageJournal, bindingsJournal, queue1, queue2, queue3, qf);
-
-      assertEquals(3, bindings.size());
-      assertEquals(3, destinations.size());
-
-      assertEquals(saddress1, bindings.get(0).getAddress());
-      assertEquals(saddress2, bindings.get(1).getAddress());
-      assertEquals(saddress3, bindings.get(2).getAddress());
-
-      assertEquals(sdest1, destinations.get(0));
-      assertEquals(sdest2, destinations.get(1));
-      assertEquals(sdest3, destinations.get(2));
-   }
-
    public void testStartStop() throws Exception
    {
       Journal messageJournal = EasyMock.createStrictMock(Journal.class);

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -41,7 +41,7 @@
 import org.jboss.messaging.core.postoffice.impl.PostOfficeImpl;
 import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.QueueFactory;
+import org.jboss.messaging.core.server.BindableFactory;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.transaction.ResourceManager;
 import org.jboss.messaging.tests.unit.core.server.impl.fakes.FakeQueueFactory;
@@ -57,14 +57,14 @@
  */
 public class PostOfficeImplTest extends UnitTestCase
 {
-   private final QueueFactory queueFactory = new FakeQueueFactory();
+   private final BindableFactory queueFactory = new FakeQueueFactory();
 
    protected boolean wildCardRoutingEnabled;
 //
 //   public void testPostOfficeStart() throws Exception
 //   {
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //
@@ -85,7 +85,7 @@
 //   public void testPostOfficeStartAndStop() throws Exception
 //   {
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //
@@ -112,7 +112,7 @@
 //
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //
 //      SimpleString address1 = new SimpleString("testAddress1");
 //      EasyMock.expect(binding.getAddress()).andStubReturn(address1);
@@ -169,7 +169,7 @@
 //      }
 //
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //      EasyMock.expect(pgm.isGlobalPageMode()).andStubReturn(true);
@@ -207,7 +207,7 @@
 //      bindingArrayList.add(binding2);
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //
 //      SimpleString address1 = new SimpleString("testAddress1");
@@ -266,7 +266,7 @@
 //      }
 //
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
@@ -304,7 +304,7 @@
 //      List<SimpleString> dests = new ArrayList<SimpleString>();
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //
 //      SimpleString address1 = new SimpleString("testAddress1");
@@ -349,7 +349,7 @@
 //   {
 //
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
@@ -415,7 +415,7 @@
 //   {
 //
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //      PagingStore pgstore = EasyMock.createNiceMock(PagingStore.class);
@@ -476,7 +476,7 @@
 //   {
 //
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //      PagingStore pgstore = EasyMock.createNiceMock(PagingStore.class);
@@ -533,7 +533,7 @@
 //   {
 //
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //      PagingStore pgstore = EasyMock.createNiceMock(PagingStore.class);
@@ -593,7 +593,7 @@
 //   public void testAddQueue() throws Exception
 //   {
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //
@@ -635,7 +635,7 @@
 //   public void testRemoveQueue() throws Exception
 //   {
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //
@@ -688,7 +688,7 @@
 //   public void testAddRemoveMultipleWithDifferentConditions() throws Exception
 //   {
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = new FakeQueueFactory();
+//      BindableFactory qf = new FakeQueueFactory();
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //
@@ -779,7 +779,7 @@
 //   {
 //      SimpleString address = new SimpleString("testAddress");
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //
@@ -806,7 +806,7 @@
 //      SimpleString address2 = new SimpleString("testAddress2");
 //      SimpleString address3 = new SimpleString("testAddress3");
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //      EasyMock.expect(pgm.createPageStore(EasyMock.isA(SimpleString.class))).andStubReturn(null);
@@ -839,7 +839,7 @@
 //
 //      SimpleString address = new SimpleString("testAddress");
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //
@@ -869,7 +869,7 @@
 //      SimpleString address2 = new SimpleString("testAddress2");
 //      SimpleString address3 = new SimpleString("testAddress3");
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //
@@ -908,7 +908,7 @@
 //   {
 //      SimpleString queueName = new SimpleString("testQueueName");
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createMock(BindableFactory.class);
 //      Filter filter = EasyMock.createStrictMock(Filter.class);
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
@@ -939,7 +939,7 @@
 //      SimpleString queueName2 = new SimpleString("testQueueName2");
 //      SimpleString queueName3 = new SimpleString("testQueueName3");
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      Filter filter = EasyMock.createStrictMock(Filter.class);
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      Queue queue2 = EasyMock.createStrictMock(Queue.class);
@@ -983,7 +983,7 @@
 //   {
 //      SimpleString queueName = new SimpleString("testQueueName");
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      Filter filter = EasyMock.createStrictMock(Filter.class);
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
@@ -1013,7 +1013,7 @@
 //      SimpleString queueName2 = new SimpleString("testQueueName2");
 //      SimpleString queueName3 = new SimpleString("testQueueName3");
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      Filter filter = EasyMock.createStrictMock(Filter.class);
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      Queue queue2 = EasyMock.createStrictMock(Queue.class);
@@ -1054,7 +1054,7 @@
 //   {
 //      SimpleString queueName = new SimpleString("testQueueName");
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      Filter filter = EasyMock.createStrictMock(Filter.class);
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
@@ -1093,7 +1093,7 @@
 //   {
 //      SimpleString queueName = new SimpleString("testQueueName");
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      Filter filter = EasyMock.createStrictMock(Filter.class);
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
@@ -1127,7 +1127,7 @@
 //      SimpleString queueName2 = new SimpleString("testQueueName2");
 //      SimpleString queueName3 = new SimpleString("testQueueName3");
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      Filter filter = EasyMock.createStrictMock(Filter.class);
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      Queue queue2 = EasyMock.createStrictMock(Queue.class);
@@ -1178,7 +1178,7 @@
 //   {
 //      SimpleString queueName = new SimpleString("testQueueName");
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      Filter filter = EasyMock.createStrictMock(Filter.class);
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
@@ -1210,7 +1210,7 @@
 //      SimpleString queueName2 = new SimpleString("testQueueName2");
 //      SimpleString queueName3 = new SimpleString("testQueueName3");
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      Filter filter = EasyMock.createStrictMock(Filter.class);
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      Queue queue2 = EasyMock.createStrictMock(Queue.class);
@@ -1257,7 +1257,7 @@
 //   {
 //      SimpleString queueName = new SimpleString("testQueueName");
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
@@ -1292,7 +1292,7 @@
 //   {
 //      ServerMessage message = EasyMock.createStrictMock(ServerMessage.class);
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //
@@ -1325,7 +1325,7 @@
 //   {
 //      ServerMessage message = EasyMock.createStrictMock(ServerMessage.class);
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //
@@ -1354,7 +1354,7 @@
 //      MessageReference messageReference = EasyMock.createStrictMock(MessageReference.class);
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //
@@ -1397,7 +1397,7 @@
 //
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //
@@ -1445,7 +1445,7 @@
 //      MessageReference messageReference = EasyMock.createStrictMock(MessageReference.class);
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //
@@ -1486,7 +1486,7 @@
 //      MessageReference messageReference = EasyMock.createStrictMock(MessageReference.class);
 //      Queue queue = EasyMock.createStrictMock(Queue.class);
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //
@@ -1530,7 +1530,7 @@
 //      Queue queue2 = EasyMock.createStrictMock(Queue.class);
 //      Queue queue3 = EasyMock.createStrictMock(Queue.class);
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //
@@ -1588,7 +1588,7 @@
 //      Queue queue2 = EasyMock.createStrictMock(Queue.class);
 //      Queue queue3 = EasyMock.createStrictMock(Queue.class);
 //      StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-//      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+//      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
 //      ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
 //      PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 //

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplWildcardManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplWildcardManagerTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/PostOfficeImplWildcardManagerTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -33,7 +33,7 @@
 import org.jboss.messaging.core.postoffice.impl.PostOfficeImpl;
 import org.jboss.messaging.core.server.MessageReference;
 import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.QueueFactory;
+import org.jboss.messaging.core.server.BindableFactory;
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.transaction.ResourceManager;
 import org.jboss.messaging.util.SimpleString;
@@ -63,7 +63,7 @@
       SimpleString address3 = new SimpleString("test.testAddress3");
       Queue queue = EasyMock.createStrictMock(Queue.class);
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
       ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
       PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
       EasyMock.expect(pgm.isGlobalPageMode()).andStubReturn(true);
@@ -122,7 +122,7 @@
       Queue queue = EasyMock.createStrictMock(Queue.class);
       Queue queue2 = EasyMock.createStrictMock(Queue.class);
       StorageManager pm = EasyMock.createStrictMock(StorageManager.class);
-      QueueFactory qf = EasyMock.createStrictMock(QueueFactory.class);
+      BindableFactory qf = EasyMock.createStrictMock(BindableFactory.class);
       ManagementService ms = EasyMock.createNiceMock(ManagementService.class);
       PagingManager pgm = EasyMock.createNiceMock(PagingManager.class);
 

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/SimpleAddressManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/SimpleAddressManagerTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/postoffice/impl/SimpleAddressManagerTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -23,6 +23,7 @@
 
 import org.easymock.EasyMock;
 import org.jboss.messaging.core.postoffice.AddressManager;
+import org.jboss.messaging.core.postoffice.BindingType;
 import org.jboss.messaging.core.postoffice.impl.BindingImpl;
 import org.jboss.messaging.core.postoffice.impl.SimpleAddressManager;
 import org.jboss.messaging.core.server.Queue;
@@ -134,15 +135,15 @@
       EasyMock.expect(q4.getName()).andStubReturn(qName4);
       EasyMock.expect(q5.getName()).andStubReturn(qName5);
       EasyMock.replay(q, q2, q3, q4, q5);
-      BindingImpl b1 = new BindingImpl(address, q, true);
+      BindingImpl b1 = new BindingImpl(BindingType.QUEUE, address, q, true);
       sam.addBinding(b1);
-      BindingImpl b2 = new BindingImpl(address2, q2, true);
+      BindingImpl b2 = new BindingImpl(BindingType.QUEUE, address2, q2, true);
       sam.addBinding(b2);
-      BindingImpl b3 = new BindingImpl(address3, q3, true);
+      BindingImpl b3 = new BindingImpl(BindingType.QUEUE, address3, q3, true);
       sam.addBinding(b3);
-      BindingImpl b4 = new BindingImpl(address4, q4, true);
+      BindingImpl b4 = new BindingImpl(BindingType.QUEUE, address4, q4, true);
       sam.addBinding(b4);
-      BindingImpl b5 = new BindingImpl(address5, q5, true);
+      BindingImpl b5 = new BindingImpl(BindingType.QUEUE, address5, q5, true);
       sam.addBinding(b5);
       assertEquals(sam.getBinding(qName), b1);
       assertEquals(sam.getBinding(qName2), b2);
@@ -176,15 +177,15 @@
       EasyMock.expect(q4.getName()).andStubReturn(qName4);
       EasyMock.expect(q5.getName()).andStubReturn(qName5);
       EasyMock.replay(q, q2, q3, q4, q5);
-      BindingImpl b1 = new BindingImpl(address, q, true);
+      BindingImpl b1 = new BindingImpl(BindingType.QUEUE, address, q, true);
       sam.addBinding(b1);
-      BindingImpl b2 = new BindingImpl(address2, q2, true);
+      BindingImpl b2 = new BindingImpl(BindingType.QUEUE, address2, q2, true);
       sam.addBinding(b2);
-      BindingImpl b3 = new BindingImpl(address3, q3, true);
+      BindingImpl b3 = new BindingImpl(BindingType.QUEUE, address3, q3, true);
       sam.addBinding(b3);
-      BindingImpl b4 = new BindingImpl(address4, q4, true);
+      BindingImpl b4 = new BindingImpl(BindingType.QUEUE, address4, q4, true);
       sam.addBinding(b4);
-      BindingImpl b5 = new BindingImpl(address5, q5, true);
+      BindingImpl b5 = new BindingImpl(BindingType.QUEUE, address5, q5, true);
       sam.addBinding(b5);
       assertEquals(sam.getBinding(qName), b1);
       assertEquals(sam.getBinding(qName2), b2);
@@ -210,7 +211,7 @@
       Queue q = EasyMock.createStrictMock(Queue.class);
       EasyMock.expect(q.getName()).andStubReturn(qName);
       EasyMock.replay(q);
-      BindingImpl b1 = new BindingImpl(address, q, true);
+      BindingImpl b1 = new BindingImpl(BindingType.QUEUE, address, q, true);
       sam.addBinding(b1);
       try
       {
@@ -231,7 +232,7 @@
       SimpleString qName = new SimpleString("q1");
       Queue q = EasyMock.createStrictMock(Queue.class);
       EasyMock.expect(q.getName()).andStubReturn(qName);
-      BindingImpl b1 = new BindingImpl(address, q, true);
+      BindingImpl b1 = new BindingImpl(BindingType.QUEUE, address, q, true);
       EasyMock.replay(q);
       sam.addMapping(address, b1);
       assertNotNull(sam.getBindings(address));
@@ -246,7 +247,7 @@
       SimpleString qName = new SimpleString("q1");
       Queue q = EasyMock.createStrictMock(Queue.class);
       EasyMock.expect(q.getName()).andStubReturn(qName);
-      BindingImpl b1 = new BindingImpl(address, q, true);
+      BindingImpl b1 = new BindingImpl(BindingType.QUEUE, address, q, true);
       EasyMock.replay(q);
       sam.addMapping(address, b1);
       assertNotNull(sam.getBindings(address));
@@ -275,11 +276,11 @@
       EasyMock.expect(q4.getName()).andStubReturn(qName4);
       Queue q5 = EasyMock.createStrictMock(Queue.class);
       EasyMock.expect(q5.getName()).andStubReturn(qName5);
-      BindingImpl b1 = new BindingImpl(address, q, true);
-      BindingImpl b2 = new BindingImpl(address, q2, true);
-      BindingImpl b3 = new BindingImpl(address, q3, true);
-      BindingImpl b4 = new BindingImpl(address, q4, true);
-      BindingImpl b5 = new BindingImpl(address, q5, true);
+      BindingImpl b1 = new BindingImpl(BindingType.QUEUE, address, q, true);
+      BindingImpl b2 = new BindingImpl(BindingType.QUEUE, address, q2, true);
+      BindingImpl b3 = new BindingImpl(BindingType.QUEUE, address, q3, true);
+      BindingImpl b4 = new BindingImpl(BindingType.QUEUE, address, q4, true);
+      BindingImpl b5 = new BindingImpl(BindingType.QUEUE, address, q5, true);
       EasyMock.replay(q, q2, q3, q4, q5);
       sam.addMapping(address, b1);
       sam.addMapping(address, b2);
@@ -314,11 +315,11 @@
       EasyMock.expect(q4.getName()).andStubReturn(qName4);
       Queue q5 = EasyMock.createStrictMock(Queue.class);
       EasyMock.expect(q5.getName()).andStubReturn(qName5);
-      BindingImpl b1 = new BindingImpl(address, q, true);
-      BindingImpl b2 = new BindingImpl(address, q2, true);
-      BindingImpl b3 = new BindingImpl(address, q3, true);
-      BindingImpl b4 = new BindingImpl(address, q4, true);
-      BindingImpl b5 = new BindingImpl(address, q5, true);
+      BindingImpl b1 = new BindingImpl(BindingType.QUEUE, address, q, true);
+      BindingImpl b2 = new BindingImpl(BindingType.QUEUE, address, q2, true);
+      BindingImpl b3 = new BindingImpl(BindingType.QUEUE, address, q3, true);
+      BindingImpl b4 = new BindingImpl(BindingType.QUEUE, address, q4, true);
+      BindingImpl b5 = new BindingImpl(BindingType.QUEUE, address, q5, true);
       EasyMock.replay(q, q2, q3, q4, q5);
       sam.addMapping(address, b1);
       sam.addMapping(address, b2);
@@ -364,11 +365,11 @@
       EasyMock.expect(q4.getName()).andStubReturn(qName4);
       Queue q5 = EasyMock.createStrictMock(Queue.class);
       EasyMock.expect(q5.getName()).andStubReturn(qName5);
-      BindingImpl b1 = new BindingImpl(address, q, true);
-      BindingImpl b2 = new BindingImpl(address2, q2, true);
-      BindingImpl b3 = new BindingImpl(address3, q3, true);
-      BindingImpl b4 = new BindingImpl(address4, q4, true);
-      BindingImpl b5 = new BindingImpl(address5, q5, true);
+      BindingImpl b1 = new BindingImpl(BindingType.QUEUE, address, q, true);
+      BindingImpl b2 = new BindingImpl(BindingType.QUEUE, address2, q2, true);
+      BindingImpl b3 = new BindingImpl(BindingType.QUEUE, address3, q3, true);
+      BindingImpl b4 = new BindingImpl(BindingType.QUEUE, address4, q4, true);
+      BindingImpl b5 = new BindingImpl(BindingType.QUEUE, address5, q5, true);
       EasyMock.replay(q, q2, q3, q4, q5);
       sam.addMapping(address, b1);
       sam.addMapping(address2, b2);
@@ -415,11 +416,11 @@
       EasyMock.expect(q4.getName()).andStubReturn(qName4);
       Queue q5 = EasyMock.createStrictMock(Queue.class);
       EasyMock.expect(q5.getName()).andStubReturn(qName5);
-      BindingImpl b1 = new BindingImpl(address, q, true);
-      BindingImpl b2 = new BindingImpl(address2, q2, true);
-      BindingImpl b3 = new BindingImpl(address3, q3, true);
-      BindingImpl b4 = new BindingImpl(address4, q4, true);
-      BindingImpl b5 = new BindingImpl(address5, q5, true);
+      BindingImpl b1 = new BindingImpl(BindingType.QUEUE, address, q, true);
+      BindingImpl b2 = new BindingImpl(BindingType.QUEUE, address2, q2, true);
+      BindingImpl b3 = new BindingImpl(BindingType.QUEUE, address3, q3, true);
+      BindingImpl b4 = new BindingImpl(BindingType.QUEUE, address4, q4, true);
+      BindingImpl b5 = new BindingImpl(BindingType.QUEUE, address5, q5, true);
       EasyMock.replay(q, q2, q3, q4, q5);
       sam.addMapping(address, b1);
       sam.addMapping(address2, b2);
@@ -497,16 +498,16 @@
       EasyMock.expect(q9.getName()).andStubReturn(qName9);
       Queue q10 = EasyMock.createStrictMock(Queue.class);
       EasyMock.expect(q10.getName()).andStubReturn(qName10);
-      BindingImpl b1 = new BindingImpl(address, q, true);
-      BindingImpl b2 = new BindingImpl(address2, q2, true);
-      BindingImpl b3 = new BindingImpl(address3, q3, true);
-      BindingImpl b4 = new BindingImpl(address4, q4, true);
-      BindingImpl b5 = new BindingImpl(address5, q5, true);
-      BindingImpl b6 = new BindingImpl(address6, q6, true);
-      BindingImpl b7 = new BindingImpl(address7, q7, true);
-      BindingImpl b8 = new BindingImpl(address8, q8, true);
-      BindingImpl b9 = new BindingImpl(address9, q9, true);
-      BindingImpl b10 = new BindingImpl(address10, q10, true);
+      BindingImpl b1 = new BindingImpl(BindingType.QUEUE, address, q, true);
+      BindingImpl b2 = new BindingImpl(BindingType.QUEUE, address2, q2, true);
+      BindingImpl b3 = new BindingImpl(BindingType.QUEUE, address3, q3, true);
+      BindingImpl b4 = new BindingImpl(BindingType.QUEUE, address4, q4, true);
+      BindingImpl b5 = new BindingImpl(BindingType.QUEUE, address5, q5, true);
+      BindingImpl b6 = new BindingImpl(BindingType.QUEUE, address6, q6, true);
+      BindingImpl b7 = new BindingImpl(BindingType.QUEUE, address7, q7, true);
+      BindingImpl b8 = new BindingImpl(BindingType.QUEUE, address8, q8, true);
+      BindingImpl b9 = new BindingImpl(BindingType.QUEUE, address9, q9, true);
+      BindingImpl b10 = new BindingImpl(BindingType.QUEUE, address10, q10, true);
       EasyMock.replay(q);
       sam.addMapping(address, b1);
       sam.addMapping(address2, b2);
@@ -577,16 +578,16 @@
       EasyMock.expect(q9.getName()).andStubReturn(qName9);
       Queue q10 = EasyMock.createStrictMock(Queue.class);
       EasyMock.expect(q10.getName()).andStubReturn(qName10);
-      BindingImpl b1 = new BindingImpl(address, q, true);
-      BindingImpl b2 = new BindingImpl(address2, q2, true);
-      BindingImpl b3 = new BindingImpl(address3, q3, true);
-      BindingImpl b4 = new BindingImpl(address4, q4, true);
-      BindingImpl b5 = new BindingImpl(address5, q5, true);
-      BindingImpl b6 = new BindingImpl(address6, q6, true);
-      BindingImpl b7 = new BindingImpl(address7, q7, true);
-      BindingImpl b8 = new BindingImpl(address8, q8, true);
-      BindingImpl b9 = new BindingImpl(address9, q9, true);
-      BindingImpl b10 = new BindingImpl(address10, q10, true);
+      BindingImpl b1 = new BindingImpl(BindingType.QUEUE, address, q, true);
+      BindingImpl b2 = new BindingImpl(BindingType.QUEUE, address2, q2, true);
+      BindingImpl b3 = new BindingImpl(BindingType.QUEUE, address3, q3, true);
+      BindingImpl b4 = new BindingImpl(BindingType.QUEUE, address4, q4, true);
+      BindingImpl b5 = new BindingImpl(BindingType.QUEUE, address5, q5, true);
+      BindingImpl b6 = new BindingImpl(BindingType.QUEUE, address6, q6, true);
+      BindingImpl b7 = new BindingImpl(BindingType.QUEUE, address7, q7, true);
+      BindingImpl b8 = new BindingImpl(BindingType.QUEUE, address8, q8, true);
+      BindingImpl b9 = new BindingImpl(BindingType.QUEUE, address9, q9, true);
+      BindingImpl b10 = new BindingImpl(BindingType.QUEUE, address10, q10, true);
       EasyMock.replay(q, q2, q3, q4, q5);
       sam.addMapping(address, b1);
       sam.addMapping(address2, b2);

Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/BindingsImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/BindingsImplTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/BindingsImplTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -1,1687 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-
-package org.jboss.messaging.tests.unit.core.server.impl;
-
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.Executor;
-
-import org.jboss.messaging.core.filter.Filter;
-import org.jboss.messaging.core.persistence.StorageManager;
-import org.jboss.messaging.core.postoffice.Binding;
-import org.jboss.messaging.core.postoffice.Bindings;
-import org.jboss.messaging.core.postoffice.PostOffice;
-import org.jboss.messaging.core.postoffice.impl.BindingImpl;
-import org.jboss.messaging.core.postoffice.impl.BindingsImpl;
-import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
-import org.jboss.messaging.core.server.Consumer;
-import org.jboss.messaging.core.server.Distributor;
-import org.jboss.messaging.core.server.HandleStatus;
-import org.jboss.messaging.core.server.MessageReference;
-import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.ServerMessage;
-import org.jboss.messaging.core.settings.HierarchicalRepository;
-import org.jboss.messaging.core.settings.impl.QueueSettings;
-import org.jboss.messaging.core.transaction.Transaction;
-import org.jboss.messaging.tests.util.UnitTestCase;
-import org.jboss.messaging.util.SimpleString;
-import org.jboss.messaging.util.TypedProperties;
-
-/**
- * A BindingsImplTest
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * 
- * Created 18 Dec 2008 11:55:13
- *
- *
- */
-public class BindingsImplTest extends UnitTestCase
-{
-   public void testGetBindings()
-   {
-      Bindings bindings = new BindingsImpl();
-      
-      Queue queue1 = new MyQueue();
-      Queue queue2 = new MyQueue();
-      Queue queue3 = new MyQueue();
-      
-      SimpleString address1 = new SimpleString("ushgduysd");
-      SimpleString address2 = new SimpleString("asijisad");
-      SimpleString address3 = new SimpleString("iqjdiqwjd");
-      
-      Binding binding1 = new BindingImpl(address1, queue1, false);
-      Binding binding2 = new BindingImpl(address2, queue2, false);
-      Binding binding3 = new BindingImpl(address3, queue3, false);
-      
-      bindings.addBinding(binding1);
-      bindings.addBinding(binding2);
-      bindings.addBinding(binding3);
-      
-      List<Binding> theBindings = bindings.getBindings();
-      
-      assertNotNull(theBindings);
-      assertEquals(3, theBindings.size());
-      assertTrue(theBindings.contains(binding1));
-      assertTrue(theBindings.contains(binding2));
-      assertTrue(theBindings.contains(binding3));           
-   }
-   
-   public void testAddRemoveBindings()
-   {
-      Bindings bindings = new BindingsImpl();
-      
-      Queue queue1 = new MyQueue();
-      Queue queue2 = new MyQueue();
-      Queue queue3 = new MyQueue();
-      
-      SimpleString address1 = new SimpleString("ushgduysd");
-      SimpleString address2 = new SimpleString("asijisad");
-      SimpleString address3 = new SimpleString("iqjdiqwjd");
-      
-      Binding binding1 = new BindingImpl(address1, queue1, false);
-      Binding binding2 = new BindingImpl(address2, queue2, false);
-      Binding binding3 = new BindingImpl(address3, queue3, false);
-      
-      bindings.addBinding(binding1);
-
-      List<Binding> theBindings = bindings.getBindings();
-      
-      assertNotNull(theBindings);
-      assertEquals(1, theBindings.size());
-      assertTrue(theBindings.contains(binding1));
-      
-      bindings.addBinding(binding2);
-      
-      theBindings = bindings.getBindings();
-      
-      assertNotNull(theBindings);
-      assertEquals(2, theBindings.size());
-      assertTrue(theBindings.contains(binding1));
-      assertTrue(theBindings.contains(binding2));
-      
-      bindings.addBinding(binding3);
-
-      theBindings = bindings.getBindings();
-      
-      assertNotNull(theBindings);
-      assertEquals(3, theBindings.size());
-      assertTrue(theBindings.contains(binding1));
-      assertTrue(theBindings.contains(binding2));
-      assertTrue(theBindings.contains(binding3));
-      
-      bindings.removeBinding(binding1);
-      
-      theBindings = bindings.getBindings();
-      
-      assertNotNull(theBindings);
-      assertEquals(2, theBindings.size());
-      assertTrue(theBindings.contains(binding2));
-      assertTrue(theBindings.contains(binding3));
-      
-      bindings.removeBinding(binding2);
-      
-      theBindings = bindings.getBindings();
-      
-      assertNotNull(theBindings);
-      assertEquals(1, theBindings.size());      
-      assertTrue(theBindings.contains(binding3));
-      
-      bindings.removeBinding(binding3);
-      
-      theBindings = bindings.getBindings();
-      
-      assertNotNull(theBindings);
-      assertEquals(0, theBindings.size());      
-             
-   }
-   
-   public void testRouteNoBindings()
-   {
-      Bindings bindings = new BindingsImpl();
-      
-      ServerMessage msg = new MyServerMessage();
-      
-      List<MessageReference> refs = bindings.route(msg);
-      
-      assertNotNull(refs);
-      
-      assertEquals(0, refs.size());
-      
-      Queue queue1 = new MyQueue();
-           
-      SimpleString address1 = new SimpleString("ushgduysd");
-           
-      Binding binding1 = new BindingImpl(address1, queue1, false);
-      
-      bindings.addBinding(binding1);
-      
-      bindings.removeBinding(binding1);
-
-      refs = bindings.route(msg);
-      
-      assertNotNull(refs);
-      
-      assertEquals(0, refs.size());
-      
-      Binding binding2 = new BindingImpl(address1, queue1, true);
-      
-      bindings.addBinding(binding2);
-      
-      bindings.removeBinding(binding2);
-
-      refs = bindings.route(msg);
-      
-      assertNotNull(refs);
-      
-      assertEquals(0, refs.size());      
-   }
-   
-   public void testRouteNoExclusive()
-   {
-      Bindings bindings = new BindingsImpl();
-      
-      Queue queue1 = new MyQueue();
-      Queue queue2 = new MyQueue();
-      Queue queue3 = new MyQueue();
-      
-      SimpleString address1 = new SimpleString("ushgduysd");
-      SimpleString address2 = new SimpleString("asijisad");
-      SimpleString address3 = new SimpleString("iqjdiqwjd");
-      
-      Binding binding1 = new BindingImpl(address1, queue1, false);
-      Binding binding2 = new BindingImpl(address2, queue2, false);
-      Binding binding3 = new BindingImpl(address3, queue3, false);
-      
-      bindings.addBinding(binding1);
-      bindings.addBinding(binding2);
-      bindings.addBinding(binding3);
-      
-      ServerMessage msg = new MyServerMessage();
-      
-      List<MessageReference> refs = bindings.route(msg);
-      
-      assertNotNull(refs);
-      assertEquals(3, refs.size());
-      
-      Set<Queue> queues = new HashSet<Queue>();
-      for (MessageReference ref: refs)
-      {
-         queues.add(ref.getQueue());
-      }
-      
-      assertEquals(3, queues.size());
-      assertTrue(queues.contains(queue1));
-      assertTrue(queues.contains(queue2));
-      assertTrue(queues.contains(queue3));           
-   }
-   
-   public void testRouteAllExclusive()
-   {
-      Bindings bindings = new BindingsImpl();
-      
-      Queue queue1 = new MyQueue();
-      Queue queue2 = new MyQueue();
-      Queue queue3 = new MyQueue();
-      
-      SimpleString address1 = new SimpleString("ushgduysd");
-      SimpleString address2 = new SimpleString("asijisad");
-      SimpleString address3 = new SimpleString("iqjdiqwjd");
-      
-      Binding binding1 = new BindingImpl(address1, queue1, true);
-      Binding binding2 = new BindingImpl(address2, queue2, true);
-      Binding binding3 = new BindingImpl(address3, queue3, true);
-      
-      bindings.addBinding(binding1);
-      bindings.addBinding(binding2);
-      bindings.addBinding(binding3);
-      
-      ServerMessage msg = new MyServerMessage();
-      
-      List<MessageReference> refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);
-      
-      bindings.removeBinding(binding3);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      bindings.removeBinding(binding1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      bindings.addBinding(binding1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      bindings.removeBinding(binding1);
-      
-      bindings.removeBinding(binding2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(0, refs.size()); 
-      
-      bindings.addBinding(binding1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);            
-   }
-   
-   
-   public void testRouteOneExclusive()
-   {
-      Bindings bindings = new BindingsImpl();
-      
-      Queue queue1 = new MyQueue();
-      Queue queue2 = new MyQueue();
-      Queue queue3 = new MyQueue();
-      
-      SimpleString address1 = new SimpleString("ushgduysd");
-      SimpleString address2 = new SimpleString("asijisad");
-      SimpleString address3 = new SimpleString("iqjdiqwjd");
-      
-      Binding binding1 = new BindingImpl(address1, queue1, false);
-      Binding binding2 = new BindingImpl(address2, queue2, false);
-      Binding binding3 = new BindingImpl(address3, queue3, true);
-      
-      bindings.addBinding(binding1);
-      bindings.addBinding(binding2);
-      bindings.addBinding(binding3);
-      
-      ServerMessage msg = new MyServerMessage();
-      
-      List<MessageReference> refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);
-      
-      bindings.removeBinding(binding3);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(2, refs.size());   
-      
-      Set<Queue> queues = new HashSet<Queue>();
-      for (MessageReference ref: refs)
-      {
-         queues.add(ref.getQueue());
-      }
-      
-      assertEquals(2, queues.size());
-      assertTrue(queues.contains(queue1));
-      assertTrue(queues.contains(queue2));  
-      
-      bindings.addBinding(binding3);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);           
-   }
-   
-   public void testRouteWithFilterNoExclusive()
-   {
-      Bindings bindings = new BindingsImpl();
-      
-      Filter filter1 = new MyFilter(false);
-      
-      Queue queue1 = new MyQueue(filter1);
-      Queue queue2 = new MyQueue();
-      Queue queue3 = new MyQueue();
-      
-      SimpleString address1 = new SimpleString("ushgduysd");
-      SimpleString address2 = new SimpleString("asijisad");
-      SimpleString address3 = new SimpleString("iqjdiqwjd");
-      
-      Binding binding1 = new BindingImpl(address1, queue1, false);
-      Binding binding2 = new BindingImpl(address2, queue2, false);
-      Binding binding3 = new BindingImpl(address3, queue3, false);
-      
-      bindings.addBinding(binding1);
-      bindings.addBinding(binding2);
-      bindings.addBinding(binding3);
-      
-      ServerMessage msg = new MyServerMessage();
-      
-      List<MessageReference> refs = bindings.route(msg);
-      
-      assertNotNull(refs);
-      assertEquals(2, refs.size());
-      
-      Set<Queue> queues = new HashSet<Queue>();
-      for (MessageReference ref: refs)
-      {
-         queues.add(ref.getQueue());
-      }
-      
-      assertEquals(2, queues.size());
-      assertTrue(queues.contains(queue2));
-      assertTrue(queues.contains(queue3));       
-      
-   }
-   
-   public void testRouteWithFilterExclusive()
-   {
-      Bindings bindings = new BindingsImpl();
-      
-      Filter filter1 = new MyFilter(false);
-      
-      Queue queue1 = new MyQueue(filter1);
-      Queue queue2 = new MyQueue();
-      Queue queue3 = new MyQueue();
-      
-      SimpleString address1 = new SimpleString("ushgduysd");
-      SimpleString address2 = new SimpleString("asijisad");
-      SimpleString address3 = new SimpleString("iqjdiqwjd");
-      
-      Binding binding1 = new BindingImpl(address1, queue1, true);
-      Binding binding2 = new BindingImpl(address2, queue2, true);
-      Binding binding3 = new BindingImpl(address3, queue3, true);
-      
-      bindings.addBinding(binding1);
-      bindings.addBinding(binding2);
-      bindings.addBinding(binding3);
-      
-      ServerMessage msg = new MyServerMessage();
-      
-      List<MessageReference> refs = bindings.route(msg);               
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);               
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);
-      
-      refs = bindings.route(msg);               
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);               
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);
-      
-      refs = bindings.route(msg);               
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);               
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);
-      
-      bindings.removeBinding(binding2);
-      
-      refs = bindings.route(msg);               
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);
-      
-      bindings.removeBinding(binding3);
-      
-      refs = bindings.route(msg);               
-      assertNotNull(refs);
-      assertEquals(0, refs.size());         
-      
-      
-   }
-   
-   public void testRouteWithFilterExclusiveNoneMatch()
-   {
-      Bindings bindings = new BindingsImpl();
-      
-      Filter filter1 = new MyFilter(false);
-      
-      Queue queue1 = new MyQueue(filter1);
-      Queue queue2 = new MyQueue(filter1);
-      Queue queue3 = new MyQueue(filter1);
-      
-      SimpleString address1 = new SimpleString("ushgduysd");
-      SimpleString address2 = new SimpleString("asijisad");
-      SimpleString address3 = new SimpleString("iqjdiqwjd");
-      
-      Binding binding1 = new BindingImpl(address1, queue1, true);
-      Binding binding2 = new BindingImpl(address2, queue2, true);
-      Binding binding3 = new BindingImpl(address3, queue3, true);
-      
-      bindings.addBinding(binding1);
-      bindings.addBinding(binding2);
-      bindings.addBinding(binding3);
-      
-      ServerMessage msg = new MyServerMessage();
-      
-      List<MessageReference> refs = bindings.route(msg);               
-      assertNotNull(refs);
-      assertEquals(0, refs.size());   
-     
-   }
-   
-   public void testWeightedRoute()
-   {
-      Bindings bindings = new BindingsImpl();
-      
-      Queue queue1 = new MyQueue();
-      Queue queue2 = new MyQueue();
-      Queue queue3 = new MyQueue();
-      
-      SimpleString address1 = new SimpleString("ushgduysd");
-      SimpleString address2 = new SimpleString("asijisad");
-      SimpleString address3 = new SimpleString("iqjdiqwjd");
-      
-      Binding binding1 = new BindingImpl(address1, queue1, true);      
-      Binding binding2 = new BindingImpl(address2, queue2, true);
-      binding2.setWeight(2);
-      Binding binding3 = new BindingImpl(address3, queue3, true);
-      
-      bindings.addBinding(binding1);
-      bindings.addBinding(binding2);
-      bindings.addBinding(binding3);
-      
-      ServerMessage msg = new MyServerMessage();
-      
-      List<MessageReference> refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);
-      
-      bindings.removeBinding(binding3);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      bindings.removeBinding(binding1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      bindings.addBinding(binding1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      bindings.removeBinding(binding1);
-      
-      bindings.removeBinding(binding2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(0, refs.size()); 
-      
-      bindings.addBinding(binding1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);            
-   }
-   
-   public void testWeightedRoute2()
-   {
-      Bindings bindings = new BindingsImpl();
-      
-      Queue queue1 = new MyQueue();
-      Queue queue2 = new MyQueue();
-      Queue queue3 = new MyQueue();
-      
-      SimpleString address1 = new SimpleString("ushgduysd");
-      SimpleString address2 = new SimpleString("asijisad");
-      SimpleString address3 = new SimpleString("iqjdiqwjd");
-      
-      Binding binding1 = new BindingImpl(address1, queue1, true);      
-      Binding binding2 = new BindingImpl(address2, queue2, true);
-      binding2.setWeight(0);
-      Binding binding3 = new BindingImpl(address3, queue3, true);
-      
-      bindings.addBinding(binding1);
-      bindings.addBinding(binding2);
-      bindings.addBinding(binding3);
-      
-      ServerMessage msg = new MyServerMessage();
-      
-      List<MessageReference> refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue3);
-      
-      bindings.removeBinding(binding3);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      bindings.removeBinding(binding1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(0, refs.size());         
-      
-      bindings.addBinding(binding1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      bindings.removeBinding(binding1);
-      
-      bindings.removeBinding(binding2);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(0, refs.size()); 
-      
-      bindings.addBinding(binding1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);
-      
-      refs = bindings.route(msg);      
-      assertNotNull(refs);
-      assertEquals(1, refs.size());   
-      assertTrue(refs.get(0).getQueue() == queue1);            
-   }
-   
-   class MyFilter implements Filter
-   {
-      private boolean match;
-      
-      MyFilter(final boolean match)
-      {
-         this.match = match;
-      }
-
-      public SimpleString getFilterString()
-      {
-         return null;
-      }
-
-      public boolean match(ServerMessage message)
-      {
-         return match;
-      }
-      
-   }
-         
-   class MyMessageReference implements MessageReference
-   {
-      private Queue queue;
-      
-      MyMessageReference(final Queue queue)
-      {
-         this.queue = queue;
-      }
-      
-      public int getMemoryEstimate()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      
-      public boolean cancel(StorageManager storageManager,
-                            PostOffice postOffice,
-                            HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
-      {
-         // TODO Auto-generated method stub
-         return false;
-      }
-
-      public MessageReference copy(Queue queue)
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-
-      public void expire(StorageManager storageManager,
-                         PostOffice postOffice,
-                         HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void expire(Transaction tx,
-                         StorageManager storageManager,
-                         PostOffice postOffice,
-                         HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public int getDeliveryCount()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public ServerMessage getMessage()
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-
-      public Queue getQueue()
-      {         
-         return queue;
-      }
-
-      public long getScheduledDeliveryTime()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public void incrementDeliveryCount()
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void move(SimpleString toAddress, StorageManager persistenceManager, PostOffice postOffice) throws Exception
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void move(SimpleString toAddress, Transaction tx, StorageManager persistenceManager, boolean expiry) throws Exception
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void sendToDeadLetterAddress(StorageManager storageManager,
-                                          PostOffice postOffice,
-                                          HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void setDeliveryCount(int deliveryCount)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void setScheduledDeliveryTime(long scheduledDeliveryTime)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-      
-   }
-   
-   class MyServerMessage implements ServerMessage
-   {
-
-      public ServerMessage copy()
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-
-      public MessageReference createReference(Queue queue)
-      {
-         return new MyMessageReference(queue);
-      }
-
-      public int decrementDurableRefCount()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public int decrementRefCount()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public int getDurableRefCount()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public int getMemoryEstimate()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public int incrementDurableRefCount()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public void setMessageID(long id)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public boolean containsProperty(SimpleString key)
-      {
-         // TODO Auto-generated method stub
-         return false;
-      }
-
-      public void decode(MessagingBuffer buffer)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void decodeBody(MessagingBuffer buffer)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void decodeProperties(MessagingBuffer buffer)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void encode(MessagingBuffer buffer)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void encodeBody(MessagingBuffer buffer, long start, int size)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void encodeBody(MessagingBuffer buffer)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void encodeProperties(MessagingBuffer buffer)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public MessagingBuffer getBody()
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-
-      public int getBodySize()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public SimpleString getDestination()
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-
-      public int getEncodeSize()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public long getExpiration()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public long getMessageID()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public byte getPriority()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public int getPropertiesEncodeSize()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public Object getProperty(SimpleString key)
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-
-      public Set<SimpleString> getPropertyNames()
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-
-      public long getTimestamp()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public byte getType()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public boolean isDurable()
-      {
-         // TODO Auto-generated method stub
-         return false;
-      }
-
-      public boolean isExpired()
-      {
-         // TODO Auto-generated method stub
-         return false;
-      }
-
-      public void putBooleanProperty(SimpleString key, boolean value)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void putByteProperty(SimpleString key, byte value)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void putBytesProperty(SimpleString key, byte[] value)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void putDoubleProperty(SimpleString key, double value)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void putFloatProperty(SimpleString key, float value)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void putIntProperty(SimpleString key, int value)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void putLongProperty(SimpleString key, long value)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void putShortProperty(SimpleString key, short value)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void putStringProperty(SimpleString key, SimpleString value)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void putTypedProperties(TypedProperties properties)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public Object removeProperty(SimpleString key)
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-
-      public void setBody(MessagingBuffer body)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void setDestination(SimpleString destination)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void setDurable(boolean durable)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void setExpiration(long expiration)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void setPriority(byte priority)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void setTimestamp(long timestamp)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-      
-   }
-   
-   
-   class MyBinding implements Binding
-   {
-      private final SimpleString address;
-      
-      private final Queue queue;
-      
-      private int weight;
-      
-      private final boolean exclusive;
-            
-      public SimpleString getAddress()
-      {
-         return address;
-      }
-
-      public Queue getQueue()
-      {
-         return queue;
-      }
-
-      public int getWeight()
-      {
-         return weight;
-      }
-
-      public boolean isExclusive()
-      {
-         return exclusive;
-      }
-
-      public void setWeight(int weight)
-      {
-         this.weight = weight;
-      }
-
-      public MyBinding(final SimpleString address, final Queue queue, final int weight, final boolean exclusive)
-      {
-         this.address = address;
-         this.queue = queue;
-         this.weight = weight;
-         this.exclusive = exclusive;
-      }      
-   }
-   
-   class MyQueue implements Queue
-   {
-      private Filter filter;
-      
-      MyQueue(Filter filter)
-      {
-         this.filter = filter;
-      }
-      
-      MyQueue()
-      {         
-      }
-      
-      public void referenceHandled()
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-
-      public boolean activate()
-      {
-         // TODO Auto-generated method stub
-         return false;
-      }
-
-      public void activateNow(Executor executor)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void addConsumer(Consumer consumer)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public HandleStatus addFirst(MessageReference ref)
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-
-      public void addListFirst(LinkedList<MessageReference> list)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public boolean changeMessagePriority(long messageID,
-                                           byte newPriority,
-                                           StorageManager storageManager,
-                                           PostOffice postOffice,
-                                           HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
-      {
-         // TODO Auto-generated method stub
-         return false;
-      }
-
-      public boolean consumerFailedOver()
-      {
-         // TODO Auto-generated method stub
-         return false;
-      }
-
-      public int deleteAllReferences(StorageManager storageManager) throws Exception
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public int deleteMatchingReferences(Filter filter, StorageManager storageManager) throws Exception
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public boolean deleteReference(long messageID, StorageManager storageManager) throws Exception
-      {
-         // TODO Auto-generated method stub
-         return false;
-      }
-
-      public void deliverAsync(Executor executor)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void deliverNow()
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public boolean expireMessage(long messageID,
-                                   StorageManager storageManager,
-                                   PostOffice postOffice,
-                                   HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
-      {
-         // TODO Auto-generated method stub
-         return false;
-      }
-
-      public int expireMessages(Filter filter,
-                                StorageManager storageManager,
-                                PostOffice postOffice,
-                                HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public void expireMessages(StorageManager storageManager,
-                                 PostOffice postOffice,
-                                 HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public int getConsumerCount()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public int getDeliveringCount()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public Distributor getDistributionPolicy()
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-
-      public Filter getFilter()
-      {
-         return filter;
-      }
-
-      public int getMessageCount()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public int getMessagesAdded()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public SimpleString getName()
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-
-      public long getPersistenceID()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public MessageReference getReference(long id)
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-
-      public int getScheduledCount()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public List<MessageReference> getScheduledMessages()
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-
-      public boolean isBackup()
-      {
-         // TODO Auto-generated method stub
-         return false;
-      }
-
-      public boolean isClustered()
-      {
-         // TODO Auto-generated method stub
-         return false;
-      }
-
-      public boolean isDurable()
-      {
-         // TODO Auto-generated method stub
-         return false;
-      }
-
-      public boolean isTemporary()
-      {
-         // TODO Auto-generated method stub
-         return false;
-      }
-
-      public List<MessageReference> list(Filter filter)
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-
-      public boolean moveMessage(long messageID,
-                                 SimpleString toAddress,
-                                 StorageManager storageManager,
-                                 PostOffice postOffice) throws Exception
-      {
-         // TODO Auto-generated method stub
-         return false;
-      }
-
-      public int moveMessages(Filter filter,
-                              SimpleString toAddress,
-                              StorageManager storageManager,
-                              PostOffice postOffice) throws Exception
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      public void referenceAcknowledged(MessageReference ref) throws Exception
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void referenceCancelled()
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public boolean removeConsumer(Consumer consumer) throws Exception
-      {
-         // TODO Auto-generated method stub
-         return false;
-      }
-
-      public MessageReference removeFirst()
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-
-      public MessageReference removeReferenceWithID(long id) throws Exception
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-
-      public void rescheduleDelivery(long id, long scheduledDeliveryTime)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public boolean sendMessageToDeadLetterAddress(long messageID,
-                                                    StorageManager storageManager,
-                                                    PostOffice postOffice,
-                                                    HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception
-      {
-         // TODO Auto-generated method stub
-         return false;
-      }
-
-      public void setBackup()
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void setDistributionPolicy(Distributor policy)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public void setPersistenceID(long id)
-      {
-         // TODO Auto-generated method stub
-         
-      }
-
-      public HandleStatus add(MessageReference ref)
-      {
-         // TODO Auto-generated method stub
-         return null;
-      }
-      
-      public int getMemoryEstimate()
-      {
-         // TODO Auto-generated method stub
-         return 0;
-      }
-
-      
-   }
-}

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessagingServerImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessagingServerImplTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/MessagingServerImplTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -178,7 +178,7 @@
 //      EasyMock.expect(rs.getDispatcher()).andReturn(pd);
 //      EasyMock.expect(sm.isStarted()).andStubReturn(true);
 //      EasyMock.expect(rs.isStarted()).andStubReturn(true);
-//      sm.loadBindings(EasyMock.isA(QueueFactoryImpl.class), EasyMock.isA(ArrayList.class), EasyMock.isA(ArrayList.class));
+//      sm.loadBindings(EasyMock.isA(BindableFactoryImpl.class), EasyMock.isA(ArrayList.class), EasyMock.isA(ArrayList.class));
 //      sm.loadMessages(EasyMock.isA(PostOfficeImpl.class), EasyMock.isA(Map.class));
 //            
 //      pd.register(EasyMock.isA(MessagingServerPacketHandler.class));
@@ -283,7 +283,7 @@
 //      EasyMock.expect(rs.getDispatcher()).andReturn(pd);
 //      EasyMock.expect(sm.isStarted()).andStubReturn(true);
 //      EasyMock.expect(rs.isStarted()).andStubReturn(true);
-//      sm.loadBindings(EasyMock.isA(QueueFactoryImpl.class), EasyMock.isA(ArrayList.class), EasyMock.isA(ArrayList.class));
+//      sm.loadBindings(EasyMock.isA(BindableFactoryImpl.class), EasyMock.isA(ArrayList.class), EasyMock.isA(ArrayList.class));
 //      sm.loadMessages(EasyMock.isA(PostOfficeImpl.class), EasyMock.isA(Map.class));
 //            
 //      pd.register(EasyMock.isA(MessagingServerPacketHandler.class));
@@ -369,7 +369,7 @@
 //      PacketDispatcher pd = EasyMock.createMock(PacketDispatcher.class);
 //      EasyMock.expect(rs.getDispatcher()).andReturn(pd);
 //      
-//      sm.loadBindings(EasyMock.isA(QueueFactoryImpl.class), EasyMock.isA(ArrayList.class), EasyMock.isA(ArrayList.class));
+//      sm.loadBindings(EasyMock.isA(BindableFactoryImpl.class), EasyMock.isA(ArrayList.class), EasyMock.isA(ArrayList.class));
 //      sm.loadMessages(EasyMock.isA(PostOfficeImpl.class), EasyMock.isA(Map.class));
 //
 //      pd.register(EasyMock.isA(MessagingServerPacketHandler.class));      
@@ -427,7 +427,7 @@
 //      PacketDispatcher pd = EasyMock.createMock(PacketDispatcher.class);
 //      EasyMock.expect(rs.getDispatcher()).andReturn(pd);
 //      
-//      sm.loadBindings(EasyMock.isA(QueueFactoryImpl.class), EasyMock.isA(ArrayList.class), EasyMock.isA(ArrayList.class));
+//      sm.loadBindings(EasyMock.isA(BindableFactoryImpl.class), EasyMock.isA(ArrayList.class), EasyMock.isA(ArrayList.class));
 //      sm.loadMessages(EasyMock.isA(PostOfficeImpl.class), EasyMock.isA(Map.class));
 //      
 //      pd.register(EasyMock.isA(MessagingServerPacketHandler.class));      

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueFactoryImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueFactoryImplTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueFactoryImplTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -25,8 +25,9 @@
 
 import org.easymock.EasyMock;
 import org.jboss.messaging.core.filter.Filter;
+import org.jboss.messaging.core.persistence.StorageManager;
 import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.impl.QueueFactoryImpl;
+import org.jboss.messaging.core.server.impl.BindableFactoryImpl;
 import org.jboss.messaging.core.server.impl.RoundRobinDistributor;
 import org.jboss.messaging.core.settings.HierarchicalRepository;
 import org.jboss.messaging.core.settings.impl.QueueSettings;
@@ -42,6 +43,7 @@
    {
       ScheduledExecutorService scheduledExecutor = EasyMock.createStrictMock(ScheduledExecutorService.class);
       HierarchicalRepository<QueueSettings> queueSettingsRepository = EasyMock.createStrictMock(HierarchicalRepository.class);
+      StorageManager sm = EasyMock.createStrictMock(StorageManager.class);
       Filter filter = EasyMock.createStrictMock(Filter.class);
       QueueSettings queueSettings = new QueueSettings();
       queueSettings.setClustered(true);
@@ -49,7 +51,7 @@
       queueSettings.setDistributionPolicyClass("org.jboss.messaging.core.server.impl.RoundRobinDistributor");
       EasyMock.expect(queueSettingsRepository.getMatch("testQ")).andReturn(queueSettings);
       EasyMock.replay(scheduledExecutor, queueSettingsRepository);
-      QueueFactoryImpl queueFactory = new QueueFactoryImpl(scheduledExecutor, queueSettingsRepository);
+      BindableFactoryImpl queueFactory = new BindableFactoryImpl(scheduledExecutor, queueSettingsRepository, sm);
       SimpleString qName = new SimpleString("testQ");
       Queue queue = queueFactory.createQueue(123, qName, filter, true, false);
       EasyMock.verify(scheduledExecutor, queueSettingsRepository);
@@ -66,13 +68,14 @@
    {
       ScheduledExecutorService scheduledExecutor = EasyMock.createStrictMock(ScheduledExecutorService.class);
       HierarchicalRepository<QueueSettings> queueSettingsRepository = EasyMock.createStrictMock(HierarchicalRepository.class);
+      StorageManager sm = EasyMock.createStrictMock(StorageManager.class);
       QueueSettings queueSettings = new QueueSettings();
       queueSettings.setClustered(false);
       queueSettings.setMaxSizeBytes(8888);
       queueSettings.setDistributionPolicyClass(null);
       EasyMock.expect(queueSettingsRepository.getMatch("testQ2")).andReturn(queueSettings);
       EasyMock.replay(scheduledExecutor, queueSettingsRepository);
-      QueueFactoryImpl queueFactory = new QueueFactoryImpl(scheduledExecutor, queueSettingsRepository);
+      BindableFactoryImpl queueFactory = new BindableFactoryImpl(scheduledExecutor, queueSettingsRepository, sm);
       SimpleString qName = new SimpleString("testQ2");
       Queue queue = queueFactory.createQueue(456, qName, null, false, false);
       EasyMock.verify(scheduledExecutor, queueSettingsRepository);

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/QueueImplTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -75,7 +75,7 @@
    {
       final long id = 123;
 
-      Queue queue = new QueueImpl(id, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(id, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       assertEquals(id, queue.getPersistenceID());
 
@@ -90,29 +90,29 @@
    {
       final SimpleString name = new SimpleString("oobblle");
 
-      Queue queue = new QueueImpl(1, name, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, name, null, false, true, false, scheduledExecutor, null, null);
 
       assertEquals(name, queue.getName());
    }
 
    public void testClustered()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       assertFalse(queue.isClustered());
 
-      queue = new QueueImpl(1, queue1, null, true, true, false, scheduledExecutor, null);
+      queue = new QueueImpl(1, queue1, null, true, true, false, scheduledExecutor, null, null);
 
       assertTrue(queue.isClustered());
    }
 
    public void testDurable()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, false, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, false, false, scheduledExecutor, null, null);
 
       assertFalse(queue.isDurable());
 
-      queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       assertTrue(queue.isDurable());
    }
@@ -125,7 +125,7 @@
 
       Consumer cons3 = new FakeConsumer();
 
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       assertEquals(0, queue.getConsumerCount());
 
@@ -166,7 +166,7 @@
 
    public void testGetSetDistributionPolicy()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       assertNotNull(queue.getDistributionPolicy());
 
@@ -181,14 +181,14 @@
 
    public void testGetFilter()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       assertNull(queue.getFilter());
 
       Filter filter = createMock(Filter.class);
       replay(filter);
 
-      queue = new QueueImpl(1, queue1, filter, false, true, false, scheduledExecutor, null);
+      queue = new QueueImpl(1, queue1, filter, false, true, false, scheduledExecutor, null, null);
 
       assertEquals(filter, queue.getFilter());
       
@@ -197,7 +197,7 @@
 
    public void testSimpleadd()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       final int numMessages = 10;
 
@@ -205,7 +205,7 @@
       {
          MessageReference ref = generateReference(queue, i);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       assertEquals(numMessages, queue.getMessageCount());
@@ -216,7 +216,7 @@
 
    public void testSimpleDirectDelivery()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       FakeConsumer consumer = new FakeConsumer();
 
@@ -232,7 +232,7 @@
 
          refs.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       assertEquals(numMessages, queue.getMessageCount());
@@ -244,7 +244,7 @@
 
    public void testSimpleNonDirectDelivery()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       final int numMessages = 10;
 
@@ -256,7 +256,7 @@
 
          refs.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       assertEquals(10, queue.getMessageCount());
@@ -282,7 +282,7 @@
 
    public void testBusyConsumer()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       FakeConsumer consumer = new FakeConsumer();
 
@@ -300,7 +300,7 @@
 
          refs.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       assertEquals(10, queue.getMessageCount());
@@ -326,7 +326,7 @@
 
    public void testBusyConsumerThenAddMoreMessages()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       FakeConsumer consumer = new FakeConsumer();
 
@@ -344,7 +344,7 @@
 
          refs.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       assertEquals(10, queue.getMessageCount());
@@ -364,7 +364,7 @@
 
          refs.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       assertEquals(20, queue.getMessageCount());
@@ -380,7 +380,7 @@
 
          refs.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       queue.deliverNow();
@@ -393,7 +393,7 @@
 
    public void testAddFirstadd()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       final int numMessages = 10;
 
@@ -405,7 +405,7 @@
 
          refs1.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       LinkedList<MessageReference> refs2 = new LinkedList<MessageReference>();
@@ -427,7 +427,7 @@
 
          refs3.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       FakeConsumer consumer = new FakeConsumer();
@@ -448,7 +448,7 @@
 
    public void testChangeConsumersAndDeliver() throws Exception
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice());
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice(), null);
 
       final int numMessages = 10;
 
@@ -460,7 +460,7 @@
 
          refs.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       assertEquals(numMessages, queue.getMessageCount());
@@ -500,7 +500,7 @@
 
          refs.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       assertEquals(numMessages * 2, queue.getMessageCount());
@@ -532,7 +532,7 @@
 
          refs.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       assertEquals(numMessages * 3, queue.getMessageCount());
@@ -562,7 +562,7 @@
 
          refs.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       assertEquals(numMessages * 2, queue.getMessageCount());
@@ -589,7 +589,7 @@
 
          refs.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       assertEquals(numMessages, queue.getMessageCount());
@@ -602,7 +602,7 @@
 
    public void testConsumerReturningNull()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       class NullConsumer implements Consumer
       {
@@ -618,7 +618,7 @@
 
       try
       {
-         queue.add(ref);
+         queue.addLast(ref);
 
          fail("Should throw IllegalStateException");
       }
@@ -630,7 +630,7 @@
 
    public void testRoundRobinWithQueueing()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       assertTrue(queue.getDistributionPolicy() instanceof RoundRobinDistributor);
 
@@ -646,7 +646,7 @@
 
          refs.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       FakeConsumer cons1 = new FakeConsumer();
@@ -675,7 +675,7 @@
 
    public void testRoundRobinDirect()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       assertTrue(queue.getDistributionPolicy() instanceof RoundRobinDistributor);
 
@@ -699,7 +699,7 @@
 
          refs.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       assertEquals(numMessages / 2, cons1.getReferences().size());
@@ -718,7 +718,7 @@
 
    public void testDeleteAllReferences() throws Exception
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice());
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice(), null);
 
       StorageManager storageManager = EasyMock.createStrictMock(StorageManager.class);
 
@@ -734,7 +734,7 @@
 
          refs.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
       //Add some scheduled too
@@ -751,7 +751,7 @@
 
          refs.add(ref);
 
-         queue.add(ref);
+         queue.addLast(ref);
       }
 
 
@@ -802,7 +802,7 @@
 
    public void testWithPriorities()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       final int numMessages = 10;
 
@@ -816,7 +816,7 @@
 
          refs.add(ref);
 
-         assertEquals(HandleStatus.HANDLED, queue.add(ref));
+         queue.addLast(ref);
       }
 
       FakeConsumer consumer = new FakeConsumer();
@@ -851,7 +851,7 @@
 
          refs.add(ref);
 
-         assertEquals(HandleStatus.HANDLED, queue.add(ref));
+         queue.addLast(ref);
       }
 
       assertRefListsIdenticalRefs(refs, consumer.getReferences());
@@ -869,7 +869,7 @@
 
    public void testConsumerWithFilterAddAndRemove()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       Filter filter = new FakeFilter("fruit", "orange");
 
@@ -878,7 +878,7 @@
 
    public void testList()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       final int numMessages = 20;
 
@@ -888,7 +888,7 @@
       {
          MessageReference ref = generateReference(queue, i);
 
-         queue.add(ref);
+         queue.addLast(ref);
 
          refs.add(ref);
       }
@@ -902,7 +902,7 @@
 
    public void testListWithFilter()
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
 
       final int numMessages = 20;
 
@@ -917,7 +917,7 @@
             ref.getMessage().putStringProperty(new SimpleString("god"), new SimpleString("dog"));
          }
 
-         queue.add(ref);
+         queue.addLast(ref);
 
          refs.add(ref);
       }
@@ -938,7 +938,7 @@
 
    public void testConsumeWithFiltersAddAndRemoveConsumer() throws Exception
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice());
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice(), null);
 
       Filter filter = new FakeFilter("fruit", "orange");
 
@@ -952,13 +952,13 @@
 
       ref1.getMessage().putStringProperty(new SimpleString("fruit"), new SimpleString("banana"));
 
-      assertEquals(HandleStatus.HANDLED, queue.add(ref1));
+      queue.addLast(ref1);
 
       MessageReference ref2 = generateReference(queue, 2);
 
       ref2.getMessage().putStringProperty(new SimpleString("fruit"), new SimpleString("orange"));
 
-      assertEquals(HandleStatus.HANDLED, queue.add(ref2));
+      queue.addLast(ref2);
 
       refs.add(ref2);
 
@@ -988,13 +988,13 @@
 
       ref3.getMessage().putStringProperty(new SimpleString("fruit"), new SimpleString("banana"));
 
-      assertEquals(HandleStatus.HANDLED, queue.add(ref3));
+      queue.addLast(ref3);
 
       MessageReference ref4 = generateReference(queue, 4);
 
       ref4.getMessage().putStringProperty(new SimpleString("fruit"), new SimpleString("orange"));
 
-      assertEquals(HandleStatus.HANDLED, queue.add(ref4));
+      queue.addLast(ref4);
 
       refs.add(ref4);
 
@@ -1011,7 +1011,7 @@
 
    private void testConsumerWithFilters(boolean direct) throws Exception
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice());
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice(), null);
 
       Filter filter = new FakeFilter("fruit", "orange");
 
@@ -1028,19 +1028,19 @@
 
       ref1.getMessage().putStringProperty(new SimpleString("fruit"), new SimpleString("banana"));
 
-      assertEquals(HandleStatus.HANDLED, queue.add(ref1));
+      queue.addLast(ref1);
 
       MessageReference ref2 = generateReference(queue, 2);
 
       ref2.getMessage().putStringProperty(new SimpleString("cheese"), new SimpleString("stilton"));
 
-      assertEquals(HandleStatus.HANDLED, queue.add(ref2));
+      queue.addLast(ref2);
 
       MessageReference ref3 = generateReference(queue, 3);
 
       ref3.getMessage().putStringProperty(new SimpleString("cake"), new SimpleString("sponge"));
 
-      assertEquals(HandleStatus.HANDLED, queue.add(ref3));
+      queue.addLast(ref3);
 
       MessageReference ref4 = generateReference(queue, 4);
 
@@ -1048,13 +1048,13 @@
 
       refs.add(ref4);
 
-      assertEquals(HandleStatus.HANDLED, queue.add(ref4));
+      queue.addLast(ref4);
 
       MessageReference ref5 = generateReference(queue, 5);
 
       ref5.getMessage().putStringProperty(new SimpleString("fruit"), new SimpleString("apple"));
 
-      assertEquals(HandleStatus.HANDLED, queue.add(ref5));
+      queue.addLast(ref5);
 
       MessageReference ref6 = generateReference(queue, 6);
 
@@ -1062,7 +1062,7 @@
 
       refs.add(ref6);
 
-      assertEquals(HandleStatus.HANDLED, queue.add(ref6));
+      queue.addLast(ref6);
 
       if (!direct)
       {
@@ -1100,12 +1100,12 @@
    public void testMessageOrder() throws Exception
    {
       Consumer consumer = EasyMock.createStrictMock(Consumer.class);
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
       MessageReference messageReference = generateReference(queue, 1);
       MessageReference messageReference2 = generateReference(queue, 2);
       MessageReference messageReference3 = generateReference(queue, 3);
       queue.addFirst(messageReference);
-      queue.add(messageReference2);
+      queue.addLast(messageReference2);
       queue.addFirst(messageReference3);
       EasyMock.expect(consumer.handle(messageReference3)).andReturn(HandleStatus.HANDLED);
       EasyMock.expect(consumer.handle(messageReference)).andReturn(HandleStatus.HANDLED);
@@ -1118,20 +1118,20 @@
 
    public void testMessagesAdded() throws Exception
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
       MessageReference messageReference = generateReference(queue, 1);
       MessageReference messageReference2 = generateReference(queue, 2);
       MessageReference messageReference3 = generateReference(queue, 3);
-      queue.add(messageReference);
-      queue.add(messageReference2);
-      queue.add(messageReference3);
+      queue.addLast(messageReference);
+      queue.addLast(messageReference2);
+      queue.addLast(messageReference3);
       assertEquals(queue.getMessagesAdded(), 3);
    }
 
    public void testAddListFirst() throws Exception
    {
       Consumer consumer = EasyMock.createStrictMock(Consumer.class);
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
       MessageReference messageReference = generateReference(queue, 1);
       MessageReference messageReference2 = generateReference(queue, 2);
       MessageReference messageReference3 = generateReference(queue, 3);
@@ -1152,7 +1152,7 @@
    public void testRemoveReferenceWithId() throws Exception
    {
       Consumer consumer = EasyMock.createStrictMock(Consumer.class);
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
       MessageReference messageReference = generateReference(queue, 1);
       MessageReference messageReference2 = generateReference(queue, 2);
       MessageReference messageReference3 = generateReference(queue, 3);
@@ -1173,7 +1173,7 @@
 
    public void testGetReference() throws Exception
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
       MessageReference messageReference = generateReference(queue, 1);
       MessageReference messageReference2 = generateReference(queue, 2);
       MessageReference messageReference3 = generateReference(queue, 3);
@@ -1186,7 +1186,7 @@
 
    public void testGetNonExistentReference() throws Exception
    {
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
       MessageReference messageReference = generateReference(queue, 1);
       MessageReference messageReference2 = generateReference(queue, 2);
       MessageReference messageReference3 = generateReference(queue, 3);
@@ -1200,7 +1200,7 @@
    public void testConsumerRemovedAfterException() throws Exception
    {
       Consumer consumer = EasyMock.createStrictMock(Consumer.class);
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
       MessageReference messageReference = generateReference(queue, 1);
       MessageReference messageReference2 = generateReference(queue, 2);
       MessageReference messageReference3 = generateReference(queue, 3);
@@ -1220,7 +1220,7 @@
    public void testDeliveryAsync() throws Exception
    {
       Consumer consumer = EasyMock.createStrictMock(Consumer.class);
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null);
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, null, null);
       MessageReference messageReference = generateReference(queue, 1);
       MessageReference messageReference2 = generateReference(queue, 2);
       MessageReference messageReference3 = generateReference(queue, 3);
@@ -1289,7 +1289,7 @@
 //      assertEquals(0, queue.getMessageCount());
 //      assertEquals(0, queue.getDeliveringCount());
 //
-//      queue.add(messageReference);
+//      queue.addLast(messageReference);
 //      
 //      assertEquals(1, queue.getMessageCount());
 //      assertEquals(0, queue.getDeliveringCount());
@@ -1345,7 +1345,7 @@
 //      assertEquals(0, queue.getMessageCount());
 //      assertEquals(0, queue.getDeliveringCount());
 // 
-//      queue.add(messageReference);
+//      queue.addLast(messageReference);
 //      
 //      assertEquals(1, queue.getMessageCount());
 //      assertEquals(0, queue.getDeliveringCount());
@@ -1364,7 +1364,7 @@
       long newMessageID = randomLong();
       long tid = randomLong();
       final SimpleString toQueueName = new SimpleString("toQueueName");
-      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice());
+      Queue queue = new QueueImpl(1, queue1, null, false, true, false, scheduledExecutor, createMockPostOffice(), null);
       Queue toQueue = createMock(Queue.class);
     
       MessageReference messageReference = generateReference(queue, messageID);
@@ -1386,8 +1386,8 @@
       
       Binding toBinding = EasyMock.createMock(Binding.class);
       EasyMock.expect(toBinding.getAddress()).andStubReturn(toQueueName);
-      EasyMock.expect(toBinding.getQueue()).andStubReturn(toQueue);
-      EasyMock.expect(postOffice.route(EasyMock.isA(ServerMessage.class), EasyMock.isA(Transaction.class), EasyMock.eq(false))).andReturn(new ArrayList<MessageReference>());
+      EasyMock.expect(toBinding.getBindable()).andStubReturn(toQueue);
+      postOffice.route(EasyMock.isA(ServerMessage.class), EasyMock.isA(Transaction.class));
       HierarchicalRepository<QueueSettings> queueSettingsRepository = EasyMock.createMock(HierarchicalRepository.class);
 
       EasyMock.replay(storageManager, postOffice, queueSettingsRepository, toBinding, pm);
@@ -1395,7 +1395,7 @@
       assertEquals(0, queue.getMessageCount());
       assertEquals(0, queue.getDeliveringCount());
 
-      queue.add(messageReference);
+      queue.addLast(messageReference);
       
       assertEquals(1, queue.getMessageCount());
       assertEquals(0, queue.getDeliveringCount());
@@ -1449,7 +1449,7 @@
          }
          else
          {
-            queue.add(messageReference);
+            queue.addLast(messageReference);
          }
          added = true;
          countDownLatch.countDown();

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/fakes/FakeQueueFactory.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/fakes/FakeQueueFactory.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/fakes/FakeQueueFactory.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -27,8 +27,10 @@
 
 import org.jboss.messaging.core.filter.Filter;
 import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.BindableFactory;
+import org.jboss.messaging.core.server.Link;
 import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.QueueFactory;
+import org.jboss.messaging.core.server.impl.LinkImpl;
 import org.jboss.messaging.core.server.impl.QueueImpl;
 import org.jboss.messaging.util.SimpleString;
 
@@ -39,7 +41,7 @@
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  *
  */
-public class FakeQueueFactory implements QueueFactory
+public class FakeQueueFactory implements BindableFactory
 {
 	private final ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
 	
@@ -48,8 +50,18 @@
 	public Queue createQueue(long persistenceID, SimpleString name, Filter filter,
 			                   boolean durable, boolean temporary)
 	{
-		return new QueueImpl(persistenceID, name, filter, false, durable, temporary, scheduledExecutor, postOffice);
+		return new QueueImpl(persistenceID, name, filter, false, durable, temporary, scheduledExecutor, postOffice, null);
 	}
+	
+	public Link createLink(long persistenceID, SimpleString name, Filter filter,
+                            boolean durable, boolean temporary, SimpleString linkAddress)
+   {
+      Link link =  new LinkImpl(name, durable, filter, linkAddress, postOffice, null);
+      
+      link.setPersistenceID(persistenceID);
+      
+      return link;
+   }
 
    public void setPostOffice(PostOffice postOffice)
    {

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/TransactionImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/TransactionImplTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/TransactionImplTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -544,13 +544,13 @@
       EasyMock.replay(pagingManager, postOffice);
       
       //Durable queue
-      Queue queue1 = new QueueImpl(12, new SimpleString("queue1"), null, false, true, false, scheduledExecutor, postOffice);
+      Queue queue1 = new QueueImpl(12, new SimpleString("queue1"), null, false, true, false, scheduledExecutor, postOffice, null);
       
       //Durable queue
-      Queue queue2 = new QueueImpl(34, new SimpleString("queue2"), null, false, true, false, scheduledExecutor, postOffice);
+      Queue queue2 = new QueueImpl(34, new SimpleString("queue2"), null, false, true, false, scheduledExecutor, postOffice, null);
       
       //Non durable queue
-      Queue queue3 = new QueueImpl(65, new SimpleString("queue3"), null, false, false, false, scheduledExecutor, postOffice);
+      Queue queue3 = new QueueImpl(65, new SimpleString("queue3"), null, false, false, false, scheduledExecutor, postOffice, null);
       
       //Some refs to ack
       
@@ -631,10 +631,10 @@
       
       //Expect:
       
-      postOffice.deliver((List<MessageReference>)EasyMock.anyObject());
-      
-      EasyMock.expectLastCall().anyTimes();
-      
+//      postOffice.deliver((List<MessageReference>)EasyMock.anyObject());
+//      
+//      EasyMock.expectLastCall().anyTimes();
+//      
       sm.commit(txID);
 
       EasyMock.expect(pagingManager.getPageStore((SimpleString)EasyMock.anyObject())).andStubReturn(pagingStore);
@@ -671,10 +671,10 @@
       
       EasyMock.reset(po);
       
-      po.deliver((List<MessageReference>)EasyMock.anyObject());
+//      po.deliver((List<MessageReference>)EasyMock.anyObject());
+//      
+//      EasyMock.expectLastCall().anyTimes();
       
-      EasyMock.expectLastCall().anyTimes();
-      
       EasyMock.replay(po);
       
       return tx;

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/util/SimpleStringTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/util/SimpleStringTest.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/util/SimpleStringTest.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -231,13 +231,21 @@
    }
 	
 	public void testSizeofString() throws Exception
-   {
-	   assertEquals(DataConstants.SIZE_INT, SimpleString.sizeofString(null));
+   {	   
       assertEquals(DataConstants.SIZE_INT, SimpleString.sizeofString(new SimpleString("")));
 
 	   SimpleString str = new SimpleString(randomString());
 	   assertEquals(DataConstants.SIZE_INT + str.getData().length, SimpleString.sizeofString(str));
+   }
+	
+	public void testSizeofNullableString() throws Exception
+   {     
+      assertEquals(1, SimpleString.sizeofNullableString(null));
       
+      assertEquals(1 + DataConstants.SIZE_INT, SimpleString.sizeofNullableString(new SimpleString("")));
+
+      SimpleString str = new SimpleString(randomString());
+      assertEquals(1 + DataConstants.SIZE_INT + str.getData().length, SimpleString.sizeofNullableString(str));
    }
 
    public void testSplitNoDelimeter() throws Exception

Modified: trunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java	2008-12-23 03:04:27 UTC (rev 5563)
+++ trunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java	2008-12-31 14:10:26 UTC (rev 5564)
@@ -22,7 +22,22 @@
 
 package org.jboss.messaging.tests.util;
 
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.util.Iterator;
+import java.util.List;
+import java.util.UUID;
+
+import javax.transaction.xa.Xid;
+
 import junit.framework.TestCase;
+
 import org.easymock.EasyMock;
 import org.easymock.IArgumentMatcher;
 import org.jboss.messaging.core.client.ClientMessage;
@@ -36,20 +51,8 @@
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.server.impl.ServerMessageImpl;
 import org.jboss.messaging.jms.client.JBossTextMessage;
+import org.jboss.messaging.util.SimpleString;
 
-import javax.transaction.xa.Xid;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.util.Iterator;
-import java.util.List;
-import java.util.UUID;
-
 /**
  *
  * Helper base class for our unit tests
@@ -565,6 +568,8 @@
       // message.setPayload(bytes);
 
       message.getBody().putString(UUID.randomUUID().toString());
+      
+      message.setDestination(new SimpleString("foo"));
 
       return message;
    }




More information about the jboss-cvs-commits mailing list