You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2018/02/22 13:39:33 UTC

tomee git commit: Fix issues with polling-mdb example

Repository: tomee
Updated Branches:
  refs/heads/tomee-1.7.x 9d508f042 -> 9d7f5ccde


Fix issues with polling-mdb example


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

Branch: refs/heads/tomee-1.7.x
Commit: 9d7f5ccde0429f025eeac489569f40796a4f8aff
Parents: 9d508f0
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Thu Feb 22 13:24:22 2018 +0000
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Thu Feb 22 13:24:22 2018 +0000

----------------------------------------------------------------------
 examples/polling-parent/polling-mdb/pom.xml     | 26 ++++++-------
 .../src/main/java/org/superbiz/mdb/ApiLog.java  | 40 +++++++++++++-------
 .../main/java/org/superbiz/mdb/CounterBean.java |  4 +-
 .../test/java/org/superbiz/SimpleMdbTest.java   |  9 ++---
 4 files changed, 42 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/9d7f5ccd/examples/polling-parent/polling-mdb/pom.xml
----------------------------------------------------------------------
diff --git a/examples/polling-parent/polling-mdb/pom.xml b/examples/polling-parent/polling-mdb/pom.xml
index 72a4f01..171a498 100644
--- a/examples/polling-parent/polling-mdb/pom.xml
+++ b/examples/polling-parent/polling-mdb/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <artifactId>polling-parent</artifactId>
     <groupId>jug</groupId>
-    <version>1.1.0-SNAPSHOT</version>
+    <version>1.1.1-SNAPSHOT</version>
   </parent>
 
   <artifactId>polling-mdb</artifactId>
@@ -35,27 +35,23 @@
       <artifactId>junit</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.tomee</groupId>
+      <groupId>org.apache.openejb</groupId>
       <artifactId>openejb-core</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.tomee</groupId>
+      <groupId>org.apache.openejb</groupId>
       <artifactId>openejb-cxf-rs</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.tomee</groupId>
-      <artifactId>arquillian-tomee-remote</artifactId>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>arquillian-tomee-embedded</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.jboss.arquillian.junit</groupId>
-      <artifactId>arquillian-junit-container</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.tomee</groupId>
+      <groupId>org.apache.openejb</groupId>
       <artifactId>tomee-webservices</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.tomee</groupId>
+      <groupId>org.apache.openejb</groupId>
       <artifactId>ziplock</artifactId>
     </dependency>
     <dependency>
@@ -80,17 +76,17 @@
         </configuration>
       </plugin>
       <plugin>
-        <groupId>org.apache.tomee.maven</groupId>
+        <groupId>org.apache.openejb.maven</groupId>
         <artifactId>tomee-maven-plugin</artifactId>
-        <version>${tomee.version}</version>
+        <version>${version.tomee}</version>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <version>3.5.1</version>
         <configuration>
-          <source>1.7</source>
-          <target>1.7</target>
+          <source>1.6</source>
+          <target>1.6</target>
         </configuration>
       </plugin>
       <plugin>

http://git-wip-us.apache.org/repos/asf/tomee/blob/9d7f5ccd/examples/polling-parent/polling-mdb/src/main/java/org/superbiz/mdb/ApiLog.java
----------------------------------------------------------------------
diff --git a/examples/polling-parent/polling-mdb/src/main/java/org/superbiz/mdb/ApiLog.java b/examples/polling-parent/polling-mdb/src/main/java/org/superbiz/mdb/ApiLog.java
index 28474d3..6612fa4 100644
--- a/examples/polling-parent/polling-mdb/src/main/java/org/superbiz/mdb/ApiLog.java
+++ b/examples/polling-parent/polling-mdb/src/main/java/org/superbiz/mdb/ApiLog.java
@@ -18,7 +18,6 @@
 package org.superbiz.mdb;
 
 import javax.annotation.Resource;
-import javax.ejb.EJB;
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.JMSException;
@@ -29,9 +28,7 @@ import javax.jms.Session;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
 import javax.ws.rs.core.Response;
