summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/binding-jms-runtime
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-11-04 15:24:34 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-11-04 15:24:34 +0000
commit924ac265dfdbb0cf799e9690fd8a567760ab329e (patch)
tree4812f972b32bf225a60f167205b1286d35a6de18 /java/sca/modules/binding-jms-runtime
parent441111bca1f86dca988a6b9a2c529af32205cf79 (diff)
Add preliminary support for a "jmsBytes" wire format to see what the issues are.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@711271 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/provider/BytesMessageProcessor.java79
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java12
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java13
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytes.java (renamed from java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytes.java)6
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProcessor.java (renamed from java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesProcessor.java)4
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProviderFactory.java (renamed from java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesProviderFactory.java)2
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesReferenceInterceptor.java (renamed from java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesReferenceInterceptor.java)63
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesReferenceProvider.java (renamed from java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesReferenceProvider.java)2
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesServiceInterceptor.java (renamed from java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesServiceInterceptor.java)79
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesServiceProvider.java (renamed from java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesServiceProvider.java)2
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefault.java2
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor1
-rw-r--r--java/sca/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory2
13 files changed, 236 insertions, 31 deletions
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java
new file mode 100644
index 0000000000..b6e7c6b1b2
--- /dev/null
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java
@@ -0,0 +1,79 @@
+/*
+ * 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.provider;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.tuscany.sca.binding.jms.impl.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException;
+
+/**
+ * MessageProcessor for sending/receiving javax.jms.BytesMessage with the JMSBinding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BytesMessageProcessor extends AbstractMessageProcessor {
+
+ public BytesMessageProcessor(JMSBinding jmsBinding) {
+ super(jmsBinding);
+ }
+
+ @Override
+ protected Object[] extractPayload(Message msg) {
+ try {
+
+ if (!(msg instanceof BytesMessage)) {
+ throw new IllegalStateException("expecting JMS BytesMessage: " + msg);
+ }
+
+ // TODO - Just an experiment
+ // how should this be wired into databinding?
+ // how to enforce single byte array parameter
+ // also casting long -> int!
+ long noOfBytes = ((BytesMessage)msg).getBodyLength();
+ byte [] bytes = new byte[(int)noOfBytes];
+ ((BytesMessage)msg).readBytes(bytes);
+ return new Object[] {bytes};
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ @Override
+ protected Message createJMSMessage(Session session, Object o) {
+ try {
+
+ // TODO - just and experiment. How to enforce a single
+ // byte array parameter
+ BytesMessage message = session.createBytesMessage();
+ byte [] bytes = (byte[])((Object[])o)[0];
+ message.writeBytes(bytes);
+ return message;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+}
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java
index 0fa67ccc62..22f8f76afb 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java
@@ -82,8 +82,13 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi
this.component = component;
this.jmsResourceFactory = jmsResourceFactory;
- if (XMLTextMessageProcessor.class.isAssignableFrom(JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding).getClass())) {
- setXMLDataBinding(reference);
+ // TODO - need to look at what the impact of the wireformat
+ // on the binding interface contract is
+ if ((jmsBinding.getRequestWireFormat() == null) ||
+ (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSDefault)) {
+ if (XMLTextMessageProcessor.class.isAssignableFrom(JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding).getClass())) {
+ setXMLDataBinding(reference);
+ }
}
// Get the factories/providers for operation selection
@@ -97,6 +102,7 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi
// Get the factories/providers for wire format
+ // TODO - Move into the binding
// if no request wire format specified then assume the default
if (jmsBinding.getRequestWireFormat() == null){
jmsBinding.setRequestWireFormat(new WireFormatJMSDefault());
@@ -115,7 +121,7 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi
this.responseWireFormatProviderFactory =
(WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getResponseWireFormat().getClass());
- if (this.responseWireFormatProvider != null){
+ if (this.responseWireFormatProviderFactory != null){
this.responseWireFormatProvider = responseWireFormatProviderFactory.createReferenceWireFormatProvider(component, reference, jmsBinding);
}
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 2642d6d370..779288a6be 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
@@ -124,9 +124,14 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR
}
}
- if (XMLTextMessageProcessor.class.isAssignableFrom(JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding).getClass())) {
- if (!isOnMessage()) {
- setXMLDataBinding(service);
+ // TODO - need to look at what the impact of the wireformat
+ // on the binding interface contract is
+ if ((jmsBinding.getRequestWireFormat() == null) ||
+ (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSDefault)) {
+ if (XMLTextMessageProcessor.class.isAssignableFrom(JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding).getClass())) {
+ if (!isOnMessage()) {
+ setXMLDataBinding(service);
+ }
}
}
@@ -168,7 +173,7 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR
this.responseWireFormatProviderFactory =
(WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getResponseWireFormat().getClass());
- if (this.responseWireFormatProvider != null){
+ if (this.responseWireFormatProviderFactory != null){
this.responseWireFormatProvider = responseWireFormatProviderFactory.createServiceWireFormatProvider(component, service, jmsBinding);
}
}
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytes.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytes.java
index 899bbbc13f..84d1a2740f 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytes.java
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytes.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.binding.jms.wireformat.bytes;
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes;
import javax.xml.namespace.QName;
@@ -30,10 +30,10 @@ import org.apache.tuscany.sca.assembly.WireFormat;
* @version $Rev$ $Date$
*/
public class WireFormatJMSBytes implements WireFormat {
- public static final QName WIRE_FORMAT_JMS_BYTE_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "wireFormat.JMSBytes");
+ public static final QName WIRE_FORMAT_JMS_BYTES_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "wireFormat.jmsBytes");
public QName getSchemaName() {
- return WIRE_FORMAT_JMS_BYTE_QNAME;
+ return WIRE_FORMAT_JMS_BYTES_QNAME;
}
public boolean isUnresolved() {
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesProcessor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProcessor.java
index 62b87fd54f..c8a5dea2cb 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesProcessor.java
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProcessor.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.binding.jms.wireformat.bytes;
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes;
import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
@@ -44,7 +44,7 @@ import org.apache.tuscany.sca.monitor.Monitor;
public class WireFormatJMSBytesProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<WireFormatJMSBytes> {
public QName getArtifactType() {
- return WireFormatJMSBytes.WIRE_FORMAT_JMS_BYTE_QNAME;
+ return WireFormatJMSBytes.WIRE_FORMAT_JMS_BYTES_QNAME;
}
public WireFormatJMSBytesProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) {
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesProviderFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProviderFactory.java
index f26ef4f546..19c703264c 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesProviderFactory.java
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProviderFactory.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.tuscany.sca.binding.jms.wireformat.bytes;
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesReferenceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesReferenceInterceptor.java
index edc998bcd9..b4575701b3 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesReferenceInterceptor.java
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesReferenceInterceptor.java
@@ -16,17 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.binding.jms.wireformat.bytes;
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes;
+import javax.jms.JMSException;
import javax.jms.Session;
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;
import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.WireFormatJMSDefault;
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
@@ -44,24 +48,73 @@ public class WireFormatJMSBytesReferenceInterceptor implements Interceptor {
private JMSBinding jmsBinding;
private JMSMessageProcessor requestMessageProcessor;
private JMSMessageProcessor responseMessageProcessor;
+ private WireFormat requestWireFormat;
+ private WireFormat responseWireFormat;
public WireFormatJMSBytesReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) {
super();
this.jmsBinding = jmsBinding;
this.runtimeWire = runtimeWire;
this.jmsResourceFactory = jmsResourceFactory;
+
+ if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSBytes){
+ this.requestWireFormat = jmsBinding.getRequestWireFormat();
+ this.jmsBinding.setRequestMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME);
+ }
+
+ if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSBytes){
+ this.responseWireFormat = jmsBinding.getResponseWireFormat();
+ this.jmsBinding.setResponseMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME);
+ }
+
this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding);
+
}
public Message invoke(Message msg) {
+ if (requestWireFormat != null){
+ msg = invokeRequest(msg);
+ }
- if (next != null){
- return getNext().invoke(msg);
- } else {
- return msg;
+ msg = getNext().invoke(msg);
+
+ if (responseWireFormat != null){
+ msg = invokeResponse(msg);
}
+
+ return msg;
+ }
+
+ public Message invokeRequest(Message msg) {
+ try {
+ // get the jms context
+ JMSBindingContext context = (JMSBindingContext)msg.getHeaders().get(JMSBindingConstants.MSG_CTXT_POSITION);
+ Session session = context.getJmsSession();
+
+ javax.jms.Message requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
+ msg.setBody(requestMsg);
+
+ requestMsg.setJMSReplyTo(context.getReplyToDestination());
+
+ return msg;
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
}
+
+ public Message invokeResponse(Message msg) {
+ if (msg.getBody() != null){
+ Object[] response = (Object[])responseMessageProcessor.extractPayloadFromJMSMessage((javax.jms.Message)msg.getBody());
+ if (response != null && response.length > 0){
+ msg.setBody(response[0]);
+ } else {
+ msg.setBody(null);
+ }
+ }
+
+ return msg;
+ }
public Invoker getNext() {
return next;
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesReferenceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesReferenceProvider.java
index 0aaca0c909..77bc9509aa 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesReferenceProvider.java
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesReferenceProvider.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.tuscany.sca.binding.jms.wireformat.bytes;
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes;
import java.util.List;
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/jmsbytes/WireFormatJMSBytesServiceInterceptor.java
index 39965a56ba..245619b92f 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/jmsbytes/WireFormatJMSBytesServiceInterceptor.java
@@ -16,12 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.binding.jms.wireformat.bytes;
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes;
+
+import javax.jms.JMSException;
+import javax.jms.Session;
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;
import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor;
import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil;
import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
@@ -43,30 +47,87 @@ public class WireFormatJMSBytesServiceInterceptor implements Interceptor {
private JMSBinding jmsBinding;
private JMSMessageProcessor requestMessageProcessor;
private JMSMessageProcessor responseMessageProcessor;
+ private WireFormat requestWireFormat;
+ private WireFormat responseWireFormat;
+ private String correlationScheme;
public WireFormatJMSBytesServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) {
super();
this.jmsBinding = jmsBinding;
this.runtimeWire = runtimeWire;
this.jmsResourceFactory = jmsResourceFactory;
+
+ if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSBytes){
+ this.requestWireFormat = jmsBinding.getRequestWireFormat();
+ this.jmsBinding.setRequestMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME);
+ }
+
+ if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSBytes){
+ this.responseWireFormat = jmsBinding.getResponseWireFormat();
+ this.jmsBinding.setResponseMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME);
+ }
+
this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding);
+
+ this.correlationScheme = jmsBinding.getCorrelationScheme();
}
public Message invoke(Message msg) {
+ if (requestWireFormat != null){
+ msg = invokeRequest(msg);
+ }
+
+ msg = getNext().invoke(msg);
+
+ if (responseWireFormat != null){
+ msg = invokeResponse(msg);
+ }
+
+ return msg;
+ }
+
+ public Message invokeRequest(Message msg) {
// get the jms context
JMSBindingContext context = (JMSBindingContext)msg.getHeaders().get(JMSBindingConstants.MSG_CTXT_POSITION);
javax.jms.Message jmsMsg = context.getJmsMsg();
+
+ Object requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg);
+ msg.setBody(requestPayload);
+
+ return msg;
+ }
+
+ public Message invokeResponse(Message msg) {
+ try {
+ // 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());
+ } else {
+ responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
+ }
+
+ responseJMSMsg.setJMSDeliveryMode(requestJMSMsg.getJMSDeliveryMode());
+ responseJMSMsg.setJMSPriority(requestJMSMsg.getJMSPriority());
+
+ if (correlationScheme == null || JMSBindingConstants.CORRELATE_MSG_ID.equalsIgnoreCase(correlationScheme)) {
+ responseJMSMsg.setJMSCorrelationID(requestJMSMsg.getJMSMessageID());
+ } else if (JMSBindingConstants.CORRELATE_CORRELATION_ID.equalsIgnoreCase(correlationScheme)) {
+ responseJMSMsg.setJMSCorrelationID(requestJMSMsg.getJMSCorrelationID());
+ }
- msg.setBody(requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg));
-
- if (next != null){
- return getNext().invoke(msg);
- } else {
+ msg.setBody(responseJMSMsg);
+
return msg;
- }
-
- }
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
public Invoker getNext() {
return next;
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesServiceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesServiceProvider.java
index 059b0e52cb..bbd3feb3c4 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/bytes/WireFormatJMSBytesServiceProvider.java
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesServiceProvider.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.tuscany.sca.binding.jms.wireformat.bytes;
+package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes;
import java.util.List;
diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefault.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefault.java
index 6edb6f8b33..7e802f55f5 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefault.java
+++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefault.java
@@ -28,7 +28,7 @@ import org.apache.tuscany.sca.assembly.WireFormat;
* @version $Rev$ $Date$
*/
public class WireFormatJMSDefault implements WireFormat {
- public static final QName WIRE_FORMAT_JMS_DEFAULT_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "wireFormat.JMSDefault");
+ public static final QName WIRE_FORMAT_JMS_DEFAULT_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "wireFormat.jmsDefault");
public QName getSchemaName() {
return WIRE_FORMAT_JMS_DEFAULT_QNAME;
diff --git a/java/sca/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/java/sca/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
index 6a4fcca25f..1b9020c59b 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
+++ b/java/sca/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -17,4 +17,5 @@
# Implementation class for the artifact processor extension
org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.WireFormatJMSDefaultProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#wireFormat.jmsDefault,model=org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.WireFormatJMSDefault
+org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.WireFormatJMSBytesProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#wireFormat.jmsBytes,model=org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.WireFormatJMSBytes
org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.OperationSelectorJMSDefaultProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#operationSelector.jmsDefault,model=org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.OperationSelectorJMSDefault
diff --git a/java/sca/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory b/java/sca/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory
index 3658a30bb6..56c07992bd 100644
--- a/java/sca/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory
+++ b/java/sca/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory
@@ -17,4 +17,4 @@
# Implementation class for the binding extension
org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.WireFormatJMSDefaultProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.WireFormatJMSDefault
-org.apache.tuscany.sca.binding.jms.wireformat.bytes.WireFormatJMSDBytesProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.bytes.WireFormatJMSBytes
+org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.WireFormatJMSBytesProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.WireFormatJMSBytes