[jboss-cvs] JBossAS SVN: r59203 - in trunk: ejb3/src/main/org/jboss/ejb3 ejb3/src/main/org/jboss/ejb3/client ejb3/src/main/org/jboss/ejb3/clientmodule ejb3/src/main/org/jboss/ejb3/mdb ejb3/src/main/org/jboss/ejb3/naming ejb3/src/main/org/jboss/ejb3/service ejb3/src/main/org/jboss/ejb3/stateful ejb3/src/main/org/jboss/injection ejb3/src/test/org/jboss/ejb3/test/enventry ejb3/src/test/org/jboss/ejb3/test/enventry/unit server/src/main/org/jboss/ejb server/src/main/org/jboss/naming testsuite/src/main/org/jboss/test/naming/ejb tomcat/src/main/org/jboss/web/tomcat/tc6

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Dec 21 16:23:29 EST 2006


Author: bill.burke at jboss.com
Date: 2006-12-21 16:23:17 -0500 (Thu, 21 Dec 2006)
New Revision: 59203

Added:
   trunk/ejb3/src/main/org/jboss/ejb3/DefaultEjbEncFactory.java
   trunk/ejb3/src/main/org/jboss/ejb3/EjbEncFactory.java
   trunk/server/src/main/org/jboss/naming/ThreadLocalStack.java
Removed:
   trunk/ejb3/src/main/org/jboss/ejb3/ThreadLocalENCFactory.java
   trunk/ejb3/src/main/org/jboss/ejb3/naming/MultiplexerContext.java
   trunk/ejb3/src/main/org/jboss/ejb3/naming/NamingEnumerationImpl.java
   trunk/ejb3/src/main/org/jboss/ejb3/naming/SimpleMultiplexer.java
Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java
   trunk/ejb3/src/main/org/jboss/ejb3/Container.java
   trunk/ejb3/src/main/org/jboss/ejb3/EJB3Deployer.java
   trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/ENCPropagationInterceptor.java
   trunk/ejb3/src/main/org/jboss/ejb3/SessionContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/mdb/ConsumerContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
   trunk/ejb3/src/main/org/jboss/injection/InjectionContainer.java
   trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/enventry/TestEnvEntry.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/enventry/TestEnvEntryBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/enventry/unit/EnvEntryTestCase.java
   trunk/server/src/main/org/jboss/ejb/EjbUtil.java
   trunk/server/src/main/org/jboss/naming/ENCFactory.java
   trunk/server/src/main/org/jboss/naming/JNDIView.java
   trunk/testsuite/src/main/org/jboss/test/naming/ejb/TestENCBean.java
   trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/TomcatInjectionContainer.java
Log:
Revamp java:comp namespace and add EJB3 to this namespace.
Fixed a minor bug in EJB3 env-entry processing
Fixed a minor bug in EJB 2.1 container's messageLink processing

