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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Sep 7 15:23:12 EDT 2007


Author: bdecoste
Date: 2007-09-07 15:23:11 -0400 (Fri, 07 Sep 2007)
New Revision: 65242

Modified:
   branches/Branch_4_2/ejb3/build-test.xml
   branches/Branch_4_2/ejb3/src/main/org/jboss/injection/JndiPropertyInjector.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/injection/ResourceHandler.java
   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/unit/MDBUnitTestCase.java
Log:
[JBPAPP-260} merged from JBPAPP_4_2_0_GA_CP

Modified: branches/Branch_4_2/ejb3/build-test.xml
===================================================================
--- branches/Branch_4_2/ejb3/build-test.xml	2007-09-07 19:21:49 UTC (rev 65241)
+++ branches/Branch_4_2/ejb3/build-test.xml	2007-09-07 19:23:11 UTC (rev 65242)
@@ -135,7 +135,6 @@
       <path refid="trove.classpath"/>
       <path refid="xdoclet.xdoclet.classpath"/>
       <path refid="apache.ant.classpath"/>
-      <path refid="apache.ant.junit.classpath"/>
       <path refid="oswego.concurrent.classpath"/>
       <path refid="junit.junit.classpath"/>
       <path refid="apache.log4j.classpath"/>
@@ -4326,20 +4325,19 @@
             <include name="deploy-hasingleton/**"/>
          </patternset>
       </create-config>
-      <create-config baseconf="all" newconf="clusteredjms2">
+      <create-config baseconf="clusteredjms" newconf="clusteredjms2">
          <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="clusteredjms" host="${node0}" jvmargs="${ejb3.jboss.jvmargs}"/>
-	  <start-jboss conf="clusteredjms2" host="${node1}" jvmargs="${ejb3.jboss.jvmargs}"/>
-	  
-	  <antcall target="tests-clustering-wait"/> 
+      <start-jboss conf="clusteredjms2" host="${node1}" jboss.dist="${ejb3.dist}" jvmargs="${ejb3.jboss.jvmargs}"/>
+   	  <antcall target="tests-clusteredjms2-wait"/> 
+   	  <start-jboss conf="clusteredjms" host="${node0}" jboss.dist="${ejb3.dist}" jvmargs="${ejb3.jboss.jvmargs}"/>	 
+   	  <antcall target="tests-clusteredjms-wait"/>
 	
 	  <antcall target="test-with-jvmargs" inheritRefs="true">
          <param name="test" value="clusteredjms"/>
@@ -4366,6 +4364,30 @@
       <echo message="Nodes have started, waiting for cluster to stablize..."/>
    </target>
    
+   <target name="tests-clusteredjms-wait" unless="${tests.clustering.skip.startup}">
+      <echo message="Waiting for node to start..."/>
+      <waitfor maxwait="120" maxwaitunit="second"
+         checkevery="5" checkeveryunit="second" timeoutproperty="cluster.timeout">
+         <and>
+            <http url="${node0.http.url}"/>
+         </and>
+      </waitfor>
+      <fail message="Timeout waiting for nodes to start" if="cluster.timeout"/>
+      <echo message="Nodes have started, waiting for cluster to stablize..."/>
+   </target>
+	
+   <target name="tests-clusteredjms2-wait" unless="${tests.clustering.skip.startup}">
+      <echo message="Waiting for node to start..."/>
+      <waitfor maxwait="120" maxwaitunit="second"
+         checkevery="5" checkeveryunit="second" timeoutproperty="cluster.timeout">
+         <and>
+            <http url="${node1.http.url}"/>
+         </and>
+      </waitfor>
+      <fail message="Timeout waiting for nodes to start" if="cluster.timeout"/>
+      <echo message="Nodes have started, waiting for cluster to stablize..."/>
+   </target>
+   
    <target name="tests-multi-instance-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/injection/JndiPropertyInjector.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/injection/JndiPropertyInjector.java	2007-09-07 19:21:49 UTC (rev 65241)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/injection/JndiPropertyInjector.java	2007-09-07 19:23:11 UTC (rev 65242)
@@ -42,6 +42,7 @@
    private static final Logger log = Logger.getLogger(JndiPropertyInjector.class);
    
    private String jndiName;
