From 2123aa9a26dce236c3b531f74b628a867a57e3e8 Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 19 Feb 2009 15:27:53 +0000 Subject: TUSCANY-2859: Add a closeResponseConnection method to the JMSResourceFactory git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@745897 13f79535-47bb-0310-9956-ffa450edef68 --- .../jms/provider/JMSBindingReferenceBindingProvider.java | 1 + .../sca/binding/jms/provider/JMSResourceFactory.java | 2 ++ .../sca/binding/jms/provider/JMSResourceFactoryImpl.java | 16 +++++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) (limited to 'branches/sca-java-1.x/modules/binding-jms-runtime/src') diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java index f39f070321..f785a8fdb9 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java @@ -122,6 +122,7 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi public void stop() { try { jmsResourceFactory.closeConnection(); + jmsResourceFactory.closeResponseConnection(); } catch (JMSException e) { throw new JMSBindingException(e); } diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java index b8ff408292..3f61eaf033 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java @@ -80,4 +80,6 @@ public interface JMSResourceFactory { */ public abstract Session createResponseSession() throws JMSException, NamingException; + + public abstract void closeResponseConnection() throws JMSException; } 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 d3197c1f43..80d1646c71 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 @@ -29,7 +29,6 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; /** @@ -246,4 +245,19 @@ public class JMSResourceFactoryImpl implements JMSResourceFactory { return responseConnection; } + public void closeResponseConnection() throws JMSException { + if (responseConnection != null) { + try { + responseConnection.close(); + } catch (JMSException e) { + // if using an embedded broker then when shutting down Tuscany the broker may get closed + // before this stop method is called. I can't see how to detect that so for now just + // ignore the exception if the message is that the transport is already disposed + if (!e.getMessage().contains("disposed")) { + throw e; + } + } + } + } + } -- cgit v1.2.3