summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/binding-jms-runtime
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-10-31 13:51:37 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-10-31 13:51:37 +0000
commitd30ec839689a4971f35e4e927d7e574584ec1807 (patch)
treef192fd3a98ae0611b94ec34c0d2344ab5140dca1 /java/sca/modules/binding-jms-runtime
parent2ad26cd7431d5d1d0b333ec18212eb5db29fd537 (diff)
Add a context structure for the jms binding to pass along the binding wire
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@709414 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/binding-jms-runtime')
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java50
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefaultServiceInterceptor.java16
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java12
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingListener.java35
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesServiceInterceptor.java7
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultServiceInterceptor.java21
6 files changed, 104 insertions, 37 deletions
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java
new file mode 100644
index 0000000000..c4fd6f8357
--- /dev/null
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.binding.jms.context;
+
+import javax.jms.Message;
+import javax.jms.Session;
+
+
+/**
+ * Context that the JMS binding puts on the Tuscany wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSBindingContext {
+
+ private Message jmsMsg;
+ private Session jmsSession;
+
+ public Message getJmsMsg() {
+ return jmsMsg;
+ }
+
+ public void setJmsMsg(Message jmsMsg) {
+ this.jmsMsg = jmsMsg;
+ }
+
+ public Session getJmsSession() {
+ return jmsSession;
+ }
+
+ public void setJmsSession(Session jmsSession) {
+ this.jmsSession = jmsSession;
+ }
+}
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefaultServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefaultServiceInterceptor.java
index 6791bc4641..b644a4883f 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefaultServiceInterceptor.java
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefaultServiceInterceptor.java
@@ -25,6 +25,7 @@ import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
import org.apache.tuscany.sca.binding.jms.impl.JMSBinding;
import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants;
import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException;
@@ -74,8 +75,9 @@ public class OperationSelectorJMSDefaultServiceInterceptor implements Intercepto
}
public Message invokeRequest(Message msg) {
- // get the jms message
- javax.jms.Message jmsMsg = (javax.jms.Message)msg.getHeaders().get(JMSBindingConstants.MSG_CTXT_JMSREQUESTMSG_POSITION);
+ // get the jms context
+ JMSBindingContext context = (JMSBindingContext)msg.getHeaders().get(JMSBindingConstants.MSG_CTXT_POSITION);
+ javax.jms.Message jmsMsg = context.getJmsMsg();
String operationName = requestMessageProcessor.getOperationName(jmsMsg);
Operation operation = getTargetOperation(operationName);
@@ -86,12 +88,10 @@ public class OperationSelectorJMSDefaultServiceInterceptor implements Intercepto
public Message invokeResponse(Message msg) {
try {
- // get the jms message
- javax.jms.Message requestJMSMsg = (javax.jms.Message)msg.getHeaders().get(JMSBindingConstants.MSG_CTXT_JMSREQUESTMSG_POSITION);
-
- // get the jms session
- Session session = (Session)msg.getHeaders().get(JMSBindingConstants.MSG_CTXT_JMSSESSION_POSITION);
-
+ JMSBindingContext context = (JMSBindingContext)msg.getHeaders().get(JMSBindingConstants.MSG_CTXT_POSITION);
+ javax.jms.Message requestJMSMsg = context.getJmsMsg();
+ Session session = context.getJmsSession();
+
Destination destination = requestJMSMsg.getJMSReplyTo();
MessageProducer producer = session.createProducer(destination);
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java
index 9d64c4a16b..60bca05982 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java
@@ -143,7 +143,9 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR
this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
this.operationSelectorProviderFactory =
(OperationSelectorProviderFactory)providerFactories.getProviderFactory(jmsBinding.getOperationSelector().getClass());
- this.operationSelectorProvider = operationSelectorProviderFactory.createServiceOperationSelectorProvider(component, service, jmsBinding);
+ if (this.operationSelectorProviderFactory != null){
+ this.operationSelectorProvider = operationSelectorProviderFactory.createServiceOperationSelectorProvider(component, service, jmsBinding);
+ }
// Get the factories/providers for wire format
@@ -159,11 +161,15 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR
this.requestWireFormatProviderFactory =
(WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getRequestWireFormat().getClass());
- this.requestWireFormatProvider = requestWireFormatProviderFactory.createServiceWireFormatProvider(component, service, jmsBinding);
+ if (this.requestWireFormatProviderFactory != null){
+ this.requestWireFormatProvider = requestWireFormatProviderFactory.createServiceWireFormatProvider(component, service, jmsBinding);
+ }
this.responseWireFormatProviderFactory =
(WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getResponseWireFormat().getClass());
- this.responseWireFormatProvider = responseWireFormatProviderFactory.createServiceWireFormatProvider(component, service, jmsBinding);
+ if (this.responseWireFormatProvider != null){
+ this.responseWireFormatProvider = responseWireFormatProviderFactory.createServiceWireFormatProvider(component, service, jmsBinding);
+ }
}
protected boolean isOnMessage() {
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingListener.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingListener.java
index 615251610c..11c1127cf6 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingListener.java
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingListener.java
@@ -36,6 +36,7 @@ import javax.naming.NamingException;
import javax.security.auth.Subject;
import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
import org.apache.tuscany.sca.binding.jms.impl.JMSBinding;
import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants;
import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException;
@@ -137,18 +138,28 @@ public class RRBJMSBindingListener implements MessageListener {
*/
protected void invokeService(Message requestJMSMsg) throws JMSException, InvocationTargetException {
- // create the tuscany message
- org.apache.tuscany.sca.invocation.Message tuscanyMsg = messageFactory.createMessage();
-
- // populate the message context with JMS binding information
- tuscanyMsg.getHeaders().add(requestJMSMsg);
- tuscanyMsg.setBody(requestJMSMsg);
-
- // call the runtime wire
- setHeaderProperties(requestJMSMsg, tuscanyMsg, tuscanyMsg.getOperation());
- InvocationChain chain = service.getRuntimeWire(targetBinding).getBindingInvocationChain();
- chain.getHeadInvoker().invoke(tuscanyMsg);
-
+ try {
+ // create the tuscany message
+ org.apache.tuscany.sca.invocation.Message tuscanyMsg = messageFactory.createMessage();
+
+ // populate the message context with JMS binding information
+ JMSBindingContext context = new JMSBindingContext();
+ tuscanyMsg.getHeaders().add(context);
+
+ context.setJmsMsg(requestJMSMsg);
+ context.setJmsSession(jmsResourceFactory.createSession());
+
+ // set the message body
+ tuscanyMsg.setBody(requestJMSMsg);
+
+ // call the runtime wire
+ setHeaderProperties(requestJMSMsg, tuscanyMsg, tuscanyMsg.getOperation());
+ InvocationChain chain = service.getRuntimeWire(targetBinding).getBindingInvocationChain();
+ chain.getHeadInvoker().invoke(tuscanyMsg);
+ } catch (NamingException e) {
+ throw new JMSBindingException(e);
+ }
+
}
/**
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesServiceInterceptor.java
index 4bcc23edac..39965a56ba 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesServiceInterceptor.java
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesServiceInterceptor.java
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.binding.jms.wireformat.bytes;
import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
import org.apache.tuscany.sca.binding.jms.impl.JMSBinding;
import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants;
import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
@@ -52,10 +53,10 @@ public class WireFormatJMSBytesServiceInterceptor implements Interceptor {
this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding);
}
-
public Message invoke(Message msg) {
- // get the jms message
- javax.jms.Message jmsMsg = (javax.jms.Message)msg.getHeaders().get(JMSBindingConstants.MSG_CTXT_JMSREQUESTMSG_POSITION);
+ // get the jms context
+ JMSBindingContext context = (JMSBindingContext)msg.getHeaders().get(JMSBindingConstants.MSG_CTXT_POSITION);
+ javax.jms.Message jmsMsg = context.getJmsMsg();
msg.setBody(requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg));
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultServiceInterceptor.java
index 7c7c44f627..ad3ff95306 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultServiceInterceptor.java
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultServiceInterceptor.java
@@ -23,6 +23,7 @@ import javax.jms.Session;
import javax.naming.NamingException;
import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
import org.apache.tuscany.sca.binding.jms.impl.JMSBinding;
import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants;
import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException;
@@ -85,8 +86,9 @@ public class WireFormatJMSDefaultServiceInterceptor implements Interceptor {
}
public Message invokeRequest(Message msg) {
- // get the jms message
- javax.jms.Message jmsMsg = (javax.jms.Message)msg.getHeaders().get(JMSBindingConstants.MSG_CTXT_JMSREQUESTMSG_POSITION);
+ // get the jms context
+ JMSBindingContext context = (JMSBindingContext)msg.getHeaders().get(JMSBindingConstants.MSG_CTXT_POSITION);
+ javax.jms.Message jmsMsg = context.getJmsMsg();
if ("onMessage".equals(msg.getOperation().getName())) {
msg.setBody(new Object[]{jmsMsg});
@@ -100,12 +102,11 @@ public class WireFormatJMSDefaultServiceInterceptor implements Interceptor {
public Message invokeResponse(Message msg) {
try {
- // get the jms message
- javax.jms.Message requestJMSMsg = (javax.jms.Message)msg.getHeaders().get(JMSBindingConstants.MSG_CTXT_JMSREQUESTMSG_POSITION);
-
- Session session = jmsResourceFactory.createSession();
- msg.getHeaders().add(JMSBindingConstants.MSG_CTXT_JMSSESSION_POSITION, session);
-
+ // get the jms context
+ JMSBindingContext context = (JMSBindingContext)msg.getHeaders().get(JMSBindingConstants.MSG_CTXT_POSITION);
+ javax.jms.Message requestJMSMsg = context.getJmsMsg();
+ Session session = context.getJmsSession();
+
javax.jms.Message responseJMSMsg;
if (msg.isFault()) {
responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
@@ -127,9 +128,7 @@ public class WireFormatJMSDefaultServiceInterceptor implements Interceptor {
return msg;
} catch (JMSException e) {
throw new JMSBindingException(e);
- } catch (NamingException e) {
- throw new JMSBindingException(e);
- }
+ }
}
public Invoker getNext() {