[hornetq-commits] JBoss hornetq SVN: r8973 - in trunk: src/main/org/hornetq/api/jms/management and 31 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Mar 26 17:33:54 EDT 2010


Author: clebert.suconic at jboss.com
Date: 2010-03-26 17:33:52 -0400 (Fri, 26 Mar 2010)
New Revision: 8973

Added:
   trunk/src/main/org/hornetq/core/persistence/config/
   trunk/src/main/org/hornetq/core/persistence/config/PersistedAddressSetting.java
   trunk/src/main/org/hornetq/core/persistence/config/PersistedRoles.java
   trunk/src/main/org/hornetq/jms/persistence/
   trunk/src/main/org/hornetq/jms/persistence/JMSStorageManager.java
   trunk/src/main/org/hornetq/jms/persistence/config/
   trunk/src/main/org/hornetq/jms/persistence/config/PersistedConnectionFactory.java
   trunk/src/main/org/hornetq/jms/persistence/config/PersistedDestination.java
   trunk/src/main/org/hornetq/jms/persistence/config/PersistedJNDI.java
   trunk/src/main/org/hornetq/jms/persistence/config/PersistedType.java
   trunk/src/main/org/hornetq/jms/persistence/impl/
   trunk/src/main/org/hornetq/jms/persistence/impl/journal/
   trunk/src/main/org/hornetq/jms/persistence/impl/journal/JournalJMSStorageManagerImpl.java
   trunk/src/main/org/hornetq/jms/persistence/impl/nullpm/
   trunk/src/main/org/hornetq/jms/persistence/impl/nullpm/NullJMSStorageManagerImpl.java
   trunk/src/main/org/hornetq/utils/BufferHelper.java
   trunk/tests/src/org/hornetq/tests/integration/persistence/AddressSettingsConfigurationStorageTest.java
   trunk/tests/src/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java
   trunk/tests/src/org/hornetq/tests/integration/persistence/RolesConfigurationStorageTest.java
   trunk/tests/src/org/hornetq/tests/integration/persistence/StorageManagerTestBase.java
Modified:
   trunk/src/main/org/hornetq/api/core/management/HornetQServerControl.java
   trunk/src/main/org/hornetq/api/jms/management/ConnectionFactoryControl.java
   trunk/src/main/org/hornetq/api/jms/management/DestinationControl.java
   trunk/src/main/org/hornetq/api/jms/management/JMSQueueControl.java
   trunk/src/main/org/hornetq/api/jms/management/JMSServerControl.java
   trunk/src/main/org/hornetq/api/jms/management/TopicControl.java
   trunk/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java
   trunk/src/main/org/hornetq/core/persistence/StorageManager.java
   trunk/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
   trunk/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageManager.java
   trunk/src/main/org/hornetq/core/replication/impl/ReplicationEndpointImpl.java
   trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
   trunk/src/main/org/hornetq/core/settings/impl/AddressSettings.java
   trunk/src/main/org/hornetq/jms/management/impl/JMSConnectionFactoryControlImpl.java
   trunk/src/main/org/hornetq/jms/management/impl/JMSQueueControlImpl.java
   trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java
   trunk/src/main/org/hornetq/jms/management/impl/JMSTopicControlImpl.java
   trunk/src/main/org/hornetq/jms/server/JMSServerManager.java
   trunk/src/main/org/hornetq/jms/server/config/ConnectionFactoryConfiguration.java
   trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java
   trunk/src/main/org/hornetq/jms/server/impl/JMSServerDeployer.java
   trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
   trunk/src/main/org/hornetq/jms/server/management/JMSManagementService.java
   trunk/src/main/org/hornetq/jms/server/management/impl/JMSManagementServiceImpl.java
   trunk/tests/jms-tests/src/org/hornetq/jms/tests/tools/container/LocalTestServer.java
   trunk/tests/src/org/hornetq/tests/integration/jms/bridge/BridgeTestBase.java
   trunk/tests/src/org/hornetq/tests/integration/jms/bridge/JMSBridgeReconnectionTest.java
   trunk/tests/src/org/hornetq/tests/integration/jms/connection/ExceptionListenerTest.java
   trunk/tests/src/org/hornetq/tests/integration/jms/consumer/ConsumerTest.java
   trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlTest.java
   trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlUsingJMSTest.java
   trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
   trunk/tests/src/org/hornetq/tests/integration/jms/server/management/TopicControlTest.java
   trunk/tests/src/org/hornetq/tests/timing/jms/bridge/impl/JMSBridgeImplTest.java
   trunk/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java
   trunk/tests/src/org/hornetq/tests/util/JMSClusteredTestBase.java
   trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java
Log:
Configuration changes and few JNDI on management changes

Modified: trunk/src/main/org/hornetq/api/core/management/HornetQServerControl.java
===================================================================
--- trunk/src/main/org/hornetq/api/core/management/HornetQServerControl.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/api/core/management/HornetQServerControl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -524,7 +524,7 @@
 
    AddressSettings getAddressSettings(String address);
 
-   void removeAddressSettings(String addressMatch);
+   void removeAddressSettings(String addressMatch) throws Exception;
 
    /**
     * returns the address settings as a JSON string

Modified: trunk/src/main/org/hornetq/api/jms/management/ConnectionFactoryControl.java
===================================================================
--- trunk/src/main/org/hornetq/api/jms/management/ConnectionFactoryControl.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/api/jms/management/ConnectionFactoryControl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -40,7 +40,7 @@
    /**
     * Returns the JNDI bindings associated  to this connection factory.
     */
-   List<String> getBindings();
+   List<String> getJNDIBindings();
 
    /**
     * Returns the Client ID of this connection factory (or {@code null} if it is not set.

Modified: trunk/src/main/org/hornetq/api/jms/management/DestinationControl.java
===================================================================
--- trunk/src/main/org/hornetq/api/jms/management/DestinationControl.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/api/jms/management/DestinationControl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -33,11 +33,6 @@
    String getName();
 
    /**
-    * Returns the JNDI binding of this destination.
-    */
-   String getJNDIBinding();
-
-   /**
     * Returns the HornetQ address corresponding to this destination.
     */
    String getAddress();

Modified: trunk/src/main/org/hornetq/api/jms/management/JMSQueueControl.java
===================================================================
--- trunk/src/main/org/hornetq/api/jms/management/JMSQueueControl.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/api/jms/management/JMSQueueControl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -13,6 +13,7 @@
 
 package org.hornetq.api.jms.management;
 
+import java.util.List;
 import java.util.Map;
 
 import javax.management.MBeanOperationInfo;
@@ -77,6 +78,18 @@
    // Operations ----------------------------------------------------
 
    /**
+    * Returns the JNDI bindings associated  to this connection factory.
+    */
+   @Operation(desc = "Returns the list of JNDI bindings associated")
+   List<String> getJNDIBindings();
+   
+   /**
+    * Add the JNDI binding to this destination
+    */
+   @Operation(desc = "Adds the queue to another JNDI binding")
+   void addJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception;
+
+   /**
     * Lists all the JMS messages in this queue matching the specified filter.
     * <br>
     * 1 Map represents 1 message, keys are the message's properties and headers, values are the corresponding values.

Modified: trunk/src/main/org/hornetq/api/jms/management/JMSServerControl.java
===================================================================
--- trunk/src/main/org/hornetq/api/jms/management/JMSServerControl.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/api/jms/management/JMSServerControl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -14,7 +14,6 @@
 package org.hornetq.api.jms.management;
 
 import java.util.Map;
-import java.util.Set;
 
 import javax.management.MBeanOperationInfo;
 
@@ -22,8 +21,6 @@
 import org.hornetq.api.core.client.ClientSessionFactory;
 import org.hornetq.api.core.management.Operation;
 import org.hornetq.api.core.management.Parameter;
-import org.hornetq.core.security.Role;
-import org.hornetq.core.settings.impl.AddressSettings;
 import org.hornetq.spi.core.remoting.ConnectorFactory;
 
 /**

Modified: trunk/src/main/org/hornetq/api/jms/management/TopicControl.java
===================================================================
--- trunk/src/main/org/hornetq/api/jms/management/TopicControl.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/api/jms/management/TopicControl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -13,6 +13,7 @@
 
 package org.hornetq.api.jms.management;
 
+import java.util.List;
 import java.util.Map;
 
 import javax.management.MBeanOperationInfo;
@@ -54,6 +55,20 @@
     */
    int getNonDurableMessageCount();
 
