Author: clebert.suconic(a)jboss.com
Date: 2011-10-06 15:31:54 -0400 (Thu, 06 Oct 2011)
New Revision: 11479
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
Log:
Back porting HORNETQ-750 as that's the right way to do it (the binding of JNDI)
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-10-06
19:15:23 UTC (rev 11478)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2011-10-06
19:31:54 UTC (rev 11479)
@@ -103,11 +103,6 @@
private BindingRegistry registry;
- /**
- * the context to bind to
- */
- private Context context;
-
private Map<String, HornetQQueue> queues = new HashMap<String,
HornetQQueue>();
private Map<String, HornetQTopic> topics = new HashMap<String,
HornetQTopic>();
@@ -251,8 +246,9 @@
if (registry == null)
{
if (!contextSet)
- context = new InitialContext();
- registry = new JndiBindingRegistry(context);
+ {
+ registry = new JndiBindingRegistry(new InitialContext());
+ }
}
deploymentManager = new
FileDeploymentManager(server.getConfiguration().getFileDeployerScanPeriod());
@@ -313,9 +309,9 @@
topicJNDI.clear();
topics.clear();
- if (context != null)
+ if (registry != null)
{
- context.close();
+ registry.close();
}
// it could be null if a backup
@@ -375,10 +371,9 @@
public synchronized void setContext(final Context context)
{
- this.context = context;
-
- if (registry != null && registry instanceof JndiBindingRegistry)
+ if (registry == null || registry instanceof JndiBindingRegistry)
{
+ registry = new JndiBindingRegistry(context);
registry.setContext(context);
}
@@ -1456,7 +1451,7 @@
*/
private void unbindJNDI(Map<String, List<String>> param)
{
- if (context != null)
+ if (registry != null)
{
for (List<String> elementList : param.values())
{
@@ -1464,7 +1459,7 @@
{
try
{
- context.unbind(key);
+ registry.unbind(key);
}
catch (Exception e)
{
@@ -1595,13 +1590,13 @@
{
keys.remove(name);
}
- if (context != null)
+ if (registry != null)
{
Iterator<String> iter = jndiBindings.iterator();
while (iter.hasNext())
{
String jndiBinding = iter.next();
- context.unbind(jndiBinding);
+ registry.unbind(jndiBinding);
iter.remove();
}
}
@@ -1621,7 +1616,7 @@
if (jndiBindings.remove(jndi))
{
- context.unbind(jndi);
+ registry.unbind(jndi);
return true;
}
else