[hornetq-commits] JBoss hornetq SVN: r11846 - in branches/Branch_2_2_EAP/src/main/org/hornetq: jms/server/impl and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Dec 5 21:56:29 EST 2011


Author: clebert.suconic at jboss.com
Date: 2011-12-05 21:56:29 -0500 (Mon, 05 Dec 2011)
New Revision: 11846

Modified:
   branches/Branch_2_2_EAP/src/main/org/hornetq/integration/spring/SpringBindingRegistry.java
   branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
Log:
JBPAPP-7504 - duplicate JNDI should throw an exception

Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/integration/spring/SpringBindingRegistry.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/integration/spring/SpringBindingRegistry.java	2011-12-06 00:16:24 UTC (rev 11845)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/integration/spring/SpringBindingRegistry.java	2011-12-06 02:56:29 UTC (rev 11846)
@@ -1,6 +1,7 @@
 package org.hornetq.integration.spring;
 
 import org.hornetq.spi.core.naming.BindingRegistry;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
 
 /**
@@ -18,7 +19,14 @@
 
    public Object lookup(String name)
    {
-      return factory.getBean(name);
+      try
+      {
+         return factory.getBean(name);
+      }
+      catch (NoSuchBeanDefinitionException e)
+      {
+         return null;
+      }
    }
 
    public boolean bind(String name, Object obj)

Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java	2011-12-06 00:16:24 UTC (rev 11845)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java	2011-12-06 02:56:29 UTC (rev 11846)
@@ -408,6 +408,8 @@
 
          public void runException() throws Exception
          {
+            checkJNDI(jndi);
+            
             if (internalCreateQueue(queueName, selectorString, durable))
             {
 
@@ -462,6 +464,8 @@
 
          public void runException() throws Exception
          {
+            checkJNDI(jndi);
+            
             if (internalCreateTopic(topicName))
             {
                HornetQDestination destination = topics.get(topicName);
@@ -501,6 +505,8 @@
    public boolean addTopicToJndi(final String topicName, final String jndiBinding) throws Exception
    {
       checkInitialised();
+    
+      checkJNDI(jndiBinding);
 
       HornetQTopic destination = topics.get(topicName);
       if (destination == null)
@@ -540,6 +546,8 @@
    {
       checkInitialised();
 
+      checkJNDI(jndiBinding);
+
       HornetQQueue destination = queues.get(queueName);
       if (destination == null)
       {
@@ -561,6 +569,8 @@
    public boolean addConnectionFactoryToJNDI(final String name, final String jndiBinding) throws Exception
    {
       checkInitialised();
+      
+      checkJNDI(jndiBinding);
 
       HornetQConnectionFactory factory = connectionFactories.get(name);
       if (factory == null)
@@ -954,7 +964,7 @@
    {
       runAfterActive(new RunnableException()
       {
-
+  
          public String toString()
          {
             return "createConnectionFactory for " + cfConfig.getName();
@@ -962,6 +972,7 @@
 
          public void runException() throws Exception
          {
+            checkJNDI(jndi);
 
             HornetQConnectionFactory cf = internalCreateCF(storeConfig, cfConfig);
 
@@ -1402,15 +1413,24 @@
          list.add(jndiItem);
       }
    }
-
-   private boolean bindToJndi(final String jndiName, final Object objectToBind) throws NamingException
+   
+   private void checkJNDI(final String ... jndiNames) throws NamingException
    {
-      if (registry != null)
+      
+      for (String jndiName : jndiNames)
       {
          if (registry.lookup(jndiName) != null)
          {
             throw new NamingException(jndiName + " already has an object bound");
          }
+      }
+   }
+
+   private boolean bindToJndi(final String jndiName, final Object objectToBind) throws NamingException
+   {
+      if (registry != null)
+      {
+         registry.unbind(jndiName);
          registry.bind(jndiName, objectToBind);
       }
       return true;



More information about the hornetq-commits mailing list