[jboss-cvs] JBossAS SVN: r63981 - in branches/Branch_4_2/ejb3: src/main/org/jboss/ejb3 and 17 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jul 11 13:45:33 EDT 2007


Author: bdecoste
Date: 2007-07-11 13:45:33 -0400 (Wed, 11 Jul 2007)
New Revision: 63981

Added:
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/JndiUtil.java
   branches/Branch_4_2/ejb3/src/resources/test-configs/clusteredjms/
   branches/Branch_4_2/ejb3/src/resources/test-configs/clusteredjms/deploy-hasingleton/
   branches/Branch_4_2/ejb3/src/resources/test-configs/clusteredjms/deploy-hasingleton/mdbtest-service.xml
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/QueueTestMDB.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/TestStatus.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/TestStatusBean.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/unit/
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/unit/MDBUnitTestCase.java
Modified:
   branches/Branch_4_2/ejb3/build-test.xml
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/EJB3Deployer.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/EJB3Util.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/InitialContextFactory.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/embedded/EJB3StandaloneDeployer.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/embedded/JaasSecurityManagerService.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/embedded/JavaCompInitializer.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/embedded/JndiBinder.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/ProducerManagerImpl.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/naming/SimpleMultiplexer.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/proxy/handle/HomeHandleImpl.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulHandleImpl.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessHandleImpl.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/timerservice/quartz/QuartzTimerServiceFactory.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/injection/JndiFieldInjector.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/injection/JndiMethodInjector.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/injection/JndiPropertyInjector.java
Log:
[EJBTHREE-975] @Resource injection of HA resources + consolidation of InitialContext instantiation

Modified: branches/Branch_4_2/ejb3/build-test.xml
===================================================================
--- branches/Branch_4_2/ejb3/build-test.xml	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/build-test.xml	2007-07-11 17:45:33 UTC (rev 63981)
@@ -1537,6 +1537,19 @@
          </classes>
       </war>
    </target>
+   
+   <target name="clusteredjms"
+      description="Builds all jar files."
+      depends="compile-classes">
+      
+      <mkdir dir="${build.lib}"/>
+      
+      <jar jarfile="${build.lib}/clusteredjms-test.jar">
+         <fileset dir="${build.classes}">
+            <include name="org/jboss/ejb3/test/clusteredjms/*.class"/>
+         </fileset>
+      </jar>
+   </target>
 
    <target name="servlet"
       description="Builds all jar files."
@@ -3234,7 +3247,7 @@
 	  </copy>
    </target>
    
-   <target name="jars" depends="entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, servicexmbean, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader, 
+   <target name="jars" depends="clusteredjms, entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, servicexmbean, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader, 
       circulardependency, jsp, timerdependency, servicedependency, servlet, stateless14, webservices, ear, ejbthree440, 
       ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree724, ejbthree751, ejbthree832, ejbthree921,
       ejbthree959, ejbthree963, ejbthree994,
@@ -3512,6 +3525,7 @@
       <antcall target="ssl-advanced-test"  inheritRefs="true"/>
       <antcall target="jacc-test" inheritRefs="true"/>
       <antcall target="clustered-tests" inheritRefs="true"/>
+      <antcall target="clustered-jms-test" inheritRefs="true"/>
       <antcall target="invoker-test"  inheritRefs="true"/>
       <antcall target="iiop-tests"  inheritRefs="true"/>
       <antcall target="arjuna-test"  inheritRefs="true"/>
@@ -4089,7 +4103,41 @@
       </antcall>
 
    </target>
