From 67b28d98f6564c29665cd353532646b59e477b7b Mon Sep 17 00:00:00 2001 From: antelder Date: Fri, 13 Feb 2009 16:00:24 +0000 Subject: Partial fix for exceptions for sca clients using text xml wireformat git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@744151 13f79535-47bb-0310-9956-ffa450edef68 --- .../jms/provider/XMLTextMessageProcessor.java | 10 ++++++++ .../WireFormatJMSTextXMLReferenceInterceptor.java | 27 ++++++++++++---------- 2 files changed, 25 insertions(+), 12 deletions(-) (limited to 'branches/sca-java-1.x/modules/binding-jms-runtime') diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java index c453b20c5d..8794f80126 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java @@ -70,6 +70,15 @@ public class XMLTextMessageProcessor extends AbstractMessageProcessor { } } + @Override + public Object extractPayloadFromJMSMessage(Message msg) { + if (msg instanceof TextMessage) { + return extractPayload(msg); + } else { + return super.extractPayloadFromJMSMessage(msg); + } + } + @Override protected Message createJMSMessage(Session session, Object o) { if (session == null) { @@ -116,4 +125,5 @@ public class XMLTextMessageProcessor extends AbstractMessageProcessor { return super.createFaultMessage(session, o); } } + } diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java index c40429d836..adf3fda98c 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java @@ -21,31 +21,23 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.runtime; -import java.util.Map; - -import javax.jms.DeliveryMode; import javax.jms.JMSException; import javax.jms.Session; +import javax.xml.namespace.QName; -import org.apache.tuscany.sca.assembly.Reference; -import org.apache.tuscany.sca.assembly.WireFormat; +import org.apache.axiom.om.OMElement; 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.JMSBindingServiceBindingProvider; 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.jmstextxml.WireFormatJMSTextXML; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.util.FaultException; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.ReferenceParameters; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; import org.apache.tuscany.sca.runtime.RuntimeWire; /** @@ -104,9 +96,20 @@ public class WireFormatJMSTextXMLReferenceInterceptor implements Interceptor { public Message invokeResponse(Message msg) { if (msg.getBody() != null){ - Object response = responseMessageProcessor.extractPayloadFromJMSMessage((javax.jms.Message)msg.getBody()); + javax.jms.Message jmsMsg = (javax.jms.Message)msg.getBody(); + Object response = responseMessageProcessor.extractPayloadFromJMSMessage(jmsMsg); if (response != null ){ msg.setBody(response); + try { + if (jmsMsg.getBooleanProperty(JMSBindingConstants.FAULT_PROPERTY)) { + FaultException e = new FaultException("remote exception", response); + OMElement om = (OMElement) response; + e.setFaultName(new QName(om.getNamespace().getNamespaceURI(), om.getLocalName())); + msg.setFaultBody(e); + } + } catch (JMSException e) { + throw new JMSBindingException(e); + } } else { msg.setBody(null); } -- cgit v1.2.3