diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-02-03 12:07:14 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-02-03 12:07:14 +0000 |
commit | 96517b984103f4b909cf1243be555c5a511262e4 (patch) | |
tree | 415c3f59266eb72f03b064d73439b0f052c3a759 /sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java | |
parent | e263378dc3d82a39abb40433612b7cd4889628ef (diff) |
Finish moving all the JMS binding off the AXIOM databinding to the DOM based one. Theres an intermittent issue with the JMS callbacks itest where trailing spaces seem to sometimes get lost, i'll take that itest out of the build for now while its investigated
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@906021 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java')
11 files changed, 138 insertions, 119 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java index effdd5f2a9..149d1c6b4b 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java @@ -18,19 +18,13 @@ */ package org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.runtime; -import java.io.ByteArrayInputStream; -import java.io.StringReader; +import java.io.IOException; import java.util.List; import javax.jms.BytesMessage; import javax.jms.JMSException; import javax.jms.TextMessage; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -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.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingException; import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext; @@ -39,6 +33,7 @@ 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.WireFormatJMSDefault; import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSTextXML; +import org.apache.tuscany.sca.common.xml.dom.DOMHelper; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; @@ -46,6 +41,8 @@ import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.runtime.RuntimeComponentService; import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.w3c.dom.Node; +import org.xml.sax.SAXException; /** * Policy handler to handle PolicySet related to Logging with the QName @@ -65,7 +62,7 @@ public class OperationSelectorJMSDefaultServiceInterceptor implements Intercepto private JMSMessageProcessor responseMessageProcessor; private RuntimeComponentService service; private List<Operation> serviceOperations; - + private DOMHelper domHelper; public OperationSelectorJMSDefaultServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint) { super(); @@ -76,6 +73,7 @@ public class OperationSelectorJMSDefaultServiceInterceptor implements Intercepto this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(registry, jmsBinding); this.service = (RuntimeComponentService)endpoint.getService(); this.serviceOperations = service.getInterfaceContract().getInterface().getOperations(); + this.domHelper = DOMHelper.getInstance(registry); } public Message invoke(Message msg) { @@ -114,7 +112,7 @@ public class OperationSelectorJMSDefaultServiceInterceptor implements Intercepto } else if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSDefault || jmsBinding.getRequestWireFormat() instanceof WireFormatJMSTextXML) { - OMElement rootElement; + Node rootElement; String operationFromPayload; try { @@ -122,9 +120,7 @@ public class OperationSelectorJMSDefaultServiceInterceptor implements Intercepto String xmlPayload = ((TextMessage) jmsMsg).getText(); if (xmlPayload != null) { - XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xmlPayload)); - StAXOMBuilder builder = new StAXOMBuilder(reader); - rootElement = builder.getDocumentElement(); + rootElement = domHelper.load(xmlPayload); operationFromPayload = rootElement.getLocalName(); for (Operation op : serviceOperations) { if (op.getName().equals(operationFromPayload)) { @@ -140,9 +136,7 @@ public class OperationSelectorJMSDefaultServiceInterceptor implements Intercepto ((BytesMessage) jmsMsg).reset(); if (bytes != null) { - XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(bytes)); - StAXOMBuilder builder = new StAXOMBuilder(reader); - rootElement = builder.getDocumentElement(); + rootElement = domHelper.load(new String(bytes)); operationFromPayload = rootElement.getLocalName(); for (Operation op : serviceOperations) { if (op.getName().equals(operationFromPayload)) { @@ -153,7 +147,9 @@ public class OperationSelectorJMSDefaultServiceInterceptor implements Intercepto } } - } catch (XMLStreamException e) { + } catch (IOException e) { + //let's ignore this in case the client doesn't want to use a wrapped xml message + } catch (SAXException e) { //let's ignore this in case the client doesn't want to use a wrapped xml message } catch (JMSException e) { throw new JMSBindingException(e); diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultMessageProcessor.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultMessageProcessor.java index 4132657945..c538dd01da 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultMessageProcessor.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultMessageProcessor.java @@ -18,8 +18,7 @@ */ package org.apache.tuscany.sca.binding.jms.provider; -import java.io.ByteArrayInputStream; -import java.io.StringReader; +import java.io.IOException; import java.util.logging.Logger; import javax.jms.BytesMessage; @@ -27,18 +26,18 @@ import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Session; import javax.jms.TextMessage; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; +import javax.xml.namespace.QName; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMNode; -import org.apache.axiom.om.impl.builder.StAXOMBuilder; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.JMSBindingException; +import org.apache.tuscany.sca.common.xml.dom.DOMHelper; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.util.FaultException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.xml.sax.SAXException; /** * MessageProcessor for sending/receiving XML over javax.jms.TextMessage or javax.jms.BytesMessage @@ -51,8 +50,11 @@ import org.apache.tuscany.sca.interfacedef.util.FaultException; public class DefaultMessageProcessor extends AbstractMessageProcessor { private static final Logger logger = Logger.getLogger(DefaultMessageProcessor.class.getName()); + private DOMHelper domHelper; + public DefaultMessageProcessor(JMSBinding jmsBinding, ExtensionPointRegistry registry) { super(jmsBinding); + this.domHelper = DOMHelper.getInstance(registry); } // inherited methods that don't do anything useful @@ -77,15 +79,14 @@ public class DefaultMessageProcessor extends AbstractMessageProcessor { // handle text messages - public Object extractPayloadFromJMSTextMessage(Message msg, OMElement wrapper) { + public Object extractPayloadFromJMSTextMessage(Message msg, Node wrapper) { if (msg instanceof TextMessage) { try { String xml = ((TextMessage) msg).getText(); + Object os; - if (xml != null) { - XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml)); - StAXOMBuilder builder = new StAXOMBuilder(reader); - os = builder.getDocumentElement(); + if (xml != null && xml.length() > 0) { + os = domHelper.load(xml); } else { os = null; } @@ -93,19 +94,26 @@ public class DefaultMessageProcessor extends AbstractMessageProcessor { if (wrapper != null){ //don't modify the original wrapper since it will be reused //clone the wrapper - OMElement newWrapper = wrapper.cloneOMElement(); - if (os != null){ - newWrapper.addChild((OMNode)os); + Node node = ((Node)os); + if (node == null) { + node = domHelper.newDocument(); } + Element newWrapper = DOMHelper.createElement((Document)node, new QName(wrapper.getNamespaceURI(), wrapper.getLocalName())); + if (os != null){ + Node child = node.getFirstChild(); + newWrapper.appendChild(child); + } return newWrapper; } return os; - } catch (XMLStreamException e) { - throw new JMSBindingException(e); } catch (JMSException e) { throw new JMSBindingException(e); + } catch (IOException e) { + throw new JMSBindingException(e); + } catch (SAXException e) { + throw new JMSBindingException(e); } } else { // handle the non-text fault case @@ -119,31 +127,31 @@ public class DefaultMessageProcessor extends AbstractMessageProcessor { TextMessage message = session.createTextMessage(); - if (o instanceof OMElement) { + if (o instanceof Node) { if (unwrap){ - OMElement firstElement = ((OMElement)o).getFirstElement(); + Node firstElement = ((Node)o).getFirstChild(); if (firstElement == null ) { - message.setText(null); + message.setText(""); } else { - message.setText(firstElement.toString()); + message.setText(domHelper.saveAsString(firstElement)); } }else { - message.setText(o.toString()); + message.setText(domHelper.saveAsString((Node)o)); } - } else if ((o instanceof Object[]) && ((Object[]) o)[0] instanceof OMElement) { + } else if ((o instanceof Object[]) && ((Object[]) o)[0] instanceof Node) { if (unwrap){ - OMElement firstElement = ((OMElement)((Object[]) o)[0]).getFirstElement(); + Node firstElement = ((Node)((Object[]) o)[0]).getFirstChild(); if (firstElement == null ) { message.setText(null); } else { - message.setText(firstElement.toString()); + message.setText(domHelper.saveAsString(firstElement)); } }else { - message.setText(((Object[]) o)[0].toString()); + message.setText(domHelper.saveAsString((Node)((Object[])o)[0])); } } else if (o != null) { - throw new IllegalStateException("expecting OMElement payload: " + o); + throw new IllegalStateException("expecting Node payload: " + o); } return message; @@ -163,7 +171,7 @@ public class DefaultMessageProcessor extends AbstractMessageProcessor { try { TextMessage message = session.createTextMessage(); - message.setText(String.valueOf(((FaultException) o).getFaultInfo())); + message.setText(domHelper.saveAsString((Node)((FaultException)o).getFaultInfo())); message.setBooleanProperty(JMSBindingConstants.FAULT_PROPERTY, true); return message; @@ -178,7 +186,7 @@ public class DefaultMessageProcessor extends AbstractMessageProcessor { // handle bytes messages - public Object extractPayloadFromJMSBytesMessage(Message msg, OMElement wrapper) { + public Object extractPayloadFromJMSBytesMessage(Message msg, Node wrapper) { if (msg instanceof BytesMessage) { try { @@ -190,9 +198,7 @@ public class DefaultMessageProcessor extends AbstractMessageProcessor { ((BytesMessage)msg).reset(); if ((bytes != null) && (bytes.length > 0)) { - XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(bytes)); - StAXOMBuilder builder = new StAXOMBuilder(reader); - os = builder.getDocumentElement(); + os = domHelper.load(new String(bytes)); } else { os = null; } @@ -200,19 +206,26 @@ public class DefaultMessageProcessor extends AbstractMessageProcessor { if (wrapper != null){ //don't modify the original wrapper since it will be reused //clone the wrapper - OMElement newWrapper = wrapper.cloneOMElement(); + Node node = ((Node)os); + if (node == null) { + node = domHelper.newDocument(); + } + Element newWrapper = DOMHelper.createElement((Document)node, new QName(wrapper.getNamespaceURI(), wrapper.getLocalName())); if (os != null){ - newWrapper.addChild((OMNode)os); + Node child = node.getFirstChild(); + newWrapper.appendChild(child); } return newWrapper; } return os; - } catch (XMLStreamException e) { - throw new JMSBindingException(e); } catch (JMSException e) { throw new JMSBindingException(e); + } catch (IOException e) { + throw new JMSBindingException(e); + } catch (SAXException e) { + throw new JMSBindingException(e); } } else { // trap the non-bytes fault case @@ -227,33 +240,33 @@ public class DefaultMessageProcessor extends AbstractMessageProcessor { BytesMessage message = session.createBytesMessage(); - if (o instanceof OMElement) { + if (o instanceof Node) { if (unwrap) { - OMElement firstElement = ((OMElement)o).getFirstElement(); + Node firstElement = ((Node)o).getFirstChild(); if (firstElement == null ) { //do nothing, the message will just be set with a byte[0] } else { - message.writeBytes(firstElement.toString().getBytes()); + message.writeBytes(domHelper.saveAsString(firstElement).getBytes()); } } else { - message.writeBytes(o.toString().getBytes()); + message.writeBytes(domHelper.saveAsString((Node)o).getBytes()); } - } else if ((o instanceof Object[]) && ((Object[]) o)[0] instanceof OMElement) { + } else if ((o instanceof Object[]) && ((Object[]) o)[0] instanceof Node) { if (unwrap){ - OMElement firstElement = ((OMElement)((Object[]) o)[0]).getFirstElement(); + Node firstElement = ((Node)((Object[]) o)[0]).getFirstChild(); if (firstElement == null ) { //do nothing, the message will just be set with a byte[0] } else { - message.writeBytes(firstElement.toString().getBytes()); + message.writeBytes(domHelper.saveAsString(firstElement).getBytes()); } }else { - message.writeBytes(((Object[]) o)[0].toString().getBytes()); + message.writeBytes(domHelper.saveAsString((Node)((Object[]) o)[0]).getBytes()); } } else if (o != null) { - throw new IllegalStateException("expecting OMElement payload: " + o); + throw new IllegalStateException("expecting Node payload: " + o); } return message; @@ -274,7 +287,8 @@ public class DefaultMessageProcessor extends AbstractMessageProcessor { try { BytesMessage message = session.createBytesMessage(); - message.writeBytes(String.valueOf(((FaultException) o).getFaultInfo()).getBytes()); + String s = domHelper.saveAsString((Node)((FaultException)o).getFaultInfo()); + message.writeBytes(s.getBytes()); message.setBooleanProperty(JMSBindingConstants.FAULT_PROPERTY, true); return message; diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLBytesMessageProcessor.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLBytesMessageProcessor.java index 915bb2e50c..69a69064d0 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLBytesMessageProcessor.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLBytesMessageProcessor.java @@ -18,24 +18,22 @@ */ package org.apache.tuscany.sca.binding.jms.provider; -import java.io.ByteArrayInputStream; +import java.io.IOException; import java.util.logging.Logger; import javax.jms.BytesMessage; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.Session; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -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.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.JMSBindingException; +import org.apache.tuscany.sca.common.xml.dom.DOMHelper; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.util.FaultException; +import org.w3c.dom.Node; +import org.xml.sax.SAXException; /** * MessageProcessor for sending/receiving XML javax.jms.BytesMessage with the JMSBinding. @@ -43,8 +41,11 @@ import org.apache.tuscany.sca.interfacedef.util.FaultException; public class XMLBytesMessageProcessor extends AbstractMessageProcessor { private static final Logger logger = Logger.getLogger(XMLBytesMessageProcessor.class.getName()); + private DOMHelper domHelper; + public XMLBytesMessageProcessor(JMSBinding jmsBinding, ExtensionPointRegistry registry) { super(jmsBinding); + this.domHelper = DOMHelper.getInstance(registry); } @Override @@ -62,17 +63,17 @@ public class XMLBytesMessageProcessor extends AbstractMessageProcessor { Object os; if (noOfBytes > 0) { - XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(bytes)); - StAXOMBuilder builder = new StAXOMBuilder(reader); - os = builder.getDocumentElement(); + os = domHelper.load(new String(bytes)); } else { os = null; } return os; - } catch (XMLStreamException e) { - throw new JMSBindingException(e); } catch (JMSException e) { throw new JMSBindingException(e); + } catch (IOException e) { + throw new JMSBindingException(e); + } catch (SAXException e) { + throw new JMSBindingException(e); } } @@ -94,12 +95,12 @@ public class XMLBytesMessageProcessor extends AbstractMessageProcessor { try { BytesMessage message = session.createBytesMessage(); - if (o instanceof OMElement) { - message.writeBytes(o.toString().getBytes()); - } else if ((o instanceof Object[]) && ((Object[])o)[0] instanceof OMElement) { - message.writeBytes(((Object[])o)[0].toString().getBytes()); + if (o instanceof Node) { + message.writeBytes(domHelper.saveAsString((Node)o).getBytes()); + } else if ((o instanceof Object[]) && ((Object[])o)[0] instanceof Node) { + message.writeBytes(domHelper.saveAsString((Node)((Object[])o)[0]).getBytes()); } else if (o != null) { - throw new IllegalStateException("expecting OMElement payload: " + o); + throw new IllegalStateException("expecting Node payload: " + o); } return message; @@ -120,7 +121,7 @@ public class XMLBytesMessageProcessor extends AbstractMessageProcessor { try { BytesMessage message = session.createBytesMessage(); - message.writeBytes(String.valueOf(((FaultException) o).getFaultInfo()).getBytes()); + message.writeBytes(domHelper.saveAsString((Node)((FaultException)o).getFaultInfo()).getBytes()); message.setBooleanProperty(JMSBindingConstants.FAULT_PROPERTY, true); return message; diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java index 9b652d05b8..5031f55c6b 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java @@ -97,7 +97,7 @@ public class XMLTextMessageProcessor extends AbstractMessageProcessor { } else if ((o instanceof Object[]) && ((Object[])o)[0] instanceof Node) { message.setText(domHelper.saveAsString((Node)((Object[])o)[0])); } else if (o != null) { - throw new IllegalStateException("expecting OMElement payload: " + o); + throw new IllegalStateException("expecting Node payload: " + o); } return message; diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java index 701a32e236..e453940d30 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java @@ -22,7 +22,6 @@ 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.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.JMSBindingException; @@ -37,6 +36,7 @@ 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.RuntimeEndpointReference; +import org.w3c.dom.Node; public class WireFormatJMSBytesXMLReferenceInterceptor implements Interceptor { @@ -98,8 +98,8 @@ public class WireFormatJMSBytesXMLReferenceInterceptor implements Interceptor { 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())); + Node om = ((Node)response).getFirstChild(); + e.setFaultName(new QName(om.getNamespaceURI(), om.getLocalName())); msg.setFaultBody(e); } } catch (JMSException e) { diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java index e56d35a8ed..e0f928de12 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java @@ -19,7 +19,6 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytesxml.runtime; -import org.apache.axiom.om.OMElement; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSBytesXML; @@ -27,6 +26,7 @@ import org.apache.tuscany.sca.binding.ws.WebServiceBinding; import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator; import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.databinding.xml.DOMDataBinding; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; @@ -67,7 +67,7 @@ public class WireFormatJMSBytesXMLReferenceProvider implements WireFormatProvide WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); BindingWSDLGenerator.generateWSDL(endpointReference.getComponent(), endpointReference.getContract(), wsBinding, registry, null); interfaceContract = wsBinding.getBindingInterfaceContract(); - interfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); + interfaceContract.getInterface().resetDataBinding(DOMDataBinding.NAME); } public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java index 00aaee39d5..d2ff153227 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java @@ -19,7 +19,6 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytesxml.runtime; -import org.apache.axiom.om.OMElement; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory; @@ -28,6 +27,7 @@ import org.apache.tuscany.sca.binding.ws.WebServiceBinding; import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator; import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.databinding.xml.DOMDataBinding; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; @@ -71,7 +71,7 @@ public class WireFormatJMSBytesXMLServiceProvider implements WireFormatProvider WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); BindingWSDLGenerator.generateWSDL(endpoint.getComponent(), endpoint.getService(), wsBinding, registry, null); interfaceContract = wsBinding.getBindingInterfaceContract(); - interfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); + interfaceContract.getInterface().resetDataBinding(DOMDataBinding.NAME); } public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java index 499784095a..87d99a014e 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java @@ -25,7 +25,6 @@ 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.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.JMSBindingException; @@ -41,6 +40,7 @@ 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.RuntimeEndpointReference; +import org.w3c.dom.Node; /** * @@ -55,10 +55,10 @@ public class WireFormatJMSDefaultReferenceInterceptor implements Interceptor { private DefaultMessageProcessor requestMessageProcessor; private DefaultMessageProcessor responseMessageProcessor; private HashMap<String, Boolean> inputWrapperMap; - private HashMap<String, OMElement> outputWrapperMap; + private HashMap<String, Node> outputWrapperMap; public WireFormatJMSDefaultReferenceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpointReference endpointReference, HashMap<String, Boolean> inputWrapperMap, - HashMap<String, OMElement> outputWrapperMap) { + HashMap<String, Node> outputWrapperMap) { super(); this.jmsBinding = (JMSBinding) endpointReference.getBinding(); this.endpointReference = endpointReference; @@ -126,7 +126,7 @@ public class WireFormatJMSDefaultReferenceInterceptor implements Interceptor { msg.setBody(jmsMsg); } else { - OMElement wrapper = null; + Node wrapper = null; // if we have a fault no need to wrap the response try { if (!jmsMsg.getBooleanProperty(JMSBindingConstants.FAULT_PROPERTY)) { @@ -149,8 +149,8 @@ public class WireFormatJMSDefaultReferenceInterceptor implements Interceptor { 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())); + Node om = ((Node)response).getFirstChild(); + e.setFaultName(new QName(om.getNamespaceURI(), om.getLocalName())); msg.setFaultBody(e); } } catch (JMSException e) { diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java index 2732241b61..127680c283 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java @@ -22,10 +22,8 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.runtime; import java.util.HashMap; import java.util.List; -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.axiom.om.OMNamespace; +import javax.xml.namespace.QName; + import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; @@ -33,7 +31,9 @@ import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSDefault; import org.apache.tuscany.sca.binding.ws.WebServiceBinding; import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator; +import org.apache.tuscany.sca.common.xml.dom.DOMHelper; import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.databinding.xml.DOMDataBinding; import org.apache.tuscany.sca.interfacedef.DataType; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.Operation; @@ -42,6 +42,9 @@ import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; /** * @version $Rev$ $Date$ @@ -52,8 +55,9 @@ public class WireFormatJMSDefaultReferenceProvider implements WireFormatProvider private ComponentReference reference; private JMSBinding binding; private InterfaceContract interfaceContract; + private DOMHelper domHelper; private HashMap<String, Boolean> inputWrapperMap; - private HashMap<String, OMElement> outputWrapperMap; + private HashMap<String, Node> outputWrapperMap; public WireFormatJMSDefaultReferenceProvider(ExtensionPointRegistry registry, RuntimeEndpointReference endpointReference) { super(); @@ -61,8 +65,9 @@ public class WireFormatJMSDefaultReferenceProvider implements WireFormatProvider this.endpointReference = endpointReference; this.binding = (JMSBinding) endpointReference.getBinding(); + this.domHelper = DOMHelper.getInstance(registry); this.inputWrapperMap = new HashMap<String, Boolean>(); - this.outputWrapperMap = new HashMap<String, OMElement>(); + this.outputWrapperMap = new HashMap<String, Node>(); // configure the reference based on this wire format @@ -87,7 +92,6 @@ public class WireFormatJMSDefaultReferenceProvider implements WireFormatProvider List<Operation> opList = reference.getReference().getInterfaceContract().getInterface().getOperations(); // Go through each operation and add wrapper info - OMFactory factory = OMAbstractFactory.getOMFactory(); // set the binding interface contract to represent the WSDL for the // xml messages that will be sent @@ -97,7 +101,7 @@ public class WireFormatJMSDefaultReferenceProvider implements WireFormatProvider WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); BindingWSDLGenerator.generateWSDL(endpointReference.getComponent(), reference, wsBinding, registry, null); interfaceContract = wsBinding.getBindingInterfaceContract(); - interfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); + interfaceContract.getInterface().resetDataBinding(DOMDataBinding.NAME); List<Operation> wsdlOpList = interfaceContract.getInterface().getOperations(); @@ -138,9 +142,8 @@ public class WireFormatJMSDefaultReferenceProvider implements WireFormatProvider ElementInfo ei = op.getWrapper().getOutputWrapperElement(); String namespace = ei.getQName().getNamespaceURI(); String opName = ei.getQName().getLocalPart(); - OMNamespace ns = factory.createOMNamespace(namespace, "ns2"); - OMElement wrapper = factory.createOMElement(opName, ns); - + Document document = domHelper.newDocument(); + Element wrapper = DOMHelper.createElement(document, new QName(namespace, opName)); this.outputWrapperMap.put(name, wrapper); } } diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java index 5d12af9b38..731de78cfe 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java @@ -24,7 +24,6 @@ import java.util.List; import javax.jms.BytesMessage; import javax.jms.Session; -import org.apache.axiom.om.OMElement; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext; import org.apache.tuscany.sca.binding.jms.provider.DefaultMessageProcessor; @@ -37,6 +36,7 @@ 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.RuntimeEndpoint; +import org.w3c.dom.Node; /** * Policy handler to handle PolicySet related to Logging with the QName {http://tuscany.apache.org/xmlns/sca/1.1/impl/java}LoggingPolicy @@ -50,10 +50,10 @@ public class WireFormatJMSDefaultServiceInterceptor implements Interceptor { private JMSBinding jmsBinding; private DefaultMessageProcessor requestMessageProcessor; private DefaultMessageProcessor responseMessageProcessor; - private HashMap<String,OMElement> inputWrapperMap; + private HashMap<String, Node> inputWrapperMap; private HashMap<String, Boolean> outputWrapperMap; - public WireFormatJMSDefaultServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint, HashMap<String, OMElement> inputWrapperMap, + public WireFormatJMSDefaultServiceInterceptor(ExtensionPointRegistry registry, JMSResourceFactory jmsResourceFactory, RuntimeEndpoint endpoint, HashMap<String, Node> inputWrapperMap, HashMap<String, Boolean> outputWrapperMap) { super(); this.jmsBinding = (JMSBinding) endpoint.getBinding(); @@ -112,7 +112,7 @@ public class WireFormatJMSDefaultServiceInterceptor implements Interceptor { } else { // If there is only one arg we must add a wrapper if the operation is wrapper style - OMElement wrapper = this.inputWrapperMap.get(msg.getOperation().getName()); + Node wrapper = this.inputWrapperMap.get(msg.getOperation().getName()); Object requestPayload; if (jmsMsg instanceof BytesMessage) { diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java index 85c775136c..3541666007 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java @@ -22,10 +22,8 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.runtime; import java.util.HashMap; import java.util.List; -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.axiom.om.OMNamespace; +import javax.xml.namespace.QName; + import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingConstants; @@ -34,7 +32,9 @@ import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSDefault; import org.apache.tuscany.sca.binding.ws.WebServiceBinding; import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator; +import org.apache.tuscany.sca.common.xml.dom.DOMHelper; import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.databinding.xml.DOMDataBinding; import org.apache.tuscany.sca.interfacedef.DataType; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.Operation; @@ -43,6 +43,9 @@ import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; /** * @version $Rev$ $Date$ @@ -54,17 +57,20 @@ public class WireFormatJMSDefaultServiceProvider implements WireFormatProvider { private JMSBinding binding; private JMSResourceFactory jmsResourceFactory; private InterfaceContract interfaceContract; - private HashMap<String, OMElement> inputWrapperMap; + private DOMHelper domHelper; + private HashMap<String, Node> inputWrapperMap; private HashMap<String, Boolean> outputWrapperMap; public WireFormatJMSDefaultServiceProvider(ExtensionPointRegistry registry, RuntimeEndpoint endpoint, JMSResourceFactory jmsResourceFactory) { super(); + this.registry = registry; this.endpoint = endpoint; this.binding = (JMSBinding) endpoint.getBinding(); this.service = endpoint.getService(); this.jmsResourceFactory = jmsResourceFactory; - this.inputWrapperMap = new HashMap<String, OMElement>(); + this.domHelper = DOMHelper.getInstance(registry); + this.inputWrapperMap = new HashMap<String, Node>(); this.outputWrapperMap = new HashMap<String, Boolean>(); // configure the service based on this wire format @@ -82,7 +88,6 @@ public class WireFormatJMSDefaultServiceProvider implements WireFormatProvider { List<Operation> opList = service.getService().getInterfaceContract().getInterface().getOperations(); // Go through each operation and add wrapper info - OMFactory factory = OMAbstractFactory.getOMFactory(); // set the binding interface contract to represent the WSDL for the // xml messages that will be sent @@ -93,7 +98,7 @@ public class WireFormatJMSDefaultServiceProvider implements WireFormatProvider { WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); BindingWSDLGenerator.generateWSDL(endpoint.getComponent(), service, wsBinding, registry, null); interfaceContract = wsBinding.getBindingInterfaceContract(); - interfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); + interfaceContract.getInterface().resetDataBinding(DOMDataBinding.NAME); List<Operation> wsdlOpList = interfaceContract.getInterface().getOperations(); @@ -122,8 +127,8 @@ public class WireFormatJMSDefaultServiceProvider implements WireFormatProvider { ElementInfo ei = op.getWrapper().getInputWrapperElement(); String namespace = ei.getQName().getNamespaceURI(); String opName = ei.getQName().getLocalPart(); - OMNamespace ns = factory.createOMNamespace(namespace, "ns1"); - OMElement wrapper = factory.createOMElement(opName, ns); + Document document = domHelper.newDocument(); + Element wrapper = DOMHelper.createElement(document, new QName(namespace, opName)); this.inputWrapperMap.put(name, wrapper); } } |