Modified: trunk/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -141,15 +141,15 @@
       String newName;
       if (name.startsWith("/"))
       {
-         newName = Container.ENC_CTX_NAME + "/env" + name;
+         newName = "env" + name;
       }
       else
       {
-         newName = Container.ENC_CTX_NAME + "/env/" + name;
+         newName = "env/" + name;
       }
       try
       {
-         return getContainer().getInitialContext().lookup(newName);
+         return getContainer().getEnc().lookup(newName);
       }
       catch (NamingException ignored)
       {

Modified: trunk/ejb3/src/main/org/jboss/ejb3/Container.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Container.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Container.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -37,7 +37,7 @@
  */
 public interface Container
 {
-   String ENC_CTX_NAME = "java:comp.ejb3";
+   String ENC_CTX_NAME = "java:comp";
 
    Class getBeanClass();
 

Added: trunk/ejb3/src/main/org/jboss/ejb3/DefaultEjbEncFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/DefaultEjbEncFactory.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/DefaultEjbEncFactory.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -0,0 +1,73 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3;
+
+import org.jboss.ejb.EjbUtil;
+import org.jboss.naming.ENCFactory;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * comment
+ *
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @version $Revision: 1.1 $
+ */
+public class DefaultEjbEncFactory implements EjbEncFactory
+{
+
+   public Context getEnc(EJBContainer container)
+   {
+      pushEnc(container);
+      InitialContext ctx = container.getInitialContext();
+      try
+      {
+         return (Context)ctx.lookup("java:comp");
+      }
+      catch (NamingException e)
+      {
+         throw new RuntimeException(e);
+      }
+      finally
+      {
+         popEnc(container);   
+      }
+   }
+
+   public void pushEnc(EJBContainer container)
+   {
+      ENCFactory.pushContextId(container.getObjectName());
+   }
+
+   public void popEnc(EJBContainer container)
+   {
+      ENCFactory.popContextId();
+   }
+
+
+   public void cleanupEnc(EJBContainer container)
+   {
+      ENCFactory.getEncById().remove(container.getObjectName());
+   }
+}

Modified: trunk/ejb3/src/main/org/jboss/ejb3/EJB3Deployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJB3Deployer.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJB3Deployer.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -38,15 +38,12 @@
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
-import javax.naming.RefAddr;
-import javax.naming.Reference;
-import javax.naming.StringRefAddr;
+import javax.naming.LinkRef;
+
 import org.jboss.deployment.DeploymentException;
 import org.jboss.deployment.DeploymentInfo;
 import org.jboss.deployment.SubDeployer;
 import org.jboss.deployment.SubDeployerSupport;
-import org.jboss.ejb3.naming.MultiplexerContext;
-import org.jboss.ejb3.naming.SimpleMultiplexer;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.MetaData;
 import org.jboss.metadata.XmlFileLoader;
@@ -317,25 +314,11 @@
       initializeJavaComp(iniCtx);
    }
 
-   private static void hackJNDI(Context ctx) throws NamingException
-   {
-      log.info("Starting java:comp hack");
-      // rename to something SimpleMultiPlexer knows.
-      ctx.rename("comp", "comp.original");
-      RefAddr refAddr = new StringRefAddr("nns", "ENC-MULTIPLEXER");
-      Reference ref = new Reference("javax.naming.Context", refAddr, SimpleMultiplexer.class.getName(), null);
-      ctx.bind("comp", ref);
-   }
-   
    public static void initializeJavaComp(InitialContext iniCtx)
            throws NamingException
    {
-      RefAddr refAddr = new StringRefAddr("nns", "ENC-EJB3");
-      Reference envRef = new Reference("javax.naming.Context", refAddr, ThreadLocalENCFactory.class.getName(), null);
       Context ctx = (Context) iniCtx.lookup("java:");
-      ctx.rebind("comp.ejb3", envRef);
-      
-      hackJNDI(ctx);
+      ctx.rebind("comp.ejb3", new LinkRef("java:comp"));
    }
 
    /**

Modified: trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -23,12 +23,10 @@
 
 import org.jboss.annotation.ejb.PoolClass;
 import org.jboss.aop.AspectManager;
-import org.jboss.aop.ClassAdvisor;
 import org.jboss.aop.ClassContainer;
 import org.jboss.aop.advice.Interceptor;
 import org.jboss.aop.annotation.AnnotationElement;
 import org.jboss.aop.joinpoint.ConstructorInvocation;
-import org.jboss.aop.util.MethodHashing;
 import org.jboss.ejb3.entity.PersistenceUnitDeployment;
 import org.jboss.ejb3.interceptor.InterceptorInfo;
 import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
@@ -52,9 +50,9 @@
 import org.jboss.injection.ResourceHandler;
 import org.jboss.injection.WebServiceRefHandler;
 import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.PersistenceContextRef;
 import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
 import org.jboss.naming.Util;
+import org.jboss.naming.ENCFactory;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
@@ -65,7 +63,6 @@
 import javax.management.ObjectName;
 import javax.naming.Context;
 import javax.naming.InitialContext;
-import javax.naming.LinkRef;
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
 
@@ -97,6 +94,8 @@
 
    private static final Logger log = Logger.getLogger(EJBContainer.class);
 
+   protected EjbEncFactory encFactory = new DefaultEjbEncFactory();
+
    protected Pool pool;
 
    protected String ejbName;
@@ -113,7 +112,6 @@
    protected List<Injector> injectors = new ArrayList<Injector>();
 
    protected Context enc;
-   protected Context encEnv;
 
    protected Class beanContextClass;
 
@@ -185,11 +183,9 @@
          throw new RuntimeException("failed to create object name for: " + on, e);
       }
       initialContextProperties = ctxProperties;
-      Context ctx = getInitialContext();
       try
       {
-         enc = ThreadLocalENCFactory.create(ctx);
-         encEnv = Util.createSubcontext(enc, "env");
+         Util.createSubcontext(getEnc(), "env");
       }
       catch (Exception e)
       {
@@ -198,6 +194,39 @@
       this.interceptorRepository = interceptorRepository;
       this.interceptorRepository.addBeanClass(clazz.getName());
    }
+
+
+   public EjbEncFactory getEncFactory()
+   {
+      return encFactory;
+   }
+
+   public void setEncFactory(EjbEncFactory encFactory)
+   {
+      this.encFactory = encFactory;
+   }
+
+   /**
+    * Makes sure that EJB's ENC is available
+    * Delegates to whatever implementation is used to push the ENC of the EJB
+    * onto the stack
+    *
+    */
+   public void pushEnc()
+   {
+      encFactory.pushEnc(this);
+   }
+
+
+   /**
+    * Pops EJB's ENC from the stack.  Delegates to whatever implementation
+    * is used to pop the EJB's ENC from the stock
+    *
+    */
+   public void popEnc()
+   {
+      encFactory.popEnc(this);
+   }
    
    public EnvironmentRefGroup getEnvironmentRefGroup()
    {
@@ -370,14 +399,13 @@
 
    public Context getEnc()
    {
+      if (enc == null)
+      {
+         enc = encFactory.getEnc(this);
+      }
       return enc;
    }
 
-   public Context getEncEnv()
-   {
-      return enc;
-   }
-
    public Hashtable getInitialContextProperties()
    {
       return initialContextProperties;
@@ -485,6 +513,7 @@
 
    public void stop() throws Exception
    {
+      encFactory.cleanupEnc(this);
    }
 
    public void destroy() throws Exception
@@ -541,24 +570,24 @@
 
    protected void resolveInjectors() throws Exception
    {
-      ThreadLocalENCFactory.push(enc);
+      pushEnc();
       try
       {
          Thread.currentThread().setContextClassLoader(classloader);
          try
          {
-            Util.rebind(enc, "UserTransaction", new UserTransactionImpl());
+            Util.rebind(getEnc(), "UserTransaction", new UserTransactionImpl());
          }
          catch (NamingException e)
          {
-            NamingException namingException = new NamingException("Could not bind user transaction for ejb name " + ejbName + " into JNDI under jndiName: " + enc.getNameInNamespace() + "/" + "UserTransaction");
+            NamingException namingException = new NamingException("Could not bind user transaction for ejb name " + ejbName + " into JNDI under jndiName: " + getEnc().getNameInNamespace() + "/" + "UserTransaction");
             namingException.setRootCause(e);
             throw namingException;
          }
       }
       finally
       {
-         ThreadLocalENCFactory.pop();
+         popEnc();
       }
    }
 

Modified: trunk/ejb3/src/main/org/jboss/ejb3/ENCPropagationInterceptor.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ENCPropagationInterceptor.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ENCPropagationInterceptor.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -39,16 +39,15 @@
 
    public Object invoke(Invocation invocation) throws Throwable
    {
+      EJBContainer container = (EJBContainer) invocation.getAdvisor();
       try
       {
-         Container container = (Container) invocation.getAdvisor();
-         ThreadLocalENCFactory.push(container.getEnc());
-
+         container.pushEnc();
          return invocation.invokeNext();
       }
       finally
       {
-         ThreadLocalENCFactory.pop();
+         container.popEnc();
       }
    }
 }

Added: trunk/ejb3/src/main/org/jboss/ejb3/EjbEncFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EjbEncFactory.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EjbEncFactory.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.ejb3;
+
+import javax.naming.Context;
+
+/**
+ * ENC Abstraction for EJB Container
+ *
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @version $Revision: 1.1 $
+ */
+public interface EjbEncFactory
+{
+   Context getEnc(EJBContainer container);
+
+   /**
+    * Push the EJB's ENC onto the current thread
+    *
+    * @param container
+    */
+   void pushEnc(EJBContainer container);
+
+   /**
+    * pop the EJB's ENC from the current thread
+    *
+    * @param container
+    */
+   void popEnc(EJBContainer container);
+
+   /**
+    * 
+    * @param container
+    */
+   void cleanupEnc(EJBContainer container);
+}

Modified: trunk/ejb3/src/main/org/jboss/ejb3/SessionContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/SessionContainer.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/SessionContainer.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -264,7 +264,7 @@
    public Object invoke(ProxyFactory factory, Object id, Method method, Object args[], FutureHolder provider) throws Throwable
    {
       ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-      ThreadLocalENCFactory.push(enc);
+      pushEnc();
       try
       {
          long hash = MethodHashing.calculateHash(method);
@@ -310,7 +310,7 @@
       finally
       {
          Thread.currentThread().setContextClassLoader(oldLoader);
-         ThreadLocalENCFactory.pop();
+         popEnc();
       }
    }
    

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/ThreadLocalENCFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ThreadLocalENCFactory.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ThreadLocalENCFactory.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -1,96 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3;
-
-import java.util.Hashtable;
-import java.util.LinkedList;
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.spi.ObjectFactory;
-import org.jnp.interfaces.NamingContext;
-import org.jnp.server.NamingServer;
-
-/**
- * Implementation of "java:comp" namespace factory. The context is associated
- * with the thread class loader.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class ThreadLocalENCFactory
-        implements ObjectFactory
-{
-   private static ThreadLocal<Context> enc = new ThreadLocal<Context>();
-   private static ThreadLocal<LinkedList<Context>> stack = new ThreadLocal<LinkedList<Context>>();
-
-   public static Context create(Context parent) throws Exception
-   {
-      NamingServer srv = new NamingServer();
-      return new NamingContext(parent.getEnvironment(), null, srv);
-   }
-
-   public static void push(Context ctx)
-   {
-      if (enc.get() == null)
-      {
-         enc.set(ctx);
-         return;
-      }
-      LinkedList<Context> currentStack = stack.get();
-      if (currentStack == null)
-      {
-         currentStack = new LinkedList<Context>();
-         stack.set(currentStack);
-      }
-      currentStack.addLast(enc.get());
-      enc.set(ctx);
-   }
-
-   public static void pop()
-   {
-      LinkedList<Context> currentStack = stack.get();
-      if (currentStack == null)
-      {
-         enc.set(null);
-         return;
-      }
-      if (currentStack.size() == 0)
-      {
-         enc.set(null);
-         return;
-      }
-      Context previous = currentStack.removeLast();
-      enc.set(previous);
-   }
-   // Constructors --------------------------------------------------
-
-   // Public --------------------------------------------------------
-
-   // ObjectFactory implementation ----------------------------------
-   public Object getObjectInstance(Object obj, Name name, Context nameCtx,
-                                   Hashtable environment)
-           throws Exception
-   {
-      return enc.get();
-   }
-
-}

Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -215,14 +215,6 @@
    }
 
    /* (non-Javadoc)
-    * @see org.jboss.injection.InjectionContainer#getEncEnv()
-    */
-   public Context getEncEnv()
-   {
-      return encEnv;
-   }
-
-   /* (non-Javadoc)
     * @see org.jboss.injection.InjectionContainer#getEncInjections()
     */
    public Map<String, Map<AccessibleObject, Injector>> getEncInjections()

Modified: trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -214,11 +214,6 @@
       return enc;
    }
 
-   public Context getEncEnv()
-   {
-      return encEnv;
-   }
-
    public Map<String, Map<AccessibleObject, Injector>> getEncInjections()
    {
       return encInjections;

Modified: trunk/ejb3/src/main/org/jboss/ejb3/mdb/ConsumerContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/mdb/ConsumerContainer.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/mdb/ConsumerContainer.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -21,45 +21,8 @@
 */ 
 package org.jboss.ejb3.mdb;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Map;
-
-import javax.ejb.ActivationConfigProperty;
-import javax.ejb.EJBException;
-import javax.ejb.MessageDriven;
-import javax.ejb.Timer;
-import javax.ejb.TimerService;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
-import javax.ejb.TransactionManagement;
-import javax.ejb.TransactionManagementType;
-import javax.jms.Connection;
-import javax.jms.ConnectionConsumer;
-import javax.jms.Destination;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.ServerSessionPool;
-import javax.jms.Topic;
-import javax.jms.TopicConnection;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.transaction.Transaction;
-import org.jboss.annotation.ejb.AcknowledgementMode;
 import org.jboss.annotation.ejb.Consumer;
 import org.jboss.annotation.ejb.DefaultActivationSpecs;
-import org.jboss.annotation.ejb.Durability;
 import org.jboss.annotation.ejb.Local;
 import org.jboss.annotation.ejb.MessageProperties;
 import org.jboss.annotation.ejb.MessagePropertiesImpl;
@@ -71,27 +34,23 @@
 import org.jboss.aop.joinpoint.Invocation;
 import org.jboss.aop.joinpoint.InvocationResponse;
 import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.aop.util.MethodHashing;
 import org.jboss.aop.util.PayloadKey;
-import org.jboss.deployment.DeploymentException;
 import org.jboss.ejb3.Container;
-import org.jboss.ejb3.EJBContainer;
 import org.jboss.ejb3.EJBContainerInvocation;
-import org.jboss.ejb3.Ejb3Module;
-import org.jboss.ejb3.ProxyFactoryHelper;
-import org.jboss.ejb3.ThreadLocalENCFactory;
 import org.jboss.ejb3.Ejb3Deployment;
 import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
-import org.jboss.ejb3.mdb.inflow.JBossMessageEndpointFactory;
-import org.jboss.ejb3.timerservice.TimedObjectInvoker;
-import org.jboss.ejb3.timerservice.TimerServiceFactory;
-import org.jboss.ejb3.tx.TxUtil;
-import org.jboss.jms.ConnectionFactoryHelper;
-import org.jboss.jms.asf.ServerSessionPoolFactory;
-import org.jboss.jms.asf.StdServerSessionPool;
-import org.jboss.jms.jndi.JMSProviderAdapter;
 import org.jboss.logging.Logger;
 
+import javax.ejb.ActivationConfigProperty;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.ObjectMessage;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
 /**
  * Comment
  *
@@ -133,7 +92,7 @@
    {
       ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
       EJBContainerInvocation newSi = null;
-      ThreadLocalENCFactory.push(enc);
+      pushEnc();
       try
       {
          Thread.currentThread().setContextClassLoader(classloader);
@@ -157,7 +116,7 @@
       finally
       {
          Thread.currentThread().setContextClassLoader(oldLoader);
-         ThreadLocalENCFactory.pop();
+         popEnc();
       }
    }
    
@@ -185,7 +144,7 @@
       if (info.getAdvisedMethod().equals(getOnMessage()))
       {
          ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-         ThreadLocalENCFactory.push(enc);
+         pushEnc();
          
          try
          {
@@ -197,7 +156,7 @@
          finally
          {
             Thread.currentThread().setContextClassLoader(oldLoader);
-            ThreadLocalENCFactory.pop();
+            popEnc();
          }
       }
       else

Modified: trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -236,7 +236,7 @@
    public Object localInvoke(MethodInfo info, Object[] args) throws Throwable
    {     
       ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-      ThreadLocalENCFactory.push(enc);
+      pushEnc();
       try
       {
          Interceptor[] aspects = info.getInterceptors();
@@ -248,7 +248,7 @@
       finally
       {
          Thread.currentThread().setContextClassLoader(oldLoader);
-         ThreadLocalENCFactory.pop();
+         popEnc();
       }
    }
 

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/naming/MultiplexerContext.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/naming/MultiplexerContext.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/naming/MultiplexerContext.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -1,283 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.naming;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Hashtable;
-
-import javax.naming.Binding;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.Name;
-import javax.naming.NameClassPair;
-import javax.naming.NameParser;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.OperationNotSupportedException;
-
-/**
- * A context which combines two contexts.
- * 
- * Read operations are combined, write operations are done on the first context.
- * All other operations are not supported.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class MultiplexerContext implements Context, Serializable
-{
-   private static final long serialVersionUID = -2306711582586456135L;
-   
-   private transient InitialContext initialCtx;
-   
-   private String contextOneName;
-   private String contextTwoName;
-
-   public MultiplexerContext(String contextOneName, String contextTwoName) throws NamingException
-   {
-      assert contextOneName != null;
-      assert contextTwoName != null;
-      
-      this.contextOneName = contextOneName;
-      this.contextTwoName = contextTwoName;
-      
-      // make sure this works further down the line
-      getContextOne();
-      getContextTwo();
-   }
-   
-   private <T extends NameClassPair> void addAll(Collection<T> collection, NamingEnumeration<T> ne) throws NamingException
-   {
-      // TODO: how about duplicates?
-      while(ne.hasMore())
-      {
-         T ncp = ne.next();
-         collection.add(ncp);
-      }
-   }
-   
-   public Object addToEnvironment(String propName, Object propVal) throws NamingException
-   {
-      throw new OperationNotSupportedException();
-   }
-
-   public void bind(Name name, Object obj) throws NamingException
-   {
-      getContextOne().bind(name, obj);  
-   }
-
-   public void bind(String name, Object obj) throws NamingException
-   {
-      getContextOne().bind(name, obj);
-   }
-
-   public void close() throws NamingException
-   {
-      // do nothing
-   }
-
-   public Name composeName(Name name, Name prefix) throws NamingException
-   {
-      return getContextOne().composeName(name, prefix);
-   }
-
-   public String composeName(String name, String prefix) throws NamingException
-   {
-      return getContextOne().composeName(name, prefix);
-   }
-
-   public Context createSubcontext(Name name) throws NamingException
-   {
-      return getContextOne().createSubcontext(name);
-   }
-
-   public Context createSubcontext(String name) throws NamingException
-   {
-      return getContextOne().createSubcontext(name);
-   }
-
-   public void destroySubcontext(Name name) throws NamingException
-   {
-      getContextOne().destroySubcontext(name);
-   }
-
-   public void destroySubcontext(String name) throws NamingException
-   {
-      getContextOne().destroySubcontext(name);
-   }
-
-   private Context getContextOne() throws NamingException
-   {
-      return (Context) getInitialContext().lookup(contextOneName);
-   }
-   
-   private Context getContextTwo() throws NamingException
-   {
-      return (Context) getInitialContext().lookup(contextTwoName);
-   }
-   
-   public Hashtable<?, ?> getEnvironment() throws NamingException
-   {
-      throw new UnsupportedOperationException();
-   }
-
-   private InitialContext getInitialContext() throws NamingException
-   {
-      if(initialCtx == null)
-      {
-         initialCtx = new InitialContext();
-      }
-      return initialCtx;
-   }
-   
-   public String getNameInNamespace() throws NamingException
-   {
-      throw new UnsupportedOperationException();
-   }
-
-   public NameParser getNameParser(Name name) throws NamingException
-   {
-      return getContextOne().getNameParser(name);
-   }
-
-   public NameParser getNameParser(String name) throws NamingException
-   {
-      return getContextOne().getNameParser(name);
-   }
-
-   public NamingEnumeration<NameClassPair> list(Name name) throws NamingException
-   {
-      Collection<NameClassPair> set = new ArrayList<NameClassPair>();
-      addAll(set, getContextOne().list(name));
-      addAll(set, getContextTwo().list(name));
-      return new NamingEnumerationImpl<NameClassPair>(set);
-   }
-
-   public NamingEnumeration<NameClassPair> list(String name) throws NamingException
-   {
-      Collection<NameClassPair> set = new ArrayList<NameClassPair>();
-      addAll(set, getContextOne().list(name));
-      addAll(set, getContextTwo().list(name));
-      return new NamingEnumerationImpl<NameClassPair>(set);
-   }
-
-   public NamingEnumeration<Binding> listBindings(Name name) throws NamingException
-   {
-      Collection<Binding> set = new ArrayList<Binding>();
-      addAll(set, getContextOne().listBindings(name));
-      addAll(set, getContextTwo().listBindings(name));
-      return new NamingEnumerationImpl<Binding>(set);
-   }
-
-   public NamingEnumeration<Binding> listBindings(String name) throws NamingException
-   {
-      Collection<Binding> set = new ArrayList<Binding>();
-      addAll(set, getContextOne().listBindings(name));
-      addAll(set, getContextTwo().listBindings(name));
-      return new NamingEnumerationImpl<Binding>(set);
-   }
-
-   public Object lookup(Name name) throws NamingException
-   {
-      try
-      {
-         return getContextOne().lookup(name);
-      }
-      catch(NamingException e)
-      {
-         return getContextTwo().lookup(name);
-      }
-   }
-
-   public Object lookup(String name) throws NamingException
-   {
-      try
-      {
-         return getContextOne().lookup(name);
-      }
-      catch(NamingException e)
-      {
-         return getContextTwo().lookup(name);
-      }
-   }
-
-   public Object lookupLink(Name name) throws NamingException
-   {
-      try
-      {
-         return getContextOne().lookupLink(name);
-      }
-      catch(NamingException e)
-      {
-         return getContextTwo().lookupLink(name);
-      }
-   }
-
-   public Object lookupLink(String name) throws NamingException
-   {
-      try
-      {
-         return getContextOne().lookupLink(name);
-      }
-      catch(NamingException e)
-      {
-         return getContextTwo().lookupLink(name);
-      }
-   }
-
-   public void rebind(Name name, Object obj) throws NamingException
-   {
-      getContextOne().rebind(name, obj);
-   }
-
-   public void rebind(String name, Object obj) throws NamingException
-   {
-      getContextOne().rebind(name, obj);
-   }
-
-   public Object removeFromEnvironment(String propName) throws NamingException
-   {
-      throw new UnsupportedOperationException();
-   }
-
-   public void rename(Name oldName, Name newName) throws NamingException
-   {
-      getContextOne().rename(oldName, newName);
-   }
-
-   public void rename(String oldName, String newName) throws NamingException
-   {
-      getContextOne().rename(oldName, newName);
-   }
-
-   public void unbind(Name name) throws NamingException
-   {
-      getContextOne().unbind(name);
-   }
-
-   public void unbind(String name) throws NamingException
-   {
-      getContextOne().unbind(name);
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/naming/NamingEnumerationImpl.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/naming/NamingEnumerationImpl.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/naming/NamingEnumerationImpl.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -1,85 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.naming;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import javax.naming.NameClassPair;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class NamingEnumerationImpl<T extends NameClassPair> implements NamingEnumeration<T>
-{
-   private Iterator<T> iterator;
-   
-   NamingEnumerationImpl(Collection<T> set)
-   {
-      this.iterator = set.iterator();
-   }
-
-   /* (non-Javadoc)
-    * @see javax.naming.NamingEnumeration#close()
-    */
-   public void close() throws NamingException
-   {
-      // do nothing
-   }
-
-   /* (non-Javadoc)
-    * @see javax.naming.NamingEnumeration#hasMore()
-    */
-   public boolean hasMore() throws NamingException
-   {
-      return hasMoreElements();
-   }
-
-   /* (non-Javadoc)
-    * @see javax.naming.NamingEnumeration#next()
-    */
-   public T next() throws NamingException
-   {
-      return nextElement();
-   }
-
-   /* (non-Javadoc)
-    * @see java.util.Enumeration#hasMoreElements()
-    */
-   public boolean hasMoreElements()
-   {
-      return iterator.hasNext();
-   }
-
-   /* (non-Javadoc)
-    * @see java.util.Enumeration#nextElement()
-    */
-   public T nextElement()
-   {
-      return iterator.next();
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/naming/SimpleMultiplexer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/naming/SimpleMultiplexer.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/naming/SimpleMultiplexer.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.naming;
-
-import java.util.Hashtable;
-
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.spi.ObjectFactory;
-
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class SimpleMultiplexer implements ObjectFactory
-{
-   private Context context;
-   
-   public SimpleMultiplexer() throws NamingException
-   {
-      this.context = new MultiplexerContext("java:comp.original", "java:comp.ejb3");
-   }
-   
-   public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception
-   {
-      return context;
-   }
-}

Modified: trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -21,25 +21,6 @@
 */
 package org.jboss.ejb3.service;
 
-import java.lang.reflect.Method;
-import java.util.Hashtable;
-
-import javax.ejb.EJBException;
-import javax.ejb.Handle;
-import javax.ejb.Timer;
-import javax.ejb.TimerService;
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-
 import org.jboss.annotation.ejb.Management;
 import org.jboss.annotation.ejb.Service;
 import org.jboss.aop.AspectManager;
@@ -58,14 +39,31 @@
 import org.jboss.ejb3.Ejb3Deployment;
 import org.jboss.ejb3.ProxyFactory;
 import org.jboss.ejb3.SessionContainer;
-import org.jboss.ejb3.ThreadLocalENCFactory;
 import org.jboss.ejb3.asynchronous.AsynchronousInterceptor;
 import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
 import org.jboss.ejb3.timerservice.TimedObjectInvoker;
 import org.jboss.ejb3.timerservice.TimerServiceFactory;
-import org.jboss.logging.Logger;
 import org.jboss.injection.Injector;
+import org.jboss.logging.Logger;
 
+import javax.ejb.EJBException;
+import javax.ejb.Handle;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.InvalidAttributeValueException;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+import java.lang.reflect.Method;
+import java.util.Hashtable;
+
 /**
  * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
  * @version $Revision$
@@ -417,7 +415,7 @@
       {
          try
          {
-            ThreadLocalENCFactory.push(enc);
+            pushEnc();
             for (Injector injector : injectors)
             {
                injector.inject(ctx);
@@ -425,7 +423,7 @@
          }
          finally
          {
-            ThreadLocalENCFactory.pop();
+            popEnc();
          }
       }
       injected = true;

Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -39,13 +39,12 @@
 import org.jboss.ejb3.ProxyFactoryHelper;
 import org.jboss.ejb3.ProxyUtils;
 import org.jboss.ejb3.SessionContainer;
-import org.jboss.ejb3.ThreadLocalENCFactory;
 import org.jboss.ejb3.cache.StatefulCache;
-import org.jboss.injection.Injector;
-import org.jboss.injection.JndiFieldInjector;
 import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
 import org.jboss.ejb3.proxy.EJBMetaDataImpl;
 import org.jboss.ejb3.proxy.handle.HomeHandleImpl;
+import org.jboss.injection.Injector;
+import org.jboss.injection.JndiFieldInjector;
 import org.jboss.logging.Logger;
 
 import javax.annotation.PostConstruct;
@@ -136,7 +135,7 @@
    public Object localHomeInvoke(Method method, Object[] args) throws Throwable
    {
       ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-      ThreadLocalENCFactory.push(enc);
+      pushEnc();
       try
       {
          long hash = MethodHashing.calculateHash(method);
@@ -152,7 +151,7 @@
       finally
       {
          Thread.currentThread().setContextClassLoader(oldLoader);
-         ThreadLocalENCFactory.pop();
+         popEnc();
       }
    }
 
@@ -167,7 +166,7 @@
       long start = System.currentTimeMillis();
 
       ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-      ThreadLocalENCFactory.push(enc);
+      pushEnc();
       try
       {
          long hash = MethodHashing.calculateHash(method);
@@ -223,7 +222,7 @@
       finally
       {
          Thread.currentThread().setContextClassLoader(oldLoader);
-         ThreadLocalENCFactory.pop();
+         popEnc();
       }
    }
 
@@ -235,7 +234,7 @@
    public Object createSession()
    {
       ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-      ThreadLocalENCFactory.push(enc);
+      pushEnc();
       try
       {
          Thread.currentThread().setContextClassLoader(classloader);
@@ -244,7 +243,7 @@
       finally
       {
          Thread.currentThread().setContextClassLoader(oldLoader);
-         ThreadLocalENCFactory.pop();
+         popEnc();
       }
    }
 
@@ -256,7 +255,7 @@
    public Object createSession(Class[] initTypes, Object[] initValues)
    {
       ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-      ThreadLocalENCFactory.push(enc);
+      pushEnc();
       try
       {
          Thread.currentThread().setContextClassLoader(classloader);
@@ -265,7 +264,7 @@
       finally
       {
          Thread.currentThread().setContextClassLoader(oldLoader);
-         ThreadLocalENCFactory.pop();
+         popEnc();
       }
    }
 
@@ -287,7 +286,7 @@
       
       ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
       EJBContainerInvocation newSi = null;
-      ThreadLocalENCFactory.push(enc);
+      pushEnc();
       try
       {
          Thread.currentThread().setContextClassLoader(classloader);
@@ -372,7 +371,7 @@
       finally
       {
          Thread.currentThread().setContextClassLoader(oldLoader);
-         ThreadLocalENCFactory.pop();
+         popEnc();
       }
    }
 

Modified: trunk/ejb3/src/main/org/jboss/injection/InjectionContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/InjectionContainer.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/injection/InjectionContainer.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -67,7 +67,6 @@
    List<Injector> getInjectors();
 
    Context getEnc();
-   Context getEncEnv();
 
 
    PersistenceUnitDeployment getPersistenceUnitDeployment(String unitName) throws NameNotFoundException;

Modified: trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -423,7 +423,7 @@
          //encName = InjectionUtil.getEncName(field);
          encName = property.getDeclaringClass().getName() + "/" + property.getName();
       }
-      else
+      if (!encName.startsWith("env/"))
       {
          encName = "env/" + encName;
       }

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/enventry/TestEnvEntry.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/enventry/TestEnvEntry.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/enventry/TestEnvEntry.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -29,7 +29,7 @@
  */
 public interface TestEnvEntry
 {
-   void checkJNDI() throws NamingException;
+   int checkJNDI() throws NamingException;
    
    int getMaxExceptions();
    

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/enventry/TestEnvEntryBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/enventry/TestEnvEntryBean.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/enventry/TestEnvEntryBean.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -24,6 +24,7 @@
 import javax.annotation.Resource;
 import javax.ejb.Stateless;
 import javax.ejb.Remote;
+import javax.ejb.SessionContext;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
@@ -46,14 +47,18 @@
    @Resource(name="maxExceptions") private int maxExceptions = 4;
    
    @Resource private int numExceptions = 3;
+
+   @Resource
+   SessionContext sessionCtx;
    
    private int minExceptions = 1;
    
-   public void checkJNDI() throws NamingException
+   public int checkJNDI() throws NamingException
    {
       InitialContext ctx = new InitialContext();
-      Integer i = (Integer) ctx.lookup("java:comp/env/maxExceptions");
-      log.info("maxExceptions = " + i);
+      int rtn = (Integer) ctx.lookup("java:comp/env/maxExceptions");
+      if (rtn != (Integer)sessionCtx.lookup("maxExceptions")) throw new RuntimeException("Failed to match env lookup");
+      return rtn;
    }
    
    public int getMaxExceptions()

Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/enventry/unit/EnvEntryTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/enventry/unit/EnvEntryTestCase.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/enventry/unit/EnvEntryTestCase.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -112,7 +112,7 @@
       TestEnvEntry test = (TestEnvEntry)getInitialContext().lookup("TestEnvEntry");
       assertNotNull(test);
       
-      test.checkJNDI();
+      assertEquals(15, test.checkJNDI());
    }
    
    public static Test suite() throws Exception

Modified: trunk/server/src/main/org/jboss/ejb/EjbUtil.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/EjbUtil.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/server/src/main/org/jboss/ejb/EjbUtil.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -388,7 +388,7 @@
       {
          // link contains a Bean Name, scan the DeploymentInfo tree
          DeploymentContext top = unit.getDeploymentContext();
-         while (top != null)
+         while (top.getParent() != null)
          {
             top = top.getParent();
          }

Modified: trunk/server/src/main/org/jboss/naming/ENCFactory.java
===================================================================
--- trunk/server/src/main/org/jboss/naming/ENCFactory.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/server/src/main/org/jboss/naming/ENCFactory.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -23,6 +23,9 @@
 
 import java.util.Hashtable;
 import java.util.WeakHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
 import java.security.PrivilegedAction;
 import java.security.AccessController;
 import javax.naming.Context;
@@ -38,6 +41,7 @@
  *     
  *   @author <a href="mailto:rickard.oberg at telkel.com">Rickard Oberg</a>
  *   @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
+ *   @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  *   @version $Revision$
  */
 public class ENCFactory
@@ -46,9 +50,31 @@
    // Constants -----------------------------------------------------
     
    // Attributes ----------------------------------------------------
-   private static WeakHashMap encs = new WeakHashMap();
+   private static WeakHashMap classloaderKeyedEncs = new WeakHashMap();
    private static ClassLoader topLoader;
+   private static ThreadLocalStack<Object> encIdStack = new ThreadLocalStack<Object>();
+   private static ConcurrentHashMap<Object, Context> encById = new ConcurrentHashMap<Object, Context>();
 
+   public static List<Object> getIdStack()
+   {
+      return encIdStack.getList();
+   }
+
+   public static ConcurrentHashMap<Object, Context> getEncById()
+   {
+      return encById;
+   }
+
+   public static void pushContextId(Object id)
+   {
+      encIdStack.push(id);
+   }
+
+   public static Object popContextId()
+   {
+      return encIdStack.pop();
+   }
+
    // Static --------------------------------------------------------
    public static void setTopClassLoader(ClassLoader topLoader)
    {
@@ -69,11 +95,23 @@
       Hashtable environment)
       throws Exception
    {
+      Object currentId = encIdStack.get();
+      if (currentId != null)
+      {
+         Context compCtx = encById.get(currentId);
+         if (compCtx == null)
+         {
+            NamingServer srv = new NamingServer();
+            compCtx = new NamingContext(environment, null, srv);
+            encById.put(currentId, compCtx);
+         }
+         return compCtx;
+      }
       // Get naming for this component
       ClassLoader ctxClassLoader = GetTCLAction.getContextClassLoader();
-      synchronized (encs)
+      synchronized (classloaderKeyedEncs)
       {
-         Context compCtx = (Context) encs.get(ctxClassLoader);
+         Context compCtx = (Context) classloaderKeyedEncs.get(ctxClassLoader);
 
          /* If this is the first time we see ctxClassLoader first check to see
           if a parent ClassLoader has created an ENC namespace.
@@ -84,7 +122,7 @@
             GetParentAction action = new GetParentAction(ctxClassLoader);
             while( loader != null && loader != topLoader && compCtx == null )
             {
-               compCtx = (Context) encs.get(loader);
+               compCtx = (Context) classloaderKeyedEncs.get(loader);
                loader = action.getParent();
             }
             // If we did not find an ENC create it
@@ -92,7 +130,7 @@
             {
                NamingServer srv = new NamingServer();
                compCtx = new NamingContext(environment, null, srv);
-               encs.put(ctxClassLoader, compCtx);
+               classloaderKeyedEncs.put(ctxClassLoader, compCtx);
             }
          }
          return compCtx;

Modified: trunk/server/src/main/org/jboss/naming/JNDIView.java
===================================================================
--- trunk/server/src/main/org/jboss/naming/JNDIView.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/server/src/main/org/jboss/naming/JNDIView.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -27,6 +27,7 @@
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Set;
+import java.util.HashSet;
 
 import javax.management.Attribute;
 import javax.management.AttributeList;
@@ -50,25 +51,28 @@
  * A simple utlity mbean that allows one to recursively list the default
  * JBoss InitialContext.
  *
+ * @author <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>.
+ * @author Vladimir Blagojevic <vladimir at xisnext.2y.net>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @version <tt>$Revision$</tt>
  * @jmx:mbean name="jboss:type=JNDIView"
- *            extends="org.jboss.system.ServiceMBean"
- *            
- * @version <tt>$Revision$</tt>
- * @author  <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>.
- * @author  Vladimir Blagojevic <vladimir at xisnext.2y.net>
- * @author  <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * extends="org.jboss.system.ServiceMBean"
  */
 public class JNDIView
-      extends ServiceMBeanSupport
-      implements JNDIViewMBean
+        extends ServiceMBeanSupport
+        implements JNDIViewMBean
 {
-   /** The HANamingService attributes, order is significant in getHAUrl() */
+   /**
+    * The HANamingService attributes, order is significant in getHAUrl()
+    */
    protected static final String[] g_haAttributes = new String[]{"BindAddress", "Port"};
-   
-   /** The HANamingService service name */
-   protected String haNamingService;  
-  
+
    /**
+    * The HANamingService service name
+    */
+   protected String haNamingService;
+
+   /**
     * Provided for JMX compliance.
     */
    public JNDIView()
@@ -79,13 +83,12 @@
     * List deployed application java:comp namespaces, the java:
     * namespace as well as the global InitialContext JNDI namespace.
     *
+    * @param verbose, if true, list the class of each object in addition to its name
     * @jmx:managed-operation
-    * 
-    * @param verbose, if true, list the class of each object in addition to its name
     */
    public String list(boolean verbose)
    {
-      StringBuffer buffer = new StringBuffer(4096);      
+      StringBuffer buffer = new StringBuffer(4096);
       Context context = null;
       ClassLoader currentLoader = Thread.currentThread().getContextClassLoader();
 
@@ -103,11 +106,11 @@
          while (it.hasNext() == true)
          {
             WebApplication webApplication = (WebApplication) it.next();
-            
+
             Thread.currentThread().setContextClassLoader(webApplication.getMetaData().getENCLoader());
 
             buffer.append("<h2>java:comp namespace of the " + webApplication.getCanonicalName()
-                  + " application:</h2>\n");
+                    + " application:</h2>\n");
 
             try
             {
@@ -129,8 +132,8 @@
       catch (Throwable e)
       {
          log.debug("Unable to list web applications ENC", e);
-      }      
-      
+      }
+
       // Get all deployed applications so that we can list their
       // java: namespaces which are ClassLoader local
       Set ejbModules = null;
@@ -149,13 +152,14 @@
       }
 
       // List each application JNDI namespace
+      HashSet ejb2Ids = new HashSet();
       for (Iterator i = ejbModules.iterator(); i.hasNext();)
       {
          ObjectName app = (ObjectName) i.next();
          String module = app.getKeyProperty("module");
-         if( module == null )
+         if (module == null)
             module = app.toString();
-         buffer.append("<h1>Ejb Module: " + module + "</h1>\n");
+         buffer.append("<h1>Ejb 2.1 Module: " + module + "</h1>\n");
          try
          {
             Collection containers = (Collection) server.getAttribute(app, "Containers");
@@ -168,11 +172,13 @@
                */
                Thread.currentThread().setContextClassLoader(con.getClassLoader());
                String bean = con.getBeanMetaData().getEjbName();
+               Object on = con.getJmxName();
                buffer.append("<h2>java:comp namespace of the " + bean + " bean:</h2>\n");
 
                try
                {
-                  context = new InitialContext();
+                  context = ENCFactory.getEncById().get(on);
+                  ejb2Ids.add(on);
                   context = (Context) context.lookup("java:comp");
                }
                catch (NamingException e)
@@ -196,6 +202,18 @@
          }
       }
 
+      buffer.append("<h1> Other components with java:comp namespace</h1>\n");
+      for (Object key : ENCFactory.getEncById().keySet())
+      {
+         // skip EJB 2.1 keys
+         if (ejb2Ids.contains(key)) continue;
+         context = ENCFactory.getEncById().get(key);
+         buffer.append("<h2>java:comp namespace of the component " + key + " :</h2>\n");
+         buffer.append("<pre>\n");
+         list(context, " ", buffer, verbose);
+         buffer.append("</pre>\n");
+      }
+
       // List the java: namespace
       Thread.currentThread().setContextClassLoader(currentLoader);
       try
@@ -217,7 +235,7 @@
       // List the global JNDI namespace
       try
       {
-         context = new InitialContext();         
+         context = new InitialContext();
          buffer.append("<h1>Global JNDI Namespace</h1>\n");
          buffer.append("<pre>\n");
          list(context, " ", buffer, verbose);
@@ -229,14 +247,14 @@
          buffer.append("Failed to get InitialContext, " + e.toString(true));
          formatException(buffer, e);
       }
-      
+
       // List the HA-JNDI namespace if the HAJNDI service is available
       try
-      {  
-         String url = getHAUrl();            
+      {
+         String url = getHAUrl();
          if (url != null)
          {
-            java.util.Hashtable env = new java.util.Hashtable();        
+            java.util.Hashtable env = new java.util.Hashtable();
             env.put(Context.PROVIDER_URL, url);
             context = new InitialContext(env);
             buffer.append("<h1>HA-JNDI Namespace</h1>\n");
@@ -260,9 +278,7 @@
     * XML Format.
     *
     * @jmx:managed-operation
-    *
-    * @param verbose, if true, list the class of each object in addition to its name
-    **/
+    */
    public String listXML()
    {
       StringBuffer buffer = new StringBuffer(4096);
@@ -275,39 +291,39 @@
       {
          // Get all deployed web applications so that we can list their
          // java: namespaces which are ClassLoader local
-         Iterator it = (Iterator) server.getAttribute(AbstractWebDeployerMBean.OBJECT_NAME, "DeployedApplications"); 
-                  
-         while ( it.hasNext()==true )
+         Iterator it = (Iterator) server.getAttribute(AbstractWebDeployerMBean.OBJECT_NAME, "DeployedApplications");
+
+         while (it.hasNext() == true)
          {
             WebApplication webApplication = (WebApplication) it.next();
             openWebModuleTag(buffer, webApplication.getCanonicalName());
-            
+
             Thread.currentThread().setContextClassLoader(webApplication.getMetaData().getENCLoader());
-            
+
             try
-            {                              
+            {
                context = new InitialContext();
                context = (Context) context.lookup("java:comp");
-               
+
                listXML(context, buffer);
             }
-               catch (NamingException e)
-               {
-                  buffer.append("Failed on lookup, " + e.toString(true));
-                  formatException(buffer, e);
-                  continue;
-               }
-             finally 
+            catch (NamingException e)
             {
+               buffer.append("Failed on lookup, " + e.toString(true));
+               formatException(buffer, e);
+               continue;
+            }
+            finally
+            {
                closeWebModuleTag(buffer);
-            }            
-         }            
+            }
+         }
       }
       catch (Throwable e)
       {
          log.debug("Unable to list web applications ENC", e);
-      }      
-      
+      }
+
       /* Get all deployed applications so that we can list their
          java: namespaces which are ClassLoader local
       */
@@ -317,24 +333,85 @@
       }
       catch (Exception e)
       {
-         log.error("getDeployedApplications failed", e);         
+         log.error("getDeployedApplications failed", e);
          appendErrorTag(buffer,
-               "Failed to getDeployedApplications " + e.toString());
+                 "Failed to getDeployedApplications " + e.toString());
          closeJndiTag(buffer);
          return buffer.toString();
       }
 
+      HashSet ejb2Ids = new HashSet();
       // List each application JNDI namespace
       for (Iterator i = ejbModules.iterator(); i.hasNext();)
       {
          ObjectName app = (ObjectName) i.next();
          openEjbModuleTag(buffer, app.getKeyProperty("url"));
 
-         listModuleContainers(buffer, app);
+         Collection containers = null;
 
+         try
+         {
+            containers = (Collection) server.getAttribute(app, "Containers");
+         }
+         catch (Throwable t)
+         {
+            log.error("getContainers failed", t);
+            appendPreExceptionTag(buffer, "Failed to get ejbs in module", t);
+         }
+
+         for (Iterator iter = containers.iterator(); iter.hasNext();)
+         {
+            Container con = (Container) iter.next();
+            Object on = con.getJmxName();
+            ejb2Ids.add(on);
+            /* Set the thread class loader to that of the container as
+                     the class loader is used by the java: context object
+                     factory to partition the container namespaces.
+                  */
+            Thread.currentThread().setContextClassLoader(con.getClassLoader());
+            String bean = con.getBeanMetaData().getEjbName();
+            openContextTag(buffer);
+            appendBeanTag(buffer, bean);
+            Context context1 = ENCFactory.getEncById().get(on);
+            if (context1 == null)
+            {
+               appendErrorTag(buffer,
+                       "Failed to find ENC of EJB: " + on);
+               context1 = null;
+            }
+
+            if (context1 != null)
+            {
+               try
+               {
+                  listXML(context1, buffer);
+               }
+               catch (Throwable t)
+               {
+                  appendErrorTag(buffer,
+                          "Failed on list contents, " + t.toString());
+               }
+            }   //   if ( context != null )
+
+            closeContextTag(buffer);
+         }
+
          closeEjbModuleTag(buffer);
       }
 
+      //buffer.append("<h1> Other components with java:comp namespace</h1>\n");
+      for (Object key : ENCFactory.getEncById().keySet())
+      {
+         // skip EJB 2.1 keys
+         if (ejb2Ids.contains(key)) continue;
+         context = ENCFactory.getEncById().get(key);
+         buffer.append("<other-encs>");
+         openContextTag(buffer);
+         appendBeanTag(buffer, key.toString());
+         listXML(context, buffer);
+         closeContextTag(buffer);
+         buffer.append("</other-encs>");
+      }
       // List the java: namespace
       Thread.currentThread().setContextClassLoader(currentLoader);
       try
@@ -346,8 +423,8 @@
       {
          log.error("Failed to get InitialContext for (java:)", e);
          appendErrorTag(buffer,
-               "Failed to get InitialContext for (java:), " +
-               e.toString(true));
+                 "Failed to get InitialContext for (java:), " +
+                         e.toString(true));
       }
 
       if (context != null)
@@ -362,8 +439,8 @@
          {
             log.error("Failed to list contents of (java:)", t);
             appendErrorTag(buffer,
-                  "Failed to list contents of (java:), " +
-                  t.toString());
+                    "Failed to list contents of (java:), " +
+                            t.toString());
          }
          closeContextTag(buffer);
 
@@ -378,7 +455,7 @@
       {
          log.error("Failed to get InitialContext", e);
          appendErrorTag(buffer,
-               "Failed to get InitialContext, " + e.toString(true));
+                 "Failed to get InitialContext, " + e.toString(true));
       }
 
       if (context != null)
@@ -393,20 +470,20 @@
          {
             log.error("Failed to list global contents ", t);
             appendErrorTag(buffer,
-                  "Failed to list global contents, " + t.toString());
+                    "Failed to list global contents, " + t.toString());
          }
          closeContextTag(buffer);
 
       }   //   if ( context != null )
-      
+
       // List the HA-JNDI namespace if the HAJNDI service is available
       String url = null;
       try
       {
-         url = getHAUrl();            
+         url = getHAUrl();
          if (url != null)
-         {   
-            java.util.Hashtable env = new java.util.Hashtable();        
+         {
+            java.util.Hashtable env = new java.util.Hashtable();
             env.put(Context.PROVIDER_URL, url);
             context = new InitialContext(env);
          }
@@ -415,7 +492,7 @@
       {
          log.error("Failed to get InitialContext", e);
          appendErrorTag(buffer,
-               "Failed to get InitialContext, " + e.toString(true));
+                 "Failed to get InitialContext, " + e.toString(true));
       }
 
       if (url != null && context != null)
@@ -430,28 +507,29 @@
          {
             log.error("Failed to list HA-JNDI contents ", t);
             appendErrorTag(buffer,
-                  "Failed to list HA-JNDI contents, " + t.toString());
+                    "Failed to list HA-JNDI contents, " + t.toString());
          }
          closeContextTag(buffer);
 
       }   //   if ( url != null && context != null )
 
       closeJndiTag(buffer);
-      
+
       return buffer.toString();
    }
-   
+
    public String getHANamingService()
    {
       return haNamingService;
    }
+
    public void setHANamingService(String serviceName)
    {
       haNamingService = serviceName;
    }
 
    protected ObjectName getObjectName(MBeanServer server, ObjectName name)
-         throws javax.management.MalformedObjectNameException
+           throws javax.management.MalformedObjectNameException
    {
       return name == null ? OBJECT_NAME : name;
    }
@@ -651,8 +729,8 @@
                   catch (Throwable t)
                   {
                      appendErrorTag(buffer,
-                           "Failed to lookup: " + name +
-                           ", errmsg=" + t.getMessage());
+                             "Failed to lookup: " + name +
+                                     ", errmsg=" + t.getMessage());
                   }
 
                   if (value instanceof Context)