+   
+   <target name="clustered-jms-test">
+      <create-config baseconf="all" newconf="clusteredjms" jboss.dist="${ejb3.dist}">
+         <patternset>
+	        <include name="conf/**"/>
+	        <include name="deploy*/**"/>
+	        <include name="lib/**"/>
+            <include name="deploy-hasingleton/**"/>
+         </patternset>
+      </create-config>
+      <create-config baseconf="all" newconf="node1" jboss.dist="${ejb3.dist}">
+         <patternset>
+	        <include name="conf/**"/>
+	        <include name="deploy*/**"/>
+	        <include name="lib/**"/>
+            <include name="deploy-hasingleton/**"/>
+            <exclude name="deploy-hasingleton/mdbtest-service.xml"/>
+         </patternset>
+      </create-config>
+      
+      <start-jboss conf="node1" host="${node1}" jboss.dist="${ejb3.dist}" jvmargs="${ejb3.jboss.jvmargs}"/>
+	  <start-jboss conf="clusteredjms" host="${node0}" jboss.dist="${ejb3.dist}" jvmargs="${ejb3.jboss.jvmargs}"/>	  
+	  
+	  <antcall target="tests-clustering-wait"/> 
+	
+	  <antcall target="test-with-jvmargs" inheritRefs="true">
+         <param name="test" value="clusteredjms"/>
+         <param name="jvmargs" value=""/>
+      </antcall>
+      
+      <stop-jboss url="${node0.jndi.url}" jboss.dist="${ejb3.dist}"/>
+      <stop-jboss url="${node1.jndi.url}" jboss.dist="${ejb3.dist}"/>
 
+   </target>
+
    <target name="tests-clustering-wait" unless="${tests.clustering.skip.startup}">
       <echo message="Waiting for nodes to start..."/>
       <waitfor maxwait="120" maxwaitunit="second"

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/EJB3Deployer.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/EJB3Deployer.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/EJB3Deployer.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -332,7 +332,7 @@
       mainDeployer.addDeployer(thisProxy);
 
       // todo remove when we merge older model of ENC
-      InitialContext iniCtx = new InitialContext();
+      InitialContext iniCtx = InitialContextFactory.getInitialContext();
       initializeJavaComp(iniCtx);
    }
 

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/EJB3Util.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/EJB3Util.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/EJB3Util.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -22,6 +22,7 @@
 package org.jboss.ejb3;
 
 import java.util.Hashtable;
+import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javassist.bytecode.AnnotationsAttribute;
@@ -85,18 +86,6 @@
       
       return defaultContainerName;
    }
