From 2baba4611afa59bc74b06a082950fec0697a61b5 Mon Sep 17 00:00:00 2001 From: antelder Date: Fri, 13 Feb 2009 12:33:53 +0000 Subject: Change XMLTextMessageProcessor to override the createFaultMessage to handle FaultExceptions git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@744098 13f79535-47bb-0310-9956-ffa450edef68 --- .../jms/provider/XMLTextMessageProcessor.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (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 47adb27cf9..c453b20c5d 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 @@ -32,7 +32,9 @@ import javax.xml.stream.XMLStreamReader; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.impl.builder.StAXOMBuilder; 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.interfacedef.util.FaultException; /** * MessageProcessor for sending/receiving XML javax.jms.TextMessage with the JMSBinding. @@ -92,5 +94,26 @@ public class XMLTextMessageProcessor extends AbstractMessageProcessor { throw new JMSBindingException(e); } } + + @Override + public Message createFaultMessage(Session session, Throwable o) { + if (session == null) { + logger.fine("no response session to create fault message: " + String.valueOf(o)); + return null; + } + if (o instanceof FaultException) { + try { + TextMessage message = session.createTextMessage(); + message.setText(String.valueOf(((FaultException)o).getFaultInfo())); + message.setBooleanProperty(JMSBindingConstants.FAULT_PROPERTY, true); + return message; + + } catch (JMSException e) { + throw new JMSBindingException(e); + } + } else { + return super.createFaultMessage(session, o); + } + } } -- cgit v1.2.3