@Override
 public void deleteConnectionFactory(final String cfName) throws Exception {
   PersistedConnectionFactory oldCF = mapFactories.remove(cfName);
   if (oldCF != null) {
     jmsJournal.appendDeleteRecord(oldCF.getId(), false);
   }
 }
 @Override
 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);
 }
  @Override
  public void load() throws Exception {
    mapFactories.clear();

    List<RecordInfo> data = new ArrayList<>();

    ArrayList<PreparedTransactionInfo> list = new ArrayList<>();

    jmsJournal.load(data, list, null);

    for (RecordInfo record : data) {
      long id = record.id;

      ActiveMQBuffer buffer = ActiveMQBuffers.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<>(destination.getType(), destination.getName()), destination);
      } else if (rec == BINDING_RECORD) {
        PersistedBindings bindings = new PersistedBindings();
        bindings.decode(buffer);
        bindings.setId(id);
        Pair<PersistedType, String> key = new Pair<>(bindings.getType(), bindings.getName());
        mapBindings.put(key, bindings);
      } else {
        throw new IllegalStateException("Invalid record type " + rec);
      }
    }
  }