@@ -668,8 +746,8 @@
                      catch (Throwable t)
                      {
                         appendErrorTag(buffer,
-                              "Failed to list contents of: " + name +
-                              ", errmsg=" + t.getMessage());
+                                "Failed to list contents of: " + name +
+                                        ", errmsg=" + t.getMessage());
                      }
 
                      closeContextTag(buffer);
@@ -690,72 +768,11 @@
       catch (NamingException ne)
       {
          appendErrorTag(buffer,
-               "error while listing context " +
-               ctx.toString() + ": " + ne.toString(true));
+                 "error while listing context " +
+                         ctx.toString() + ": " + ne.toString(true));
       }
    }
 
-   private void listModuleContainers(StringBuffer buffer, ObjectName app)
-   {
-      Collection containers = null;
-
-      try
-      {
-         containers = (Collection) server.getAttribute(app, "Containers");
-      }
-      catch (Throwable t)
-      {
-         log.error("getContainers failed", t);
-         appendPreExceptionTag(buffer, "Failed to get ejbs in module", t);
-      }
-
-      for (Iterator iter = containers.iterator(); iter.hasNext();)
-      {
-         listContainerContext(buffer, (Container) iter.next());
-      }
-
-   }   //   listModuleContainers()
-
-   private void listContainerContext(StringBuffer buffer, Container con)
-   {
-      /* Set the thread class loader to that of the container as
-         the class loader is used by the java: context object
-         factory to partition the container namespaces.
-      */
-      Thread.currentThread().setContextClassLoader(con.getClassLoader());
-      String bean = con.getBeanMetaData().getEjbName();
-      openContextTag(buffer);
-      appendBeanTag(buffer, bean);
-      Context context = null;
-      try
-      {
-         context = new InitialContext();
-         context = (Context) context.lookup("java:comp");
-      }
-      catch (NamingException e)
-      {
-         appendErrorTag(buffer,
-               "Failed on lookup " + e.toString(true));
-         context = null;
-      }
-
-      if (context != null)
-      {
-         try
-         {
-            listXML(context, buffer);
-         }
-         catch (Throwable t)
-         {
-            appendErrorTag(buffer,
-                  "Failed on list contents, " + t.toString());
-         }
-      }   //   if ( context != null )
-
-      closeContextTag(buffer);
-
-   }   //   listContainerContext()
-
    private void openJndiTag(StringBuffer buffer)
    {
       buffer.append("<jndi>\n");
@@ -776,7 +793,7 @@
    {
       buffer.append("</webmodule>\n");
    }
-   
+
    private void openEjbModuleTag(StringBuffer buffer, String file)
    {
       buffer.append("<ejbmodule>\n");
@@ -792,7 +809,7 @@
                                       String msg,
                                       Throwable t)
    {
-      buffer.append("<pre>\n" + msg+"\n");
+      buffer.append("<pre>\n" + msg + "\n");
       formatException(buffer, t);
       buffer.append("</pre>\n");
    }
@@ -812,7 +829,7 @@
    {
       buffer.append("<name>Global</name>\n");
    }
-   
+
    private void appendHANameTag(StringBuffer buffer)
    {
       buffer.append("<name>HA</name>\n");
@@ -832,10 +849,10 @@
       catch (NamingException e)
       {
          appendErrorTag(buffer,
-               "Failed to getLinkName, " + e.toString(true));
+                 "Failed to getLinkName, " + e.toString(true));
       }
       buffer.append("<attribute name='class'>" + ncp.getClassName() +
-            "</attribute>\n");
+              "</attribute>\n");
       buffer.append("</link-ref>\n");
    }
 
