[jboss-cvs] JBoss Messaging SVN: r2944 - trunk/tests/src/org/jboss/test/messaging/tools/container.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 31 19:11:24 EDT 2007


Author: timfox
Date: 2007-07-31 19:11:24 -0400 (Tue, 31 Jul 2007)
New Revision: 2944

Modified:
   trunk/tests/src/org/jboss/test/messaging/tools/container/InVMContext.java
   trunk/tests/src/org/jboss/test/messaging/tools/container/InVMInitialContextFactory.java
Log:
Now the real fix


Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/InVMContext.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/InVMContext.java	2007-07-31 22:14:26 UTC (rev 2943)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/InVMContext.java	2007-07-31 23:11:24 UTC (rev 2944)
@@ -41,6 +41,7 @@
 import javax.naming.RefAddr;
 import javax.naming.Reference;
 
+import org.jboss.logging.Logger;
 import org.jboss.messaging.util.NotYetImplementedException;
 import org.jboss.util.naming.NonSerializableFactory;
 
@@ -56,7 +57,10 @@
    // Constants -----------------------------------------------------
 
    private static final long serialVersionUID = 385743957345L;
+   
+   private static final Logger log = Logger.getLogger(InVMContext.class);
 
+
    // Static --------------------------------------------------------
 
    // Attributes ----------------------------------------------------
@@ -72,7 +76,7 @@
    }
 
    // Context implementation ----------------------------------------
-
+   
    public Object lookup(Name name) throws NamingException
    {
       throw new NotYetImplementedException();
@@ -318,6 +322,7 @@
 
    private void internalBind(String name, Object obj, boolean rebind) throws NamingException
    {
+   	log.info("Binding " + name + " obj " + obj + " rebind " + rebind);
       name = trimSlashes(name);
       int i = name.lastIndexOf("/");
       InVMContext c = this;

Modified: trunk/tests/src/org/jboss/test/messaging/tools/container/InVMInitialContextFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/InVMInitialContextFactory.java	2007-07-31 22:14:26 UTC (rev 2943)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/InVMInitialContextFactory.java	2007-07-31 23:11:24 UTC (rev 2944)
@@ -21,9 +21,9 @@
 */
 package org.jboss.test.messaging.tools.container;
 
-import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Hashtable;
-import java.util.List;
+import java.util.Map;
 
 import javax.naming.Context;
 import javax.naming.NamingException;
@@ -43,12 +43,11 @@
 
    // Static --------------------------------------------------------
 
-   // List<InitialContext>
-   private static List initialContexts;
+   private static Map initialContexts;
 
    static
    {
-      initialContexts = new ArrayList();
+      initialContexts = new HashMap();
    }
 
    public static Hashtable getJNDIEnvironment()
@@ -76,8 +75,7 @@
 
    // Public --------------------------------------------------------
 
-   //NOTE!! This method MUST be synchronized
-   public synchronized Context getInitialContext(Hashtable environment) throws NamingException
+   public Context getInitialContext(Hashtable environment) throws NamingException      
    {
       // try first in the environment passed as argument ...
       String s = (String)environment.get(Constants.SERVER_INDEX_PROPERTY_NAME);
@@ -105,29 +103,22 @@
                                    Constants.SERVER_INDEX_PROPERTY_NAME +"\". " +
                                    s + " is not an integer");
       }
-  
-      int size = initialContexts.size();
 
-      // pad the list to the right size
-
-      if (size <= serverIndex)
-      {
-         for(int i = 0; i < serverIndex - size + 1; i++)
-         {
-            initialContexts.add(null);
-         }
-      }
-
-      InVMContext ic = (InVMContext)initialContexts.get(serverIndex);
-
-      if (ic == null)
-      {
-         ic = new InVMContext();
-         ic.bind("java:/", new InVMContext());
-         initialContexts.set(serverIndex, ic);
-      }
-
-      return ic;
+   	//Note! This MUST be synchronized
+   	synchronized (initialContexts)
+   	{
+	   	      
+	      InVMContext ic = (InVMContext)initialContexts.get(new Integer(serverIndex));
+	
+	      if (ic == null)
+	      {
+	         ic = new InVMContext();
+	         ic.bind("java:/", new InVMContext());
+	         initialContexts.put(new Integer(serverIndex), ic);
+	      }
+	
+	      return ic;
+   	}
    }
 
    // Package protected ---------------------------------------------




More information about the jboss-cvs-commits mailing list