summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.x/modules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java26
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java6
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java7
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java6
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java13
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java12
-rw-r--r--branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java11
7 files changed, 72 insertions, 9 deletions
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java
index 183e006b04..6801270ee1 100644
--- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java
+++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java
@@ -62,6 +62,18 @@ public class JMSBindingContext {
return jmsSession;
}
+ public synchronized void closeJmsSession() {
+ if (jmsSession != null) {
+ try {
+ jmsSession.close();
+ } catch (Exception e) {
+ throw new JMSBindingException(e);
+ } finally {
+ jmsSession = null;
+ }
+ }
+ }
+
public synchronized Session getJmsResponseSession() {
if (jmsResponseSession == null) {
try {
@@ -72,7 +84,19 @@ public class JMSBindingContext {
}
return jmsResponseSession;
}
-
+
+ public synchronized void closeJmsResponseSession() {
+ if (jmsResponseSession != null) {
+ try {
+ jmsResponseSession.close();
+ } catch (Exception e) {
+ throw new JMSBindingException(e);
+ } finally {
+ jmsResponseSession = null;
+ }
+ }
+ }
+
public Destination getRequestDestination() {
return requestDestination;
}
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java
index 93bf0cb03e..bb578ef25b 100644
--- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java
+++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java
@@ -94,7 +94,11 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR
this.extensionPoints = extensionPoints;
this.jmsResourceFactory = jmsResourceFactory;
- if (jmsBinding.getDestinationName() == null) {
+ // Set the default destination when using a connection factory.
+ // If an activation spec is being used, do not set the destination
+ // because the activation spec provides the destination.
+ if (jmsBinding.getDestinationName() == null &&
+ (jmsBinding.getActivationSpecName() == null || jmsBinding.getActivationSpecName().equals(""))) {
if (!service.isCallback()) {
// use the SCA service name as the default destination name
jmsBinding.setDestinationName(service.getName());
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 3f61eaf033..7062d0455d 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
@@ -82,4 +82,11 @@ public interface JMSResourceFactory {
public abstract void closeResponseConnection() throws JMSException;
+
+ /*
+ * Indicates whether connections obtained using getConnection() or getResponseConnection()
+ * must be closed after each use. This is necessary in environments where connections are
+ * shared with other users, or where connections cannot be held across transaction boundaries.
+ */
+ public abstract boolean isConnectionClosedAfterUse();
}
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 aef0902e8c..5e9cce0c98 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
@@ -260,4 +260,10 @@ public class JMSResourceFactoryImpl implements JMSResourceFactory {
}
}
+ public boolean isConnectionClosedAfterUse() {
+ // It is assumed this resource factory is used in an environment
+ // where the connection can be held for the life of the binding.
+ return false;
+ }
+
}
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java
index 08849e6245..e2b75de5b9 100644
--- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java
+++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java
@@ -69,7 +69,13 @@ public class RRBJMSBindingInvoker implements Invoker, DataExchangeSemantics {
this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding);
try {
- bindingRequestDest = lookupDestination();
+ // If this is a callback reference, the destination is determined dynamically based on
+ // properties of the inbound service request. We should not look for or require a
+ // statically-configured destination unless a message is received that does not have
+ // the necessary properties.
+ if (!reference.isCallback()) {
+ bindingRequestDest = lookupDestination();
+ }
bindingReplyDest = lookupResponseDestination();
} catch (NamingException e) {
throw new JMSBindingException(e);
@@ -216,7 +222,10 @@ public class RRBJMSBindingInvoker implements Invoker, DataExchangeSemantics {
} catch (Throwable e) {
tuscanyMsg.setFaultBody(e);
} finally {
- session.close();
+ context.closeJmsSession();
+ if (jmsResourceFactory.isConnectionClosedAfterUse()) {
+ jmsResourceFactory.closeConnection();
+ }
}
return tuscanyMsg;
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java
index c3e6031b85..8382e3874f 100644
--- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java
+++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java
@@ -115,9 +115,8 @@ public class TransportReferenceInterceptor implements Interceptor {
}
public Message invokeResponse(Message msg) {
+ JMSBindingContext context = msg.getBindingContext();
try {
- // get the jms context
- JMSBindingContext context = msg.getBindingContext();
Session session = context.getJmsResponseSession();
javax.jms.Message requestMessage = (javax.jms.Message)msg.getBody();
@@ -148,7 +147,14 @@ public class TransportReferenceInterceptor implements Interceptor {
throw new JMSBindingException(e);
} catch (NamingException e) {
throw new JMSBindingException(e);
- }
+ } finally {
+ try {
+ context.closeJmsResponseSession();
+ if (jmsResourceFactory.isConnectionClosedAfterUse())
+ jmsResourceFactory.closeResponseConnection();
+ } catch (JMSException e) {
+ }
+ }
}
public Invoker getNext() {
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java
index eebac3a8b7..6cc7fff593 100644
--- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java
+++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java
@@ -85,6 +85,13 @@ public class TransportServiceInterceptor implements Interceptor {
msg.setBody(replyJMSMsg);
invokeResponse(msg);
return msg;
+ } finally {
+ try {
+ ((JMSBindingContext)msg.getBindingContext()).closeJmsResponseSession();
+ if (jmsResourceFactory.isConnectionClosedAfterUse())
+ jmsResourceFactory.closeResponseConnection();
+ } catch (JMSException e) {
+ }
}
}
@@ -163,13 +170,13 @@ public class TransportServiceInterceptor implements Interceptor {
producer.send((javax.jms.Message)msg.getBody());
producer.close();
- session.close();
+ context.closeJmsResponseSession();
return msg;
} catch (JMSException e) {
throw new JMSBindingException(e);
- }
+ }
}
public Invoker getNext() {