@@ -874,7 +891,7 @@
    {
       buffer.append("<name>" + ncp.getName() + "</name>\n");
       buffer.append("<attribute name='class'>" + ncp.getClassName() +
-            "</attribute>\n");
+              "</attribute>\n");
    }
 
    private void appendErrorTag(StringBuffer buffer, String msg)
@@ -893,12 +910,12 @@
       buffer.append(sw.toString());
       buffer.append("</pre>\n");
    }
-   
+
    private String getHAUrl()
    {
       String bindAddress = null;
       String portNumber = null;
-      
+
       AttributeList list = getHAJndiAttributes();
       // list will be null if HA-JNDI service couldn't be retrieved
       if (list == null)
@@ -907,29 +924,29 @@
       // list[0] is BindAddress
       Object o = list.get(0);
       if (o != null)
-         bindAddress = ((Attribute)o).getValue().toString();
-      
+         bindAddress = ((Attribute) o).getValue().toString();
+
       // list[1] is Port
       o = list.get(1);
       if (o != null)
-         portNumber = ((Attribute)o).getValue().toString();
+         portNumber = ((Attribute) o).getValue().toString();
 
       if (bindAddress != null && portNumber != null)
-         return "jnp://"+bindAddress+":"+portNumber;
+         return "jnp://" + bindAddress + ":" + portNumber;
 
       return null;
    }