-import java.util.List;
 
 @Path("/log")
 public class ApiLog {
@@ -42,23 +39,38 @@ public class ApiLog {
     @Resource(name = "LoggingBean")
     private Queue vector;
 
-    @EJB
-    private CounterBean logs;
-
     @GET
     @Path("/{txt}")
     public Response get(@PathParam("txt") String txt) throws JMSException {
-        try (final Connection connection = connectionFactory.createConnection()) {
+
+        Connection connection = null;
+        Session session = null;
+        MessageProducer producer = null;
+
+        try {
+            connection = connectionFactory.createConnection();
             connection.start();
-            try (final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) {
-                try (final MessageProducer producer = session.createProducer(vector)) {
-                    final Message msg = session.createMessage();
-                    msg.setStringProperty("txt", txt);
-                    producer.send(msg);
-                }
+            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            producer = session.createProducer(vector);
+
+
+            final Message msg = session.createMessage();
+            msg.setStringProperty("txt", txt);
+            producer.send(msg);
+            return Response.ok().build();
+        } finally {
+            if (producer != null) {
+                producer.close();
+            }
+
+            if (session != null) {
+                session.close();
+            }
+
+            if (connection != null) {
+                connection.close();
             }
         }
-        return Response.ok().build();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/9d7f5ccd/examples/polling-parent/polling-mdb/src/main/java/org/superbiz/mdb/CounterBean.java
----------------------------------------------------------------------
diff --git a/examples/polling-parent/polling-mdb/src/main/java/org/superbiz/mdb/CounterBean.java b/examples/polling-parent/polling-mdb/src/main/java/org/superbiz/mdb/CounterBean.java
index 0b5328b..5078536 100644
--- a/examples/polling-parent/polling-mdb/src/main/java/org/superbiz/mdb/CounterBean.java
+++ b/examples/polling-parent/polling-mdb/src/main/java/org/superbiz/mdb/CounterBean.java
@@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 @Singleton
 @Startup
 public class CounterBean {
-    private Map<Integer, AtomicInteger> logs = new TreeMap<>();
+    private Map<Integer, AtomicInteger> logs = new TreeMap<Integer, AtomicInteger>();
 
     public void add(Integer beanId) {
         if(!this.logs.containsKey(beanId)) {
@@ -36,7 +36,7 @@ public class CounterBean {
     }
 
     public Map<Integer, AtomicInteger> getUsage() {
-        Map<Integer, AtomicInteger> copy = new TreeMap<>();
+        Map<Integer, AtomicInteger> copy = new TreeMap<Integer, AtomicInteger>();
         copy.putAll(this.logs);
         return copy;
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/9d7f5ccd/examples/polling-parent/polling-mdb/src/test/java/org/superbiz/SimpleMdbTest.java
----------------------------------------------------------------------
diff --git a/examples/polling-parent/polling-mdb/src/test/java/org/superbiz/SimpleMdbTest.java b/examples/polling-parent/polling-mdb/src/test/java/org/superbiz/SimpleMdbTest.java
index d70b8d8..636f058 100644
--- a/examples/polling-parent/polling-mdb/src/test/java/org/superbiz/SimpleMdbTest.java
+++ b/examples/polling-parent/polling-mdb/src/test/java/org/superbiz/SimpleMdbTest.java
@@ -32,10 +32,8 @@ import org.superbiz.mdb.LogMdb;
 
 import javax.ejb.EJB;
 import java.io.BufferedReader;
-import java.io.IOException;
 import java.io.InputStreamReader;
 import java.net.HttpURLConnection;
-import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Map;
 import java.util.TreeMap;
@@ -69,7 +67,7 @@ public class SimpleMdbTest {
         }
         executor.shutdown();
         Assert.assertTrue("Unable to execute all the GET calls", executor.awaitTermination(10, TimeUnit.SECONDS));
-        Map<Integer, AtomicInteger> expected = new TreeMap<>();
+        Map<Integer, AtomicInteger> expected = new TreeMap<Integer, AtomicInteger>();
         expected.put(1, new AtomicInteger(20));
         expected.put(2, new AtomicInteger(20));
         expected.put(3, new AtomicInteger(20));
@@ -103,12 +101,11 @@ public class SimpleMdbTest {
             try {
                 HttpURLConnection conn = (HttpURLConnection) url.toURI().resolve("log/lala_" + index).toURL().openConnection();
                 conn.setRequestMethod("GET");
-                try (BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
+                BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                     while (rd.readLine() != null) {
                         // ignore
                     }
-                }
-            } catch (IOException | URISyntaxException e) {
+            } catch (Exception e) {
                 // ignore
             }
         }