-
-   public static InitialContext getInitialContext(Hashtable props)
-           throws NamingException
-   {
-      InitialContext ctx = null;
-      if (props != null)
-      {
-         ctx = new InitialContext(props);
-      }
-      else ctx = new InitialContext();
-      return ctx;
-   }
 }
 
 

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/EJBContainer.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/EJBContainer.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -433,10 +433,7 @@
    {
       try
       {
-         if (initialContextProperties == null)
-            return new InitialContext();
-         else
-            return new InitialContext(initialContextProperties);
+         return InitialContextFactory.getInitialContext(initialContextProperties);
       }
       catch (NamingException e)
       {

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -111,7 +111,7 @@
       this.deploymentScope = deploymentScope;
       try
       {
-         initialContext = EJB3Util.getInitialContext(unit.getJndiProperties());
+         initialContext = InitialContextFactory.getInitialContext(unit.getJndiProperties());
       }
       catch (NamingException e)
       {

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/InitialContextFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/InitialContextFactory.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/InitialContextFactory.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -21,27 +21,54 @@
  */
 package org.jboss.ejb3;
 
+import java.util.Hashtable;
 import java.util.Properties;
 
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
+import org.jboss.logging.Logger;
+
+import org.jboss.mx.util.MBeanServerLocator;
+
 /**
  * @version <tt>$Revision$</tt>
  * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
  */
 public class InitialContextFactory
 {
+   private static final Logger log = Logger.getLogger(InitialContextFactory.class);
+   
    private static Properties props = null;
    private static Properties securityProperties = null;
+   private static InitialContext baseInitialContext = null;
+   private static Context haContext = null;
+   private static Integer haJndiPort = null;
    
    public static InitialContext getInitialContext() throws NamingException
    {
       InitialContext jndiContext;
       
       if (props == null)
-         jndiContext = new InitialContext();
+      {
+         if (baseInitialContext == null)
+         {
+            baseInitialContext = new InitialContext();
+         }
+         jndiContext = baseInitialContext;
+         
+         try
+         {
+            jndiContext.getEnvironment();
+         }
+         catch (NamingException e)
+         {
+            jndiContext = baseInitialContext = new InitialContext();
+         }      
+      }
       else
       {
          if (securityProperties != null)
@@ -54,10 +81,62 @@
          else
             jndiContext = new InitialContext(props);
       }
-      
+       
       return jndiContext;
    }
    
+   public static InitialContext getInitialContext(Hashtable props)
+      throws NamingException
+   {
+      InitialContext ctx = null;
+      if (props != null)
+      {
+         ctx = new InitialContext(props);
+      }
+      else
+      {
+         ctx = getInitialContext();
+      }
+      return ctx;
+   }
+   
+   public static Context getHAContext(Context ctx)
+      throws NamingException
+   {
+      if (haContext == null)
+      {
+         Hashtable env = ctx.getEnvironment();
+         Object providerUrl = env.get(Context.PROVIDER_URL);
+         if (providerUrl == null)
+         {          
+            try
+            {
+               env.put(Context.PROVIDER_URL, "localhost:" + getHaJndiPort());
+               InitialContext haCtx = new InitialContext(env);
+               haCtx.bind("HA_TEST", null);
+               haCtx.unbind("HA_TEST");
+               haContext = haCtx;
+            }
+            catch (Exception e)
+            {
+               log.debug("Unable to access HA JNDI: " + e);
+            }
+         }
+      }
+      return haContext;
+   }
+   
+   private static Integer getHaJndiPort() throws Exception
+   {
+      if (haJndiPort == null)
+      {
+         MBeanServer server = MBeanServerLocator.locateJBoss();
+         ObjectName objectName = new ObjectName("jboss:service=HAJNDI");
+         haJndiPort = (Integer)server.getAttribute(objectName, "Port");
+      }
+      return haJndiPort;
+   }
+   
    public static void setProperties(Properties properties)
    {
       props = properties;

Added: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/JndiUtil.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/JndiUtil.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/JndiUtil.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class JndiUtil
+{
+   private static final Logger log = Logger.getLogger(JndiUtil.class);
+   
+   public static Object lookup(Context jndiContext, String binding)
+      throws NamingException
+   {
+      Object object = null;
+
+      try
+      {
+         object = jndiContext.lookup(binding);
+      }
+      catch (NameNotFoundException e)
+      {
+         Context haCtx = InitialContextFactory.getHAContext(jndiContext);
+         object = haCtx.lookup(binding);
+      }
+      
+      return object;
+   }
+}
+
+


Property changes on: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/JndiUtil.java
___________________________________________________________________
Name: svn:executable
   + *

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -42,6 +42,7 @@
 
 import org.jboss.ejb3.Container;
 import org.jboss.ejb3.DependencyPolicy;
+import org.jboss.ejb3.InitialContextFactory;
 import org.jboss.ejb3.entity.PersistenceUnitDeployment;
 import org.jboss.ejb3.metamodel.ApplicationClientDD;
 import org.jboss.ejb3.metamodel.LifecycleCallback;
@@ -93,7 +94,7 @@
       this.applicationClientName = applicationClientName;
       
       //Context ctx = getInitialContext();
-      Context ctx = new InitialContext();
+      Context ctx = InitialContextFactory.getInitialContext();
       enc = (Context) ctx.lookup(applicationClientName);
       NamingEnumeration<NameClassPair> e = enc.list("");
       while(e.hasMore())

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -24,6 +24,7 @@
 import org.jboss.deployers.plugins.deployers.helpers.AbstractSimpleRealDeployer;
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.ejb3.InitialContextFactory;
 import org.jboss.ejb3.KernelAbstraction;
 import org.jboss.ejb3.MCKernelAbstraction;
 import org.jboss.ejb3.clientmodule.ClientENCInjectionContainer;
@@ -72,7 +73,7 @@
       try
       {
          // I create the namespace here, because I destroy it in undeploy
-         InitialContext iniCtx = new InitialContext();
+         InitialContext iniCtx = InitialContextFactory.getInitialContext();
          Context encCtx = Util.createSubcontext(iniCtx, appClientName);
          log.debug("Creating client ENC binding under: " + appClientName);
 
@@ -204,7 +205,7 @@
       log.debug("Removing client ENC from: " + jndiName);
       try
       {
-         InitialContext iniCtx = new InitialContext();
+         InitialContext iniCtx = InitialContextFactory.getInitialContext();
          Util.unbind(iniCtx, jndiName);
       }
       catch(NameNotFoundException e)

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/embedded/EJB3StandaloneDeployer.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/embedded/EJB3StandaloneDeployer.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/embedded/EJB3StandaloneDeployer.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -45,6 +45,7 @@
 
 import org.jboss.dependency.spi.ControllerContext;
 import org.jboss.ejb3.DeploymentUnit;
+import org.jboss.ejb3.InitialContextFactory;
 import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
 import org.jboss.kernel.Kernel;
 import org.jboss.logging.Logger;
@@ -547,7 +548,7 @@
    {
       System.out.println("lookup " + name);
       try {
-         InitialContext jndiContext = new InitialContext();
+         InitialContext jndiContext = InitialContextFactory.getInitialContext();
          NamingEnumeration names = jndiContext.list(name);
          if (names != null){
             while (names.hasMore()){

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/embedded/JaasSecurityManagerService.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/embedded/JaasSecurityManagerService.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/embedded/JaasSecurityManagerService.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -22,6 +22,7 @@
 package org.jboss.ejb3.embedded;
 
 
+import org.jboss.ejb3.InitialContextFactory;
 import org.jboss.ejb3.naming.BrainlessContext;
 import org.jboss.logging.Logger;
 import org.jboss.security.auth.callback.SecurityAssociationHandler;
@@ -63,8 +64,7 @@
 
    private InitialContext getInitialContext() throws NamingException
    {
-      if (initialContextProperties != null) return new InitialContext(initialContextProperties);
-      else return new InitialContext();
+      return InitialContextFactory.getInitialContext(initialContextProperties);
    }
 
    public void start() throws Exception

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/embedded/JavaCompInitializer.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/embedded/JavaCompInitializer.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/embedded/JavaCompInitializer.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -25,6 +25,7 @@
 import javax.naming.InitialContext;
 import org.jboss.ejb3.EJB3Deployer;
 import org.jboss.ejb3.EJB3Util;
+import org.jboss.ejb3.InitialContextFactory;
 
 /**
  * Initializes java:comp
@@ -49,7 +50,7 @@
 
    public void start() throws Exception
    {
-      InitialContext ctx = EJB3Util.getInitialContext(jndiProperties);
+      InitialContext ctx = InitialContextFactory.getInitialContext(jndiProperties);
       EJB3Deployer.initializeJavaComp(ctx);
    }
 }

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/embedded/JndiBinder.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/embedded/JndiBinder.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/embedded/JndiBinder.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -26,6 +26,7 @@
 import javax.naming.NamingException;
 
 import org.jboss.ejb3.EJB3Util;
+import org.jboss.ejb3.InitialContextFactory;
 import org.jboss.ejb3.NonSerializableFactory;
 import org.jboss.naming.Util;
 
@@ -64,7 +65,7 @@
 
    public void start() throws Exception
    {
-      InitialContext ctx = EJB3Util.getInitialContext(properties);
+      InitialContext ctx = InitialContextFactory.getInitialContext(properties);
       
       try
       {
@@ -86,7 +87,7 @@
 
    public void stop() throws Exception
    {
-      InitialContext ctx = EJB3Util.getInitialContext(properties);
+      InitialContext ctx = InitialContextFactory.getInitialContext(properties);
       if (serializable)
       {
          Util.unbind(ctx, bindTo);

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -37,6 +37,7 @@
 import org.jboss.annotation.ejb.RemoteBinding;
 import org.jboss.aop.Advisor;
 import org.jboss.ejb3.Container;
+import org.jboss.ejb3.InitialContextFactory;
 import org.jboss.ejb3.NonSerializableFactory;
 import org.jboss.ejb3.ProxyFactoryHelper;
 import org.jboss.ejb3.SessionContainer;
@@ -269,13 +270,13 @@
       
       // Get orb and irPoa references
       try {
-         orb = (ORB)new InitialContext().lookup("java:/" + CorbaORBService.ORB_NAME);
+         orb = (ORB)InitialContextFactory.getInitialContext().lookup("java:/" + CorbaORBService.ORB_NAME);
       }
       catch (NamingException e) {
          throw new Exception("Cannot lookup java:/" + CorbaORBService.ORB_NAME + ": " + e);
       }
       try {
-         irPoa = (POA)new InitialContext().lookup("java:/" + CorbaORBService.IR_POA_NAME);
+         irPoa = (POA)InitialContextFactory.getInitialContext().lookup("java:/" + CorbaORBService.IR_POA_NAME);
       }
       catch (NamingException e) {
          throw new Exception("Cannot lookup java:/" + CorbaORBService.IR_POA_NAME + ": " + e);
@@ -373,7 +374,7 @@
       }
       
       // bind HandleDelegate stuff
-      Context compCtx = (Context) new InitialContext().lookup("java:comp");
+      Context compCtx = (Context) InitialContextFactory.getInitialContext().lookup("java:comp");
       NonSerializableFactory.rebind(compCtx, "ORB", orb);
       NonSerializableFactory.rebind(compCtx, "HandleDelegate", new HandleDelegateImpl());
    }
@@ -435,7 +436,7 @@
 
    private NamingContextExt getNamingContextExt() throws NamingException
    {
-      Context initialContext = new InitialContext();
+      Context initialContext = InitialContextFactory.getInitialContext();
       
       // NOTE: eclipse editor parser crashes silently on this line (because of org.jboss.iiop.CorbaNamingService) with unknown reason
       // that's why this method is at the end

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/ProducerManagerImpl.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/ProducerManagerImpl.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/ProducerManagerImpl.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -44,6 +44,7 @@
 import org.jboss.aop.joinpoint.Invocation;
 import org.jboss.aop.joinpoint.MethodInvocation;
 import org.jboss.ejb3.EJB3Util;
+import org.jboss.ejb3.InitialContextFactory;
 import org.jboss.logging.Logger;
 
 /**
@@ -106,7 +107,7 @@
       initialContextProperties = (Hashtable)in.readObject();
       try
       {
-         initialContext = EJB3Util.getInitialContext(initialContextProperties);
+         initialContext = InitialContextFactory.getInitialContext(initialContextProperties);
       }
       catch (NamingException e)
       {
@@ -134,7 +135,7 @@
       this.initialContextProperties = initialContextProperties;
       try
       {
-         this.initialContext = EJB3Util.getInitialContext(initialContextProperties);
+         this.initialContext = InitialContextFactory.getInitialContext(initialContextProperties);
       }
       catch (NamingException e)
       {
@@ -164,7 +165,7 @@
       this.initialContextProperties = initialContextProperties;
       try
       {
-         this.initialContext = EJB3Util.getInitialContext(initialContextProperties);
+         this.initialContext = InitialContextFactory.getInitialContext(initialContextProperties);
       }
       catch (NamingException e)
       {

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/naming/SimpleMultiplexer.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/naming/SimpleMultiplexer.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/naming/SimpleMultiplexer.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -31,6 +31,7 @@
 import javax.naming.NamingException;
 import javax.naming.spi.ObjectFactory;
 
+import org.jboss.ejb3.InitialContextFactory;
 import org.jboss.logging.Logger;
 
 /**
@@ -81,7 +82,7 @@
    {
       if(nameCtx == null)
       {
-         nameCtx = (Context) new InitialContext().lookup("java:");
+         nameCtx = (Context) InitialContextFactory.getInitialContext().lookup("java:");
          try
          {
             return createMultiplexer(nameCtx);

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/proxy/handle/HomeHandleImpl.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/proxy/handle/HomeHandleImpl.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/proxy/handle/HomeHandleImpl.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -35,7 +35,9 @@
 import java.util.Hashtable;
 import org.jboss.naming.NamingContextFactory;
 
+import org.jboss.ejb3.InitialContextFactory;
 
+
 /**
  * An EJB home handle implementation.
  *
@@ -97,11 +99,8 @@
    {
       try
       {
-         InitialContext ic = null;
-         if( jndiEnv != null )
-            ic = new InitialContext(jndiEnv);
-         else
-            ic = new InitialContext();
+         InitialContext ic = InitialContextFactory.getInitialContext(jndiEnv);
+         
          EJBHome home = (EJBHome) ic.lookup(jndiName);
          return home;
       }

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulHandleImpl.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulHandleImpl.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulHandleImpl.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -33,6 +33,7 @@
 import javax.ejb.Handle;
 import javax.naming.InitialContext;
 
+import org.jboss.ejb3.InitialContextFactory;
 import org.jboss.invocation.Invoker;
 import org.jboss.logging.Logger;
 import org.jboss.naming.NamingContextFactory;
@@ -164,11 +165,7 @@
    {
       try
       {
-         InitialContext ic = null;
-         if( jndiEnv != null )
-            ic = new InitialContext(jndiEnv);
-         else
-            ic = new InitialContext();
+         InitialContext ic = InitialContextFactory.getInitialContext(jndiEnv);
     
          Proxy proxy = (Proxy) ic.lookup(jndiName);
 

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessHandleImpl.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessHandleImpl.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessHandleImpl.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -36,6 +36,7 @@
 import javax.ejb.EJBObject;
 import javax.ejb.EJBHome;
 
+import org.jboss.ejb3.InitialContextFactory;
 import org.jboss.naming.NamingContextFactory;
 
 /**
@@ -89,11 +90,7 @@
    {
       try
       {
-         InitialContext ic = null;
-         if( jndiEnv != null )
-            ic = new InitialContext(jndiEnv);
-         else
-            ic = new InitialContext();
+         InitialContext ic = InitialContextFactory.getInitialContext(jndiEnv);
     
          Proxy proxy = (Proxy) ic.lookup(jndiName);
 

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/timerservice/quartz/QuartzTimerServiceFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/timerservice/quartz/QuartzTimerServiceFactory.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/timerservice/quartz/QuartzTimerServiceFactory.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -37,6 +37,7 @@
 import javax.transaction.SystemException;
 import javax.transaction.TransactionManager;
 
+import org.jboss.ejb3.InitialContextFactory;
 import org.jboss.ejb3.timerservice.TimedObjectInvoker;
 import org.jboss.ejb3.timerservice.TimerServiceFactory;
 import org.jboss.logging.Logger;
@@ -243,7 +244,7 @@
       
       log.debug("properties = " + properties);
       
-      InitialContext ctx = new InitialContext();
+      InitialContext ctx = InitialContextFactory.getInitialContext();
       tm = (TransactionManager) ctx.lookup(TransactionManagerService.JNDI_NAME);
       
       createSchema();

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/injection/JndiFieldInjector.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/injection/JndiFieldInjector.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/injection/JndiFieldInjector.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -28,6 +28,7 @@
 import org.jboss.logging.Logger;
 
 import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.JndiUtil;
 
 /**
  * Comment
@@ -78,7 +79,7 @@
 
       try
       {
-         dependency = ctx.lookup(jndiName);
+         dependency = JndiUtil.lookup(ctx, jndiName);
 
          if (dependency instanceof javax.xml.rpc.Service && !field.isAssignableFrom(javax.xml.rpc.Service.class))
          {

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/injection/JndiMethodInjector.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/injection/JndiMethodInjector.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/injection/JndiMethodInjector.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -26,6 +26,7 @@
 import javax.naming.Context;
 import javax.naming.NamingException;
 import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.JndiUtil;
 import org.jboss.logging.Logger;
 
 /**
@@ -68,7 +69,7 @@
       
       try
       {
-         dependency = ctx.lookup(jndiName);
+         dependency = JndiUtil.lookup(ctx, jndiName);
       }
       catch (NamingException e)
       {

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/injection/JndiPropertyInjector.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/injection/JndiPropertyInjector.java	2007-07-11 17:01:45 UTC (rev 63980)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/injection/JndiPropertyInjector.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -25,6 +25,7 @@
 import javax.naming.NamingException;
 
 import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.JndiUtil;
 import org.jboss.injection.lang.reflect.BeanProperty;
 import org.jboss.logging.Logger;
 
@@ -66,7 +67,7 @@
       
       try
       {
-         dependency = ctx.lookup(jndiName);
+         dependency = JndiUtil.lookup(ctx, jndiName);
       }
       catch (NamingException e)
       {

Added: branches/Branch_4_2/ejb3/src/resources/test-configs/clusteredjms/deploy-hasingleton/mdbtest-service.xml
===================================================================
--- branches/Branch_4_2/ejb3/src/resources/test-configs/clusteredjms/deploy-hasingleton/mdbtest-service.xml	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/resources/test-configs/clusteredjms/deploy-hasingleton/mdbtest-service.xml	2007-07-11 17:45:33 UTC (rev 63981)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+   <mbean code="org.jboss.mq.server.jmx.Queue"
+      name="jboss.mq.destination:service=Queue,name=queuetest">
+      <attribute name="JNDIName">queue/mdbtest</attribute>
+      <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+   </mbean>
+</server>

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/QueueTestMDB.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/QueueTestMDB.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/QueueTestMDB.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.clusteredjms;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+import javax.ejb.MessageDriven;
+import javax.ejb.MessageDrivenContext;
+import javax.ejb.EJB;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.naming.InitialContext;
+
+import javax.annotation.security.RunAs;
+
+import org.jboss.annotation.security.SecurityDomain;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at MessageDriven(activationConfig =
+        {
+        @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
+        @ActivationConfigProperty(propertyName="destination", propertyValue="queue/mdbtest")
+        })
+public class QueueTestMDB
+implements MessageListener
+{
+   private static final Logger log = Logger.getLogger(QueueTestMDB.class);
+   
+   public int count = 0;
+
+   public void onMessage(Message recvMsg)
+   {
+      ++TestStatusBean.queueRan;
+      
+      System.out.println("+++ QueueTestMDB onMessage " + TestStatusBean.queueRan + " " + count + " " + this);
+   }
+}

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/TestStatus.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/TestStatus.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/TestStatus.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.clusteredjms;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface TestStatus
+{
+   void clear();
+
+   int queueFired();
+   
+   String testInjection() throws Exception;
+}

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/TestStatusBean.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/TestStatusBean.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/TestStatusBean.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.clusteredjms;
+
+import javax.annotation.Resource;
+import javax.ejb.Stateless;
+import javax.ejb.Remote;
+import javax.jms.Queue;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateless
+ at Remote(TestStatus.class)
+public class TestStatusBean implements TestStatus
+{
+   private static final Logger log = Logger.getLogger(TestStatusBean.class);
+   
+   public static int queueRan = 0;
+   
+   @Resource(mappedName="queue/mdbtest") Queue queue;
+
+   public void clear()
+   {
+      queueRan = 0;
+   }
+
+   public int queueFired()
+   {
+      return queueRan;
+   }
+   
+   public String testInjection() throws Exception
+   {
+      return queue.getQueueName();
+   }
+}

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/unit/MDBUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/unit/MDBUnitTestCase.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/unit/MDBUnitTestCase.java	2007-07-11 17:45:33 UTC (rev 63981)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.clusteredjms.unit;
+
+import java.util.Properties;
+
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+import javax.jms.TopicConnectionFactory;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.clusteredjms.TestStatus;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class MDBUnitTestCase extends JBossTestCase
+{
+   private static final Logger log = Logger.getLogger(MDBUnitTestCase.class);
+
+   public MDBUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testQueue() throws Exception
+   {
+
+      TestStatus status = (TestStatus) getInitialContext().lookup(
+            "TestStatusBean/remote");
+      clear(status);
+      QueueConnection cnn = null;
+      QueueSender sender = null;
+      QueueSession session = null;
+
+      Queue queue = (Queue) getInitialContext().lookup("queue/mdbtest");
+      QueueConnectionFactory factory = getQueueConnectionFactory();
+      cnn = factory.createQueueConnection();
+      session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+
+      TextMessage msg = session.createTextMessage("Hello World");
+
+      sender = session.createSender(queue);
+      sender.send(msg);
+      sender.send(msg);
+      sender.send(msg);
+      sender.send(msg);
+      sender.send(msg);
+      session.close();
+      cnn.close();
+
+      Thread.sleep(2000);
+      assertEquals(5, status.queueFired());
+      
+      assertEquals("mdbtest", status.testInjection());
+   }
+
+   protected QueueConnectionFactory getQueueConnectionFactory()
+         throws Exception
+   {
+      try
+      {
+         return (QueueConnectionFactory) getInitialContext().lookup(
+               "ConnectionFactory");
+      } catch (NamingException e)
+      {
+         return (QueueConnectionFactory) getInitialContext().lookup(
+               "java:/ConnectionFactory");
+      }
+   }
+
+   protected TopicConnectionFactory getTopicConnectionFactory()
+         throws Exception
+   {
+      try
+      {
+         return (TopicConnectionFactory) getInitialContext().lookup(
+               "ConnectionFactory");
+      } catch (NamingException e)
+      {
+         return (TopicConnectionFactory) getInitialContext().lookup(
+               "java:/ConnectionFactory");
+      }
+   }
+
+   protected void clear(TestStatus status)
+   {
+      status.clear();
+   }
+   
+   protected InitialContext getInitialContext() throws Exception
+   {
+      Properties env = new Properties();
+      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+      env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
+      //env.put(Context.PROVIDER_URL, "localhost:1100");
+      
+      return new InitialContext(env);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(MDBUnitTestCase.class, "clusteredjms-test.jar");
+   }
+
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list