[jboss-cvs] JBossAS SVN: r65193 - in branches/JBPAPP_4_2_0_GA_CP/ejb3: src/main/org/jboss/injection and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Sep 6 15:56:10 EDT 2007
Author: bdecoste
Date: 2007-09-06 15:56:10 -0400 (Thu, 06 Sep 2007)
New Revision: 65193
Modified:
branches/JBPAPP_4_2_0_GA_CP/ejb3/build-test.xml
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/JndiPropertyInjector.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/ResourceHandler.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/QueueTestMDB.java
branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/unit/MDBUnitTestCase.java
Log:
[EJBTHREE-975] fixed problem for injection of a queue on node2 from a bean on node1
Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/build-test.xml
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/build-test.xml 2007-09-06 19:33:32 UTC (rev 65192)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/build-test.xml 2007-09-06 19:56:10 UTC (rev 65193)
@@ -4261,7 +4261,7 @@
<include name="deploy-hasingleton/**"/>
</patternset>
</create-config>
- <create-config baseconf="all" newconf="clusteredjms2" jboss.dist="${ejb3.dist}">
+ <create-config baseconf="clusteredjms" newconf="clusteredjms2" jboss.dist="${ejb3.dist}">
<patternset>
<include name="conf/**"/>
<include name="deploy*/**"/>
@@ -4270,10 +4270,10 @@
</patternset>
</create-config>
- <start-jboss conf="clusteredjms" host="${node0}" jboss.dist="${ejb3.dist}" jvmargs="${ejb3.jboss.jvmargs}"/>
- <start-jboss conf="clusteredjms2" host="${node1}" jboss.dist="${ejb3.dist}" 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"/>
@@ -4312,6 +4312,30 @@
<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-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>
<macrodef name="create-ejb3-cluster-node"
description="Create a simplified cluster configuration for ejb3 testing">
Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/JndiPropertyInjector.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/JndiPropertyInjector.java 2007-09-06 19:33:32 UTC (rev 65192)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/JndiPropertyInjector.java 2007-09-06 19:56:10 UTC (rev 65193)
@@ -44,6 +44,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)
@@ -52,6 +53,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)
{
@@ -73,9 +82,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/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/ResourceHandler.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/ResourceHandler.java 2007-09-06 19:33:32 UTC (rev 65192)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/injection/ResourceHandler.java 2007-09-06 19:56:10 UTC (rev 65193)
@@ -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/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/QueueTestMDB.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/QueueTestMDB.java 2007-09-06 19:33:32 UTC (rev 65192)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/QueueTestMDB.java 2007-09-06 19:56:10 UTC (rev 65193)
@@ -52,12 +52,10 @@
{
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/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/unit/MDBUnitTestCase.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/unit/MDBUnitTestCase.java 2007-09-06 19:33:32 UTC (rev 65192)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/clusteredjms/unit/MDBUnitTestCase.java 2007-09-06 19:56:10 UTC (rev 65193)
@@ -39,11 +39,12 @@
import org.jboss.ejb3.test.clusteredjms.TestStatus;
import org.jboss.logging.Logger;
import org.jboss.test.JBossTestCase;
+import org.jboss.test.JBossClusteredTestCase;
/**
* @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
*/
-public class MDBUnitTestCase extends JBossTestCase
+public class MDBUnitTestCase extends JBossTestCase //JBossClusteredTestCase
{
private static final Logger log = Logger.getLogger(MDBUnitTestCase.class);
@@ -55,14 +56,14 @@
public void testQueue() throws Exception
{
- TestStatus status = (TestStatus) getInitialContext().lookup(
+ 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);
@@ -81,7 +82,8 @@
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 +91,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 +119,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