+   private String mappedName;
    private Context ctx;
 
    public JndiPropertyInjector(BeanProperty property, String jndiName, Context ctx)
@@ -50,6 +51,14 @@
       this.jndiName = jndiName;
       this.ctx = ctx;
    }
+   
+   public JndiPropertyInjector(BeanProperty property, String jndiName, String mappedName, Context ctx)
+   {
+      super(property);
+      this.jndiName = jndiName;
+      this.mappedName = mappedName;
+      this.ctx = ctx;
+   }
 
    public void inject(BeanContext bctx)
    {
@@ -71,9 +80,23 @@
       }
       catch (NamingException e)
       {
-         Throwable cause = e;
+         if (mappedName != null)
+         {
+            try
+            {
+               dependency = JndiUtil.lookup(ctx, mappedName);
+               return dependency;
+            }
+            catch (NamingException e1)
+            {   
+               log.info("Unable to lookup jndi dependency from mappedName " + mappedName);
+            }
+         }
+         
+         Throwable cause = e; 
          while(cause.getCause() != null)
             cause = cause.getCause();
+      
          throw new RuntimeException("Unable to inject jndi dependency: " + jndiName + " into property " + property + ": " + cause.getMessage(), e);
       }
       return dependency;

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/injection/ResourceHandler.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/injection/ResourceHandler.java	2007-09-07 19:21:49 UTC (rev 65241)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/injection/ResourceHandler.java	2007-09-07 19:23:11 UTC (rev 65242)
@@ -507,7 +507,7 @@
             }
             container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.mappedName(), "@Resource"));
          }
-         injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
+         injectors.put(accObj, new JndiPropertyInjector(property, encName, ref.mappedName(), container.getEnc()));
       }      
    }
 }

Modified: 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	2007-09-07 19:21:49 UTC (rev 65241)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/QueueTestMDB.java	2007-09-07 19:23:11 UTC (rev 65242)
@@ -51,13 +51,11 @@
 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);
+      System.out.println("+++ QueueTestMDB onMessage " + TestStatusBean.queueRan + " " + this);
    }
 }

Modified: 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	2007-09-07 19:21:49 UTC (rev 65241)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/unit/MDBUnitTestCase.java	2007-09-07 19:23:11 UTC (rev 65242)
@@ -55,20 +55,20 @@
    public void testQueue() throws Exception
    {
 
-      TestStatus status = (TestStatus) getInitialContext().lookup(
-            "TestStatusBean/remote");
+      TestStatus status = (TestStatus) new InitialContext().lookup(
+      "TestStatusBean/remote");
       clear(status);
       QueueConnection cnn = null;
       QueueSender sender = null;
       QueueSession session = null;
-
-      Queue queue = (Queue) getInitialContext().lookup("queue/mdbtest");
+      
+      Queue queue = (Queue) getHAInitialContext().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);
@@ -77,11 +77,12 @@
       sender.send(msg);
       session.close();
       cnn.close();
-
+      
       Thread.sleep(2000);
       assertEquals(5, status.queueFired());
       
-      assertEquals("queuetest", status.testInjection());
+      for (int i = 0 ; i < 100 ; ++i)
+         assertEquals("queuetest", status.testInjection());
    }
 
    protected QueueConnectionFactory getQueueConnectionFactory()
@@ -89,11 +90,11 @@
    {
       try
       {
-         return (QueueConnectionFactory) getInitialContext().lookup(
+         return (QueueConnectionFactory) getHAInitialContext().lookup(
                "ConnectionFactory");
       } catch (NamingException e)
       {
-         return (QueueConnectionFactory) getInitialContext().lookup(
+         return (QueueConnectionFactory) getHAInitialContext().lookup(
                "java:/ConnectionFactory");
       }
    }
@@ -117,12 +118,12 @@
       status.clear();
    }
    
-   protected InitialContext getInitialContext() throws Exception
+   protected InitialContext getHAInitialContext() 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");
+      env.put(Context.PROVIDER_URL, "localhost:1100");
       
       return new InitialContext(env);
    }




More information about the jboss-cvs-commits mailing list