diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-04-30 15:26:38 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-04-30 15:26:38 +0000 |
commit | 4bd58916e3e72d14787ba292d8f970cd5ac89fc5 (patch) | |
tree | 72232a3d4f37697a912e522f799fcc6867146833 /branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime | |
parent | 4ee7e0562a4b1cb0a6d91d0bb5fd8d153cb482c7 (diff) |
TUSCANY-2965 - add fault handling code for wireFormat.bytesXML
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@770283 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
4 files changed, 34 insertions, 21 deletions
diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java index 2c9f1ce7e8..782f226fe6 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java @@ -20,6 +20,9 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytesxml.runtime; import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; +import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory; +import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactoryExtensionPoint; import org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.WireFormatJMSBytes; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.provider.WireFormatProvider; @@ -31,10 +34,12 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService; public class WireFormatJMSBytesXMLProviderFactory implements WireFormatProviderFactory<WireFormatJMSBytes> { private ExtensionPointRegistry registry; + private JMSResourceFactoryExtensionPoint jmsRFEP; public WireFormatJMSBytesXMLProviderFactory(ExtensionPointRegistry registry) { super(); this.registry = registry; + jmsRFEP = (JMSResourceFactoryExtensionPoint)registry.getExtensionPoint(JMSResourceFactoryExtensionPoint.class); } /** @@ -50,7 +55,8 @@ public class WireFormatJMSBytesXMLProviderFactory implements WireFormatProviderF public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, RuntimeComponentService service, Binding binding) { - return new WireFormatJMSBytesXMLServiceProvider(registry, component, service, binding); + JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding)binding); + return new WireFormatJMSBytesXMLServiceProvider(registry, component, service, binding, jmsRF); } /** diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java index 5d25be069c..cbcd848c85 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java @@ -18,17 +18,20 @@ */ package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytesxml.runtime; -import java.lang.reflect.InvocationTargetException; import javax.jms.JMSException; import javax.jms.Session; +import javax.xml.namespace.QName; +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.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.jmsbytesxml.WireFormatJMSBytesXML; +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; @@ -73,13 +76,7 @@ public class WireFormatJMSBytesXMLReferenceInterceptor implements Interceptor { JMSBindingContext context = msg.getBindingContext(); Session session = context.getJmsSession(); - Object[] requestParams = msg.getBody(); - javax.jms.Message requestMsg = null; - if (requestParams != null && requestParams.length > 0 ){ - requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, requestParams[0]); - } else { - requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, null); - } + javax.jms.Message requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody()); msg.setBody(requestMsg); @@ -93,20 +90,27 @@ public class WireFormatJMSBytesXMLReferenceInterceptor implements Interceptor { public Message invokeResponse(Message msg) { if (msg.getBody() != null){ - Object response = responseMessageProcessor.extractPayloadFromJMSMessage((javax.jms.Message)msg.getBody()); - if (response instanceof InvocationTargetException) { - msg.setFaultBody(((InvocationTargetException) response).getCause()); - } else { - if (response != null){ - msg.setBody(response); - } else { - msg.setBody(null); + 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); } } return msg; - } + } public Invoker getNext() { return next; diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java index 3004704c39..bd04d4b24f 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java @@ -23,7 +23,6 @@ import org.apache.axiom.om.OMElement; import org.apache.tuscany.sca.assembly.Binding; 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.wireformat.jmsbytes.WireFormatJMSBytes; import org.apache.tuscany.sca.binding.jms.wireformat.jmsbytesxml.WireFormatJMSBytesXML; import org.apache.tuscany.sca.binding.ws.WebServiceBinding; import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java index ca0807d635..c2d81600e1 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java @@ -23,6 +23,7 @@ import org.apache.axiom.om.OMElement; import org.apache.tuscany.sca.assembly.Binding; 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.JMSResourceFactory; import org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.WireFormatJMSBytes; import org.apache.tuscany.sca.binding.jms.wireformat.jmsbytesxml.WireFormatJMSBytesXML; import org.apache.tuscany.sca.binding.ws.WebServiceBinding; @@ -41,17 +42,20 @@ public class WireFormatJMSBytesXMLServiceProvider implements WireFormatProvider private RuntimeComponent component; private RuntimeComponentService service; private JMSBinding binding; + private JMSResourceFactory jmsResourceFactory; private InterfaceContract interfaceContract; public WireFormatJMSBytesXMLServiceProvider(ExtensionPointRegistry registry, RuntimeComponent component, RuntimeComponentService service, - Binding binding) { + Binding binding, + JMSResourceFactory jmsResourceFactory) { super(); this.registry = registry; this.component = component; this.service = service; this.binding = (JMSBinding)binding; + this.jmsResourceFactory = jmsResourceFactory; // configure the service based on this wire format @@ -97,7 +101,7 @@ public class WireFormatJMSBytesXMLServiceProvider implements WireFormatProvider */ public Interceptor createInterceptor() { return new WireFormatJMSBytesXMLServiceInterceptor((JMSBinding)binding, - null, + jmsResourceFactory, service.getRuntimeWire(binding)); } |