-   
+
    private AttributeList getHAJndiAttributes()
    {
       if (haNamingService == null)
-	  {
+      {
          // HA-JNDI is not deployed, so there will be no attributes
          return null;
       }
 
       try
-      {        
+      {
          ObjectName name = new ObjectName(haNamingService);
          return server.getAttributes(name, g_haAttributes);
       }

Added: trunk/server/src/main/org/jboss/naming/ThreadLocalStack.java
===================================================================
--- trunk/server/src/main/org/jboss/naming/ThreadLocalStack.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/server/src/main/org/jboss/naming/ThreadLocalStack.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -0,0 +1,78 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.naming;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 42263 $
+ */
+public class ThreadLocalStack<T>
+{
+   private ThreadLocal<ArrayList<T>> stack = new ThreadLocal<ArrayList<T>>();
+
+   public void push(T obj)
+   {
+      ArrayList<T> list = stack.get();
+      if (list == null)
+      {
+         list = new ArrayList<T>(1);
+         stack.set(list);
+      }
+      list.add(obj);
+   }
+
+   public T pop()
+   {
+      ArrayList<T> list = stack.get();
+      if (list == null)
+      {
+         return null;
+      }
+      T rtn = list.remove(list.size() - 1);
+      if (list.size() == 0)
+      {
+         stack.set(null);
+         list.clear();
+      }
+      return rtn;
+   }
+
+   public T get()
+   {
+      ArrayList<T> list = (ArrayList<T>)stack.get();
+      if (list == null)
+      {
+         return null;
+      }
+      return list.get(list.size() - 1);
+   }
+
+   public List<T> getList()
+   {
+      return stack.get();
+   }
+}

Modified: trunk/testsuite/src/main/org/jboss/test/naming/ejb/TestENCBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/naming/ejb/TestENCBean.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/testsuite/src/main/org/jboss/test/naming/ejb/TestENCBean.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -117,7 +117,7 @@
       }
       catch (NamingException e)
       {
-         log.debug("failed", e);
+         log.error("failed", e);
          throw new EJBException(e.toString(true));
       }
       catch (JMSException e)

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/TomcatInjectionContainer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/TomcatInjectionContainer.java	2006-12-21 20:52:50 UTC (rev 59202)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/TomcatInjectionContainer.java	2006-12-21 21:23:17 UTC (rev 59203)
@@ -404,27 +404,6 @@
       }
    }
 
-   public Context getEncEnv()
-   {
-      ClassLoader old = Thread.currentThread().getContextClassLoader();
-      try
-      {
-         Thread.currentThread().setContextClassLoader(getClassloader());
-         try
-         {
-            return (Context) new InitialContext().lookup("java:comp/env");
-         }
-         catch (NamingException e)
-         {
-            throw new RuntimeException(e);
-         }
-      }
-      finally
-      {
-         Thread.currentThread().setContextClassLoader(old);
-      }
-   }
-
    public PersistenceUnitDeployment getPersistenceUnitDeployment(String unitName) throws NameNotFoundException
    {
       return persistenceUnitResolver.getPersistenceUnitDeployment(unitName);




More information about the jboss-cvs-commits mailing list