diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-12 10:45:29 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-12 10:45:29 +0000 |
commit | 90e4c11facf6f4011a7e4294f64cbc9d7c189128 (patch) | |
tree | 54f35a21a1818d3b6c81e1ec8678142276747ad2 /branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java | |
parent | 57979d20af5d2fd2bc2811a2be8f475bee8eafed (diff) |
TUSCANY-2841: start to add support for using a seperate response connection factory
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@743685 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java')
-rw-r--r-- | branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java index d0624fb52e..8136c524c6 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java @@ -46,11 +46,16 @@ public class JMSResourceFactoryImpl implements JMSResourceFactory { protected Connection connection; protected Context context; protected boolean isConnectionStarted; + private Connection responseConnection; + private String responseConnectionFactoryName; - public JMSResourceFactoryImpl(String connectionFactoryName, String initialContextFactoryName, String jndiURL) { + public JMSResourceFactoryImpl(String connectionFactoryName, String responseConnectionFactoryName, String initialContextFactoryName, String jndiURL) { if (connectionFactoryName != null && connectionFactoryName.trim().length() > 0) { this.connectionFactoryName = connectionFactoryName.trim(); } + if (responseConnectionFactoryName != null && responseConnectionFactoryName.trim().length() > 0) { + this.responseConnectionFactoryName = responseConnectionFactoryName.trim(); + } if (initialContextFactoryName != null && initialContextFactoryName.trim().length() > 0) { this.initialContextFactoryName = initialContextFactoryName.trim(); } @@ -220,4 +225,25 @@ public class JMSResourceFactoryImpl implements JMSResourceFactory { } return o; } + + public Session createResponseSession() throws JMSException, NamingException { + return getResponseConnection().createSession(false, Session.AUTO_ACKNOWLEDGE); + } + + public Connection getResponseConnection() throws NamingException, JMSException { + if (responseConnection == null) { + if (responseConnectionFactoryName != null) { + ConnectionFactory connectionFactory = (ConnectionFactory)jndiLookUp(responseConnectionFactoryName); + if (connectionFactory == null) { + throw new JMSBindingException("connection factory not found: " + responseConnectionFactoryName); + } + responseConnection = connectionFactory.createConnection(); + } else { + // if no response connection is defined in the SCDL use the request connection + responseConnection = getConnection(); + } + } + return responseConnection; + } + } |