mirror of https://github.com/apache/activemq.git
Ensure PooledConnectionFactory implements QueueConnectionFactory and TopicConnectionFactory
This commit is contained in:
parent
9ae22642dc
commit
459593c427
|
@ -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);
|
||||
|
@ -183,6 +187,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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -55,6 +57,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 {
|
||||
|
||||
|
|
Loading…
Reference in New Issue