activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [2/4] git commit: https://issues.apache.org/jira/browse/AMQ-5224
Date Fri, 13 Jun 2014 16:35:30 GMT
https://issues.apache.org/jira/browse/AMQ-5224

Ensure PooledConnectionFactory implements QueueConnectionFactory and
TopicConnectionFactory

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

Branch: refs/heads/trunk
Commit: 459593c4277637e1a5186d823c04f6afebc21858
Parents: 9ae2264
Author: Timothy Bish <tabish121@gmail.com>
Authored: Fri Jun 13 11:18:24 2014 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Fri Jun 13 11:18:24 2014 -0400

----------------------------------------------------------------------
 .../jms/pool/PooledConnectionFactory.java       | 26 ++++++++++++++++++-
 .../jms/pool/XaPooledConnectionFactory.java     | 27 +-------------------
 .../jms/pool/PooledConnectionFactoryTest.java   |  9 +++++++
 3 files changed, 35 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/459593c4/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
----------------------------------------------------------------------
diff --git a/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
b/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
index 8bc7bcc..16f2701 100644
--- a/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
+++ b/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/PooledConnectionFactory.java
@@ -22,6 +22,10 @@ import java.util.concurrent.atomic.AtomicReference;
 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 javax.jms.XAConnectionFactory;
 
 import org.apache.commons.pool.KeyedPoolableObjectFactory;
@@ -58,7 +62,7 @@ import org.slf4j.LoggerFactory;
  * configure the idle eviction thread to run.
  *
  */
-public class PooledConnectionFactory implements ConnectionFactory {
+public class PooledConnectionFactory implements ConnectionFactory, QueueConnectionFactory,
TopicConnectionFactory {
     private static final transient Logger LOG = LoggerFactory.getLogger(PooledConnectionFactory.class);
 
     protected final AtomicBoolean stopped = new AtomicBoolean(false);
@@ -184,6 +188,26 @@ public class PooledConnectionFactory implements ConnectionFactory {
     }
 
     @Override
+    public QueueConnection createQueueConnection() throws JMSException {
+        return (QueueConnection) createConnection();
+    }
+
+    @Override
+    public QueueConnection createQueueConnection(String userName, String password) throws
JMSException {
+        return (QueueConnection) createConnection(userName, password);
+    }
+
+    @Override
+    public TopicConnection createTopicConnection() throws JMSException {
+        return (TopicConnection) createConnection();
+    }
+
+    @Override
+    public TopicConnection createTopicConnection(String userName, String password) throws
JMSException {
+        return (TopicConnection) createConnection(userName, password);
+    }
+
+    @Override
     public Connection createConnection() throws JMSException {
         return createConnection(null, null);
     }

http://git-wip-us.apache.org/repos/asf/activemq/blob/459593c4/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/XaPooledConnectionFactory.java
----------------------------------------------------------------------
diff --git a/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/XaPooledConnectionFactory.java
b/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/XaPooledConnectionFactory.java
index 5e44be2..d5fbc60 100644
--- a/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/XaPooledConnectionFactory.java
+++ b/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/XaPooledConnectionFactory.java
@@ -20,11 +20,6 @@ import java.io.Serializable;
 import java.util.Hashtable;
 
 import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.jms.TopicConnection;
-import javax.jms.TopicConnectionFactory;
 import javax.naming.Binding;
 import javax.naming.Context;
 import javax.naming.InitialContext;
@@ -40,7 +35,7 @@ import org.slf4j.LoggerFactory;
  * A pooled connection factory that automatically enlists sessions in the
  * current active XA transaction if any.
  */
-public class XaPooledConnectionFactory extends PooledConnectionFactory implements ObjectFactory,
Serializable, QueueConnectionFactory, TopicConnectionFactory {
+public class XaPooledConnectionFactory extends PooledConnectionFactory implements ObjectFactory,
Serializable {
 
     private static final transient Logger LOG = LoggerFactory.getLogger(XaPooledConnectionFactory.class);
     private static final long serialVersionUID = -6545688026350913005L;
@@ -122,24 +117,4 @@ public class XaPooledConnectionFactory extends PooledConnectionFactory
implement
     public void setTmFromJndi(boolean tmFromJndi) {
         this.tmFromJndi = tmFromJndi;
     }
-
-    @Override
-    public QueueConnection createQueueConnection() throws JMSException {
-        return (QueueConnection) createConnection();
-    }
-
-    @Override
-    public QueueConnection createQueueConnection(String userName, String password) throws
JMSException {
-        return (QueueConnection) createConnection(userName, password);
-    }
-
-    @Override
-    public TopicConnection createTopicConnection() throws JMSException {
-        return (TopicConnection) createConnection();
-    }
-
-    @Override
-    public TopicConnection createTopicConnection(String userName, String password) throws
JMSException {
-        return (TopicConnection) createConnection(userName, password);
-    }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/459593c4/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java
----------------------------------------------------------------------
diff --git a/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java
b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java
index e20a605..289030f 100644
--- a/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java
+++ b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java
@@ -32,7 +32,9 @@ import java.util.concurrent.TimeUnit;
 
 import javax.jms.Connection;
 import javax.jms.JMSException;
+import javax.jms.QueueConnectionFactory;
 import javax.jms.Session;
+import javax.jms.TopicConnectionFactory;
 
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
@@ -56,6 +58,13 @@ public class PooledConnectionFactoryTest {
     public final static Logger LOG = Logger.getLogger(PooledConnectionFactoryTest.class);
 
     @Test
+    public void testInstanceOf() throws  Exception {
+        PooledConnectionFactory pcf = new PooledConnectionFactory();
+        assertTrue(pcf instanceof QueueConnectionFactory);
+        assertTrue(pcf instanceof TopicConnectionFactory);
+    }
+
+    @Test
     public void testClearAllConnections() throws Exception {
 
         ActiveMQConnectionFactory amq = new ActiveMQConnectionFactory("vm://broker1?marshal=false&broker.persistent=false");


Mime
View raw message