tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andygumbre...@apache.org
Subject tomee git commit: Wrap AMQ
Date Thu, 19 Nov 2015 18:38:32 GMT
Repository: tomee
Updated Branches:
  refs/heads/tomee-1.7.x ac2603905 -> b768c4a04


Wrap AMQ


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

Branch: refs/heads/tomee-1.7.x
Commit: b768c4a0471e6bfc9fe7fb02ed93e6294b1b10c4
Parents: ac26039
Author: AndyGee <andy.is@gmx.de>
Authored: Thu Nov 19 19:38:14 2015 +0100
Committer: AndyGee <andy.is@gmx.de>
Committed: Thu Nov 19 19:38:14 2015 +0100

----------------------------------------------------------------------
 .../org/apache/openejb/InjectionProcessor.java  |  8 ++---
 .../activemq/ConnectionFactoryWrapper.java      | 36 ++++++++++++++++----
 .../resource/activemq/ConnectionWrapper.java    |  4 +++
 3 files changed, 37 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/b768c4a0/container/openejb-core/src/main/java/org/apache/openejb/InjectionProcessor.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/InjectionProcessor.java
b/container/openejb-core/src/main/java/org/apache/openejb/InjectionProcessor.java
index 5bc6e90..6586214 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/InjectionProcessor.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/InjectionProcessor.java
@@ -20,6 +20,7 @@ package org.apache.openejb;
 import org.apache.openejb.core.ivm.naming.JndiUrlReference;
 import org.apache.openejb.injection.FallbackPropertyInjector;
 import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.resource.activemq.ConnectionFactoryWrapper;
 import org.apache.openejb.spi.ContainerSystem;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
@@ -28,9 +29,6 @@ import org.apache.xbean.naming.reference.SimpleReference;
 import org.apache.xbean.recipe.ObjectRecipe;
 import org.apache.xbean.recipe.Option;
 
-import javax.jms.ConnectionFactory;
-import javax.jms.QueueConnection;
-import javax.jms.TopicConnection;
 import javax.naming.Context;
 import javax.naming.NamingException;
 import java.lang.reflect.InvocationTargetException;
@@ -252,9 +250,9 @@ public class InjectionProcessor<T> {
 
                 if (value != null) {
 
-                    if(ConnectionFactory.class.isInstance(value) && !TopicConnection.class.isInstance(value)
&& !QueueConnection.class.isInstance(value)){
+                    if("org.apache.activemq.ra.ActiveMQConnectionFactory".equals(value.getClass().getName())){
                         //Wrap
-                        //value = new ConnectionFactoryWrapper(ConnectionFactory.class.cast(value));
+                        value = new ConnectionFactoryWrapper(value);
                     }
 
                     final String prefix;

http://git-wip-us.apache.org/repos/asf/tomee/blob/b768c4a0/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ConnectionFactoryWrapper.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ConnectionFactoryWrapper.java
b/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ConnectionFactoryWrapper.java
index 731f286..546137b 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ConnectionFactoryWrapper.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ConnectionFactoryWrapper.java
@@ -13,29 +13,33 @@ package org.apache.openejb.resource.activemq;
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.JMSException;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-public class ConnectionFactoryWrapper implements ConnectionFactory {
+public class ConnectionFactoryWrapper implements ConnectionFactory, TopicConnectionFactory,
QueueConnectionFactory {
 
     private static final ArrayList<ConnectionWrapper> connections = new ArrayList<ConnectionWrapper>();
 
-    private final ConnectionFactory factory;
+    private final org.apache.activemq.ra.ActiveMQConnectionFactory factory;
 
-    public ConnectionFactoryWrapper(final ConnectionFactory factory) {
-        this.factory = factory;
+    public ConnectionFactoryWrapper(final Object factory) {
+        this.factory = org.apache.activemq.ra.ActiveMQConnectionFactory.class.cast(factory);
     }
 
     @Override
     public Connection createConnection() throws JMSException {
-        return getConnection(factory.createConnection());
+        return getConnection(this.factory.createConnection());
     }
 
     @Override
     public Connection createConnection(final String userName, final String password) throws
JMSException {
-        return getConnection(factory.createConnection(userName, password));
+        return getConnection(this.factory.createConnection(userName, password));
     }
 
     private static Connection getConnection(final Connection connection) {
@@ -63,4 +67,24 @@ public class ConnectionFactoryWrapper implements ConnectionFactory {
             }
         }
     }
+
+    @Override
+    public QueueConnection createQueueConnection() throws JMSException {
+        return this.factory.createQueueConnection();
+    }
+
+    @Override
+    public QueueConnection createQueueConnection(final String userName, final String password)
throws JMSException {
+        return this.factory.createQueueConnection(userName, password);
+    }
+
+    @Override
+    public TopicConnection createTopicConnection() throws JMSException {
+        return this.factory.createTopicConnection();
+    }
+
+    @Override
+    public TopicConnection createTopicConnection(final String userName, final String password)
throws JMSException {
+        return this.factory.createTopicConnection(userName, password);
+    }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/b768c4a0/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ConnectionWrapper.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ConnectionWrapper.java
b/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ConnectionWrapper.java
index a4a7018..dc98db2 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ConnectionWrapper.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ConnectionWrapper.java
@@ -21,6 +21,8 @@ import javax.jms.Session;
 import javax.jms.Topic;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 public class ConnectionWrapper implements Connection {
 
@@ -89,6 +91,8 @@ public class ConnectionWrapper implements Connection {
                 next.close();
             } catch (final Exception e) {
                 //no-op
+            } finally {
+                Logger.getLogger(ConnectionFactoryWrapper.class.getName()).log(Level.SEVERE,
"Closed a JMS session. You have an application that fails to close this session");
             }
         }
 


Mime
View raw message