fix for AMQ-348 to allow a ConnectionFactory to be specified so it can be shared across inbound and outputbound messaging

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@366161 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2006-01-05 11:14:38 +00:00
parent e310c21a8d
commit cc1de0e202
1 changed files with 24 additions and 1 deletions

View File

@ -57,6 +57,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter {
private BootstrapContext bootstrapContext;
private String brokerXmlConfig;
private BrokerService broker;
private ActiveMQConnectionFactory connectionFactory;
public ActiveMQResourceAdapter() {
}
@ -77,7 +78,12 @@ public class ActiveMQResourceAdapter implements ResourceAdapter {
}
public ActiveMQConnection makeConnection() throws JMSException {
return makeConnection(info);
if (connectionFactory != null) {
return makeConnection(info, connectionFactory);
}
else {
return makeConnection(info);
}
}
/**
@ -85,6 +91,10 @@ public class ActiveMQResourceAdapter implements ResourceAdapter {
public ActiveMQConnection makeConnection(ActiveMQConnectionRequestInfo info) throws JMSException {
ActiveMQConnectionFactory connectionFactory = createConnectionFactory(info);
return makeConnection(info, connectionFactory);
}
public ActiveMQConnection makeConnection(ActiveMQConnectionRequestInfo info, ActiveMQConnectionFactory connectionFactory) throws JMSException {
String userName = info.getUserName();
String password = info.getPassword();
ActiveMQConnection physicalConnection = (ActiveMQConnection) connectionFactory.createConnection(userName, password);
@ -459,5 +469,18 @@ public class ActiveMQResourceAdapter implements ResourceAdapter {
info.setUseInboundSession(useInboundSession);
}
public ActiveMQConnectionFactory getConnectionFactory() {
return connectionFactory;
}
/**
* This allows a connection factory to be configured and shared between a ResourceAdaptor and outbound messaging.
* Note that setting the connectionFactory will overload many of the properties on this POJO such as the redelivery
* and prefetch policies; the properties on the connectionFactory will be used instead.
*/
public void setConnectionFactory(ActiveMQConnectionFactory connectionFactory) {
this.connectionFactory = connectionFactory;
}
}