+   /**
+    * Returns the JNDI bindings associated  to this connection factory.
+    */
+   @Operation(desc = "Returns the list of JNDI bindings associated")
+   List<String> getJNDIBindings();
+   
+   /**
+    * Add the JNDI binding to this destination
+    */
+   @Operation(desc = "Adds the queue to another JNDI binding")
+   void addJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception;
+
+
+
    // Operations ----------------------------------------------------
 
    /**

Modified: trunk/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -38,6 +38,8 @@
 import org.hornetq.core.messagecounter.MessageCounterManager;
 import org.hornetq.core.messagecounter.impl.MessageCounterManagerImpl;
 import org.hornetq.core.persistence.StorageManager;
+import org.hornetq.core.persistence.config.PersistedAddressSetting;
+import org.hornetq.core.persistence.config.PersistedRoles;
 import org.hornetq.core.postoffice.PostOffice;
 import org.hornetq.core.remoting.server.RemotingService;
 import org.hornetq.core.security.CheckType;
@@ -85,7 +87,6 @@
 
    // Static --------------------------------------------------------
 
-   
    // Constructors --------------------------------------------------
 
    public HornetQServerControlImpl(final PostOffice postOffice,
@@ -537,6 +538,7 @@
          blockOnIO();
       }
    }
+
    public void deployQueue(final String address, final String name, final String filterString) throws Exception
    {
       checkStarted();
@@ -1167,7 +1169,7 @@
          blockOnIO();
       }
    }
-   
+
    public void addSecuritySettings(String addressMatch,
                                    String sendRoles,
                                    String consumeRoles,
@@ -1175,16 +1177,33 @@
                                    String deleteDurableQueueRoles,
                                    String createTempQueueRoles,
                                    String deleteTempQueueRoles,
-                                   String manageRoles)
+                                   String manageRoles) throws Exception
    {
       checkStarted();
 
       clearIO();
       try
       {
-         Set<Role> roles = SecurityFormatter.createSecurity(sendRoles, consumeRoles, createDurableQueueRoles, deleteDurableQueueRoles, createTempQueueRoles, deleteTempQueueRoles, manageRoles);
+         Set<Role> roles = SecurityFormatter.createSecurity(sendRoles,
+                                                            consumeRoles,
+                                                            createDurableQueueRoles,
+                                                            deleteDurableQueueRoles,
+                                                            createTempQueueRoles,
+                                                            deleteTempQueueRoles,
+                                                            manageRoles);
 
-         server.getSecurityRepository().addMatch(addressMatch, roles );
+         server.getSecurityRepository().addMatch(addressMatch, roles);
+
+         PersistedRoles persistedRoles = new PersistedRoles(addressMatch,
+                                                            sendRoles,
+                                                            consumeRoles,
+                                                            createDurableQueueRoles,
+                                                            deleteDurableQueueRoles,
+                                                            createTempQueueRoles,
+                                                            deleteTempQueueRoles,
+                                                            manageRoles);
+         
+         storageManager.storeSecurityRoles(persistedRoles);
       }
       finally
       {
@@ -1192,8 +1211,7 @@
       }
    }
 
-
-   public void removeSecuritySettings(String addressMatch)
+   public void removeSecuritySettings(String addressMatch) throws Exception
    {
       checkStarted();
 
@@ -1201,6 +1219,7 @@
       try
       {
          server.getSecurityRepository().removeMatch(addressMatch);
+         storageManager.deleteSecurityRoles(new SimpleString(addressMatch));
       }
       finally
       {
@@ -1219,9 +1238,10 @@
       }
       finally
       {
-         blockOnIO();   
+         blockOnIO();
       }
    }
+
    public Object[] getRoles(String addressMatch) throws Exception
    {
       checkStarted();
@@ -1283,11 +1303,11 @@
 
       AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch(address);
       Map<String, Object> settings = new HashMap<String, Object>();
-      if(addressSettings.getDeadLetterAddress() != null)
+      if (addressSettings.getDeadLetterAddress() != null)
       {
          settings.put("DLA", addressSettings.getDeadLetterAddress());
       }
-      if(addressSettings.getExpiryAddress() != null)
+      if (addressSettings.getExpiryAddress() != null)
       {
          settings.put("expiryAddress", addressSettings.getExpiryAddress());
       }
@@ -1298,7 +1318,9 @@
       settings.put("redistributionDelay", addressSettings.getRedistributionDelay());
       settings.put("lastValueQueue", addressSettings.isLastValueQueue());
       settings.put("sendToDLAOnNoRoute", addressSettings.isSendToDLAOnNoRoute());
-      String policy = addressSettings.getAddressFullMessagePolicy() == AddressFullMessagePolicy.PAGE?"PAGE":addressSettings.getAddressFullMessagePolicy() == AddressFullMessagePolicy.BLOCK?"BLOCK":"DROP";
+      String policy = addressSettings.getAddressFullMessagePolicy() == AddressFullMessagePolicy.PAGE ? "PAGE"
+                                                                                                    : addressSettings.getAddressFullMessagePolicy() == AddressFullMessagePolicy.BLOCK ? "BLOCK"
+                                                                                                                                                                                     : "DROP";
       settings.put("addressFullMessagePolicy", policy);
 
       JSONObject jsonObject = new JSONObject(settings);
@@ -1320,8 +1342,8 @@
       checkStarted();
 
       AddressSettings addressSettings = new AddressSettings();
-      addressSettings.setDeadLetterAddress(DLA == null?null:new SimpleString(DLA));
-      addressSettings.setExpiryAddress(expiryAddress == null?null:new SimpleString(expiryAddress));
+      addressSettings.setDeadLetterAddress(DLA == null ? null : new SimpleString(DLA));
+      addressSettings.setExpiryAddress(expiryAddress == null ? null : new SimpleString(expiryAddress));
       addressSettings.setLastValueQueue(lastValueQueue);
       addressSettings.setMaxDeliveryAttempts(deliveryAttempts);
       addressSettings.setMaxSizeBytes(maxSizeBytes);
@@ -1329,23 +1351,25 @@
       addressSettings.setRedeliveryDelay(redeliveryDelay);
       addressSettings.setRedistributionDelay(redistributionDelay);
       addressSettings.setSendToDLAOnNoRoute(sendToDLAOnNoRoute);
-      if(addressFullMessagePolicy == null)
+      if (addressFullMessagePolicy == null)
       {
          addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
       }
-      else if(addressFullMessagePolicy.equalsIgnoreCase("PAGE"))
+      else if (addressFullMessagePolicy.equalsIgnoreCase("PAGE"))
       {
          addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
       }
-      else if(addressFullMessagePolicy.equalsIgnoreCase("DROP"))
+      else if (addressFullMessagePolicy.equalsIgnoreCase("DROP"))
       {
          addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.DROP);
       }
-      else if(addressFullMessagePolicy.equalsIgnoreCase("BLOCK"))
+      else if (addressFullMessagePolicy.equalsIgnoreCase("BLOCK"))
       {
          addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK);
       }
       server.getAddressSettingsRepository().addMatch(address, addressSettings);
+
+      storageManager.storeAddressSetting(new PersistedAddressSetting(new SimpleString(address), addressSettings));
    }
 
    public AddressSettings getAddressSettings(final String address)
@@ -1355,11 +1379,12 @@
       return server.getAddressSettingsRepository().getMatch(address);
    }
 
-   public void removeAddressSettings(String addressMatch)
+   public void removeAddressSettings(String addressMatch) throws Exception
    {
       checkStarted();
 
       server.getAddressSettingsRepository().removeMatch(addressMatch);
+      storageManager.deleteAddressSetting(new SimpleString(addressMatch));
    }
 
    public void sendQueueInfoToQueue(final String queueName, final String address) throws Exception

Modified: trunk/src/main/org/hornetq/core/persistence/StorageManager.java
===================================================================
--- trunk/src/main/org/hornetq/core/persistence/StorageManager.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/core/persistence/StorageManager.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -13,6 +13,7 @@
 
 package org.hornetq.core.persistence;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.Executor;
@@ -26,6 +27,8 @@
 import org.hornetq.core.paging.PageTransactionInfo;
 import org.hornetq.core.paging.PagedMessage;
 import org.hornetq.core.paging.PagingManager;
+import org.hornetq.core.persistence.config.PersistedAddressSetting;
+import org.hornetq.core.persistence.config.PersistedRoles;
 import org.hornetq.core.postoffice.Binding;
 import org.hornetq.core.postoffice.PostOffice;
 import org.hornetq.core.server.HornetQComponent;
@@ -160,4 +163,16 @@
    void addGrouping(GroupBinding groupBinding) throws Exception;
 
    void deleteGrouping(GroupBinding groupBinding) throws Exception;
+   
+   void storeAddressSetting(PersistedAddressSetting addressSetting) throws Exception;
+   
+   void deleteAddressSetting(SimpleString addressMatch) throws Exception;
+   
+   List<PersistedAddressSetting> recoverAddressSettings() throws Exception;
+   
+   void storeSecurityRoles(PersistedRoles persistedRoles) throws Exception;
+   
+   void deleteSecurityRoles(SimpleString addressMatch) throws Exception;
+
+   List<PersistedRoles> recoverPersistedRoles() throws Exception;
 }

Added: trunk/src/main/org/hornetq/core/persistence/config/PersistedAddressSetting.java
===================================================================
--- trunk/src/main/org/hornetq/core/persistence/config/PersistedAddressSetting.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/core/persistence/config/PersistedAddressSetting.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.persistence.config;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.core.journal.EncodingSupport;
+import org.hornetq.core.settings.impl.AddressSettings;
+
+/**
+ * A PersistedAddressSetting
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ */
+public class PersistedAddressSetting implements EncodingSupport
+{
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private long storeId;
+
+   private SimpleString addressMatch;
+
+   private AddressSettings setting;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public PersistedAddressSetting()
+   {
+      super();
+   }
+
+   /**
+    * @param addressMatch
+    * @param setting
+    */
+   public PersistedAddressSetting(SimpleString addressMatch, AddressSettings setting)
+   {
+      super();
+      this.addressMatch = addressMatch;
+      this.setting = setting;
+   }
+
+   // Public --------------------------------------------------------
+
+   public void setStoreId(long id)
+   {
+      this.storeId = id;
+   }
+
+   public long getStoreId()
+   {
+      return storeId;
+   }
+
+   /**
+    * @return the addressMatch
+    */
+   public SimpleString getAddressMatch()
+   {
+      return addressMatch;
+   }
+
+   /**
+    * @return the setting
+    */
+   public AddressSettings getSetting()
+   {
+      return setting;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#decode(org.hornetq.api.core.HornetQBuffer)
+    */
+   public void decode(HornetQBuffer buffer)
+   {
+      addressMatch = buffer.readSimpleString();
+
+      setting = new AddressSettings();
+      setting.decode(buffer);
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#encode(org.hornetq.api.core.HornetQBuffer)
+    */
+   public void encode(HornetQBuffer buffer)
+   {
+      buffer.writeSimpleString(addressMatch);
+
+      setting.encode(buffer);
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#getEncodeSize()
+    */
+   public int getEncodeSize()
+   {
+      return addressMatch.sizeof() + setting.getEncodeSize();
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Added: trunk/src/main/org/hornetq/core/persistence/config/PersistedRoles.java
===================================================================
--- trunk/src/main/org/hornetq/core/persistence/config/PersistedRoles.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/core/persistence/config/PersistedRoles.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -0,0 +1,316 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.persistence.config;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.core.journal.EncodingSupport;
+
+/**
+ * A ConfiguredRoles
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class PersistedRoles implements EncodingSupport
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private long storeId;
+
+   private SimpleString addressMatch;
+
+   private SimpleString sendRoles;
+
+   private SimpleString consumeRoles;
+
+   private SimpleString createDurableQueueRoles;
+
+   private SimpleString deleteDurableQueueRoles;
+
+   private SimpleString createTempQueueRoles;
+
+   private SimpleString deleteTempQueueRoles;
+
+   private SimpleString manageRoles;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public PersistedRoles()
+   {
+   }
+
+   /**
+    * @param address
+    * @param addressMatch
+    * @param sendRoles
+    * @param consumeRoles
+    * @param createDurableQueueRoles
+    * @param deleteDurableQueueRoles
+    * @param createTempQueueRoles
+    * @param deleteTempQueueRoles
+    * @param manageRoles
+    */
+   public PersistedRoles(final String addressMatch,
+                         final String sendRoles,
+                         final String consumeRoles,
+                         final String createDurableQueueRoles,
+                         final String deleteDurableQueueRoles,
+                         final String createTempQueueRoles,
+                         final String deleteTempQueueRoles,
+                         final String manageRoles)
+   {
+      super();
+      this.addressMatch = SimpleString.toSimpleString(addressMatch);
+      this.sendRoles = SimpleString.toSimpleString(sendRoles);
+      this.consumeRoles = SimpleString.toSimpleString(consumeRoles);
+      this.createDurableQueueRoles = SimpleString.toSimpleString(createDurableQueueRoles);
+      this.deleteDurableQueueRoles = SimpleString.toSimpleString(deleteDurableQueueRoles);
+      this.createTempQueueRoles = SimpleString.toSimpleString(createTempQueueRoles);
+      this.deleteTempQueueRoles = SimpleString.toSimpleString(deleteTempQueueRoles);
+      this.manageRoles = SimpleString.toSimpleString(manageRoles);
+   }
+
+   // Public --------------------------------------------------------
+
+   public long getStoreId()
+   {
+      return storeId;
+   }
+
+   public void setStoreId(final long id)
+   {
+      storeId = id;
+   }
+
+   /**
+    * @return the addressMatch
+    */
+   public SimpleString getAddressMatch()
+   {
+      return addressMatch;
+   }
+
+   /**
+    * @return the sendRoles
+    */
+   public String getSendRoles()
+   {
+      return sendRoles.toString();
+   }
+
+   /**
+    * @return the consumeRoles
+    */
+   public String getConsumeRoles()
+   {
+      return consumeRoles.toString();
+   }
+
+   /**
+    * @return the createDurableQueueRoles
+    */
+   public String getCreateDurableQueueRoles()
+   {
+      return createDurableQueueRoles.toString();
+   }
+
+   /**
+    * @return the deleteDurableQueueRoles
+    */
+   public String getDeleteDurableQueueRoles()
+   {
+      return deleteDurableQueueRoles.toString();
+   }
+
+   /**
+    * @return the createTempQueueRoles
+    */
+   public String getCreateTempQueueRoles()
+   {
+      return createTempQueueRoles.toString();
+   }
+
+   /**
+    * @return the deleteTempQueueRoles
+    */
+   public String getDeleteTempQueueRoles()
+   {
+      return deleteTempQueueRoles.toString();
+   }
+
+   /**
+    * @return the manageRoles
+    */
+   public String getManageRoles()
+   {
+      return manageRoles.toString();
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#encode(org.hornetq.api.core.HornetQBuffer)
+    */
+   public void encode(final HornetQBuffer buffer)
+   {
+      buffer.writeSimpleString(addressMatch);
+      buffer.writeNullableSimpleString(sendRoles);
+      buffer.writeNullableSimpleString(consumeRoles);
+      buffer.writeNullableSimpleString(createDurableQueueRoles);
+      buffer.writeNullableSimpleString(deleteDurableQueueRoles);
+      buffer.writeNullableSimpleString(createTempQueueRoles);
+      buffer.writeNullableSimpleString(deleteTempQueueRoles);
+      buffer.writeNullableSimpleString(manageRoles);
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#getEncodeSize()
+    */
+   public int getEncodeSize()
+   {
+      return addressMatch.sizeof() + SimpleString.sizeofNullableString(sendRoles) +
+             SimpleString.sizeofNullableString(consumeRoles) +
+             SimpleString.sizeofNullableString(createDurableQueueRoles) +
+             SimpleString.sizeofNullableString(deleteDurableQueueRoles) +
+             SimpleString.sizeofNullableString(createTempQueueRoles) +
+             SimpleString.sizeofNullableString(deleteTempQueueRoles) +
+             SimpleString.sizeofNullableString(manageRoles);
+
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#decode(org.hornetq.api.core.HornetQBuffer)
+    */
+   public void decode(final HornetQBuffer buffer)
+   {
+      addressMatch = buffer.readSimpleString();
+      sendRoles = buffer.readNullableSimpleString();
+      consumeRoles = buffer.readNullableSimpleString();
+      createDurableQueueRoles = buffer.readNullableSimpleString();
+      deleteDurableQueueRoles = buffer.readNullableSimpleString();
+      createTempQueueRoles = buffer.readNullableSimpleString();
+      deleteTempQueueRoles = buffer.readNullableSimpleString();
+      manageRoles = buffer.readNullableSimpleString();
+   }
+
+   /* (non-Javadoc)
+    * @see java.lang.Object#hashCode()
+    */
+   @Override
+   public int hashCode()
+   {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((addressMatch == null) ? 0 : addressMatch.hashCode());
+      result = prime * result + ((consumeRoles == null) ? 0 : consumeRoles.hashCode());
+      result = prime * result + ((createDurableQueueRoles == null) ? 0 : createDurableQueueRoles.hashCode());
+      result = prime * result + ((createTempQueueRoles == null) ? 0 : createTempQueueRoles.hashCode());
+      result = prime * result + ((deleteDurableQueueRoles == null) ? 0 : deleteDurableQueueRoles.hashCode());
+      result = prime * result + ((deleteTempQueueRoles == null) ? 0 : deleteTempQueueRoles.hashCode());
+      result = prime * result + ((manageRoles == null) ? 0 : manageRoles.hashCode());
+      result = prime * result + ((sendRoles == null) ? 0 : sendRoles.hashCode());
+      result = prime * result + (int)(storeId ^ (storeId >>> 32));
+      return result;
+   }
+
+   /* (non-Javadoc)
+    * @see java.lang.Object#equals(java.lang.Object)
+    */
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (this == obj)
+         return true;
+      if (obj == null)
+         return false;
+      if (getClass() != obj.getClass())
+         return false;
+      PersistedRoles other = (PersistedRoles)obj;
+      if (addressMatch == null)
+      {
+         if (other.addressMatch != null)
+            return false;
+      }
+      else if (!addressMatch.equals(other.addressMatch))
+         return false;
+      if (consumeRoles == null)
+      {
+         if (other.consumeRoles != null)
+            return false;
+      }
+      else if (!consumeRoles.equals(other.consumeRoles))
+         return false;
+      if (createDurableQueueRoles == null)
+      {
+         if (other.createDurableQueueRoles != null)
+            return false;
+      }
+      else if (!createDurableQueueRoles.equals(other.createDurableQueueRoles))
+         return false;
+      if (createTempQueueRoles == null)
+      {
+         if (other.createTempQueueRoles != null)
+            return false;
+      }
+      else if (!createTempQueueRoles.equals(other.createTempQueueRoles))
+         return false;
+      if (deleteDurableQueueRoles == null)
+      {
+         if (other.deleteDurableQueueRoles != null)
+            return false;
+      }
+      else if (!deleteDurableQueueRoles.equals(other.deleteDurableQueueRoles))
+         return false;
+      if (deleteTempQueueRoles == null)
+      {
+         if (other.deleteTempQueueRoles != null)
+            return false;
+      }
+      else if (!deleteTempQueueRoles.equals(other.deleteTempQueueRoles))
+         return false;
+      if (manageRoles == null)
+      {
+         if (other.manageRoles != null)
+            return false;
+      }
+      else if (!manageRoles.equals(other.manageRoles))
+         return false;
+      if (sendRoles == null)
+      {
+         if (other.sendRoles != null)
+            return false;
+      }
+      else if (!sendRoles.equals(other.sendRoles))
+         return false;
+      if (storeId != other.storeId)
+         return false;
+      return true;
+   }
+   
+   
+   
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Modified: trunk/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- trunk/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -20,6 +20,7 @@
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Executor;
 
 import javax.transaction.xa.Xid;
@@ -53,6 +54,8 @@
 import org.hornetq.core.persistence.OperationContext;
 import org.hornetq.core.persistence.QueueBindingInfo;
 import org.hornetq.core.persistence.StorageManager;
+import org.hornetq.core.persistence.config.PersistedAddressSetting;
+import org.hornetq.core.persistence.config.PersistedRoles;
 import org.hornetq.core.postoffice.Binding;
 import org.hornetq.core.postoffice.PostOffice;
 import org.hornetq.core.replication.ReplicationManager;
@@ -101,6 +104,10 @@
 
    public static final byte ID_COUNTER_RECORD = 24;
 
+   public static final byte ADDRESS_SETTING_RECORD = 25;
+
+   public static final byte SECURITY_RECORD = 26;
+
    // type + expiration + timestamp + priority
    public static final int SIZE_FIELDS = DataConstants.SIZE_INT + DataConstants.SIZE_LONG +
                                          DataConstants.SIZE_LONG +
@@ -160,6 +167,12 @@
    private final String journalDir;
 
    private final String largeMessagesDirectory;
+   
+   
+   // Persisted core configuration
+   private final Map<SimpleString, PersistedRoles> mapPersistedRoles = new ConcurrentHashMap<SimpleString, PersistedRoles>();
+   
+   private final Map<SimpleString, PersistedAddressSetting> mapPersistedAddressSettings = new ConcurrentHashMap<SimpleString, PersistedAddressSetting>();
 
    public JournalStorageManager(final Configuration config, final ExecutorFactory executorFactory)
    {
@@ -690,7 +703,69 @@
                                         getContext(syncNonTransactional));
 
    }
+   
+   
+   public void storeAddressSetting(PersistedAddressSetting addressSetting) throws Exception
+   {
+      deleteAddressSetting(addressSetting.getAddressMatch());
+      long id = idGenerator.generateID();
+      addressSetting.setStoreId(id);
+      bindingsJournal.appendAddRecord(id, ADDRESS_SETTING_RECORD, addressSetting, true);
+      mapPersistedAddressSettings.put(addressSetting.getAddressMatch(), addressSetting);
+   }
+   
+   public List<PersistedAddressSetting> recoverAddressSettings() throws Exception
+   {
+      ArrayList<PersistedAddressSetting> list = new ArrayList<PersistedAddressSetting>(mapPersistedAddressSettings.size());
+      list.addAll(mapPersistedAddressSettings.values());
+      return list;
+   }
+   
 
+   /* (non-Javadoc)
+    * @see org.hornetq.core.persistence.StorageManager#recoverPersistedRoles()
+    */
+   public List<PersistedRoles> recoverPersistedRoles() throws Exception
+   {
+      ArrayList<PersistedRoles> list = new ArrayList<PersistedRoles>(mapPersistedRoles.size());
+      list.addAll(mapPersistedRoles.values());
+      return list;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.persistence.StorageManager#storeSecurityRoles(org.hornetq.core.persistconfig.PersistedRoles)
+    */
+   public void storeSecurityRoles(PersistedRoles persistedRoles) throws Exception
+   {
+
+      deleteSecurityRoles(persistedRoles.getAddressMatch());
+      long id = idGenerator.generateID();
+      persistedRoles.setStoreId(id);
+      bindingsJournal.appendAddRecord(id, SECURITY_RECORD, persistedRoles, true);
+      mapPersistedRoles.put(persistedRoles.getAddressMatch(), persistedRoles);
+   }
+
+   public void deleteAddressSetting(SimpleString addressMatch) throws Exception
+   {
+      PersistedAddressSetting oldSetting = mapPersistedAddressSettings.remove(addressMatch);
+      if (oldSetting != null)
+      {
+         bindingsJournal.appendDeleteRecord(oldSetting.getStoreId(), false);
+      }
+      
+   }
+   
+   public void deleteSecurityRoles(SimpleString addressMatch) throws Exception
+   {
+      PersistedRoles oldRoles = mapPersistedRoles.remove(addressMatch);
+      if (oldRoles != null)
+      {
+         bindingsJournal.appendDeleteRecord(oldRoles.getStoreId(), false);
+      }
+   }
+
+
+
    public JournalLoadInformation loadMessageJournal(final PostOffice postOffice,
                                                     final PagingManager pagingManager,
                                                     final ResourceManager resourceManager,
@@ -1028,6 +1103,20 @@
             encoding.setId(id);
             groupingInfos.add(encoding);
          }
+         else if (rec == JournalStorageManager.ADDRESS_SETTING_RECORD)
+         {
+            PersistedAddressSetting setting = new PersistedAddressSetting();
+            setting.decode(buffer);
+            setting.setStoreId(id);
+            mapPersistedAddressSettings.put(setting.getAddressMatch(), setting);
+         }
+         else if (rec == JournalStorageManager.SECURITY_RECORD)
+         {
+            PersistedRoles roles = new PersistedRoles();
+            roles.decode(buffer);
+            roles.setStoreId(id);
+            mapPersistedRoles.put(roles.getAddressMatch(), roles);
+         }
          else
          {
             throw new IllegalStateException("Invalid record type " + rec);
@@ -2051,5 +2140,4 @@
 
    }
 
-
 }

Modified: trunk/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageManager.java
===================================================================
--- trunk/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageManager.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/core/persistence/impl/nullpm/NullStorageManager.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -13,6 +13,8 @@
 
 package org.hornetq.core.persistence.impl.nullpm;
 
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.Executor;
@@ -33,6 +35,8 @@
 import org.hornetq.core.persistence.OperationContext;
 import org.hornetq.core.persistence.QueueBindingInfo;
 import org.hornetq.core.persistence.StorageManager;
+import org.hornetq.core.persistence.config.PersistedAddressSetting;
+import org.hornetq.core.persistence.config.PersistedRoles;
 import org.hornetq.core.postoffice.Binding;
 import org.hornetq.core.postoffice.PostOffice;
 import org.hornetq.core.replication.ReplicationManager;
@@ -388,4 +392,48 @@
    {
    }
 
+   /* (non-Javadoc)
+    * @see org.hornetq.core.persistence.StorageManager#recoverAddressSettings()
+    */
+   public List<PersistedAddressSetting> recoverAddressSettings() throws Exception
+   {
+      return Collections.emptyList();
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.persistence.StorageManager#storeAddressSetting(org.hornetq.core.persistconfig.PersistedAddressSetting)
+    */
+   public void storeAddressSetting(PersistedAddressSetting addressSetting) throws Exception
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.persistence.StorageManager#recoverPersistedRoles()
+    */
+   public List<PersistedRoles> recoverPersistedRoles() throws Exception
+   {
+      return Collections.emptyList();
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.persistence.StorageManager#storeSecurityRoles(org.hornetq.core.persistconfig.PersistedRoles)
+    */
+   public void storeSecurityRoles(PersistedRoles persistedRoles) throws Exception
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.persistence.StorageManager#deleteAddressSetting(org.hornetq.api.core.SimpleString)
+    */
+   public void deleteAddressSetting(SimpleString addressMatch) throws Exception
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.persistence.StorageManager#deleteSecurityRoles(org.hornetq.api.core.SimpleString)
+    */
+   public void deleteSecurityRoles(SimpleString addressMatch) throws Exception
+   {
+   }
+
 }

Modified: trunk/src/main/org/hornetq/core/replication/impl/ReplicationEndpointImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/replication/impl/ReplicationEndpointImpl.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/core/replication/impl/ReplicationEndpointImpl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -76,11 +76,9 @@
    private final HornetQServer server;
 
    private Channel channel;
+   
+   private Journal[] journals;
 
-   private Journal bindingsJournal;
-
-   private Journal messagingJournal;
-
    private JournalStorageManager storage;
 
    private PagingManager pageManager;
@@ -101,6 +99,26 @@
    }
 
    // Public --------------------------------------------------------
+   
+   public void registerJournal(final byte id, final Journal journal)
+   {
+      if (journals == null || id >= journals.length)
+      {
+         Journal[] oldJournals = journals;
+         journals = new Journal[id + 1];
+         
+         if (oldJournals != null)
+         {
+            for (int i = 0 ; i < oldJournals.length; i++)
+            {
+               journals[i] = oldJournals[i];
+            }
+         }
+      }
+      
+      journals[id] = journal;
+   }
+   
    /* 
     * (non-Javadoc)
     * @see org.hornetq.core.remoting.ChannelHandler#handlePacket(org.hornetq.core.remoting.Packet)
@@ -194,8 +212,8 @@
 
       server.getManagementService().setStorageManager(storage);
 
-      bindingsJournal = storage.getBindingsJournal();
-      messagingJournal = storage.getMessageJournal();
+      registerJournal((byte)1, storage.getMessageJournal());
+      registerJournal((byte)0, storage.getBindingsJournal());
 
       // We only need to load internal structures on the backup...
       journalLoadInformation = storage.loadInternalOnly();
@@ -591,16 +609,7 @@
     */
    private Journal getJournal(final byte journalID)
    {
-      Journal journalToUse;
-      if (journalID == (byte)0)
-      {
-         journalToUse = bindingsJournal;
-      }
-      else
-      {
-         journalToUse = messagingJournal;
-      }
-      return journalToUse;
+      return this.journals[journalID];
    }
 
    // Inner classes -------------------------------------------------

Modified: trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -62,6 +62,8 @@
 import org.hornetq.core.persistence.GroupingInfo;
 import org.hornetq.core.persistence.QueueBindingInfo;
 import org.hornetq.core.persistence.StorageManager;
+import org.hornetq.core.persistence.config.PersistedAddressSetting;
+import org.hornetq.core.persistence.config.PersistedRoles;
 import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
 import org.hornetq.core.persistence.impl.nullpm.NullStorageManager;
 import org.hornetq.core.postoffice.Binding;
@@ -111,6 +113,7 @@
 import org.hornetq.utils.ExecutorFactory;
 import org.hornetq.utils.HornetQThreadFactory;
 import org.hornetq.utils.OrderedExecutorFactory;
+import org.hornetq.utils.SecurityFormatter;
 import org.hornetq.utils.UUID;
 import org.hornetq.utils.UUIDGenerator;
 import org.hornetq.utils.VersionLoader;
@@ -258,7 +261,7 @@
       addressSettingsRepository = new HierarchicalObjectRepository<AddressSettings>();
 
       addressSettingsRepository.setDefault(new AddressSettings());
-      
+
       securityRepository = new HierarchicalObjectRepository<Set<Role>>();
 
       securityRepository.setDefault(new HashSet<Role>());
@@ -434,9 +437,9 @@
          {
             memoryManager.stop();
          }
-         
+
          addressSettingsRepository.clear();
-         
+
          securityRepository.clear();
 
          pagingManager = null;
@@ -554,7 +557,7 @@
                                       final boolean xa,
                                       final SessionCallback callback) throws Exception
    {
-      
+
       if (securityStore != null)
       {
          securityStore.authenticate(username, password);
@@ -692,7 +695,11 @@
 
       if (queue.getConsumerCount() != 0)
       {
-         throw new HornetQException(HornetQException.ILLEGAL_STATE, "Cannot delete queue "  + queue.getName() + " on binding " + queueName + " - it has consumers = " + binding.getClass().getName());
+         throw new HornetQException(HornetQException.ILLEGAL_STATE, "Cannot delete queue " + queue.getName() +
+                                                                    " on binding " +
+                                                                    queueName +
+                                                                    " - it has consumers = " +
+                                                                    binding.getClass().getName());
       }
 
       if (session != null)
@@ -975,7 +982,7 @@
                                                                 configuration.isBackup());
 
       // Address settings need to deployed initially, since they're require on paging manager.start()
-      
+
       deployAddressSettingsFromConfiguration();
 
       if (configuration.isFileDeploymentEnabled())
@@ -1120,7 +1127,6 @@
       }
    }
 
-
    private JournalLoadInformation[] loadJournals() throws Exception
    {
       JournalLoadInformation[] journalInfo = new JournalLoadInformation[2];
@@ -1131,6 +1137,8 @@
 
       journalInfo[0] = storageManager.loadBindingJournal(queueBindingInfos, groupingInfos);
 
+      recoverStoredConfigs();
+
       // Set the node id - must be before we load the queues into the postoffice, but after we load the journal
       setNodeID();
 
@@ -1190,6 +1198,33 @@
       return journalInfo;
    }
 
+   /**
+    * @throws Exception
+    */
+   private void recoverStoredConfigs() throws Exception
+   {
+      List<PersistedAddressSetting> adsettings = storageManager.recoverAddressSettings();
+      for (PersistedAddressSetting set : adsettings)
+      {
+         addressSettingsRepository.addMatch(set.getAddressMatch().toString(), set.getSetting());
+      }
+
+      List<PersistedRoles> roles = storageManager.recoverPersistedRoles();
+
+      for (PersistedRoles roleItem : roles)
+      {
+         Set<Role> setRoles = SecurityFormatter.createSecurity(roleItem.getSendRoles(),
+                                                               roleItem.getConsumeRoles(),
+                                                               roleItem.getCreateDurableQueueRoles(),
+                                                               roleItem.getDeleteDurableQueueRoles(),
+                                                               roleItem.getCreateTempQueueRoles(),
+                                                               roleItem.getDeleteTempQueueRoles(),
+                                                               roleItem.getManageRoles());
+
+         securityRepository.addMatch(roleItem.getAddressMatch().toString(), setRoles);
+      }
+   }
+
    private void setNodeID() throws Exception
    {
       if (!configuration.isBackup())

Modified: trunk/src/main/org/hornetq/core/settings/impl/AddressSettings.java
===================================================================
--- trunk/src/main/org/hornetq/core/settings/impl/AddressSettings.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/core/settings/impl/AddressSettings.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -15,9 +15,13 @@
 
 import java.io.Serializable;
 
+import org.hornetq.api.core.HornetQBuffer;
 import org.hornetq.api.core.SimpleString;
+import org.hornetq.core.journal.EncodingSupport;
 import org.hornetq.core.logging.Logger;
 import org.hornetq.core.settings.Mergeable;
+import org.hornetq.utils.BufferHelper;
+import org.hornetq.utils.DataConstants;
 
 /**
  * Configuration settings that are applied on the address level
@@ -25,7 +29,7 @@
  * @author <a href="ataylor at redhat.com">Andy Taylor</a>
  * @author <a href="tim.fox at jboss.com">Tim Fox</a>
  */
-public class AddressSettings implements Mergeable<AddressSettings>, Serializable
+public class AddressSettings implements Mergeable<AddressSettings>, Serializable, EncodingSupport
 {
    private static final long serialVersionUID = 1607502280582336366L;
 
@@ -240,4 +244,250 @@
       }
    }
 
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#decode(org.hornetq.api.core.HornetQBuffer)
+    */
+   public void decode(HornetQBuffer buffer)
+   {
+      SimpleString policyStr = buffer.readNullableSimpleString();
+
+      if (policyStr != null)
+      {
+         addressFullMessagePolicy = AddressFullMessagePolicy.valueOf(policyStr.toString());
+      }
+      else
+      {
+         addressFullMessagePolicy = null;
+      }
+
+      maxSizeBytes = BufferHelper.readNullableLong(buffer);
+
+      pageSizeBytes = BufferHelper.readNullableInteger(buffer);
+
+      dropMessagesWhenFull = BufferHelper.readNullableBoolean(buffer);
+
+      maxDeliveryAttempts = BufferHelper.readNullableInteger(buffer);
+
+      messageCounterHistoryDayLimit = BufferHelper.readNullableInteger(buffer);
+
+      redeliveryDelay = BufferHelper.readNullableLong(buffer);
+
+      deadLetterAddress = buffer.readNullableSimpleString();
+
+      expiryAddress = buffer.readNullableSimpleString();
+
+      lastValueQueue = BufferHelper.readNullableBoolean(buffer);
+
+      redeliveryDelay = BufferHelper.readNullableLong(buffer);
+
+      sendToDLAOnNoRoute = BufferHelper.readNullableBoolean(buffer);
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#getEncodeSize()
+    */
+   public int getEncodeSize()
+   {
+
+      return BufferHelper.sizeOfNullableSimpleString(addressFullMessagePolicy != null ? addressFullMessagePolicy.toString()
+                                                                                     : null) + BufferHelper.sizeOfNullableLong(maxSizeBytes) +
+             BufferHelper.sizeOfNullableInteger(pageSizeBytes) +
+             BufferHelper.sizeOfNullableBoolean(dropMessagesWhenFull) +
+             BufferHelper.sizeOfNullableInteger(maxDeliveryAttempts) +
+             BufferHelper.sizeOfNullableInteger(messageCounterHistoryDayLimit) +
+             BufferHelper.sizeOfNullableLong(redeliveryDelay) +
+             SimpleString.sizeofNullableString(deadLetterAddress) +
+             SimpleString.sizeofNullableString(expiryAddress) +
+             BufferHelper.sizeOfNullableBoolean(lastValueQueue) +
+             BufferHelper.sizeOfNullableLong(redistributionDelay) +
+             BufferHelper.sizeOfNullableBoolean(sendToDLAOnNoRoute);
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#encode(org.hornetq.api.core.HornetQBuffer)
+    */
+   public void encode(HornetQBuffer buffer)
+   {
+      buffer.writeNullableSimpleString(addressFullMessagePolicy != null ? new SimpleString(addressFullMessagePolicy.toString())
+                                                                       : null);
+
+      BufferHelper.writeNullableLong(buffer, maxSizeBytes);
+
+      BufferHelper.writeNullableInteger(buffer, pageSizeBytes);
+
+      BufferHelper.writeNullableBoolean(buffer, dropMessagesWhenFull);
+
+      BufferHelper.writeNullableInteger(buffer, maxDeliveryAttempts);
+
+      BufferHelper.writeNullableInteger(buffer, messageCounterHistoryDayLimit);
+
+      BufferHelper.writeNullableLong(buffer, redeliveryDelay);
+
+      buffer.writeNullableSimpleString(deadLetterAddress);
+
+      buffer.writeNullableSimpleString(expiryAddress);
+
+      BufferHelper.writeNullableBoolean(buffer, lastValueQueue);
+
+      BufferHelper.writeNullableLong(buffer, redistributionDelay);
+
+      BufferHelper.writeNullableBoolean(buffer, sendToDLAOnNoRoute);
+   }
+
+   /* (non-Javadoc)
+    * @see java.lang.Object#hashCode()
+    */
+   @Override
+   public int hashCode()
+   {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((addressFullMessagePolicy == null) ? 0 : addressFullMessagePolicy.hashCode());
+      result = prime * result + ((deadLetterAddress == null) ? 0 : deadLetterAddress.hashCode());
+      result = prime * result + ((dropMessagesWhenFull == null) ? 0 : dropMessagesWhenFull.hashCode());
+      result = prime * result + ((expiryAddress == null) ? 0 : expiryAddress.hashCode());
+      result = prime * result + ((lastValueQueue == null) ? 0 : lastValueQueue.hashCode());
+      result = prime * result + ((maxDeliveryAttempts == null) ? 0 : maxDeliveryAttempts.hashCode());
+      result = prime * result + ((maxSizeBytes == null) ? 0 : maxSizeBytes.hashCode());
+      result = prime * result +
+               ((messageCounterHistoryDayLimit == null) ? 0 : messageCounterHistoryDayLimit.hashCode());
+      result = prime * result + ((pageSizeBytes == null) ? 0 : pageSizeBytes.hashCode());
+      result = prime * result + ((redeliveryDelay == null) ? 0 : redeliveryDelay.hashCode());
+      result = prime * result + ((redistributionDelay == null) ? 0 : redistributionDelay.hashCode());
+      result = prime * result + ((sendToDLAOnNoRoute == null) ? 0 : sendToDLAOnNoRoute.hashCode());
+      return result;
+   }
+
+   /* (non-Javadoc)
+    * @see java.lang.Object#equals(java.lang.Object)
+    */
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (this == obj)
+         return true;
+      if (obj == null)
+         return false;
+      if (getClass() != obj.getClass())
+         return false;
+      AddressSettings other = (AddressSettings)obj;
+      if (addressFullMessagePolicy == null)
+      {
+         if (other.addressFullMessagePolicy != null)
+            return false;
+      }
+      else if (!addressFullMessagePolicy.equals(other.addressFullMessagePolicy))
+         return false;
+      if (deadLetterAddress == null)
+      {
+         if (other.deadLetterAddress != null)
+            return false;
+      }
+      else if (!deadLetterAddress.equals(other.deadLetterAddress))
+         return false;
+      if (dropMessagesWhenFull == null)
+      {
+         if (other.dropMessagesWhenFull != null)
+            return false;
+      }
+      else if (!dropMessagesWhenFull.equals(other.dropMessagesWhenFull))
+         return false;
+      if (expiryAddress == null)
+      {
+         if (other.expiryAddress != null)
+            return false;
+      }
+      else if (!expiryAddress.equals(other.expiryAddress))
+         return false;
+      if (lastValueQueue == null)
+      {
+         if (other.lastValueQueue != null)
+            return false;
+      }
+      else if (!lastValueQueue.equals(other.lastValueQueue))
+         return false;
+      if (maxDeliveryAttempts == null)
+      {
+         if (other.maxDeliveryAttempts != null)
+            return false;
+      }
+      else if (!maxDeliveryAttempts.equals(other.maxDeliveryAttempts))
+         return false;
+      if (maxSizeBytes == null)
+      {
+         if (other.maxSizeBytes != null)
+            return false;
+      }
+      else if (!maxSizeBytes.equals(other.maxSizeBytes))
+         return false;
+      if (messageCounterHistoryDayLimit == null)
+      {
+         if (other.messageCounterHistoryDayLimit != null)
+            return false;
+      }
+      else if (!messageCounterHistoryDayLimit.equals(other.messageCounterHistoryDayLimit))
+         return false;
+      if (pageSizeBytes == null)
+      {
+         if (other.pageSizeBytes != null)
+            return false;
+      }
+      else if (!pageSizeBytes.equals(other.pageSizeBytes))
+         return false;
+      if (redeliveryDelay == null)
+      {
+         if (other.redeliveryDelay != null)
+            return false;
+      }
+      else if (!redeliveryDelay.equals(other.redeliveryDelay))
+         return false;
+      if (redistributionDelay == null)
+      {
+         if (other.redistributionDelay != null)
+            return false;
+      }
+      else if (!redistributionDelay.equals(other.redistributionDelay))
+         return false;
+      if (sendToDLAOnNoRoute == null)
+      {
+         if (other.sendToDLAOnNoRoute != null)
+            return false;
+      }
+      else if (!sendToDLAOnNoRoute.equals(other.sendToDLAOnNoRoute))
+         return false;
+      return true;
+   }
+
+   /* (non-Javadoc)
+    * @see java.lang.Object#toString()
+    */
+   @Override
+   public String toString()
+   {
+      return "AddressSettings [addressFullMessagePolicy=" + addressFullMessagePolicy +
+             ", deadLetterAddress=" +
+             deadLetterAddress +
+             ", dropMessagesWhenFull=" +
+             dropMessagesWhenFull +
+             ", expiryAddress=" +
+             expiryAddress +
+             ", lastValueQueue=" +
+             lastValueQueue +
+             ", maxDeliveryAttempts=" +
+             maxDeliveryAttempts +
+             ", maxSizeBytes=" +
+             maxSizeBytes +
+             ", messageCounterHistoryDayLimit=" +
+             messageCounterHistoryDayLimit +
+             ", pageSizeBytes=" +
+             pageSizeBytes +
+             ", redeliveryDelay=" +
+             redeliveryDelay +
+             ", redistributionDelay=" +
+             redistributionDelay +
+             ", sendToDLAOnNoRoute=" +
+             sendToDLAOnNoRoute +
+             "]";
+   }
+
 }

Modified: trunk/src/main/org/hornetq/jms/management/impl/JMSConnectionFactoryControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/management/impl/JMSConnectionFactoryControlImpl.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/jms/management/impl/JMSConnectionFactoryControlImpl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -21,10 +21,10 @@
 
 import org.hornetq.api.core.Pair;
 import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.ClientSessionFactory;
-import org.hornetq.jms.client.HornetQConnectionFactory;
 import org.hornetq.api.jms.management.ConnectionFactoryControl;
 import org.hornetq.core.management.impl.MBeanInfoHelper;
+import org.hornetq.jms.client.HornetQConnectionFactory;
+import org.hornetq.jms.server.JMSServerManager;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -40,31 +40,31 @@
 
    private final HornetQConnectionFactory cf;
 
-   private final List<String> bindings;
-
    private final String name;
+   
+   private final JMSServerManager jmsManager;
 
    // Static --------------------------------------------------------
 
    // Constructors --------------------------------------------------
 
    public JMSConnectionFactoryControlImpl(final HornetQConnectionFactory cf,
-                                          final String name,
-                                          final List<String> bindings) throws NotCompliantMBeanException
+                                          final JMSServerManager jmsManager,
+                                          final String name) throws NotCompliantMBeanException
    {
       super(ConnectionFactoryControl.class);
       this.cf = cf;
       this.name = name;
-      this.bindings = bindings;
+      this.jmsManager = jmsManager;
    }
 
    // Public --------------------------------------------------------
 
    // ManagedConnectionFactoryMBean implementation ------------------
 
-   public List<String> getBindings()
+   public List<String> getJNDIBindings()
    {
-      return bindings;
+      return jmsManager.getJNDIOnConnectionFactory(name);
    }
 
    public String getClientID()

Modified: trunk/src/main/org/hornetq/jms/management/impl/JMSQueueControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/management/impl/JMSQueueControlImpl.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/jms/management/impl/JMSQueueControlImpl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -13,6 +13,7 @@
 
 package org.hornetq.jms.management.impl;
 
+import java.util.List;
 import java.util.Map;
 
 import javax.management.MBeanInfo;
@@ -30,6 +31,7 @@
 import org.hornetq.jms.client.HornetQDestination;
 import org.hornetq.jms.client.HornetQMessage;
 import org.hornetq.jms.client.SelectorTranslator;
+import org.hornetq.jms.server.JMSServerManager;
 import org.hornetq.utils.json.JSONArray;
 import org.hornetq.utils.json.JSONObject;
 
@@ -48,11 +50,11 @@
    // Attributes ----------------------------------------------------
 
    private final HornetQDestination managedQueue;
+   
+   private final JMSServerManager jmsServerManager;
 
    private final QueueControl coreQueueControl;
 
-   private final String binding;
-
    private final MessageCounter counter;
 
    // Static --------------------------------------------------------
@@ -85,13 +87,13 @@
 
    public JMSQueueControlImpl(final HornetQDestination managedQueue,
                               final QueueControl coreQueueControl,
-                              final String jndiBinding,
+                              final JMSServerManager jmsServerManager,
                               final MessageCounter counter) throws Exception
    {
       super(JMSQueueControl.class);
       this.managedQueue = managedQueue;
+      this.jmsServerManager = jmsServerManager;
       this.coreQueueControl = coreQueueControl;
-      binding = jndiBinding;
       this.counter = counter;
    }
 
@@ -144,11 +146,6 @@
       return coreQueueControl.isDurable();
    }
 
-   public String getJNDIBinding()
-   {
-      return binding;
-   }
-
    public String getDeadLetterAddress()
    {
       return coreQueueControl.getDeadLetterAddress();
@@ -169,6 +166,20 @@
       coreQueueControl.setExpiryAddress(expiryAddres);
    }
 
+   /* (non-Javadoc)
+    * @see org.hornetq.api.jms.management.JMSQueueControl#addJNDI(java.lang.String)
+    */
+   public void addJNDI(String jndi) throws Exception
+   {
+      jmsServerManager.addQueueToJndi(managedQueue.getName(), jndi);
+   }
+   
+   public List<String> getJNDIBindings()
+   {
+      return jmsServerManager.getJNDIOnQueue(managedQueue.getName());
+   }
+
+
    public boolean removeMessage(final String messageID) throws Exception
    {
       String filter = JMSQueueControlImpl.createFilterForJMSMessageID(messageID);
@@ -355,7 +366,7 @@
                            MBeanInfoHelper.getMBeanOperationsInfo(JMSQueueControl.class),
                            info.getNotifications());
    }
-   
+
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------

Modified: trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -283,7 +283,7 @@
 
       try
       {
-         boolean created = server.createQueue(name, jndiBinding, null, true);
+         boolean created = server.createQueue(name, null, true, jndiBinding);
          if (created)
          {
             sendNotification(NotificationType.QUEUE_CREATED, name);

Modified: trunk/src/main/org/hornetq/jms/management/impl/JMSTopicControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/management/impl/JMSTopicControlImpl.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/jms/management/impl/JMSTopicControlImpl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -34,6 +34,7 @@
 import org.hornetq.jms.client.HornetQDestination;
 import org.hornetq.jms.client.HornetQMessage;
 import org.hornetq.jms.client.SelectorTranslator;
+import org.hornetq.jms.server.JMSServerManager;
 import org.hornetq.utils.json.JSONArray;
 import org.hornetq.utils.json.JSONObject;
 
@@ -53,11 +54,11 @@
 
    private final HornetQDestination managedTopic;
 
-   private final String binding;
-
    private final AddressControl addressControl;
 
    private final ManagementService managementService;
+   
+   private final JMSServerManager jmsServerManager;
 
    // Static --------------------------------------------------------
 
@@ -70,19 +71,33 @@
    // Constructors --------------------------------------------------
 
    public JMSTopicControlImpl(final HornetQDestination topic,
+                              final JMSServerManager jmsServerManager,
                               final AddressControl addressControl,
-                              final String jndiBinding,
                               final ManagementService managementService) throws Exception
    {
       super(TopicControl.class);
+      this.jmsServerManager = jmsServerManager;
       managedTopic = topic;
       this.addressControl = addressControl;
-      binding = jndiBinding;
       this.managementService = managementService;
    }
 
    // TopicControlMBean implementation ------------------------------
+   
+   /* (non-Javadoc)
+    * @see org.hornetq.api.jms.management.JMSQueueControl#addJNDI(java.lang.String)
+    */
+   public void addJNDI(String jndi) throws Exception
+   {
+      jmsServerManager.addQueueToJndi(managedTopic.getName(), jndi);
+   }
+   
+   public List<String> getJNDIBindings()
+   {
+      return jmsServerManager.getJNDIOnQueue(managedTopic.getName());
+   }
 
+
    public String getName()
    {
       return managedTopic.getName();
@@ -98,11 +113,6 @@
       return managedTopic.getAddress();
    }
 
-   public String getJNDIBinding()
-   {
-      return binding;
-   }
-
    public int getMessageCount()
    {
       return getMessageCount(DurabilityType.ALL);

Added: trunk/src/main/org/hornetq/jms/persistence/JMSStorageManager.java
===================================================================
--- trunk/src/main/org/hornetq/jms/persistence/JMSStorageManager.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/jms/persistence/JMSStorageManager.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.persistence;
+
+import java.util.List;
+
+import org.hornetq.core.server.HornetQComponent;
+import org.hornetq.jms.persistence.config.PersistedConnectionFactory;
+import org.hornetq.jms.persistence.config.PersistedDestination;
+import org.hornetq.jms.persistence.config.PersistedJNDI;
+import org.hornetq.jms.persistence.config.PersistedType;
+
+/**
+ * A JMSPersistence
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public interface JMSStorageManager extends HornetQComponent
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   void storeDestination(PersistedDestination destination) throws Exception;
+
+   void deleteDestination(PersistedType type, String name) throws Exception;
+   
+   List<PersistedDestination> recoverDestinations();
+   
+   void deleteConnectionFactory(String connectionFactory) throws Exception;
+   
+   void storeConnectionFactory(PersistedConnectionFactory connectionFactory) throws Exception;
+   
+   List<PersistedConnectionFactory> recoverConnectionFactories();
+   
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+   void addJNDI(PersistedType type, String name, String address) throws Exception;
+   
+   List<PersistedJNDI> recoverPersistedJNDI() throws Exception;
+   
+   void deleteJNDI(PersistedType type, String name, String address) throws Exception;
+   
+   void deleteJNDI(PersistedType type, String name) throws Exception;
+}

Added: trunk/src/main/org/hornetq/jms/persistence/config/PersistedConnectionFactory.java
===================================================================
--- trunk/src/main/org/hornetq/jms/persistence/config/PersistedConnectionFactory.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/jms/persistence/config/PersistedConnectionFactory.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.persistence.config;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.core.journal.EncodingSupport;
+import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
+import org.hornetq.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
+
+/**
+ * A PersistedConnectionFactory
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class PersistedConnectionFactory implements EncodingSupport
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private long id;
+
+   private ConnectionFactoryConfiguration config;
+
+   public PersistedConnectionFactory()
+   {
+      super();
+   }
+
+   /**
+    * @param id
+    * @param config
+    */
+   public PersistedConnectionFactory(final ConnectionFactoryConfiguration config)
+   {
+      super();
+      this.config = config;
+   }
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   /**
+    * @return the id
+    */
+   public long getId()
+   {
+      return id;
+   }
+
+   public void setId(final long id)
+   {
+      this.id = id;
+   }
+   
+   public String getName()
+   {
+      return config.getName();
+   }
+
+   /**
+    * @return the config
+    */
+   public ConnectionFactoryConfiguration getConfig()
+   {
+      return config;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#decode(org.hornetq.api.core.HornetQBuffer)
+    */
+   public void decode(final HornetQBuffer buffer)
+   {
+      config = new ConnectionFactoryConfigurationImpl();
+      config.decode(buffer);
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#encode(org.hornetq.api.core.HornetQBuffer)
+    */
+   public void encode(final HornetQBuffer buffer)
+   {
+      config.encode(buffer);
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#getEncodeSize()
+    */
+   public int getEncodeSize()
+   {
+      return config.getEncodeSize();
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Added: trunk/src/main/org/hornetq/jms/persistence/config/PersistedDestination.java
===================================================================
--- trunk/src/main/org/hornetq/jms/persistence/config/PersistedDestination.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/jms/persistence/config/PersistedDestination.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.persistence.config;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.core.journal.EncodingSupport;
+import org.hornetq.utils.BufferHelper;
+import org.hornetq.utils.DataConstants;
+
+/**
+ * A PersistedDestination
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ */
+public class PersistedDestination implements EncodingSupport
+{
+
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private long id;
+
+   private PersistedType type;
+
+   private String name;
+
+   private String selector;
+
+   private boolean durable;
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public PersistedDestination()
+   {
+   }
+   
+   public PersistedDestination(final PersistedType type, final String name)
+   {
+      this(type, name, null, true);
+   }
+
+   public PersistedDestination(final PersistedType type, final String name, final String selector, final boolean durable)
+   {
+      this.type = type;
+      this.name = name;
+      this.selector = selector;
+      this.durable = durable;
+   }
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+
+   public long getId()
+   {
+      return id;
+   }
+
+   public void setId(final long id)
+   {
+      this.id = id;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public PersistedType getType()
+   {
+      return type;
+   }
+
+   public String getSelector()
+   {
+      return selector;
+   }
+
+   public boolean isDurable()
+   {
+      return durable;
+   }
+
+   public int getEncodeSize()
+   {
+      return DataConstants.SIZE_BYTE +
+            BufferHelper.sizeOfSimpleString(name) +
+            BufferHelper.sizeOfNullableSimpleString(selector) +
+            DataConstants.SIZE_BOOLEAN;
+   }
+
+   public void encode(final HornetQBuffer buffer)
+   {
+      buffer.writeByte(type.getType());
+      buffer.writeString(name);
+      buffer.writeNullableString(selector);
+      buffer.writeBoolean(durable);
+   }
+
+   public void decode(final HornetQBuffer buffer)
+   {
+      type = PersistedType.getType(buffer.readByte());
+      name = buffer.readString();
+      selector = buffer.readNullableString();
+      durable = buffer.readBoolean();
+   }
+}

Added: trunk/src/main/org/hornetq/jms/persistence/config/PersistedJNDI.java
===================================================================
--- trunk/src/main/org/hornetq/jms/persistence/config/PersistedJNDI.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/jms/persistence/config/PersistedJNDI.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -0,0 +1,176 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.persistence.config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.core.journal.EncodingSupport;
+import org.hornetq.utils.BufferHelper;
+import org.hornetq.utils.DataConstants;
+
+/**
+ * A PersistedJNDI
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class PersistedJNDI implements EncodingSupport
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+   
+   private long id;
+   
+   private PersistedType type;
+   
+   private String name;
+   
+   private ArrayList<String> jndi = new ArrayList<String>();
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public PersistedJNDI()
+   {
+   }
+
+   /**
+    * @param type
+    * @param name
+    */
+   public PersistedJNDI(PersistedType type, String name)
+   {
+      super();
+      this.type = type;
+      this.name = name;
+   }
+
+   // Public --------------------------------------------------------
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#decode(org.hornetq.api.core.HornetQBuffer)
+    */
+   public void decode(HornetQBuffer buffer)
+   {
+      type = PersistedType.getType(buffer.readByte());
+      name = buffer.readSimpleString().toString();
+      int jndiArraySize = buffer.readInt();
+      jndi = new ArrayList<String>(jndiArraySize);
+      
+      for (int i = 0 ; i < jndiArraySize; i++)
+      {
+         jndi.add(buffer.readSimpleString().toString());
+      }
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#encode(org.hornetq.api.core.HornetQBuffer)
+    */
+   public void encode(HornetQBuffer buffer)
+   {
+      buffer.writeByte(type.getType());
+      BufferHelper.writeAsSimpleString(buffer, name);
+      buffer.writeInt(jndi.size());
+      for (String jndiEl : jndi)
+      {
+         BufferHelper.writeAsSimpleString(buffer, jndiEl);
+      }
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#getEncodeSize()
+    */
+   public int getEncodeSize()
+   {
+      return DataConstants.SIZE_BYTE +
+             BufferHelper.sizeOfSimpleString(name) +
+             sizeOfJNDI();
+   }
+   
+   private int sizeOfJNDI()
+   {
+      int size = DataConstants.SIZE_INT; // for the number of elements written
+      
+      for (String str : jndi)
+      {
+         size += BufferHelper.sizeOfSimpleString(str);
+      }
+      
+      return size;
+   }
+
+   /**
+    * @return the id
+    */
+   public long getId()
+   {
+      return id;
+   }
+
+   /**
+    * @param id the id to set
+    */
+   public void setId(long id)
+   {
+      this.id = id;
+   }
+
+   /**
+    * @return the type
+    */
+   public PersistedType getType()
+   {
+      return type;
+   }
+
+   /**
+    * @return the name
+    */
+   public String getName()
+   {
+      return name;
+   }
+   
+   /**
+    * @return the jndi
+    */
+   public List<String> getJndi()
+   {
+      return jndi;
+   }
+   
+   public void addJNDI(String address)
+   {
+      jndi.add(address);
+   }
+   
+   public void deleteJNDI(String address)
+   {
+      jndi.remove(address);
+   }
+   
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Added: trunk/src/main/org/hornetq/jms/persistence/config/PersistedType.java
===================================================================
--- trunk/src/main/org/hornetq/jms/persistence/config/PersistedType.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/jms/persistence/config/PersistedType.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.persistence.config;
+
+/**
+ * A PersistedType
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public enum PersistedType
+{
+    ConnectionFactory, Topic, Queue;
+    
+    public byte getType()
+    {
+       switch (this)
+       {
+          case ConnectionFactory: return 0;
+          case Topic: return 1;
+          case Queue: return 2;
+          default: return -1;
+       }
+    }
+    
+    public static PersistedType getType(byte type)
+    {
+       switch (type)
+       {
+          case 0: return ConnectionFactory;
+          case 1: return Topic;
+          case 2: return Queue;
+          default: return null;
+       }
+    }
+}

Added: trunk/src/main/org/hornetq/jms/persistence/impl/journal/JournalJMSStorageManagerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/persistence/impl/journal/JournalJMSStorageManagerImpl.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/jms/persistence/impl/journal/JournalJMSStorageManagerImpl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -0,0 +1,385 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.persistence.impl.journal;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.api.core.HornetQBuffers;
+import org.hornetq.api.core.Pair;
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.journal.Journal;
+import org.hornetq.core.journal.PreparedTransactionInfo;
+import org.hornetq.core.journal.RecordInfo;
+import org.hornetq.core.journal.SequentialFileFactory;
+import org.hornetq.core.journal.impl.JournalImpl;
+import org.hornetq.core.journal.impl.NIOSequentialFileFactory;
+import org.hornetq.core.replication.ReplicationManager;
+import org.hornetq.core.replication.impl.ReplicatedJournal;
+import org.hornetq.core.server.JournalType;
+import org.hornetq.jms.persistence.JMSStorageManager;
+import org.hornetq.jms.persistence.config.PersistedConnectionFactory;
+import org.hornetq.jms.persistence.config.PersistedDestination;
+import org.hornetq.jms.persistence.config.PersistedJNDI;
+import org.hornetq.jms.persistence.config.PersistedType;
+import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
+import org.hornetq.utils.IDGenerator;
+
+/**
+ * A JournalJMSStorageManagerImpl
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class JournalJMSStorageManagerImpl implements JMSStorageManager
+{
+
+   // Constants -----------------------------------------------------
+
+   private final byte CF_RECORD = 1;
+
+   private final byte DESTINATION_RECORD = 2;
+   
+   private final byte JNDI_RECORD = 3;
+   
+   // Attributes ----------------------------------------------------
+
+   private final IDGenerator idGenerator;
+   
+   private final String bindingsDir;
+   
+   private final boolean createBindingsDir;
+   
+   private final Journal jmsJournal;
+
+   private volatile boolean started;
+   
+   private Map<String, PersistedConnectionFactory> mapFactories = new ConcurrentHashMap<String, PersistedConnectionFactory>();
+
+   private Map<Pair<PersistedType, String>, PersistedDestination> destinations = new ConcurrentHashMap<Pair<PersistedType, String>, PersistedDestination>();
+   
+   private Map<Pair<PersistedType, String>, PersistedJNDI> mapJNDI = new ConcurrentHashMap<Pair<PersistedType, String>, PersistedJNDI>();
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+   public JournalJMSStorageManagerImpl(final IDGenerator idGenerator,
+                                       final Configuration config,
+                                final ReplicationManager replicator)
+   {
+      if (config.getJournalType() != JournalType.NIO && config.getJournalType() != JournalType.ASYNCIO)
+      {
+         throw new IllegalArgumentException("Only NIO and AsyncIO are supported journals");
+      }
+
+      bindingsDir = config.getBindingsDirectory();
+
+      if (bindingsDir == null)
+      {
+         throw new NullPointerException("bindings-dir is null");
+      }
+
+      createBindingsDir = config.isCreateBindingsDir();
+
+      SequentialFileFactory bindingsJMS = new NIOSequentialFileFactory(bindingsDir);
+
+      Journal localJMS = new JournalImpl(1024 * 1024,
+                                              2,
+                                              config.getJournalCompactMinFiles(),
+                                              config.getJournalCompactPercentage(),
+                                              bindingsJMS,
+                                              "hornetq-jms-config",
+                                              "jms",
+                                              1);
+
+      if (replicator != null)
+      {
+         jmsJournal = new ReplicatedJournal((byte)2, localJMS, replicator);
+      }
+      else
+      {
+         jmsJournal = localJMS;
+      }
+      
+      this.idGenerator = idGenerator;
+   }
+
+
+   // Public --------------------------------------------------------
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.persistence.JMSStorageManager#recoverConnectionFactories()
+    */
+   public List<PersistedConnectionFactory> recoverConnectionFactories()
+   {
+      List<PersistedConnectionFactory> cfs = new ArrayList<PersistedConnectionFactory>(mapFactories.size());
+      cfs.addAll(mapFactories.values());
+      return cfs;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.persistence.JMSStorageManager#storeConnectionFactory(org.hornetq.jms.persistence.PersistedConnectionFactory)
+    */
+   public void storeConnectionFactory(final PersistedConnectionFactory connectionFactory) throws Exception
+   {
+      deleteConnectionFactory(connectionFactory.getName());
+      long id = idGenerator.generateID();
+      connectionFactory.setId(id);
+      jmsJournal.appendAddRecord(id, CF_RECORD, connectionFactory, true);
+      mapFactories.put(connectionFactory.getName(), connectionFactory);
+   }
+   
+   public void deleteConnectionFactory(final String cfName) throws Exception
+   {
+      PersistedConnectionFactory oldCF = mapFactories.remove(cfName);
+      if (oldCF != null)
+      {
+         jmsJournal.appendDeleteRecord(oldCF.getId(), false);
+      }
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.persistence.JMSStorageManager#recoverDestinations()
+    */
+   public List<PersistedDestination> recoverDestinations()
+   {
+      List<PersistedDestination> destinations = new ArrayList<PersistedDestination>(this.destinations.size());
+      destinations.addAll(this.destinations.values());
+      return destinations;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.persistence.JMSStorageManager#storeDestination(org.hornetq.jms.persistence.PersistedDestination)
+    */
+   public void storeDestination(final PersistedDestination destination) throws Exception
+   {
+      deleteDestination(destination.getType(), destination.getName());
+      long id = idGenerator.generateID();
+      destination.setId(id);
+      jmsJournal.appendAddRecord(id, DESTINATION_RECORD, destination, true);
+      destinations.put(new Pair<PersistedType, String>(destination.getType(), destination.getName()), destination);
+   }
+   
+   public List<PersistedJNDI> recoverPersistedJNDI() throws Exception
+   {
+      ArrayList<PersistedJNDI> list = new ArrayList<PersistedJNDI>();
+      
+      list.addAll(mapJNDI.values());
+      
+      return list;
+   }
+   
+   public void addJNDI(PersistedType type, String name, String address) throws Exception
+   {
+      Pair<PersistedType, String> key = new Pair<PersistedType, String>(type, name);
+
+      long tx = idGenerator.generateID();
+      
+      PersistedJNDI currentJNDI = mapJNDI.get(key);
+      if (currentJNDI != null)
+      {
+         jmsJournal.appendDeleteRecordTransactional(tx, currentJNDI.getId());
+      }
+      else
+      {
+         currentJNDI = new PersistedJNDI(type, name);
+      }
+      
+      currentJNDI.addJNDI(address);
+
+      long newId = idGenerator.generateID();
+      
+      currentJNDI.setId(newId);
+      
+      jmsJournal.appendAddRecordTransactional(tx, newId, JNDI_RECORD, currentJNDI);
+      
+      jmsJournal.appendCommitRecord(tx, true);
+   }
+   
+   public void deleteJNDI(PersistedType type, String name, String address) throws Exception
+   {
+      Pair<PersistedType, String> key = new Pair<PersistedType, String>(type, name);
+
+      long tx = idGenerator.generateID();
+      
+      PersistedJNDI currentJNDI = mapJNDI.get(key);
+      if (currentJNDI == null)
+      {
+         return;
+      }
+      else
+      {
+         jmsJournal.appendDeleteRecordTransactional(tx, currentJNDI.getId());
+      }
+      
+      currentJNDI.deleteJNDI(address);
+      
+      if (currentJNDI.getJndi().size() == 0)
+      {
+         mapJNDI.remove(key);
+      }
+      else
+      {
+         long newId = idGenerator.generateID();
+         currentJNDI.setId(newId);
+         jmsJournal.appendAddRecordTransactional(tx, newId, JNDI_RECORD, currentJNDI);
+      }
+      
+      jmsJournal.appendCommitRecord(tx, true);
+   }
+
+   
+   public void deleteJNDI(PersistedType type, String name) throws Exception
+   {
+      Pair<PersistedType, String> key = new Pair<PersistedType, String>(type, name);
+      
+      PersistedJNDI currentJNDI = mapJNDI.remove(key);
+
+      if (currentJNDI == null)
+      {
+         return;
+      }
+      else
+      {
+         jmsJournal.appendDeleteRecord(currentJNDI.getId(), true);
+      }
+   }
+
+   public void deleteDestination(final PersistedType type, final String name) throws Exception
+   {
+      PersistedDestination destination = destinations.get(new Pair<PersistedType, String>(type, name));
+      if(destination != null)
+      {
+         jmsJournal.appendDeleteRecord(destination.getId(), false);
+      }
+      deleteJNDI(type, name);
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.server.HornetQComponent#isStarted()
+    */
+   public boolean isStarted()
+   {
+      return started;
+   }
+
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.server.HornetQComponent#start()
+    */
+   public void start() throws Exception
+   {
+
+      checkAndCreateDir(bindingsDir, createBindingsDir);
+
+      jmsJournal.start();
+      
+      load();
+      
+      started = true;
+   }
+
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.server.HornetQComponent#stop()
+    */
+   public void stop() throws Exception
+   {
+      jmsJournal.stop();
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   private void load() throws Exception
+   {
+      mapFactories.clear();
+      
+      List<RecordInfo> data = new ArrayList<RecordInfo>();
+      
+      ArrayList<PreparedTransactionInfo> list = new ArrayList<PreparedTransactionInfo>();
+      
+      jmsJournal.load(data, list, null);
+      
+      for (RecordInfo record : data)
+      {
+         long id = record.id;
+
+         HornetQBuffer buffer = HornetQBuffers.wrappedBuffer(record.data);
+
+         byte rec = record.getUserRecordType();
+         
+         if (rec == CF_RECORD)
+         {
+            PersistedConnectionFactory cf = new PersistedConnectionFactory();
+            cf.decode(buffer);
+            cf.setId(id);
+            mapFactories.put(cf.getName(), cf);
+         }
+         else if(rec == DESTINATION_RECORD)
+         {
+            PersistedDestination destination = new PersistedDestination();
+            destination.decode(buffer);
+            destination.setId(id);
+            destinations.put(new Pair<PersistedType, String>(destination.getType(), destination.getName()), destination);
+         }
+         else if (rec == JNDI_RECORD)
+         {
+            PersistedJNDI jndi = new PersistedJNDI();
+            jndi.decode(buffer);
+            jndi.setId(id);
+            Pair<PersistedType, String> key = new Pair<PersistedType, String>(jndi.getType(), jndi.getName());
+            mapJNDI.put(key, jndi);
+         }
+         else
+         {
+            throw new IllegalStateException("Invalid record type " + rec);
+         }
+         
+      }
+      
+   }
+
+   private void checkAndCreateDir(final String dir, final boolean create)
+   {
+      File f = new File(dir);
+
+      if (!f.exists())
+      {
+         if (create)
+         {
+            if (!f.mkdirs())
+            {
+               throw new IllegalStateException("Failed to create directory " + dir);
+            }
+         }
+         else
+         {
+            throw new IllegalArgumentException("Directory " + dir + " does not exist and will not create it");
+         }
+      }
+   }
+
+
+   // Inner classes -------------------------------------------------
+
+}

Added: trunk/src/main/org/hornetq/jms/persistence/impl/nullpm/NullJMSStorageManagerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/persistence/impl/nullpm/NullJMSStorageManagerImpl.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/jms/persistence/impl/nullpm/NullJMSStorageManagerImpl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.persistence.impl.nullpm;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.hornetq.jms.persistence.JMSStorageManager;
+import org.hornetq.jms.persistence.config.PersistedConnectionFactory;
+import org.hornetq.jms.persistence.config.PersistedDestination;
+import org.hornetq.jms.persistence.config.PersistedJNDI;
+import org.hornetq.jms.persistence.config.PersistedType;
+
+/**
+ * A NullJMSStorageManagerImpl
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class NullJMSStorageManagerImpl implements JMSStorageManager
+{
+
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.persistence.JMSStorageManager#deleteConnectionFactory(java.lang.String)
+    */
+   public void deleteConnectionFactory(String connectionFactory) throws Exception
+   {
+      
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.persistence.JMSStorageManager#recoverConnectionFactories()
+    */
+   public List<PersistedConnectionFactory> recoverConnectionFactories()
+   {
+      return Collections.emptyList();
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.persistence.JMSStorageManager#recoverDestinations()
+    */
+   public List<PersistedDestination> recoverDestinations()
+   {
+      return Collections.emptyList();
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.persistence.JMSStorageManager#storeConnectionFactory(org.hornetq.jms.persistence.PersistedConnectionFactory)
+    */
+   public void storeConnectionFactory(PersistedConnectionFactory connectionFactory) throws Exception
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.persistence.JMSStorageManager#storeDestination(org.hornetq.jms.persistence.PersistedDestination)
+    */
+   public void storeDestination(PersistedDestination destination)
+   {
+   }
+
+    /* (non-Javadoc)
+    * @see org.hornetq.jms.persistence.JMSStorageManager#deleteDestination (org.hornetq.jms.persistence.PersistedDestination)
+    */
+   public void deleteDestination(String name) throws Exception
+   {
+
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.server.HornetQComponent#isStarted()
+    */
+   public boolean isStarted()
+   {
+      return true;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.server.HornetQComponent#start()
+    */
+   public void start() throws Exception
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.server.HornetQComponent#stop()
+    */
+   public void stop() throws Exception
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.persistence.JMSStorageManager#addJNDI(org.hornetq.jms.persistence.PersistedType, java.lang.String, java.lang.String)
+    */
+   public void addJNDI(PersistedType type, String name, String address) throws Exception
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.persistence.JMSStorageManager#deleteJNDI(org.hornetq.jms.persistence.PersistedType, java.lang.String, java.lang.String)
+    */
+   public void deleteJNDI(PersistedType type, String name, String address) throws Exception
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.persistence.JMSStorageManager#deleteDestination(org.hornetq.jms.persistence.PersistedType, java.lang.String)
+    */
+   public void deleteDestination(PersistedType type, String name) throws Exception
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.persistence.JMSStorageManager#deleteJNDI(org.hornetq.jms.persistence.PersistedType, java.lang.String)
+    */
+   public void deleteJNDI(PersistedType type, String name) throws Exception
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.persistence.JMSStorageManager#recoverPersistedJNDI()
+    */
+   public List<PersistedJNDI> recoverPersistedJNDI() throws Exception
+   {
+      return Collections.emptyList();
+   }
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Modified: trunk/src/main/org/hornetq/jms/server/JMSServerManager.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/JMSServerManager.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/jms/server/JMSServerManager.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -49,8 +49,6 @@
     * 
     * @param queueName
     *           The name of the queue to create
-    * @param jndiBinding
-    *           the name of the binding for JNDI
     * @param selectorString
     * @param durable
     * @return true if the queue is created or if it existed and was added to
@@ -58,7 +56,9 @@
     * @throws Exception
     *            if problems were encountered creating the queue.
     */
-   boolean createQueue(String queueName, String jndiBinding, String selectorString, boolean durable) throws Exception;
+   boolean createQueue(String queueName, String selectorString, boolean durable, String ...jndi) throws Exception;
+   
+   boolean addQueueToJndi(final String queueName, final String jndiBinding) throws Exception;
 
    /**
     * Creates a JMS Topic
@@ -72,10 +72,10 @@
     * @throws Exception
     *            if a problem occurred creating the topic
     */
-   boolean createTopic(String topicName, String jndiBinding) throws Exception;
+   boolean createTopic(String topicName, String ... jndi) throws Exception;
 
    /**
-    * Remove the destination from JNDI.
+    * Remove the topic from JNDI.
     * Calling this method does <em>not</em> destroy the destination.
     * 
     * @param name
@@ -84,9 +84,45 @@
     * @throws Exception
     *            if a problem occurred removing the destination
     */
-   boolean undeployDestination(String name) throws Exception;
+   boolean removeTopicFromJNDI(String name, String jndi) throws Exception;
 
    /**
+    * Remove the topic from JNDI.
+    * Calling this method does <em>not</em> destroy the destination.
+    * 
+    * @param name
+    *           the name of the destination to remove from JNDI
+    * @return true if removed
+    * @throws Exception
+    *            if a problem occurred removing the destination
+    */
+   boolean removeTopicFromJNDI(String name) throws Exception;
+
+   /**
+    * Remove the queue from JNDI.
+    * Calling this method does <em>not</em> destroy the destination.
+    * 
+    * @param name
+    *           the name of the destination to remove from JNDI
+    * @return true if removed
+    * @throws Exception
+    *            if a problem occurred removing the destination
+    */
+   boolean removeQueueFromJNDI(String name, String jndi) throws Exception;
+
+   /**
+    * Remove the queue from JNDI.
+    * Calling this method does <em>not</em> destroy the destination.
+    * 
+    * @param name
+    *           the name of the destination to remove from JNDI
+    * @return true if removed
+    * @throws Exception
+    *            if a problem occurred removing the destination
+    */
+   boolean removeQueueFromJNDI(String name) throws Exception;
+
+   /**
     * destroys a queue and removes it from JNDI
     * 
     * @param name
@@ -96,6 +132,12 @@
     *            if a problem occurred destroying the queue
     */
    boolean destroyQueue(String name) throws Exception;
+   
+   List<String> getJNDIOnQueue(String queue);
+   
+   List<String> getJNDIOnTopic(String topic);
+   
+   List<String> getJNDIOnConnectionFactory(String factoryName);
 
    /**
     * destroys a topic and removes it from JNDI

Modified: trunk/src/main/org/hornetq/jms/server/config/ConnectionFactoryConfiguration.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/config/ConnectionFactoryConfiguration.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/jms/server/config/ConnectionFactoryConfiguration.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -17,6 +17,7 @@
 
 import org.hornetq.api.core.Pair;
 import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.core.journal.EncodingSupport;
 import org.hornetq.jms.server.JMSServerManager;
 
 /**
@@ -26,7 +27,7 @@
  *
  *
  */
-public interface ConnectionFactoryConfiguration
+public interface ConnectionFactoryConfiguration extends EncodingSupport
 {
    String getName();
 

Modified: trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -14,12 +14,16 @@
 package org.hornetq.jms.server.config.impl;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
+import org.hornetq.api.core.HornetQBuffer;
 import org.hornetq.api.core.Pair;
 import org.hornetq.api.core.TransportConfiguration;
 import org.hornetq.api.core.client.HornetQClient;
 import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
+import org.hornetq.utils.BufferHelper;
+import org.hornetq.utils.DataConstants;
 
 /**
  * A ConnectionFactoryConfigurationImpl
@@ -34,10 +38,10 @@
 
    // Attributes ----------------------------------------------------
 
-   private final String[] bindings;
+   private String name;
 
-   private final String name;
-   
+   private String[] bindings;
+
    private String discoveryGroupName;
 
    private String discoveryAddress;
@@ -45,7 +49,7 @@
    private int discoveryPort;
 
    private List<Pair<String, String>> connectorNames;
-   
+
    private List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs;
 
    private String clientID = null;
@@ -112,6 +116,11 @@
 
    // Constructors --------------------------------------------------
 
+   /** To be used on persistence only */
+   public ConnectionFactoryConfigurationImpl()
+   {
+   }
+   
    public ConnectionFactoryConfigurationImpl(final String name,
                                              final String discoveryAddress,
                                              final int discoveryPort,
@@ -527,9 +536,306 @@
    public void setDiscoveryGroupName(String groupName)
    {
       this.discoveryGroupName = groupName;
+
+   }
+
+   // Encoding Support Implementation --------------------------------------------------------------
+   
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#decode(org.hornetq.api.core.HornetQBuffer)
+    */
+   public void decode(HornetQBuffer buffer)
+   {
+      name = buffer.readSimpleString().toString();
+
+      int nbindings = buffer.readInt();
+
+      bindings = new String[nbindings];
+
+      for (int i = 0; i < nbindings; i++)
+      {
+         bindings[i] = buffer.readSimpleString().toString();
+      }
+
+      discoveryGroupName = BufferHelper.readNullableSimpleStringAsString(buffer); 
+
+      discoveryAddress = BufferHelper.readNullableSimpleStringAsString(buffer);
+
+      discoveryPort = buffer.readInt();
+
+      int nConnectors = buffer.readInt();
+
+      connectorNames = new ArrayList<Pair<String, String>>(nConnectors);
+
+      for (int i = 0; i < nConnectors; i++)
+      {
+         String a = BufferHelper.readNullableSimpleStringAsString(buffer);
+         
+         String b = BufferHelper.readNullableSimpleStringAsString(buffer);
+         
+         connectorNames.add(new Pair<String, String>(a, b));
+      }
+
+      clientID = BufferHelper.readNullableSimpleStringAsString(buffer);
+
+      discoveryRefreshTimeout = buffer.readLong();
+
+      clientFailureCheckPeriod = buffer.readLong();
+
+      connectionTTL = buffer.readLong();
+
+      callTimeout = buffer.readLong();
+
+      cacheLargeMessagesClient = buffer.readBoolean();
+
+      minLargeMessageSize = buffer.readInt();
+
+      consumerWindowSize = buffer.readInt();
+
+      consumerMaxRate = buffer.readInt();
+
+      confirmationWindowSize = buffer.readInt();
+
+      producerWindowSize = buffer.readInt();
+
+      producerMaxRate = buffer.readInt();
+
+      blockOnAcknowledge = buffer.readBoolean();
+
+      blockOnDurableSend = buffer.readBoolean();
+
+      blockOnNonDurableSend = buffer.readBoolean();
+
+      autoGroup = buffer.readBoolean();
+
+      preAcknowledge = buffer.readBoolean();
+
+      loadBalancingPolicyClassName = buffer.readSimpleString().toString();
+
+      transactionBatchSize = buffer.readInt();
+
+      dupsOKBatchSize = buffer.readInt();
+
+      initialWaitTimeout = buffer.readLong();
+
+      useGlobalPools = buffer.readBoolean();
+
+      scheduledThreadPoolMaxSize = buffer.readInt();
+
+      threadPoolMaxSize = buffer.readInt();
+
+      retryInterval = buffer.readLong();
+
+      retryIntervalMultiplier = buffer.readDouble();
+
+      maxRetryInterval = buffer.readLong();
+
+      reconnectAttempts = buffer.readInt();
+
+      failoverOnServerShutdown = buffer.readBoolean();
+
+      groupID = BufferHelper.readNullableSimpleStringAsString(buffer);
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#encode(org.hornetq.api.core.HornetQBuffer)
+    */
+   public void encode(HornetQBuffer buffer)
+   {
+      BufferHelper.writeAsSimpleString(buffer, name);
+
+      buffer.writeInt(bindings.length);
+
+      for (String str : bindings)
+      {
+         BufferHelper.writeAsSimpleString(buffer, str);
+      }
+
+      BufferHelper.writeAsNullableSimpleString(buffer, discoveryGroupName);
+
+      BufferHelper.writeAsNullableSimpleString(buffer, discoveryAddress);
+
+      buffer.writeInt(discoveryPort);
+
+      buffer.writeInt(connectorNames == null ? 0 : connectorNames.size());
+
+      if (connectorNames != null)
+      {
+         for (Pair<String, String> namePair : connectorNames)
+         {
+            BufferHelper.writeAsNullableSimpleString(buffer, namePair.a);
+            BufferHelper.writeAsNullableSimpleString(buffer, namePair.b);
+         }
+      }
+
+      BufferHelper.writeAsNullableSimpleString(buffer, clientID);
+
+      buffer.writeLong(discoveryRefreshTimeout);
+
+      buffer.writeLong(clientFailureCheckPeriod);
+
+      buffer.writeLong(connectionTTL);
+
+      buffer.writeLong(callTimeout);
+
+      buffer.writeBoolean(cacheLargeMessagesClient);
+
+      buffer.writeInt(minLargeMessageSize);
+
+      buffer.writeInt(consumerWindowSize);
+
+      buffer.writeInt(consumerMaxRate);
+
+      buffer.writeInt(confirmationWindowSize);
+
+      buffer.writeInt(producerWindowSize);
+
+      buffer.writeInt(producerMaxRate);
+
+      buffer.writeBoolean(blockOnAcknowledge);
+
+      buffer.writeBoolean(blockOnDurableSend);
+
+      buffer.writeBoolean(blockOnNonDurableSend);
+
+      buffer.writeBoolean(autoGroup);
+
+      buffer.writeBoolean(preAcknowledge);
+
+      BufferHelper.writeAsSimpleString(buffer, loadBalancingPolicyClassName);
+
+      buffer.writeInt(transactionBatchSize);
+
+      buffer.writeInt(dupsOKBatchSize);
+
+      buffer.writeLong(initialWaitTimeout);
+
+      buffer.writeBoolean(useGlobalPools);
+
+      buffer.writeInt(scheduledThreadPoolMaxSize);
+
+      buffer.writeInt(threadPoolMaxSize);
+
+      buffer.writeLong(retryInterval);
+
+      buffer.writeDouble(retryIntervalMultiplier);
+
+      buffer.writeLong(maxRetryInterval);
+
+      buffer.writeInt(reconnectAttempts);
+
+      buffer.writeBoolean(failoverOnServerShutdown);
+
+      BufferHelper.writeAsNullableSimpleString(buffer, groupID);
+   }
+
+   private int sizeOfBindings()
+   {
+      int size = DataConstants.SIZE_INT; // for the number of bindings persisted
+
+      for (String str : bindings)
+      {
+         size += BufferHelper.sizeOfSimpleString(str);
+      }
+
+      return size;
+
+   }
+
+   private int sizeOfConnectors()
+   {
+      int size = DataConstants.SIZE_INT; // for the number of connectors persisted
+
+      if (connectorNames != null)
+      {
+         for (Pair<String, String> pair : connectorNames)
+         {
+            size += BufferHelper.sizeOfNullableSimpleString(pair.a);
+            size += BufferHelper.sizeOfNullableSimpleString(pair.b);
+         }
+      }
+
+      return size;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.core.journal.EncodingSupport#getEncodeSize()
+    */
+   public int getEncodeSize()
+   {
+      return BufferHelper.sizeOfSimpleString(name) +
       
+             sizeOfBindings() +
+             
+             BufferHelper.sizeOfNullableSimpleString(discoveryGroupName) +
+             
+             BufferHelper.sizeOfNullableSimpleString(discoveryAddress)+
+             
+             DataConstants.SIZE_INT + // discoveryPort
+             
+             sizeOfConnectors() +
+             
+             BufferHelper.sizeOfNullableSimpleString(clientID) +
+             
+             DataConstants.SIZE_LONG + // discoveryRefreshTimeout 
+             
+             DataConstants.SIZE_LONG + // clientFailureCheckPeriod
+
+             DataConstants.SIZE_LONG + // connectionTTL
+
+             DataConstants.SIZE_LONG + // callTimeout
+
+             DataConstants.SIZE_BOOLEAN + // cacheLargeMessagesClient
+             
+             DataConstants.SIZE_INT + // minLargeMessageSize
+
+             DataConstants.SIZE_INT + // consumerWindowSize
+
+             DataConstants.SIZE_INT + // consumerMaxRate
+
+             DataConstants.SIZE_INT + // confirmationWindowSize
+
+             DataConstants.SIZE_INT + // producerWindowSize
+
+             DataConstants.SIZE_INT + // producerMaxRate
+
+             DataConstants.SIZE_BOOLEAN + // blockOnAcknowledge
+
+             DataConstants.SIZE_BOOLEAN + // blockOnDurableSend
+
+             DataConstants.SIZE_BOOLEAN + // blockOnNonDurableSend
+
+             DataConstants.SIZE_BOOLEAN + // autoGroup
+
+             DataConstants.SIZE_BOOLEAN + // preAcknowledge
+
+             BufferHelper.sizeOfSimpleString(loadBalancingPolicyClassName) + 
+
+             DataConstants.SIZE_INT + // transactionBatchSize
+
+             DataConstants.SIZE_INT + // dupsOKBatchSize
+
+             DataConstants.SIZE_LONG + // initialWaitTimeout
+
+             DataConstants.SIZE_BOOLEAN + // useGlobalPools
+
+             DataConstants.SIZE_INT + // scheduledThreadPoolMaxSize
+
+             DataConstants.SIZE_INT + // threadPoolMaxSize
+
+             DataConstants.SIZE_LONG + // retryInterval
+
+             DataConstants.SIZE_DOUBLE + // retryIntervalMultiplier
+
+             DataConstants.SIZE_LONG + // maxRetryInterval
+
+             DataConstants.SIZE_INT + // reconnectAttempts
+
+             DataConstants.SIZE_BOOLEAN + // failoverOnServerShutdown
+             
+             BufferHelper.sizeOfNullableSimpleString(groupID);
    }
-
+   
    // Public --------------------------------------------------------
 
    // Package protected ---------------------------------------------

Modified: trunk/src/main/org/hornetq/jms/server/impl/JMSServerDeployer.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/impl/JMSServerDeployer.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/jms/server/impl/JMSServerDeployer.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -13,8 +13,6 @@
 
 package org.hornetq.jms.server.impl;
 
-import java.util.ArrayList;
-
 import org.hornetq.core.config.Configuration;
 import org.hornetq.core.deployers.DeploymentManager;
 import org.hornetq.core.deployers.impl.XmlDeployer;
@@ -39,7 +37,7 @@
    
    private final JMSServerConfigParser parser;
 
-   private final JMSServerManager jmsServerControl;
+   private final JMSServerManager jmsServerManager;
 
    protected static final String CONNECTOR_REF_ELEMENT = "connector-ref";
 
@@ -67,7 +65,7 @@
    {
       super(deploymentManager);
 
-      jmsServerControl = jmsServerManager;
+      this.jmsServerManager = jmsServerManager;
 
       configuration = config;
       
@@ -139,17 +137,17 @@
       if (node.getNodeName().equals(JMSServerDeployer.CONNECTION_FACTORY_NODE_NAME))
       {
          String cfName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
-         jmsServerControl.destroyConnectionFactory(cfName);
+         jmsServerManager.destroyConnectionFactory(cfName);
       }
       else if (node.getNodeName().equals(JMSServerDeployer.QUEUE_NODE_NAME))
       {
          String queueName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
-         jmsServerControl.undeployDestination(queueName);
+         jmsServerManager.removeQueueFromJNDI(queueName);
       }
       else if (node.getNodeName().equals(JMSServerDeployer.TOPIC_NODE_NAME))
       {
          String topicName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
-         jmsServerControl.undeployDestination(topicName);
+         jmsServerManager.removeTopicFromJNDI(topicName);
       }
    }
 
@@ -171,7 +169,7 @@
       TopicConfiguration topicConfig = parser.parseTopicConfiguration(node);
       for (String jndi : topicConfig.getBindings())
       {
-         jmsServerControl.createTopic(topicConfig.getName(), jndi);
+         jmsServerManager.createTopic(topicConfig.getName(), jndi);
       }
    }
 
@@ -182,10 +180,7 @@
    private void deployQueue(final Node node) throws Exception
    {
       JMSQueueConfiguration queueconfig = parser.parseQueueConfiguration(node);
-      for (String jndiName : queueconfig.getBindings())
-      {
-         jmsServerControl.createQueue(queueconfig.getName(), jndiName, queueconfig.getSelector(), queueconfig.isDurable());
-      }
+      jmsServerManager.createQueue(queueconfig.getName(), queueconfig.getSelector(), queueconfig.isDurable(), queueconfig.getBindings());
    }
 
    /**
@@ -195,7 +190,7 @@
    private void deployConnectionFactory(final Node node) throws Exception
    {
       ConnectionFactoryConfiguration cfConfig = parser.parseConnectionFactoryConfiguration(node);
-      jmsServerControl.createConnectionFactory(cfConfig);
+      jmsServerManager.createConnectionFactory(cfConfig);
    }
 
    

Modified: trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -42,6 +42,13 @@
 import org.hornetq.jms.client.HornetQConnectionFactory;
 import org.hornetq.jms.client.HornetQDestination;
 import org.hornetq.jms.client.SelectorTranslator;
+import org.hornetq.jms.persistence.JMSStorageManager;
+import org.hornetq.jms.persistence.config.PersistedConnectionFactory;
+import org.hornetq.jms.persistence.config.PersistedDestination;
+import org.hornetq.jms.persistence.config.PersistedJNDI;
+import org.hornetq.jms.persistence.config.PersistedType;
+import org.hornetq.jms.persistence.impl.journal.JournalJMSStorageManagerImpl;
+import org.hornetq.jms.persistence.impl.nullpm.NullJMSStorageManagerImpl;
 import org.hornetq.jms.server.JMSServerManager;
 import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
 import org.hornetq.jms.server.config.JMSConfiguration;
@@ -49,6 +56,7 @@
 import org.hornetq.jms.server.config.TopicConfiguration;
 import org.hornetq.jms.server.management.JMSManagementService;
 import org.hornetq.jms.server.management.impl.JMSManagementServiceImpl;
+import org.hornetq.utils.TimeAndCounterIDGenerator;
 
 /**
  * A Deployer used to create and add to JNDI queues, topics and connection
@@ -77,12 +85,18 @@
     */
    private Context context;
 
-   private final Map<String, List<String>> destinations = new HashMap<String, List<String>>();
+   private Map<String, HornetQDestination> queues = new HashMap<String, HornetQDestination>();
 
+   private Map<String, HornetQDestination> topics = new HashMap<String, HornetQDestination>();
+
    private final Map<String, HornetQConnectionFactory> connectionFactories = new HashMap<String, HornetQConnectionFactory>();
 
-   private final Map<String, List<String>> connectionFactoryBindings = new HashMap<String, List<String>>();
+   private final Map<String, List<String>> queueJNDI = new HashMap<String, List<String>>();
 
+   private final Map<String, List<String>> topicJNDI = new HashMap<String, List<String>>();
+
+   private final Map<String, List<String>> connectionFactoryJNDI = new HashMap<String, List<String>>();
+
    private final HornetQServer server;
 
    private JMSManagementService jmsManagementService;
@@ -101,6 +115,10 @@
 
    private JMSConfiguration config;
 
+   private Configuration coreConfig;
+
+   private JMSStorageManager storage;
+
    public JMSServerManagerImpl(final HornetQServer server) throws Exception
    {
       this.server = server;
@@ -130,12 +148,14 @@
    {
       active = true;
 
-      jmsManagementService = new JMSManagementServiceImpl(server.getManagementService());
+      jmsManagementService = new JMSManagementServiceImpl(server.getManagementService(), this);
 
       try
       {
          jmsManagementService.registerJMSServer(this);
 
+         initJournal();
+
          // start the JMS deployer only if the configuration is not done using the JMSConfiguration object
          if (config == null)
          {
@@ -157,6 +177,7 @@
          {
             deploy();
          }
+
       }
       catch (Exception e)
       {
@@ -204,19 +225,19 @@
          deploymentManager.stop();
       }
 
-      for (String destination : destinations.keySet())
-      {
-         undeployDestination(destination);
-      }
+      // for (String destination : destinationBindings.keySet())
+      // {
+      // undeployDestination(destination);
+      // }
 
       for (String connectionFactory : new HashSet<String>(connectionFactories.keySet()))
       {
          destroyConnectionFactory(connectionFactory);
       }
 
-      destinations.clear();
+      // destinationBindings.clear();
       connectionFactories.clear();
-      connectionFactoryBindings.clear();
+      connectionFactoryJNDI.clear();
 
       if (context != null)
       {
@@ -278,91 +299,173 @@
       return server.getVersion().getFullVersion();
    }
 
-   public synchronized boolean createQueue(final String queueName,
-                                           final String jndiBinding,
-                                           final String selectorString,
-                                           final boolean durable) throws Exception
+   public synchronized boolean createQueue(final String queueName, final String selectorString, final boolean durable, final String ... jndi) throws Exception
    {
       checkInitialised();
-      HornetQDestination jBossQueue = HornetQDestination.createQueue(queueName);
 
-      // Convert from JMS selector to core filter
-      SimpleString coreFilterString = null;
+      boolean added = internalCreateQueue(queueName, selectorString, durable);
 
-      if (selectorString != null)
+      storage.storeDestination(new PersistedDestination(PersistedType.Queue, queueName, selectorString, durable));
+      
+      for (String jndiItem : jndi)
       {
-         coreFilterString = SimpleString.toSimpleString(SelectorTranslator.convertToHornetQFilterString(selectorString));
+         addQueueToJndi(queueName, jndiItem);
       }
 
-      server.deployQueue(jBossQueue.getSimpleAddress(),
-                         jBossQueue.getSimpleAddress(),
-                         coreFilterString,
-                         durable,
-                         false);
+      return added;
+   }
 
-      boolean added = bindToJndi(jndiBinding, jBossQueue);
+   public synchronized boolean createTopic(final String topicName, final String ... jndi) throws Exception
+   {
+      checkInitialised();
 
-      if (added)
+      boolean added = internalCreateTopic(topicName);
+
+      storage.storeDestination(new PersistedDestination(PersistedType.Topic, topicName));
+      
+      for (String jndiItem : jndi)
       {
-         addToDestinationBindings(queueName, jndiBinding);
+         addTopicToJndi(topicName, jndiItem);
       }
 
-      jmsManagementService.registerQueue(jBossQueue, jndiBinding);
       return added;
    }
 
-   public synchronized boolean createTopic(final String topicName, final String jndiBinding) throws Exception
+   public boolean addTopicToJndi(final String topicName, final String jndiBinding) throws Exception
    {
       checkInitialised();
-      HornetQDestination jBossTopic = HornetQDestination.createTopic(topicName);
-      // We create a dummy subscription on the topic, that never receives messages - this is so we can perform JMS
-      // checks when routing messages to a topic that
-      // does not exist - otherwise we would not be able to distinguish from a non existent topic and one with no
-      // subscriptions - core has no notion of a topic
-      server.deployQueue(jBossTopic.getSimpleAddress(),
-                         jBossTopic.getSimpleAddress(),
-                         SimpleString.toSimpleString(JMSServerManagerImpl.REJECT_FILTER),
-                         true, 
-                         false);
       
-      boolean added = bindToJndi(jndiBinding, jBossTopic);
+      HornetQDestination destination = topics.get(topicName);
+      if (destination == null)
+      {
+         throw new IllegalArgumentException("Topic does not exist");
+      }
+      if (destination.getTopicName() == null)
+      {
+         throw new IllegalArgumentException(topicName + " is not a topic");
+      }
+      boolean added = bindToJndi(jndiBinding, destination);
+
       if (added)
       {
-         addToDestinationBindings(topicName, jndiBinding);
+         addToBindings(topicJNDI, topicName, jndiBinding);
+         storage.addJNDI(PersistedType.Topic, topicName, jndiBinding);
       }
-      jmsManagementService.registerTopic(jBossTopic, jndiBinding);
       return added;
    }
+   
+   public List<String> getJNDIOnQueue(String queue)
+   {
+      return getJNDIList(queueJNDI, queue);
+   }
+   
+   public List<String> getJNDIOnTopic(String topic)
+   {
+      return getJNDIList(topicJNDI, topic);
+   }
+   
+   public List<String> getJNDIOnConnectionFactory(String factoryName)
+   {
+      return getJNDIList(connectionFactoryJNDI, factoryName);
+   }
 
-   public synchronized boolean undeployDestination(final String name) throws Exception
+
+
+   public boolean addQueueToJndi(final String queueName, final String jndiBinding) throws Exception
    {
       checkInitialised();
-      List<String> jndiBindings = destinations.get(name);
-      if (jndiBindings == null || jndiBindings.size() == 0)
+      
+      HornetQDestination destination = queues.get(queueName);
+      if (destination == null)
       {
-         return false;
+         throw new IllegalArgumentException("Queue does not exist");
       }
-      if (context != null)
+      if (destination.getQueueName() == null)
       {
-         Iterator<String> iter = jndiBindings.iterator();
-         while (iter.hasNext())
-         {
-            String jndiBinding = iter.next();
-            context.unbind(jndiBinding);
-            iter.remove();
-         }
+         throw new IllegalArgumentException(queueName + " is not a queue");
       }
+      boolean added = bindToJndi(jndiBinding, destination);
+      if (added)
+      {
+         addToBindings(queueJNDI, queueName, jndiBinding);
+         storage.addJNDI(PersistedType.Queue, queueName, jndiBinding);
+      }
+      return added;
+   }
+
+
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.server.JMSServerManager#removeQueueFromJNDI(java.lang.String, java.lang.String)
+    */
+   public boolean removeQueueFromJNDI(String name, String jndi) throws Exception
+   {
+      checkInitialised();
+      
+      removeFromJNDI(queueJNDI, name, jndi);
+      
+      storage.deleteJNDI(PersistedType.Queue, name, jndi);
+      
       return true;
    }
 
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.server.JMSServerManager#removeQueueFromJNDI(java.lang.String, java.lang.String)
+    */
+   public boolean removeQueueFromJNDI(String name) throws Exception
+   {
+      checkInitialised();
+      
+      removeFromJNDI(queueJNDI, name);
+      
+      storage.deleteJNDI(PersistedType.Queue, name);
+      
+      return true;
+   }
+
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.server.JMSServerManager#removeTopicFromJNDI(java.lang.String, java.lang.String)
+    */
+   public boolean removeTopicFromJNDI(String name, String jndi) throws Exception
+   {
+      checkInitialised();
+      
+      removeFromJNDI(topicJNDI, name, jndi);
+      
+      storage.deleteJNDI(PersistedType.Topic, name, jndi);
+      
+      return true;
+   }
+   
+   /* (non-Javadoc)
+    * @see org.hornetq.jms.server.JMSServerManager#removeTopicFromJNDI(java.lang.String, java.lang.String)
+    */
+   public boolean removeTopicFromJNDI(String name) throws Exception
+   {
+      checkInitialised();
+      
+      removeFromJNDI(topicJNDI, name);
+      
+      storage.deleteJNDI(PersistedType.Topic, name);
+      
+      return true;
+   }
+   
+
    public synchronized boolean destroyQueue(final String name) throws Exception
    {
       checkInitialised();
-      undeployDestination(name);
+      
+      removeFromJNDI(queueJNDI, name);
+      
 
-      destinations.remove(name);
+      queues.remove(name);
+      queueJNDI.remove(name);
+      
       jmsManagementService.unregisterQueue(name);
-      server.destroyQueue(HornetQDestination.createQueueAddressFromName(name), null);
+      
+      server.getHornetQServerControl().destroyQueue(HornetQDestination.createQueueAddressFromName(name).toString());
+      
+      storage.deleteDestination(PersistedType.Queue, name);
 
       return true;
    }
@@ -370,11 +473,16 @@
    public synchronized boolean destroyTopic(final String name) throws Exception
    {
       checkInitialised();
-      undeployDestination(name);
+      
+      removeFromJNDI(topicJNDI, name);
 
-      destinations.remove(name);
+      topics.remove(name);
+      topicJNDI.remove(name);
+
       jmsManagementService.unregisterTopic(name);
-      AddressControl addressControl = (AddressControl)server.getManagementService().getResource(ResourceNames.CORE_ADDRESS + HornetQDestination.createTopicAddressFromName(name));
+      
+      AddressControl addressControl = (AddressControl)server.getManagementService()
+                                                            .getResource(ResourceNames.CORE_ADDRESS + HornetQDestination.createTopicAddressFromName(name));
       if (addressControl != null)
       {
          for (String queueName : addressControl.getQueueNames())
@@ -382,10 +490,13 @@
             Binding binding = server.getPostOffice().getBinding(new SimpleString(queueName));
             if (binding == null)
             {
-               log.warn("Queue " + queueName + " doesn't exist on the topic " + name + ". It was deleted manually probably.");
+               log.warn("Queue " + queueName +
+                        " doesn't exist on the topic " +
+                        name +
+                        ". It was deleted manually probably.");
                continue;
             }
-            
+
             // We can't remove the remote binding. As this would be the bridge associated with the topic on this case
             if (binding.getType() != BindingType.REMOTE_QUEUE)
             {
@@ -393,6 +504,7 @@
             }
          }
       }
+      storage.deleteDestination(PersistedType.Topic, name);
       return true;
    }
 
@@ -604,7 +716,80 @@
 
    public synchronized void createConnectionFactory(final ConnectionFactoryConfiguration cfConfig) throws Exception
    {
+      internalCreateCF(cfConfig);
+      storage.storeConnectionFactory(new PersistedConnectionFactory(cfConfig));
+   }
+   
+   private List<String> getJNDIList(final Map<String, List<String>> map, final String name)
+   {
+      List<String> result = map.get(name);
+      if (result == null)
+      {
+         return Collections.emptyList();
+      }
+      else
+      {
+         return Collections.unmodifiableList(result);
+      }
+   }
 
+   private boolean internalCreateQueue(final String queueName, final String selectorString, final boolean durable) throws Exception
+   {
+      HornetQDestination hqQueue = HornetQDestination.createQueue(queueName);
+
+      // Convert from JMS selector to core filter
+      String coreFilterString = null;
+
+      if (selectorString != null)
+      {
+         coreFilterString = SelectorTranslator.convertToHornetQFilterString(selectorString);
+      }
+
+      server.getHornetQServerControl().deployQueue(hqQueue.getAddress(),
+                                                   hqQueue.getAddress(),
+                                                   coreFilterString,
+                                                   durable);
+      
+      queues.put(queueName, hqQueue);
+
+      jmsManagementService.registerQueue(hqQueue);
+
+      return true;
+   }
+
+   /**
+    * Performs the internal creation without activating any storage. 
+    * The storage load will call this method
+    * @param topicName
+    * @return
+    * @throws Exception
+    */
+   private boolean internalCreateTopic(final String topicName) throws Exception
+   {
+      HornetQDestination hqTopic = HornetQDestination.createTopic(topicName);
+      // We create a dummy subscription on the topic, that never receives messages - this is so we can perform JMS
+      // checks when routing messages to a topic that
+      // does not exist - otherwise we would not be able to distinguish from a non existent topic and one with no
+      // subscriptions - core has no notion of a topic
+      server.getHornetQServerControl().deployQueue(hqTopic.getAddress(),
+                                                   hqTopic.getAddress(),
+                                                   JMSServerManagerImpl.REJECT_FILTER,
+                                                   true);
+
+      topics.put(topicName, hqTopic);
+
+      jmsManagementService.registerTopic(hqTopic);
+
+      return true;
+   }
+
+   /**
+    * @param cfConfig
+    * @throws HornetQException
+    * @throws Exception
+    */
+   private void internalCreateCF(final ConnectionFactoryConfiguration cfConfig) throws HornetQException, Exception
+   {
       ArrayList<String> listBindings = new ArrayList<String>();
       for (String str : cfConfig.getBindings())
       {
@@ -686,7 +871,6 @@
                                  cfConfig.getGroupID(),
                                  listBindings);
       }
-
    }
 
    public synchronized void createConnectionFactory(final String name,
@@ -754,7 +938,7 @@
    public synchronized boolean destroyConnectionFactory(final String name) throws Exception
    {
       checkInitialised();
-      List<String> jndiBindings = connectionFactoryBindings.get(name);
+      List<String> jndiBindings = connectionFactoryJNDI.get(name);
       if (jndiBindings == null || jndiBindings.size() == 0)
       {
          return false;
@@ -773,7 +957,7 @@
             }
          }
       }
-      connectionFactoryBindings.remove(name);
+      connectionFactoryJNDI.remove(name);
       connectionFactories.remove(name);
 
       jmsManagementService.unregisterConnectionFactory(name);
@@ -809,6 +993,7 @@
       checkInitialised();
       return server.getHornetQServerControl().listSessions(connectionID);
    }
+
    // Public --------------------------------------------------------
 
    // Private -------------------------------------------------------
@@ -829,15 +1014,22 @@
       {
          bindToJndi(jndiBinding, cf);
 
-         if (connectionFactoryBindings.get(name) == null)
-         {
-            connectionFactoryBindings.put(name, new ArrayList<String>());
-         }
-         connectionFactoryBindings.get(name).add(jndiBinding);
+         addToBindings(connectionFactoryJNDI, name, jndiBinding);
       }
 
-      jmsManagementService.registerConnectionFactory(name, cf, jndiBindings);
+      jmsManagementService.registerConnectionFactory(name, cf);
    }
+   
+   private void addToBindings(Map<String, List<String>> map, String name, String jndi)
+   {
+      List<String> list = map.get(name);
+      if (list == null)
+      {
+         list = new ArrayList<String>();
+         map.put(name, list);
+      }
+      list.add(jndi);
+   }
 
    private boolean bindToJndi(final String jndiName, final Object objectToBind) throws NamingException
    {
@@ -904,15 +1096,6 @@
       }
    }
 
-   private void addToDestinationBindings(final String destination, final String jndiBinding)
-   {
-      if (destinations.get(destination) == null)
-      {
-         destinations.put(destination, new ArrayList<String>());
-      }
-      destinations.get(destination).add(jndiBinding);
-   }
-
    private void deploy() throws Exception
    {
       if (config == null)
@@ -935,9 +1118,10 @@
       for (JMSQueueConfiguration config : queueConfigs)
       {
          String[] bindings = config.getBindings();
+         createQueue(config.getName(), config.getSelector(), config.isDurable());
          for (String binding : bindings)
          {
-            createQueue(config.getName(), binding, config.getSelector(), config.isDurable());
+            addQueueToJndi(config.getName(), binding);
          }
       }
 
@@ -945,14 +1129,144 @@
       for (TopicConfiguration config : topicConfigs)
       {
          String[] bindings = config.getBindings();
+         createTopic(config.getName());
+         
          for (String binding : bindings)
          {
-            createTopic(config.getName(), binding);
+            addTopicToJndi(config.getName(), binding);
          }
       }
    }
 
    /**
+    * @param server
+    */
+   private void initJournal() throws Exception
+   {
+      this.coreConfig = server.getConfiguration();
+
+      if (coreConfig.isPersistenceEnabled())
+      {
+         // TODO: replication
+         storage = new JournalJMSStorageManagerImpl(new TimeAndCounterIDGenerator(), coreConfig, null);
+      }
+      else
+      {
+         storage = new NullJMSStorageManagerImpl();
+      }
+
+      storage.start();
+
+      List<PersistedConnectionFactory> cfs = storage.recoverConnectionFactories();
+
+      for (PersistedConnectionFactory cf : cfs)
+      {
+         internalCreateCF(cf.getConfig());
+      }
+
+      List<PersistedDestination> destinations = storage.recoverDestinations();
+
+      for (PersistedDestination destination : destinations)
+      {
+         if (destination.getType() == PersistedType.Queue)
+         {
+            internalCreateQueue(destination.getName(),
+                                destination.getSelector(),
+                                destination.isDurable());
+         }
+         else if (destination.getType() == PersistedType.Topic)
+         {
+            internalCreateTopic(destination.getName());
+         }
+      }
+      
+      List<PersistedJNDI> jndiSpace = storage.recoverPersistedJNDI();
+      for (PersistedJNDI record : jndiSpace)
+      {
+         Map<String, List<String>> mapJNDI;
+         Map<String, ?> objects;
+         
+         switch (record.getType())
+         {
+            case Queue:
+               mapJNDI = queueJNDI;
+               objects = queues;
+               break;
+            case Topic:
+               mapJNDI = topicJNDI;
+               objects = topics;
+               break;
+            default:
+            case ConnectionFactory:
+               mapJNDI = connectionFactoryJNDI;
+               objects = connectionFactories;
+               break;
+         }
+         
+         Object objectToBind = objects.get(record.getName());
+         
+         if (objectToBind == null)
+         {
+            continue;
+         }
+         
+         List<String> jndiList = mapJNDI.get(record.getName());
+         if (jndiList == null)
+         {
+            jndiList = new ArrayList<String>();
+            mapJNDI.put(record.getName(), jndiList);
+         }
+         
+         
+         for (String jndi : record.getJndi())
+         {
+            jndiList.add(jndi);
+            bindToJndi(jndi, objectToBind);
+         }
+      }
+   }
+   
+   private synchronized boolean removeFromJNDI(final Map<String, List<String>> jndiMap, final String name) throws Exception
+   {
+      checkInitialised();
+      List<String> jndiBindings = jndiMap.get(name);
+      if (jndiBindings == null || jndiBindings.size() == 0)
+      {
+         return false;
+      }
+      if (context != null)
+      {
+         Iterator<String> iter = jndiBindings.iterator();
+         while (iter.hasNext())
+         {
+            String jndiBinding = iter.next();
+            context.unbind(jndiBinding);
+            iter.remove();
+         }
+      }
+      return true;
+   }
+   
+   
+   private synchronized boolean removeFromJNDI(final Map<String, List<String>> jndiMap, final String name, final String jndi) throws Exception
+   {
+      checkInitialised();
+      List<String> jndiBindings = jndiMap.get(name);
+      if (jndiBindings == null || jndiBindings.size() == 0)
+      {
+         return false;
+      }
+      if (context != null)
+      {
+         if (jndiBindings.remove(jndi))
+         {
+            context.unbind(jndi);
+         }
+      }
+      return true;
+   }
+   
+   /**
     * @param cfConfig
     * @return
     * @throws HornetQException

Modified: trunk/src/main/org/hornetq/jms/server/management/JMSManagementService.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/management/JMSManagementService.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/jms/server/management/JMSManagementService.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -13,8 +13,6 @@
 
 package org.hornetq.jms.server.management;
 
-import java.util.List;
-
 import org.hornetq.api.jms.management.JMSServerControl;
 import org.hornetq.jms.client.HornetQConnectionFactory;
 import org.hornetq.jms.client.HornetQDestination;
@@ -32,15 +30,15 @@
 
    void unregisterJMSServer() throws Exception;
 
-   void registerQueue(HornetQDestination queue, String jndiBinding) throws Exception;
+   void registerQueue(HornetQDestination queue) throws Exception;
 
    void unregisterQueue(String name) throws Exception;
 
-   void registerTopic(HornetQDestination topic, String jndiBinding) throws Exception;
+   void registerTopic(HornetQDestination topic) throws Exception;
 
    void unregisterTopic(String name) throws Exception;
 
-   void registerConnectionFactory(String name, HornetQConnectionFactory connectionFactory, List<String> bindings) throws Exception;
+   void registerConnectionFactory(String name, HornetQConnectionFactory connectionFactory) throws Exception;
 
    void unregisterConnectionFactory(String name) throws Exception;
 

Modified: trunk/src/main/org/hornetq/jms/server/management/impl/JMSManagementServiceImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/management/impl/JMSManagementServiceImpl.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/src/main/org/hornetq/jms/server/management/impl/JMSManagementServiceImpl.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -13,8 +13,6 @@
 
 package org.hornetq.jms.server.management.impl;
 
-import java.util.List;
-
 import javax.management.ObjectName;
 
 import org.hornetq.api.core.management.AddressControl;
@@ -49,12 +47,15 @@
    // Attributes ----------------------------------------------------
 
    private final ManagementService managementService;
+   
+   private final JMSServerManager jmsServerManager;
 
    // Static --------------------------------------------------------
 
-   public JMSManagementServiceImpl(final ManagementService managementService)
+   public JMSManagementServiceImpl(final ManagementService managementService, final JMSServerManager jmsServerManager)
    {
       this.managementService = managementService;
+      this.jmsServerManager = jmsServerManager;
    }
 
    // Public --------------------------------------------------------
@@ -77,7 +78,7 @@
       managementService.unregisterFromRegistry(ResourceNames.JMS_SERVER);
    }
 
-   public synchronized void registerQueue(final HornetQDestination queue, final String jndiBinding) throws Exception
+   public synchronized void registerQueue(final HornetQDestination queue) throws Exception
    {
       QueueControl coreQueueControl = (QueueControl)managementService.getResource(ResourceNames.CORE_QUEUE + queue.getAddress());
       MessageCounterManager messageCounterManager = managementService.getMessageCounterManager();
@@ -89,7 +90,7 @@
                                                   messageCounterManager.getMaxDayCount());
       messageCounterManager.registerMessageCounter(queue.getName(), counter);
       ObjectName objectName = managementService.getObjectNameBuilder().getJMSQueueObjectName(queue.getQueueName());
-      JMSQueueControlImpl control = new JMSQueueControlImpl(queue, coreQueueControl, jndiBinding, counter);
+      JMSQueueControlImpl control = new JMSQueueControlImpl(queue, coreQueueControl, jmsServerManager, counter);
       managementService.registerInJMX(objectName, control);
       managementService.registerInRegistry(ResourceNames.JMS_QUEUE + queue.getQueueName(), control);
    }
@@ -101,11 +102,11 @@
       managementService.unregisterFromRegistry(ResourceNames.JMS_QUEUE + name);
    }
 
-   public synchronized void registerTopic(final HornetQDestination topic, final String jndiBinding) throws Exception
+   public synchronized void registerTopic(final HornetQDestination topic) throws Exception
    {
       ObjectName objectName = managementService.getObjectNameBuilder().getJMSTopicObjectName(topic.getTopicName());
       AddressControl addressControl = (AddressControl)managementService.getResource(ResourceNames.CORE_ADDRESS + topic.getAddress());
-      JMSTopicControlImpl control = new JMSTopicControlImpl(topic, addressControl, jndiBinding, managementService);
+      JMSTopicControlImpl control = new JMSTopicControlImpl(topic, jmsServerManager, addressControl, managementService);
       managementService.registerInJMX(objectName, control);
       managementService.registerInRegistry(ResourceNames.JMS_TOPIC + topic.getTopicName(), control);
    }
@@ -118,11 +119,10 @@
    }
 
    public synchronized void registerConnectionFactory(final String name,
-                                                      final HornetQConnectionFactory connectionFactory,
-                                                      final List<String> bindings) throws Exception
+                                                      final HornetQConnectionFactory connectionFactory) throws Exception
    {
       ObjectName objectName = managementService.getObjectNameBuilder().getConnectionFactoryObjectName(name);
-      JMSConnectionFactoryControlImpl control = new JMSConnectionFactoryControlImpl(connectionFactory, name, bindings);
+      JMSConnectionFactoryControlImpl control = new JMSConnectionFactoryControlImpl(connectionFactory, jmsServerManager, name);
       managementService.registerInJMX(objectName, control);
       managementService.registerInRegistry(ResourceNames.JMS_CONNECTION_FACTORY + name, control);
    }

Added: trunk/src/main/org/hornetq/utils/BufferHelper.java
===================================================================
--- trunk/src/main/org/hornetq/utils/BufferHelper.java	                        (rev 0)
+++ trunk/src/main/org/hornetq/utils/BufferHelper.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.utils;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.api.core.SimpleString;
+
+/**
+ * Helper methods to read and write from HornetQBuffer.
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class BufferHelper
+{
+
+   /** Size of a String as if it was a Nullable Simple String */
+   public static int sizeOfNullableSimpleString(String str)
+   {
+      if (str == null)
+      {
+         return DataConstants.SIZE_BOOLEAN;
+      }
+      else
+      {
+         return DataConstants.SIZE_BOOLEAN + sizeOfSimpleString(str);
+      }
+   }
+   
+   /** Size of a String as it if was a Simple String*/
+   public static int sizeOfSimpleString(String str)
+   {
+      return DataConstants.SIZE_INT + str.length() * 2;
+   }
+   
+   public static void writeAsNullableSimpleString(HornetQBuffer buffer, String str)
+   {
+      buffer.writeNullableSimpleString(SimpleString.toSimpleString(str));
+   }
+   
+   public static String readNullableSimpleStringAsString(HornetQBuffer buffer)
+   {
+      SimpleString str = buffer.readNullableSimpleString();
+      return str != null ? str.toString() : null;
+   }
+   
+   public static void writeAsSimpleString(HornetQBuffer buffer, String str)
+   {
+      buffer.writeSimpleString(new SimpleString(str));
+   }
+   
+   /**
+    * @param buffer
+    */
+   public static void writeNullableBoolean(HornetQBuffer buffer, Boolean value)
+   {
+      buffer.writeBoolean(value != null);
+
+      if (value != null)
+      {
+         buffer.writeBoolean(value.booleanValue());
+      }
+   }
+
+   public static int sizeOfNullableBoolean(Boolean value)
+   {
+      return DataConstants.SIZE_BOOLEAN + (value != null ? DataConstants.SIZE_BOOLEAN : 0);
+   }
+
+   public static Boolean readNullableBoolean(HornetQBuffer buffer)
+   {
+      boolean isNotNull = buffer.readBoolean();
+
+      if (isNotNull)
+      {
+         return buffer.readBoolean();
+      }
+      else
+      {
+         return null;
+      }
+   }
+
+   /**
+    * @param buffer
+    */
+   public static void writeNullableLong(HornetQBuffer buffer, Long value)
+   {
+      buffer.writeBoolean(value != null);
+
+      if (value != null)
+      {
+         buffer.writeLong(value.longValue());
+      }
+   }
+
+   public static int sizeOfNullableLong(Long value)
+   {
+      return DataConstants.SIZE_BOOLEAN + (value != null ? DataConstants.SIZE_LONG : 0);
+   }
+
+   public static Long readNullableLong(HornetQBuffer buffer)
+   {
+      boolean isNotNull = buffer.readBoolean();
+
+      if (isNotNull)
+      {
+         return buffer.readLong();
+      }
+      else
+      {
+         return null;
+      }
+   }
+
+   /**
+    * @param buffer
+    */
+   public static void writeNullableInteger(HornetQBuffer buffer, Integer value)
+   {
+      buffer.writeBoolean(value != null);
+
+      if (value != null)
+      {
+         buffer.writeInt(value.intValue());
+      }
+   }
+
+   public static int sizeOfNullableInteger(Integer value)
+   {
+      return DataConstants.SIZE_BOOLEAN + (value != null ? DataConstants.SIZE_INT : 0);
+   }
+
+   public static Integer readNullableInteger(HornetQBuffer buffer)
+   {
+      boolean isNotNull = buffer.readBoolean();
+
+      if (isNotNull)
+      {
+         return buffer.readInt();
+      }
+      else
+      {
+         return null;
+      }
+   }
+
+}

Modified: trunk/tests/jms-tests/src/org/hornetq/jms/tests/tools/container/LocalTestServer.java
===================================================================
--- trunk/tests/jms-tests/src/org/hornetq/jms/tests/tools/container/LocalTestServer.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/tests/jms-tests/src/org/hornetq/jms/tests/tools/container/LocalTestServer.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -210,7 +210,7 @@
 
    public void createQueue(final String name, final String jndiName) throws Exception
    {
-      getJMSServerManager().createQueue(name, "/queue/" + (jndiName != null ? jndiName : name), null, true);
+      getJMSServerManager().createQueue(name, null, true, "/queue/" + (jndiName != null ? jndiName : name));
    }
 
    public void createTopic(final String name, final String jndiName) throws Exception

Modified: trunk/tests/src/org/hornetq/tests/integration/jms/bridge/BridgeTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/bridge/BridgeTestBase.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/bridge/BridgeTestBase.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -150,7 +150,7 @@
       {
          server = jmsServer1;
       }
-      server.createQueue(queueName, "/queue/" + queueName, null, true);
+      server.createQueue(queueName, null, true, "/queue/" + queueName);
    }
 
    @Override

Modified: trunk/tests/src/org/hornetq/tests/integration/jms/bridge/JMSBridgeReconnectionTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/bridge/JMSBridgeReconnectionTest.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/bridge/JMSBridgeReconnectionTest.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -199,7 +199,7 @@
          JMSBridgeReconnectionTest.log.info("Restarting server");
          jmsServer1.start();
 
-         jmsServer1.createQueue("targetQueue", "queue/targetQueue", null, true);
+         jmsServer1.createQueue("targetQueue", null, true, "queue/targetQueue");
 
          createQueue("targetQueue", 1);
 

Modified: trunk/tests/src/org/hornetq/tests/integration/jms/connection/ExceptionListenerTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/connection/ExceptionListenerTest.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/connection/ExceptionListenerTest.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -69,7 +69,7 @@
       jmsServer = new JMSServerManagerImpl(server);
       jmsServer.setContext(new NullInitialContext());
       jmsServer.start();
-      jmsServer.createQueue(ExceptionListenerTest.Q_NAME, ExceptionListenerTest.Q_NAME, null, true);
+      jmsServer.createQueue(ExceptionListenerTest.Q_NAME, null, true, ExceptionListenerTest.Q_NAME);
       cf = (HornetQConnectionFactory) HornetQJMSClient.createConnectionFactory(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"));
       cf.setBlockOnDurableSend(true);
       cf.setPreAcknowledge(true);

Modified: trunk/tests/src/org/hornetq/tests/integration/jms/consumer/ConsumerTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/consumer/ConsumerTest.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/consumer/ConsumerTest.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -49,7 +49,7 @@
    {
       super.setUp();
 
-      jmsServer.createQueue(ConsumerTest.Q_NAME, ConsumerTest.Q_NAME, null, true);
+      jmsServer.createQueue(ConsumerTest.Q_NAME, null, true, ConsumerTest.Q_NAME);
       cf = HornetQJMSClient.createConnectionFactory(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"));
    }
 

Modified: trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlTest.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlTest.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -417,7 +417,7 @@
       JMSQueueControl queueControl = createManagementControl();
       String expiryQueueName = RandomUtil.randomString();
       HornetQDestination expiryQueue = (HornetQDestination)HornetQJMSClient.createQueue(expiryQueueName);
-      serverManager.createQueue(expiryQueueName, expiryQueueName, null, true);
+      serverManager.createQueue(expiryQueueName, null, true, expiryQueueName);
       queueControl.setExpiryAddress(expiryQueue.getAddress());
 
       JMSQueueControl expiryQueueControl = ManagementControlHelper.createJMSQueueControl(expiryQueue, mbeanServer);
@@ -544,7 +544,7 @@
    public void testSendMessageToDeadLetterAddress() throws Exception
    {
       String deadLetterQueue = RandomUtil.randomString();
-      serverManager.createQueue(deadLetterQueue, deadLetterQueue, null, true);
+      serverManager.createQueue(deadLetterQueue, null, true, deadLetterQueue);
       HornetQDestination dlq = (HornetQDestination)HornetQJMSClient.createQueue(deadLetterQueue);
 
       Connection conn = createConnection();
@@ -605,7 +605,7 @@
       String filter = "key = " + matchingValue;
 
       String deadLetterQueue = RandomUtil.randomString();
-      serverManager.createQueue(deadLetterQueue, deadLetterQueue, null, true);
+      serverManager.createQueue(deadLetterQueue, null, true, deadLetterQueue);
       HornetQDestination dlq = (HornetQDestination)HornetQJMSClient.createQueue(deadLetterQueue);
 
       Connection conn = createConnection();
@@ -647,7 +647,7 @@
    {
       String otherQueueName = RandomUtil.randomString();
 
-      serverManager.createQueue(otherQueueName, otherQueueName, null, true);
+      serverManager.createQueue(otherQueueName, null, true, otherQueueName);
       HornetQDestination otherQueue = (HornetQDestination)HornetQJMSClient.createQueue(otherQueueName);
 
       // send on queue
@@ -694,7 +694,7 @@
       String filter = "key = " + matchingValue;
       String otherQueueName = RandomUtil.randomString();
 
-      serverManager.createQueue(otherQueueName, otherQueueName, null, true);
+      serverManager.createQueue(otherQueueName, null, true, otherQueueName);
       HornetQDestination otherQueue = (HornetQDestination)HornetQJMSClient.createQueue(otherQueueName);
 
       Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
@@ -729,7 +729,7 @@
    {
       String otherQueueName = RandomUtil.randomString();
 
-      serverManager.createQueue(otherQueueName, otherQueueName, null, true);
+      serverManager.createQueue(otherQueueName, null, true, otherQueueName);
       HornetQDestination otherQueue = (HornetQDestination)HornetQJMSClient.createQueue(otherQueueName);
 
       String[] messageIDs = JMSUtil.sendMessages(queue, 1);
@@ -752,7 +752,7 @@
       String unknownMessageID = RandomUtil.randomString();
       String otherQueueName = RandomUtil.randomString();
 
-      serverManager.createQueue(otherQueueName, otherQueueName, null, true);
+      serverManager.createQueue(otherQueueName, null, true, otherQueueName);
 
       JMSQueueControl queueControl = createManagementControl();
       Assert.assertEquals(0, queueControl.getMessageCount());
@@ -834,7 +834,7 @@
       serverManager.activated();
 
       String queueName = RandomUtil.randomString();
-      serverManager.createQueue(queueName, queueName, null, true);
+      serverManager.createQueue(queueName, null, true, queueName);
       queue = (HornetQDestination)HornetQJMSClient.createQueue(queueName);
    }
 

Modified: trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlUsingJMSTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlUsingJMSTest.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlUsingJMSTest.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -13,6 +13,7 @@
 
 package org.hornetq.tests.integration.jms.server.management;
 
+import java.util.List;
 import java.util.Map;
 
 import javax.jms.QueueConnection;
@@ -270,6 +271,18 @@
          {
             return (String)proxy.retrieveAttributeValue("selector");
          }
+
+         public void addJNDI(String jndi) throws Exception
+         {
+            // TODO: Add a test for this
+            proxy.invokeOperation("addJNDI", jndi);
+         }
+
+         public List<String> getJNDIBindings()
+         {
+            // TODO: Add a test for this
+            return null;
+         }
       };
    }
 

Modified: trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -167,14 +167,14 @@
             return (Boolean)proxy.invokeOperation("closeConnectionsForAddress", ipAddress);
          }
 
-         public boolean createQueue(final String name, final String jndiBinding) throws Exception
+         public boolean createQueue(final String name) throws Exception
          {
-            return (Boolean)proxy.invokeOperation("createQueue", name, jndiBinding);
+            return (Boolean)proxy.invokeOperation("createQueue", name);
          }
 
-         public boolean createTopic(final String name, final String jndiBinding) throws Exception
+         public boolean createTopic(final String name) throws Exception
          {
-            return (Boolean)proxy.invokeOperation("createTopic", name, jndiBinding);
+            return (Boolean)proxy.invokeOperation("createTopic", name);
          }
 
          public void destroyConnectionFactory(final String name) throws Exception
@@ -253,6 +253,18 @@
             return (String)proxy.invokeOperation("getSecuritySettingsAsJSON", addressMatch);
          }
 
+         public boolean createQueue(String name, String jndiBinding) throws Exception
+         {
+            // TODO add a test for this
+            return false;
+         }
+
+         public boolean createTopic(String name, String jndiBinding) throws Exception
+         {
+            // TODO add a test for this
+            return false;
+         }
+
       };
    }
    // Public --------------------------------------------------------

Modified: trunk/tests/src/org/hornetq/tests/integration/jms/server/management/TopicControlTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/server/management/TopicControlTest.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/server/management/TopicControlTest.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -76,7 +76,6 @@
       Assert.assertEquals(topic.getTopicName(), topicControl.getName());
       Assert.assertEquals(topic.getAddress(), topicControl.getAddress());
       Assert.assertEquals(topic.isTemporary(), topicControl.isTemporary());
-      Assert.assertEquals(topic.getName(), topicControl.getJNDIBinding());
    }
 
    public void testGetXXXSubscriptionsCount() throws Exception

Added: trunk/tests/src/org/hornetq/tests/integration/persistence/AddressSettingsConfigurationStorageTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/persistence/AddressSettingsConfigurationStorageTest.java	                        (rev 0)
+++ trunk/tests/src/org/hornetq/tests/integration/persistence/AddressSettingsConfigurationStorageTest.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.persistence;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.core.persistence.config.PersistedAddressSetting;
+import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
+import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
+import org.hornetq.core.settings.impl.AddressSettings;
+
+/**
+ * A ConfigurationStorageTest
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class AddressSettingsConfigurationStorageTest extends StorageManagerTestBase
+{
+
+   private Map<SimpleString, PersistedAddressSetting> mapExpectedAddresses;
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      mapExpectedAddresses = new HashMap<SimpleString, PersistedAddressSetting>();
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      mapExpectedAddresses = null;
+
+      super.tearDown();
+   }
+
+   protected void addAddress(JournalStorageManager journal, String address, AddressSettings setting) throws Exception
+   {
+      SimpleString str = new SimpleString(address);
+      PersistedAddressSetting persistedSetting = new PersistedAddressSetting(str, setting);
+      mapExpectedAddresses.put(str, persistedSetting);
+      journal.storeAddressSetting(persistedSetting);
+   }
+
+   public void testStoreSecuritySettings() throws Exception
+   {
+      createStorage();
+
+      AddressSettings setting = new AddressSettings();
+
+      setting = new AddressSettings();
+
+      setting.setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK);
+
+      setting.setDeadLetterAddress(new SimpleString("some-test"));
+
+      addAddress(journal, "a2", setting);
+
+      journal.stop();
+
+      createStorage();
+
+      checkAddresses(journal);
+
+      setting = new AddressSettings();
+
+      setting.setDeadLetterAddress(new SimpleString("new-adddress"));
+
+      // Replacing the first setting
+      addAddress(journal, "a1", setting);
+
+      journal.stop();
+
+      createStorage();
+
+      checkAddresses(journal);
+      
+      journal.stop();
+
+      journal = null;
+
+   }
+
+   /**
+    * @param journal
+    * @throws Exception
+    */
+   private void checkAddresses(JournalStorageManager journal) throws Exception
+   {
+      List<PersistedAddressSetting> listSetting = journal.recoverAddressSettings();
+
+      assertEquals(mapExpectedAddresses.size(), listSetting.size());
+
+      for (PersistedAddressSetting el : listSetting)
+      {
+         PersistedAddressSetting el2 = mapExpectedAddresses.get(el.getAddressMatch());
+
+         assertEquals(el.getAddressMatch(), el2.getAddressMatch());
+         assertEquals(el.getSetting(), el2.getSetting());
+      }
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Added: trunk/tests/src/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java	                        (rev 0)
+++ trunk/tests/src/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.persistence;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.api.core.HornetQBuffers;
+import org.hornetq.jms.persistence.config.PersistedConnectionFactory;
+import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
+import org.hornetq.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
+
+/**
+ * A JMSConnectionFactoryConfigurationStorageTest
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class JMSConnectionFactoryConfigurationStorageTest extends StorageManagerTestBase
+{
+
+   private Map<String, PersistedConnectionFactory> mapExpectedCFs;
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      mapExpectedCFs = new HashMap<String, PersistedConnectionFactory>();
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      mapExpectedCFs = null;
+
+      super.tearDown();
+   }
+
+   protected void addSetting(PersistedConnectionFactory setting) throws Exception
+   {
+      mapExpectedCFs.put(setting.getName(), setting);
+      jmsJournal.storeConnectionFactory(setting);
+   }
+
+   public void testSettings() throws Exception
+   {
+
+      createJMSStorage();
+
+      String str[] = new String[5];
+      for (int i = 0; i < 5; i++)
+      {
+         str[i] = "str" + i;
+      }
+
+      ConnectionFactoryConfiguration config = new ConnectionFactoryConfigurationImpl("some-name", str);
+
+      addSetting(new PersistedConnectionFactory(config));
+
+      jmsJournal.stop();
+
+      createJMSStorage();
+
+      List<PersistedConnectionFactory> cfs = jmsJournal.recoverConnectionFactories();
+
+      assertEquals(1, cfs.size());
+
+      assertEquals("some-name", cfs.get(0).getName());
+
+      assertEquals(5, cfs.get(0).getConfig().getBindings().length);
+
+      for (int i = 0; i < 5; i++)
+      {
+         assertEquals("str" + i, cfs.get(0).getConfig().getBindings()[i]);
+      }
+   }
+
+   public void testSizeOfCF() throws Exception
+   {
+
+      String str[] = new String[5];
+      for (int i = 0; i < 5; i++)
+      {
+         str[i] = "str" + i;
+      }
+
+      ConnectionFactoryConfiguration config = new ConnectionFactoryConfigurationImpl("some-name", str);
+
+      int size = config.getEncodeSize();
+
+      HornetQBuffer buffer = HornetQBuffers.fixedBuffer(size);
+
+      config.encode(buffer);
+
+      assertEquals(size, buffer.writerIndex());
+      
+      PersistedConnectionFactory persistedCF = new PersistedConnectionFactory(config);
+      
+      size = persistedCF.getEncodeSize();
+
+      buffer = HornetQBuffers.fixedBuffer(size);
+      
+      persistedCF.encode(buffer);
+      
+      assertEquals(size, buffer.writerIndex());
+      
+   }
+
+   /**
+    * @param journal
+    * @throws Exception
+    */
+   private void checkSettings() throws Exception
+   {
+      List<PersistedConnectionFactory> listSetting = jmsJournal.recoverConnectionFactories();
+
+      assertEquals(mapExpectedCFs.size(), listSetting.size());
+
+      for (PersistedConnectionFactory el : listSetting)
+      {
+         PersistedConnectionFactory el2 = mapExpectedCFs.get(el.getName());
+
+         assertEquals(el, el2);
+      }
+   }
+
+}

Added: trunk/tests/src/org/hornetq/tests/integration/persistence/RolesConfigurationStorageTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/persistence/RolesConfigurationStorageTest.java	                        (rev 0)
+++ trunk/tests/src/org/hornetq/tests/integration/persistence/RolesConfigurationStorageTest.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.persistence;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.core.persistence.config.PersistedRoles;
+
+/**
+ * A ConfigurationStorageTest
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class RolesConfigurationStorageTest extends StorageManagerTestBase
+{
+
+   private Map<SimpleString, PersistedRoles> mapExpectedSets;
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      mapExpectedSets = new HashMap<SimpleString, PersistedRoles>();
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      mapExpectedSets = null;
+
+      super.tearDown();
+   }
+
+   protected void addSetting(PersistedRoles setting) throws Exception
+   {
+      mapExpectedSets.put(setting.getAddressMatch(), setting);
+      journal.storeSecurityRoles(setting);
+   }
+
+   public void testStoreSecuritySettings() throws Exception
+   {
+      createStorage();
+      
+
+      addSetting(new PersistedRoles("a#",
+                            "a1",
+                            "a1",
+                            "a1",
+                            "a1",
+                            "a1",
+                            "a1",
+                            "a1"));
+
+
+      addSetting(new PersistedRoles("a2",
+                                    "a1",
+                                    null,
+                                    "a1",
+                                    "a1",
+                                    "a1",
+                                    "a1",
+                                    "a1"));
+
+      journal.stop();
+
+      checkSettings();
+
+      createStorage();
+
+      checkSettings();
+
+      addSetting(new PersistedRoles("a2",
+                                    "a1",
+                                    null,
+                                    "a1",
+                                    "a1",
+                                    "a1",
+                                    "a1",
+                                    "a1"));
+
+      addSetting(new PersistedRoles("a3",
+                                    "a1",
+                                    null,
+                                    "a1",
+                                    "a1",
+                                    "a1",
+                                    "a1",
+                                    "a1"));
+
+      checkSettings();
+
+      journal.stop();
+
+      createStorage();
+
+      checkSettings();
+      
+      journal.stop();
+
+      journal = null;
+
+   }
+
+   /**
+    * @param journal
+    * @throws Exception
+    */
+   private void checkSettings() throws Exception
+   {
+      List<PersistedRoles> listSetting = journal.recoverPersistedRoles();
+
+      assertEquals(mapExpectedSets.size(), listSetting.size());
+
+      for (PersistedRoles el : listSetting)
+      {
+         PersistedRoles el2 = mapExpectedSets.get(el.getAddressMatch());
+
+         assertEquals(el, el2);
+      }
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Added: trunk/tests/src/org/hornetq/tests/integration/persistence/StorageManagerTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/persistence/StorageManagerTestBase.java	                        (rev 0)
+++ trunk/tests/src/org/hornetq/tests/integration/persistence/StorageManagerTestBase.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.persistence;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.persistence.GroupingInfo;
+import org.hornetq.core.persistence.QueueBindingInfo;
+import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
+import org.hornetq.core.server.JournalType;
+import org.hornetq.core.server.Queue;
+import org.hornetq.jms.persistence.JMSStorageManager;
+import org.hornetq.jms.persistence.impl.journal.JournalJMSStorageManagerImpl;
+import org.hornetq.tests.unit.core.server.impl.fakes.FakePostOffice;
+import org.hornetq.tests.util.ServiceTestBase;
+import org.hornetq.utils.ExecutorFactory;
+import org.hornetq.utils.OrderedExecutorFactory;
+import org.hornetq.utils.TimeAndCounterIDGenerator;
+
+/**
+ * A StorageManagerTestBase
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class StorageManagerTestBase extends ServiceTestBase
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+   protected ExecutorService executor;
+
+   protected ExecutorFactory execFactory;
+   
+   protected JournalStorageManager journal;
+   
+   protected JMSStorageManager jmsJournal;
+
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      executor = Executors.newCachedThreadPool();
+
+      execFactory = new OrderedExecutorFactory(executor);
+
+      File testdir = new File(getTestDir());
+ 
+      deleteDirectory(testdir);
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      executor.shutdown();
+       
+      if (journal != null)
+      {
+         try
+         {
+            journal.stop();
+         }
+         catch (Throwable e)
+         {
+            e.printStackTrace(); // >> junit report
+         }
+         
+         journal = null;
+      }
+
+      if (jmsJournal != null)
+      {
+         try
+         {
+            jmsJournal.stop();
+         }
+         catch (Throwable e)
+         {
+            e.printStackTrace(); // >> junit report
+         }
+         
+         jmsJournal = null;
+      }
+
+      super.tearDown();
+   }
+   
+   /**
+    * @return
+    * @throws Exception
+    */
+   protected void createStorage() throws Exception
+   {
+      Configuration configuration = createDefaultConfig();
+
+      configuration.setJournalType(JournalType.ASYNCIO);
+
+      journal = new JournalStorageManager(configuration, execFactory);
+
+      journal.start();
+
+      journal.loadBindingJournal(new ArrayList<QueueBindingInfo>(), new ArrayList<GroupingInfo>());
+      
+      Map<Long, Queue> queues = new HashMap<Long, Queue>();
+
+      journal.loadMessageJournal(new FakePostOffice(), null, null, queues, null);
+   }
+
+   /**
+    * @return
+    * @throws Exception
+    */
+   protected void createJMSStorage() throws Exception
+   {
+      Configuration configuration = createDefaultConfig();
+
+      configuration.setJournalType(JournalType.ASYNCIO);
+
+      jmsJournal = new JournalJMSStorageManagerImpl(new TimeAndCounterIDGenerator(), configuration, null);
+
+      jmsJournal.start();
+   }
+
+
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Modified: trunk/tests/src/org/hornetq/tests/timing/jms/bridge/impl/JMSBridgeImplTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/timing/jms/bridge/impl/JMSBridgeImplTest.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/tests/src/org/hornetq/tests/timing/jms/bridge/impl/JMSBridgeImplTest.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -533,8 +533,8 @@
       jmsServer.setContext(context);
       jmsServer.start();
 
-      jmsServer.createQueue(JMSBridgeImplTest.SOURCE, "/queue/" + JMSBridgeImplTest.SOURCE, null, true);
-      jmsServer.createQueue(JMSBridgeImplTest.TARGET, "/queue/" + JMSBridgeImplTest.TARGET, null, true);
+      jmsServer.createQueue(JMSBridgeImplTest.SOURCE, null, true, "/queue/" + JMSBridgeImplTest.SOURCE);
+      jmsServer.createQueue(JMSBridgeImplTest.TARGET, null, true, "/queue/" + JMSBridgeImplTest.TARGET);
 
    }
 

Modified: trunk/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/tests/src/org/hornetq/tests/unit/core/paging/impl/PagingStoreImplTest.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -15,6 +15,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
@@ -52,6 +53,8 @@
 import org.hornetq.core.persistence.OperationContext;
 import org.hornetq.core.persistence.QueueBindingInfo;
 import org.hornetq.core.persistence.StorageManager;
+import org.hornetq.core.persistence.config.PersistedAddressSetting;
+import org.hornetq.core.persistence.config.PersistedRoles;
 import org.hornetq.core.postoffice.Binding;
 import org.hornetq.core.postoffice.PostOffice;
 import org.hornetq.core.replication.ReplicationManager;
@@ -1307,10 +1310,52 @@
 
       public void storeReference(final long queueID, final long messageID, final boolean last) throws Exception
       {
-         // TODO Auto-generated method stub
+      }
 
+      /* (non-Javadoc)
+       * @see org.hornetq.core.persistence.StorageManager#recoverAddressSettings()
+       */
+      public List<PersistedAddressSetting> recoverAddressSettings() throws Exception
+      {
+         return Collections.emptyList();
       }
 
+      /* (non-Javadoc)
+       * @see org.hornetq.core.persistence.StorageManager#recoverPersistedRoles()
+       */
+      public List<PersistedRoles> recoverPersistedRoles() throws Exception
+      {
+         return Collections.emptyList();
+      }
+
+      /* (non-Javadoc)
+       * @see org.hornetq.core.persistence.StorageManager#storeAddressSetting(org.hornetq.core.persistconfig.PersistedAddressSetting)
+       */
+      public void storeAddressSetting(PersistedAddressSetting addressSetting) throws Exception
+      {
+      }
+
+      /* (non-Javadoc)
+       * @see org.hornetq.core.persistence.StorageManager#storeSecurityRoles(org.hornetq.core.persistconfig.PersistedRoles)
+       */
+      public void storeSecurityRoles(PersistedRoles persistedRoles) throws Exception
+      {
+      }
+
+      /* (non-Javadoc)
+       * @see org.hornetq.core.persistence.StorageManager#deleteAddressSetting(org.hornetq.api.core.SimpleString)
+       */
+      public void deleteAddressSetting(SimpleString addressMatch) throws Exception
+      {
+      }
+
+      /* (non-Javadoc)
+       * @see org.hornetq.core.persistence.StorageManager#deleteSecurityRoles(org.hornetq.api.core.SimpleString)
+       */
+      public void deleteSecurityRoles(SimpleString addressMatch) throws Exception
+      {
+      }
+
    }
 
    class FakeStoreFactory implements PagingStoreFactory

Modified: trunk/tests/src/org/hornetq/tests/util/JMSClusteredTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/util/JMSClusteredTestBase.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/tests/src/org/hornetq/tests/util/JMSClusteredTestBase.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -90,8 +90,8 @@
     */
    protected Queue createQueue(final String name) throws Exception, NamingException
    {
-      jmsServer2.createQueue(name, "/queue/" + name, null, true);
-      jmsServer1.createQueue(name, "/queue/" + name, null, true);
+      jmsServer2.createQueue(name, null, true, "/queue/" + name);
+      jmsServer1.createQueue(name, null, true, "/queue/" + name);
 
       return (Queue)context1.lookup("/queue/" + name);
    }

Modified: trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java	2010-03-26 18:10:52 UTC (rev 8972)
+++ trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java	2010-03-26 21:33:52 UTC (rev 8973)
@@ -85,7 +85,7 @@
     */
    protected Queue createQueue(final String name) throws Exception, NamingException
    {
-      jmsServer.createQueue(name, "/jms/" + name, null, true);
+      jmsServer.createQueue(name, null, true, "/jms/" + name);
 
       return (Queue)context.lookup("/jms/" + name);
    }



More information about the hornetq-commits mailing list