Permalink
Browse files

Merge pull request #40 from gaohoward/master

HORNETQ-812
  • Loading branch information...
2 parents b63834a + 4873f4a commit 6af09554916fcc7255c7020341e2f6c92bedcc3f @FranciscoBorges FranciscoBorges committed Apr 5, 2012
@@ -152,8 +152,6 @@ public void deleteConnectionFactory(final String cfName) throws Exception
{
jmsJournal.appendDeleteRecord(oldCF.getId(), false);
}
-
- this.deleteJNDI(PersistedType.ConnectionFactory, cfName);
}
/* (non-Javadoc)
@@ -140,6 +140,8 @@
private JMSStorageManager storage;
+ private Map<String, List<String>> unRecoveredJndi = new HashMap<String, List<String>>();
+
public JMSServerManagerImpl(final HornetQServer server) throws Exception
{
this.server = server;
@@ -246,7 +248,58 @@ public synchronized void activated()
JMSServerManagerImpl.log.error("Failed to start jms deployer", e);
}
}
-
+
+ public void recoverJndiBindings(String name, PersistedType type)
+ throws NamingException
+ {
+ List<String> bindings = unRecoveredJndi.get(name);
+ if ((bindings != null) && (bindings.size() > 0))
+ {
+ Map<String, List<String>> mapJNDI;
+ Map<String, ?> objects;
+
+ switch (type)
+ {
+ 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(name);
+
+ List<String> jndiList = mapJNDI.get(name);
+
+ if (objectToBind == null)
+ {
+ return;
+ }
+
+ if (jndiList == null)
+ {
+ jndiList = new ArrayList<String>();
+ mapJNDI.put(name, jndiList);
+ }
+
+ for (String jndi : bindings)
+ {
+ jndiList.add(jndi);
+ bindToJndi(jndi, objectToBind);
+ }
+
+ unRecoveredJndi.remove(name);
+ }
+ }
+
private void recoverJndiBindings() throws Exception
{
//now its time to add journal recovered stuff
@@ -275,13 +328,14 @@ private void recoverJndiBindings() throws Exception
}
Object objectToBind = objects.get(record.getName());
+ List<String> jndiList = mapJNDI.get(record.getName());
if (objectToBind == null)
{
+ unRecoveredJndi.put(record.getName(), record.getJndi());
continue;
}
- List<String> jndiList = mapJNDI.get(record.getName());
if (jndiList == null)
{
jndiList = new ArrayList<String>();
@@ -1062,7 +1116,8 @@ public void runException() throws Exception
storage.storeConnectionFactory(new PersistedConnectionFactory(cfConfig));
storage.addJNDI(PersistedType.ConnectionFactory, cfConfig.getName(), usedJNDI);
}
-
+
+ JMSServerManagerImpl.this.recoverJndiBindings(cfConfig.getName(), PersistedType.ConnectionFactory);
}
});
}
@@ -1119,6 +1174,8 @@ private boolean internalCreateQueue(final String queueName, final String selecto
queues.put(queueName, hqQueue);
+ this.recoverJndiBindings(queueName, PersistedType.Queue);
+
jmsManagementService.registerQueue(hqQueue, queue);
return true;
@@ -1155,6 +1212,8 @@ private boolean internalCreateTopic(final String topicName) throws Exception
topics.put(topicName, hqTopic);
+ this.recoverJndiBindings(topicName, PersistedType.Topic);
+
jmsManagementService.registerTopic(hqTopic);
return true;

0 comments on commit 6af0955

Please sign in to comment.