tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgallim...@apache.org
Subject tomee git commit: TOMEE-2237 ensure MessageDrivenContext is injected when using MDB pooling
Date Mon, 17 Sep 2018 14:52:49 GMT
Repository: tomee
Updated Branches:
  refs/heads/tomee-7.1.x 02c99f29b -> ad56aad8d


TOMEE-2237 ensure MessageDrivenContext is injected when using MDB pooling


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/ad56aad8
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/ad56aad8
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/ad56aad8

Branch: refs/heads/tomee-7.1.x
Commit: ad56aad8d6b1c5b545eeb43b18a8f507f94ec072
Parents: 02c99f2
Author: Jonathan Gallimore <jon@jrg.me.uk>
Authored: Mon Sep 17 15:50:29 2018 +0100
Committer: Jonathan Gallimore <jon@jrg.me.uk>
Committed: Mon Sep 17 15:52:33 2018 +0100

----------------------------------------------------------------------
 .../apache/openejb/core/mdb/MdbInstanceManager.java   | 14 ++++++++++++++
 .../apache/openejb/core/mdb/MdbPoolContainerTest.java | 14 ++++++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/ad56aad8/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceManager.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceManager.java
b/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceManager.java
index 4f75b7b..aec2bf4 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceManager.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceManager.java
@@ -28,6 +28,7 @@ import org.apache.openejb.core.Operation;
 import org.apache.openejb.core.ThreadContext;
 import org.apache.openejb.core.interceptor.InterceptorData;
 import org.apache.openejb.core.interceptor.InterceptorStack;
+import org.apache.openejb.core.timer.TimerServiceWrapper;
 import org.apache.openejb.loader.Options;
 import org.apache.openejb.monitoring.LocalMBeanServer;
 import org.apache.openejb.monitoring.ManagedMBean;
@@ -44,6 +45,7 @@ import org.apache.xbean.recipe.ObjectRecipe;
 import org.apache.xbean.recipe.Option;
 
 import javax.ejb.ConcurrentAccessTimeoutException;
+import javax.ejb.EJBContext;
 import javax.ejb.SessionBean;
 import javax.management.Attribute;
 import javax.management.AttributeList;
@@ -62,6 +64,8 @@ import javax.management.MBeanServer;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.management.ReflectionException;
+import javax.naming.Context;
+import javax.naming.NamingException;
 import javax.resource.ResourceException;
 import javax.resource.spi.ActivationSpec;
 import javax.resource.spi.ResourceAdapter;
@@ -202,6 +206,16 @@ public class MdbInstanceManager {
                 data.flush();
             }
         });
+
+        try {
+            final Context context = beanContext.getJndiEnc();
+            context.bind("comp/EJBContext", mdbContext);
+            context.bind("comp/TimerService", new TimerServiceWrapper());
+        } catch (final NamingException e) {
+            throw new OpenEJBException("Failed to bind EJBContext/TimerService", e);
+        }
+
+        beanContext.set(EJBContext.class, mdbContext);
         data.setBaseContext(mdbContext);
         beanContext.setContainerData(data);
         final MBeanServer server = LocalMBeanServer.get();

http://git-wip-us.apache.org/repos/asf/tomee/blob/ad56aad8/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MdbPoolContainerTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MdbPoolContainerTest.java
b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MdbPoolContainerTest.java
index 0548f20..3ade78b4 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MdbPoolContainerTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MdbPoolContainerTest.java
@@ -17,7 +17,6 @@
 package org.apache.openejb.core.mdb;
 
 import org.apache.activemq.ActiveMQXAConnectionFactory;
-import org.apache.openejb.activemq.AMQXASupportTest;
 import org.apache.openejb.jee.MessageDrivenBean;
 import org.apache.openejb.junit.ApplicationComposer;
 import org.apache.openejb.testing.Configuration;
@@ -30,6 +29,7 @@ import org.junit.runner.RunWith;
 import javax.annotation.Resource;
 import javax.ejb.ActivationConfigProperty;
 import javax.ejb.MessageDriven;
+import javax.ejb.MessageDrivenContext;
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.JMSException;
@@ -81,7 +81,7 @@ public class MdbPoolContainerTest {
 
     @Module
     public MessageDrivenBean jar() {
-        return new MessageDrivenBean(AMQXASupportTest.Listener.class);
+        return new MessageDrivenBean(Listener.class);
     }
 
     @Resource(name = "target")
@@ -95,7 +95,7 @@ public class MdbPoolContainerTest {
 
     @Before
     public void resetLatch() {
-        AMQXASupportTest.Listener.reset();
+        Listener.reset();
     }
 
     @Test
@@ -108,7 +108,7 @@ public class MdbPoolContainerTest {
             final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
             final MessageProducer producer = session.createProducer(destination);
             producer.send(session.createTextMessage(TEXT));
-            assertTrue(AMQXASupportTest.Listener.sync());
+            assertTrue(Listener.sync());
         } finally {
             connection.close();
         }
@@ -119,6 +119,10 @@ public class MdbPoolContainerTest {
             @ActivationConfigProperty(propertyName = "destination", propertyValue = "target")
     })
     public static class Listener implements MessageListener {
+
+        @Resource
+        private MessageDrivenContext ctx;
+
         public static CountDownLatch latch;
         public static boolean ok = false;
 
@@ -133,6 +137,8 @@ public class MdbPoolContainerTest {
             } finally {
                 latch.countDown();
             }
+
+            assertNotNull(ctx);
         }
 
         public static void reset() {


Mime
View raw message