From d76a24e5380b9834cb803417d84d9b802cd3f74c Mon Sep 17 00:00:00 2001 From: slaws Date: Sun, 9 Nov 2008 19:27:28 +0000 Subject: Tidy wire format support (move model into binding-jms and rename default to textxml). Extend support to include text and object. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@712538 13f79535-47bb-0310-9956-ffa450edef68 --- .../helloworld/HelloWorldReferenceImpl.java | 14 +- .../jmsbytes/helloworld/HelloWorldService.java | 3 +- .../jmsbytes/helloworld/HelloWorldServiceImpl.java | 13 +- .../main/resources/jmstextxml/helloworld.composite | 4 +- .../src/main/resources/tuscany-sca-binding-jms.xsd | 20 +-- .../jmsdefault/OperationSelectorJMSDefault.java | 45 ------- .../OperationSelectorJMSDefaultProcessor.java | 76 ----------- .../jms/provider/BytesMessageProcessor.java | 6 +- .../JMSBindingReferenceBindingProvider.java | 80 ++---------- .../provider/JMSBindingServiceBindingProvider.java | 90 ++----------- .../jms/provider/RRBJMSBindingListener.java | 81 +++--------- .../jms/transport/TransportServiceInterceptor.java | 32 ++++- .../wireformat/jmsbytes/WireFormatJMSBytes.java | 45 ------- .../jmsbytes/WireFormatJMSBytesProcessor.java | 79 ------------ .../WireFormatJMSBytesProviderFactory.java | 4 +- .../WireFormatJMSBytesReferenceInterceptor.java | 21 +-- .../WireFormatJMSBytesReferenceProvider.java | 50 ++++++-- .../WireFormatJMSBytesServiceInterceptor.java | 58 +++------ .../WireFormatJMSBytesServiceProvider.java | 33 ++++- .../jmsdefault/WireFormatJMSDefault.java | 48 ------- .../jmsdefault/WireFormatJMSDefaultProcessor.java | 79 ------------ .../WireFormatJMSDefaultProviderFactory.java | 71 ----------- .../WireFormatJMSDefaultReferenceInterceptor.java | 135 -------------------- .../WireFormatJMSDefaultReferenceProvider.java | 70 ---------- .../WireFormatJMSDefaultServiceInterceptor.java | 141 --------------------- .../WireFormatJMSDefaultServiceProvider.java | 69 ---------- .../WireFormatJMSObjectProviderFactory.java | 65 ++++++++++ .../WireFormatJMSObjectReferenceInterceptor.java | 111 ++++++++++++++++ .../WireFormatJMSObjectReferenceProvider.java | 94 ++++++++++++++ .../WireFormatJMSObjectServiceInterceptor.java | 111 ++++++++++++++++ .../WireFormatJMSObjectServiceProvider.java | 91 +++++++++++++ .../jmstext/WireFormatJMSTextProviderFactory.java | 65 ++++++++++ .../WireFormatJMSTextReferenceInterceptor.java | 112 ++++++++++++++++ .../WireFormatJMSTextReferenceProvider.java | 95 ++++++++++++++ .../WireFormatJMSTextServiceInterceptor.java | 111 ++++++++++++++++ .../jmstext/WireFormatJMSTextServiceProvider.java | 91 +++++++++++++ .../WireFormatJMSTextXMLProviderFactory.java | 72 +++++++++++ .../WireFormatJMSTextXMLReferenceInterceptor.java | 125 ++++++++++++++++++ .../WireFormatJMSTextXMLReferenceProvider.java | 110 ++++++++++++++++ .../WireFormatJMSTextXMLServiceInterceptor.java | 118 +++++++++++++++++ .../WireFormatJMSTextXMLServiceProvider.java | 113 +++++++++++++++++ ...ca.contribution.processor.StAXArtifactProcessor | 21 --- ....tuscany.sca.provider.WireFormatProviderFactory | 4 +- .../sca/binding/jms/impl/JMSBindingProcessor.java | 39 +++++- .../jmsdefault/OperationSelectorJMSDefault.java | 45 +++++++ .../OperationSelectorJMSDefaultProcessor.java | 76 +++++++++++ .../wireformat/jmsbytes/WireFormatJMSBytes.java | 45 +++++++ .../jmsbytes/WireFormatJMSBytesProcessor.java | 78 ++++++++++++ .../wireformat/jmsobject/WireFormatJMSObject.java | 45 +++++++ .../jmsobject/WireFormatJMSObjectProcessor.java | 78 ++++++++++++ .../jms/wireformat/jmstext/WireFormatJMSText.java | 45 +++++++ .../jmstext/WireFormatJMSTextProcessor.java | 78 ++++++++++++ .../jmstextxml/WireFormatJMSTextXML.java | 48 +++++++ .../jmstextxml/WireFormatJMSTextXMLProcessor.java | 78 ++++++++++++ ...ca.contribution.processor.StAXArtifactProcessor | 6 + .../tuscany/sca/provider/WireFormatProvider.java | 12 ++ .../apache/tuscany/sca/runtime/RuntimeWire.java | 10 ++ .../sca/core/assembly/EndpointWireImpl.java | 5 + .../tuscany/sca/core/assembly/RuntimeWireImpl.java | 12 +- 59 files changed, 2355 insertions(+), 1221 deletions(-) delete mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefault.java delete mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefaultProcessor.java delete mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytes.java delete mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProcessor.java delete mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefault.java delete mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultProcessor.java delete mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultProviderFactory.java delete mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultReferenceInterceptor.java delete mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultReferenceProvider.java delete mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultServiceInterceptor.java delete mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultServiceProvider.java create mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectProviderFactory.java create mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectReferenceInterceptor.java create mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectReferenceProvider.java create mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectServiceInterceptor.java create mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectServiceProvider.java create mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextProviderFactory.java create mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextReferenceInterceptor.java create mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextReferenceProvider.java create mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextServiceInterceptor.java create mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextServiceProvider.java create mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLProviderFactory.java create mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLReferenceInterceptor.java create mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLReferenceProvider.java create mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLServiceInterceptor.java create mode 100644 java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLServiceProvider.java delete mode 100644 java/sca/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefault.java create mode 100644 java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefaultProcessor.java create mode 100644 java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytes.java create mode 100644 java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProcessor.java create mode 100644 java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObject.java create mode 100644 java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectProcessor.java create mode 100644 java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSText.java create mode 100644 java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextProcessor.java create mode 100644 java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXML.java create mode 100644 java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLProcessor.java (limited to 'java/sca') diff --git a/java/sca/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/java/sca/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java index c42f71d838..878fdb4fe4 100644 --- a/java/sca/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java +++ b/java/sca/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java @@ -26,16 +26,10 @@ public class HelloWorldReferenceImpl implements HelloWorldReference { @Reference protected HelloWorldService helloWorldService1; - public String getGreetings(String name){ - helloWorldService1.setGreetings(name.getBytes()); - - try { - Thread.sleep(2000); - } catch (Exception ex) { - // do nothing - } - - return HelloWorldServiceImpl.getGreetings(); + public String getGreetings(String name){ + byte[] bytesValue = helloWorldService1.getByteArrayGreetings(name.getBytes()); + String stringValue = new String(bytesValue); + return stringValue; } } diff --git a/java/sca/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/java/sca/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java index b012f0f93c..82c57dfe75 100644 --- a/java/sca/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java +++ b/java/sca/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java @@ -27,8 +27,7 @@ import org.osoa.sca.annotations.Remotable; @Remotable public interface HelloWorldService { - @OneWay - public void setGreetings(byte[] msg); + public byte[] getByteArrayGreetings(byte[] msg); } diff --git a/java/sca/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/java/sca/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java index ce7b84903e..f0b7819c3b 100644 --- a/java/sca/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java +++ b/java/sca/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java @@ -20,17 +20,14 @@ package org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld; public class HelloWorldServiceImpl implements HelloWorldService { - private static String greetings = "not set"; - - public void setGreetings(byte[] msg){ + public byte[] getByteArrayGreetings(byte[] msg){ String name = new String(msg); - greetings = "Hello " + name; - } - - public static String getGreetings(){ - return greetings; + name = "Hello " + name; + + return name.getBytes(); } + } diff --git a/java/sca/itest/jms-format/src/main/resources/jmstextxml/helloworld.composite b/java/sca/itest/jms-format/src/main/resources/jmstextxml/helloworld.composite index 1862e88770..07507e0ebe 100644 --- a/java/sca/itest/jms-format/src/main/resources/jmstextxml/helloworld.composite +++ b/java/sca/itest/jms-format/src/main/resources/jmstextxml/helloworld.composite @@ -28,7 +28,7 @@ - + @@ -48,7 +48,7 @@ - + diff --git a/java/sca/modules/assembly-xsd/src/main/resources/tuscany-sca-binding-jms.xsd b/java/sca/modules/assembly-xsd/src/main/resources/tuscany-sca-binding-jms.xsd index 3c39756dbb..b998427ecb 100644 --- a/java/sca/modules/assembly-xsd/src/main/resources/tuscany-sca-binding-jms.xsd +++ b/java/sca/modules/assembly-xsd/src/main/resources/tuscany-sca-binding-jms.xsd @@ -25,12 +25,16 @@ - - - - - - - - + + + + + + + + + + + + diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefault.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefault.java deleted file mode 100644 index 71d1298c9b..0000000000 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefault.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.operationselector.jmsdefault; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.xml.Constants; -import org.apache.tuscany.sca.assembly.OperationSelector; - -/** - * Implementation for policies that could be injected as parameter - * into the axis2config. - * - * @version $Rev$ $Date$ - */ -public class OperationSelectorJMSDefault implements OperationSelector { - public static final QName OPERATION_SELECTOR_JMS_DEFAULT_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "operationSelector.JMSDefault"); - - public QName getSchemaName() { - return OPERATION_SELECTOR_JMS_DEFAULT_QNAME; - } - - public boolean isUnresolved() { - return false; - } - - public void setUnresolved(boolean unresolved) { - } -} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefaultProcessor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefaultProcessor.java deleted file mode 100644 index 4a8e4a1bd2..0000000000 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefaultProcessor.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.operationselector.jmsdefault; - - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.assembly.xml.Constants; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * - * @version $Rev$ $Date$ - */ -public class OperationSelectorJMSDefaultProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor { - - public QName getArtifactType() { - return OperationSelectorJMSDefault.OPERATION_SELECTOR_JMS_DEFAULT_QNAME; - } - - public OperationSelectorJMSDefaultProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { - } - - - public OperationSelectorJMSDefault read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - OperationSelectorJMSDefault wireFormat = new OperationSelectorJMSDefault(); - - return wireFormat; - } - - public void write(OperationSelectorJMSDefault wireFormat, XMLStreamWriter writer) - throws ContributionWriteException, XMLStreamException { - String prefix = "tuscany"; - writer.writeStartElement(prefix, - getArtifactType().getLocalPart(), - getArtifactType().getNamespaceURI()); - writer.writeNamespace("tuscany", Constants.SCA10_TUSCANY_NS); - - writer.writeEndElement(); - } - - public Class getModelType() { - return OperationSelectorJMSDefault.class; - } - - public void resolve(OperationSelectorJMSDefault arg0, ModelResolver arg1) throws ContributionResolveException { - - } - -} 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 index b6e7c6b1b2..44b2e3b990 100644 --- 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 @@ -46,10 +46,6 @@ public class BytesMessageProcessor extends AbstractMessageProcessor { 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); @@ -64,7 +60,7 @@ public class BytesMessageProcessor extends AbstractMessageProcessor { protected Message createJMSMessage(Session session, Object o) { try { - // TODO - just and experiment. How to enforce a single + // TODO - an experiment. How to enforce a single // byte array parameter BytesMessage message = session.createBytesMessage(); byte [] bytes = (byte[])((Object[])o)[0]; 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 22f8f76afb..aa66542f38 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 @@ -31,7 +31,7 @@ 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.operationselector.jmsdefault.OperationSelectorJMSDefault; import org.apache.tuscany.sca.binding.jms.transport.TransportReferenceInterceptor; -import org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.WireFormatJMSDefault; +import org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.WireFormatJMSTextXML; 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; @@ -64,7 +64,7 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi private List jmsBindingInvokers = new ArrayList(); private JMSResourceFactory jmsResourceFactory; private RuntimeComponent component; - private InterfaceContract wsdlInterfaceContract; + private InterfaceContract interfaceContract; private ExtensionPointRegistry extensions; private ProviderFactoryExtensionPoint providerFactories; @@ -81,39 +81,12 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi this.extensions = extensions; this.component = component; this.jmsResourceFactory = jmsResourceFactory; - - // 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 - - // if no operation selector is specified then assume the default - if (jmsBinding.getOperationSelector() == null){ - jmsBinding.setOperationSelector(new OperationSelectorJMSDefault()); - } + // Get the factories/providers for operation selection this.providerFactories = extensions.getExtensionPoint(ProviderFactoryExtensionPoint.class); // 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()); - } - - // if no response wire format specific then assume the default - if (jmsBinding.getResponseWireFormat() == null){ - jmsBinding.setResponseWireFormat(new WireFormatJMSDefault()); - } - - this.requestWireFormatProviderFactory = + this.requestWireFormatProviderFactory = (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getRequestWireFormat().getClass()); if (this.requestWireFormatProviderFactory != null){ this.requestWireFormatProvider = requestWireFormatProviderFactory.createReferenceWireFormatProvider(component, reference, jmsBinding); @@ -123,31 +96,7 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getResponseWireFormat().getClass()); if (this.responseWireFormatProviderFactory != null){ this.responseWireFormatProvider = responseWireFormatProviderFactory.createReferenceWireFormatProvider(component, reference, jmsBinding); - } - - } - - protected void setXMLDataBinding(RuntimeComponentReference reference) { - - WebServiceBindingFactory wsFactory = extensions.getExtensionPoint(WebServiceBindingFactory.class); - WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); - BindingWSDLGenerator.generateWSDL(component, reference, wsBinding, extensions, null); - wsdlInterfaceContract = wsBinding.getBindingInterfaceContract(); - wsdlInterfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); - - // TODO: TUSCANY-xxx, section 5.2 "Default Data Binding" in the JMS binding spec - -// try { -// InterfaceContract ic = (InterfaceContract)reference.getInterfaceContract().clone(); -// -// Interface ii = (Interface)ic.getInterface().clone(); -// ii.resetDataBinding("org.apache.axiom.om.OMElement"); -// ic.setInterface(ii); -// reference.setInterfaceContract(ic); -// -// } catch (CloneNotSupportedException e) { -// throw new RuntimeException(e); -// } + } } public Invoker createInvoker(Operation operation) { @@ -158,13 +107,8 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi } } - /* - * TODO turn on RRB version of JMS binding - */ Invoker invoker = null; invoker = new RRBJMSBindingInvoker(jmsBinding, operation, jmsResourceFactory, reference); - //invoker = new JMSBindingInvoker(jmsBinding, operation, jmsResourceFactory, reference); - //jmsBindingInvokers.add((JMSBindingInvoker)invoker); return invoker; } @@ -174,15 +118,10 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi } public InterfaceContract getBindingInterfaceContract() { - if (wsdlInterfaceContract != null) { - return wsdlInterfaceContract; - } else { - if (reference.getInterfaceContract() == null) { - return reference.getReference().getInterfaceContract(); - } else { - return reference.getInterfaceContract(); - } + if (interfaceContract == null){ + interfaceContract = this.requestWireFormatProvider.getWireFormatInterfaceContract(); } + return interfaceContract; } public void start() { @@ -198,7 +137,8 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi } /* - * RRB test methods + * set up the reference binding wire with the right set of jms reference + * interceptors */ public void configureBindingChain(RuntimeWire runtimeWire) { 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 779288a6be..da6c6d260d 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 @@ -44,9 +44,7 @@ import org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.Operation import org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.OperationSelectorJMSDefaultServiceInterceptor; import org.apache.tuscany.sca.binding.jms.transport.TransportReferenceInterceptor; import org.apache.tuscany.sca.binding.jms.transport.TransportServiceInterceptor; -import org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.WireFormatJMSDefault; -import org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.WireFormatJMSDefaultReferenceInterceptor; -import org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.WireFormatJMSDefaultServiceInterceptor; +import org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.WireFormatJMSTextXML; 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; @@ -123,29 +121,12 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR jmsBinding.setDestinationName(service.getName()); } } - - // 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); - } - } - } // Get Message factory modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); messageFactory = modelFactories.getFactory(MessageFactory.class); - // Get the factories/providers for operation selection - - // if no operation selector is specified then assume the default - if (jmsBinding.getOperationSelector() == null){ - jmsBinding.setOperationSelector(new OperationSelectorJMSDefault()); - } - + // Get the factories/providers for operation selection this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class); this.operationSelectorProviderFactory = (OperationSelectorProviderFactory)providerFactories.getProviderFactory(jmsBinding.getOperationSelector().getClass()); @@ -153,18 +134,7 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR this.operationSelectorProvider = operationSelectorProviderFactory.createServiceOperationSelectorProvider(component, service, jmsBinding); } - // Get the factories/providers for wire format - - // if no request wire format specified then assume the default - if (jmsBinding.getRequestWireFormat() == null){ - jmsBinding.setRequestWireFormat(new WireFormatJMSDefault()); - } - - // if no response wire format specific then assume the default - if (jmsBinding.getResponseWireFormat() == null){ - jmsBinding.setResponseWireFormat(new WireFormatJMSDefault()); - } - + // Get the factories/providers for wire format this.requestWireFormatProviderFactory = (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getRequestWireFormat().getClass()); if (this.requestWireFormatProviderFactory != null){ @@ -177,48 +147,9 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR this.responseWireFormatProvider = responseWireFormatProviderFactory.createServiceWireFormatProvider(component, service, jmsBinding); } } - - protected boolean isOnMessage() { - InterfaceContract ic = getBindingInterfaceContract(); - if (ic.getInterface().getOperations().size() != 1) { - return false; - } - return "onMessage".equals(ic.getInterface().getOperations().get(0).getName()); - } - - protected void setXMLDataBinding(RuntimeComponentService service) { - if (service.getInterfaceContract() != null) { - WebServiceBindingFactory wsFactory = extensionPoints.getExtensionPoint(WebServiceBindingFactory.class); - WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); - BindingWSDLGenerator.generateWSDL(component, service, wsBinding, extensionPoints, null); - wsdlInterfaceContract = wsBinding.getBindingInterfaceContract(); - wsdlInterfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); - - // TODO: TUSCANY-xxx, section 5.2 "Default Data Binding" in the JMS binding spec - -// try { -// InterfaceContract ic = (InterfaceContract)service.getInterfaceContract().clone(); -// Interface ii = ic.getInterface(); -// if (ii.getOperations().size() == 1 && "onMessage".equals(ii.getOperations().get(0).getName())) { -// return; -// } -// ii = (Interface)ii.clone(); -// ii.resetDataBinding("org.apache.axiom.om.OMElement"); -// ic.setInterface(ii); -// service.setInterfaceContract(ic); -// -// } catch (CloneNotSupportedException e) { -// throw new RuntimeException(e); -// } - } - } public InterfaceContract getBindingInterfaceContract() { - if (wsdlInterfaceContract != null) { - return wsdlInterfaceContract; - } else { - return service.getInterfaceContract(); - } + return requestWireFormatProvider.getWireFormatInterfaceContract(); } public boolean supportsOneWayInvocation() { @@ -408,18 +339,21 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR // add transport interceptor bindingChain.addInterceptor(Phase.SERVICE_BINDING_TRANSPORT, new TransportServiceInterceptor(jmsBinding, - jmsResourceFactory, - runtimeWire) ); + jmsResourceFactory, + runtimeWire) ); // add operation selector interceptor - bindingChain.addInterceptor(operationSelectorProvider.getPhase(), operationSelectorProvider.createInterceptor()); + bindingChain.addInterceptor(operationSelectorProvider.getPhase(), + operationSelectorProvider.createInterceptor()); // add request wire format - bindingChain.addInterceptor(requestWireFormatProvider.getPhase(), requestWireFormatProvider.createInterceptor()); + bindingChain.addInterceptor(requestWireFormatProvider.getPhase(), + requestWireFormatProvider.createInterceptor()); // add response wire format, but only add it if it's different from the request if (!jmsBinding.getRequestWireFormat().equals(jmsBinding.getResponseWireFormat())){ - bindingChain.addInterceptor(responseWireFormatProvider.getPhase(), responseWireFormatProvider.createInterceptor()); + bindingChain.addInterceptor(responseWireFormatProvider.getPhase(), + responseWireFormatProvider.createInterceptor()); } } } diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingListener.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingListener.java index 46578d0d30..5306e050e7 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingListener.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingListener.java @@ -93,75 +93,30 @@ public class RRBJMSBindingListener implements MessageListener { try { invokeService(requestJMSMsg); } catch (Throwable e) { - logger.log(Level.SEVERE, "Exception invoking service '" + service.getName(), e); - sendFaultReply(requestJMSMsg, e); + logger.log(Level.SEVERE, "Exception send fault response '" + service.getName(), e); } } protected void invokeService(Message requestJMSMsg) throws JMSException, InvocationTargetException { - try { - // create the tuscany message - org.apache.tuscany.sca.invocation.Message tuscanyMsg = messageFactory.createMessage(); - - // populate the message context with JMS binding information - JMSBindingContext context = new JMSBindingContext(); - tuscanyMsg.getHeaders().add(context); - - context.setJmsMsg(requestJMSMsg); - context.setJmsSession(jmsResourceFactory.createSession()); - context.setReplyToDestination(requestJMSMsg.getJMSReplyTo()); - - // set the message body - tuscanyMsg.setBody(requestJMSMsg); - - // call the runtime wire - InvocationChain chain = service.getRuntimeWire(targetBinding).getBindingInvocationChain(); - chain.getHeadInvoker().invoke(tuscanyMsg); + // create the tuscany message + org.apache.tuscany.sca.invocation.Message tuscanyMsg = messageFactory.createMessage(); + + // populate the message context with JMS binding information + JMSBindingContext context = new JMSBindingContext(); + tuscanyMsg.getHeaders().add(context); + + context.setJmsMsg(requestJMSMsg); + context.setJmsResourceFactory(jmsResourceFactory); + context.setReplyToDestination(requestJMSMsg.getJMSReplyTo()); + + // set the message body + tuscanyMsg.setBody(requestJMSMsg); + + // call the runtime wire - the response is handled by the + // transport interceptor + service.getRuntimeWire(targetBinding).invoke(tuscanyMsg); - } catch (NamingException e) { - throw new JMSBindingException(e); - } } - /* - * Send a message back if a fault has occurred - */ - protected void sendFaultReply(Message requestJMSMsg, Object responsePayload) { - try { - - if (requestJMSMsg.getJMSReplyTo() == null) { - // assume no reply is expected - if (responsePayload != null) { - logger.log(Level.FINE, "JMS service '" + service.getName() + "' dropped response as request has no replyTo"); - } - return; - } - - Session session = jmsResourceFactory.createSession(); - Message replyJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)responsePayload); - replyJMSMsg.setJMSDeliveryMode(requestJMSMsg.getJMSDeliveryMode()); - replyJMSMsg.setJMSPriority(requestJMSMsg.getJMSPriority()); - - if (correlationScheme == null || JMSBindingConstants.CORRELATE_MSG_ID.equalsIgnoreCase(correlationScheme)) { - replyJMSMsg.setJMSCorrelationID(requestJMSMsg.getJMSMessageID()); - } else if (JMSBindingConstants.CORRELATE_CORRELATION_ID.equalsIgnoreCase(correlationScheme)) { - replyJMSMsg.setJMSCorrelationID(requestJMSMsg.getJMSCorrelationID()); - } - - Destination destination = requestJMSMsg.getJMSReplyTo(); - MessageProducer producer = session.createProducer(destination); - - producer.send(replyJMSMsg); - - producer.close(); - session.close(); - - } catch (JMSException e) { - throw new JMSBindingException(e); - } catch (NamingException e) { - throw new JMSBindingException(e); - } - } - } diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java index c0703bd495..ed17140ac3 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java @@ -28,6 +28,7 @@ import javax.jms.MessageProducer; import javax.jms.Queue; import javax.jms.Session; import javax.jms.Topic; +import javax.naming.NamingException; import javax.security.auth.Subject; import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext; @@ -66,6 +67,7 @@ public class TransportServiceInterceptor implements Interceptor { private JMSMessageProcessor requestMessageProcessor; private JMSMessageProcessor responseMessageProcessor; private RuntimeComponentService service; + private String correlationScheme; public TransportServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { @@ -76,16 +78,28 @@ public class TransportServiceInterceptor implements Interceptor { this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding); this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding); this.service = (RuntimeComponentService)runtimeWire.getTarget().getContract(); + this.correlationScheme = jmsBinding.getCorrelationScheme(); } public Message invoke(Message msg) { - return invokeResponse(next.invoke(invokeRequest(msg))); + try { + return invokeResponse(next.invoke(invokeRequest(msg))); + } catch (Throwable e) { + logger.log(Level.SEVERE, "Exception invoking service '" + service.getName(), e); + JMSBindingContext context = (JMSBindingContext)msg.getHeaders().get(JMSBindingConstants.MSG_CTXT_POSITION); + javax.jms.Message replyJMSMsg = responseMessageProcessor.createFaultMessage(context.getJmsSession(), + (Throwable)e); + msg.setBody(replyJMSMsg); + invokeResponse(msg); + return msg; + } } public Message invokeRequest(Message msg) { try { JMSBindingContext context = (JMSBindingContext)msg.getHeaders().get(JMSBindingConstants.MSG_CTXT_POSITION); javax.jms.Message requestJMSMsg = context.getJmsMsg(); + context.setJmsSession(context.getJmsResourceFactory().createSession()); EndpointReference from = new EndpointReferenceImpl(null); msg.setFrom(from); @@ -100,7 +114,9 @@ public class TransportServiceInterceptor implements Interceptor { return msg; } catch (JMSException e) { throw new JMSBindingException(e); - } + } catch (NamingException e) { + throw new JMSBindingException(e); + } } public Message invokeResponse(Message msg) { @@ -108,6 +124,8 @@ public class TransportServiceInterceptor implements Interceptor { JMSBindingContext context = (JMSBindingContext)msg.getHeaders().get(JMSBindingConstants.MSG_CTXT_POSITION); Session session = context.getJmsSession(); javax.jms.Message requestJMSMsg = context.getJmsMsg(); + javax.jms.Message responseJMSMsg = msg.getBody(); + if (requestJMSMsg.getJMSReplyTo() == null) { // assume no reply is expected @@ -116,6 +134,16 @@ public class TransportServiceInterceptor implements Interceptor { } return msg; } + + 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()); + } MessageProducer producer = session.createProducer(context.getReplyToDestination()); diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytes.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytes.java deleted file mode 100644 index 84d1a2740f..0000000000 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytes.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.wireformat.jmsbytes; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.xml.Constants; -import org.apache.tuscany.sca.assembly.WireFormat; - -/** - * Implementation for policies that could be injected as parameter - * into the axis2config. - * - * @version $Rev$ $Date$ - */ -public class WireFormatJMSBytes implements WireFormat { - public static final QName WIRE_FORMAT_JMS_BYTES_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "wireFormat.jmsBytes"); - - public QName getSchemaName() { - return WIRE_FORMAT_JMS_BYTES_QNAME; - } - - public boolean isUnresolved() { - return false; - } - - public void setUnresolved(boolean unresolved) { - } -} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProcessor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProcessor.java deleted file mode 100644 index c8a5dea2cb..0000000000 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProcessor.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.wireformat.jmsbytes; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.assembly.xml.Constants; -import org.apache.tuscany.sca.binding.jms.policy.header.JMSHeaderPolicy; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * - * @version $Rev$ $Date$ - */ -public class WireFormatJMSBytesProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor { - - public QName getArtifactType() { - return WireFormatJMSBytes.WIRE_FORMAT_JMS_BYTES_QNAME; - } - - public WireFormatJMSBytesProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { - } - - - public WireFormatJMSBytes read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - WireFormatJMSBytes wireFormat = new WireFormatJMSBytes(); - - return wireFormat; - } - - public void write(WireFormatJMSBytes wireFormat, XMLStreamWriter writer) - throws ContributionWriteException, XMLStreamException { - String prefix = "tuscany"; - writer.writeStartElement(prefix, - getArtifactType().getLocalPart(), - getArtifactType().getNamespaceURI()); - writer.writeNamespace("tuscany", Constants.SCA10_TUSCANY_NS); - - writer.writeEndElement(); - } - - public Class getModelType() { - return WireFormatJMSBytes.class; - } - - public void resolve(WireFormatJMSBytes arg0, ModelResolver arg1) throws ContributionResolveException { - - } - -} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProviderFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProviderFactory.java index 19c703264c..9f554b50e9 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProviderFactory.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProviderFactory.java @@ -43,7 +43,7 @@ public class WireFormatJMSBytesProviderFactory implements WireFormatProviderFact public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, RuntimeComponentReference reference, Binding binding) { - return new WireFormatJMSBytesReferenceProvider(component, reference, binding); + return new WireFormatJMSBytesReferenceProvider(registry, component, reference, binding); } /** @@ -51,7 +51,7 @@ public class WireFormatJMSBytesProviderFactory implements WireFormatProviderFact public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, RuntimeComponentService service, Binding binding) { - return new WireFormatJMSBytesServiceProvider(component, service, binding); + return new WireFormatJMSBytesServiceProvider(registry, component, service, binding); } /** diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesReferenceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesReferenceInterceptor.java index b4575701b3..f990a9a0ba 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesReferenceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesReferenceInterceptor.java @@ -30,7 +30,6 @@ 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; @@ -48,38 +47,24 @@ 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); - + this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding); } public Message invoke(Message msg) { - if (requestWireFormat != null){ + if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSBytes){ msg = invokeRequest(msg); } msg = getNext().invoke(msg); - if (responseWireFormat != null){ + if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSBytes){ msg = invokeResponse(msg); } diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesReferenceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesReferenceProvider.java index 77bc9509aa..65de548e58 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesReferenceProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesReferenceProvider.java @@ -21,8 +21,18 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes; import java.util.List; +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.JMSMessageProcessorUtil; +import org.apache.tuscany.sca.binding.jms.provider.XMLTextMessageProcessor; +import org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.WireFormatJMSTextXML; +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.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; @@ -38,33 +48,47 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentReference; * @version $Rev$ $Date$ */ public class WireFormatJMSBytesReferenceProvider implements WireFormatProvider { + private ExtensionPointRegistry registry; private RuntimeComponent component; private RuntimeComponentReference reference; - private Binding binding; + private JMSBinding binding; + private InterfaceContract interfaceContract; - public WireFormatJMSBytesReferenceProvider(RuntimeComponent component, + public WireFormatJMSBytesReferenceProvider(ExtensionPointRegistry registry, + RuntimeComponent component, RuntimeComponentReference reference, Binding binding) { super(); + this.registry = registry; this.component = component; this.reference = reference; - this.binding = binding; + this.binding = (JMSBinding)binding; + + // configure the reference based on this wire format + + // currently maintaining the message processor structure which + // contains the details of jms message processing however overried + // any message processors specied in the SCDL in this case + this.binding.setRequestMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME); + this.binding.setResponseMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME); + + // just point to the reference interface contract so no + // databinding transformation takes place + interfaceContract = reference.getInterfaceContract(); } - /** - * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) - */ + public InterfaceContract getWireFormatInterfaceContract() { + return interfaceContract; + } + public Interceptor createInterceptor() { - return new WireFormatJMSBytesReferenceInterceptor((JMSBinding)binding, - null, - reference.getRuntimeWire(binding)); + return new WireFormatJMSBytesReferenceInterceptor(binding, + null, + reference.getRuntimeWire(binding)); } - /** - * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase() - */ public String getPhase() { - return Phase.REFERENCE_POLICY; + return Phase.REFERENCE_BINDING_WIREFORMAT; } } diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesServiceInterceptor.java index 245619b92f..7c7c622fbc 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesServiceInterceptor.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesServiceInterceptor.java @@ -47,40 +47,24 @@ 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){ + if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSBytes){ msg = invokeRequest(msg); } msg = getNext().invoke(msg); - if (responseWireFormat != null){ + if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSBytes){ msg = invokeResponse(msg); } @@ -99,34 +83,22 @@ public class WireFormatJMSBytesServiceInterceptor implements Interceptor { } 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(); + // 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()); + javax.jms.Message responseJMSMsg; + if (msg.isFault()) { + responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody()); + } else { + Object[] response = {msg.getBody()}; + responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, response); + } - 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(responseJMSMsg); - msg.setBody(responseJMSMsg); - - return msg; - } catch (JMSException e) { - throw new JMSBindingException(e); - } + return msg; } public Invoker getNext() { diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesServiceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesServiceProvider.java index bbd3feb3c4..60ea1c7ff4 100644 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesServiceProvider.java +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesServiceProvider.java @@ -23,6 +23,9 @@ import java.util.List; 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.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; @@ -38,15 +41,37 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService; * @version $Rev$ $Date$ */ public class WireFormatJMSBytesServiceProvider implements WireFormatProvider { + private ExtensionPointRegistry registry; private RuntimeComponent component; private RuntimeComponentService service; - private Binding binding; + private JMSBinding binding; + private InterfaceContract interfaceContract; - public WireFormatJMSBytesServiceProvider(RuntimeComponent component, RuntimeComponentService service, Binding binding) { + public WireFormatJMSBytesServiceProvider(ExtensionPointRegistry registry, + RuntimeComponent component, + RuntimeComponentService service, + Binding binding) { super(); + this.registry = registry; this.component = component; this.service = service; - this.binding = binding; + this.binding = (JMSBinding)binding; + + // configure the service based on this wire format + + // currently maintaining the message processor structure which + // contains the details of jms message processing however overried + // any message processors specied in the SCDL in this case + this.binding.setRequestMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME); + this.binding.setResponseMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME); + + // just point to the reference interface contract so no + // databinding transformation takes place + interfaceContract = service.getInterfaceContract(); + } + + public InterfaceContract getWireFormatInterfaceContract() { + return interfaceContract; } /** @@ -60,7 +85,7 @@ public class WireFormatJMSBytesServiceProvider implements WireFormatProvider { /** */ public String getPhase() { - return Phase.SERVICE_POLICY; + return Phase.SERVICE_BINDING_WIREFORMAT; } } 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 deleted file mode 100644 index 7e802f55f5..0000000000 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefault.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.wireformat.jmsdefault; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.assembly.xml.Constants; -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 QName getSchemaName() { - return WIRE_FORMAT_JMS_DEFAULT_QNAME; - } - - public boolean isUnresolved() { - return false; - } - - public void setUnresolved(boolean unresolved) { - } - - @Override - public boolean equals(Object obj) { - return this.getClass() == obj.getClass(); - } -} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultProcessor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultProcessor.java deleted file mode 100644 index 4ffcd22f46..0000000000 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultProcessor.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.wireformat.jmsdefault; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.tuscany.sca.assembly.xml.Constants; -import org.apache.tuscany.sca.binding.jms.policy.header.JMSHeaderPolicy; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.contribution.service.ContributionReadException; -import org.apache.tuscany.sca.contribution.service.ContributionResolveException; -import org.apache.tuscany.sca.contribution.service.ContributionWriteException; -import org.apache.tuscany.sca.monitor.Monitor; - -/** - * - * @version $Rev$ $Date$ - */ -public class WireFormatJMSDefaultProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor { - - public QName getArtifactType() { - return WireFormatJMSDefault.WIRE_FORMAT_JMS_DEFAULT_QNAME; - } - - public WireFormatJMSDefaultProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { - } - - - public WireFormatJMSDefault read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { - WireFormatJMSDefault wireFormat = new WireFormatJMSDefault(); - - return wireFormat; - } - - public void write(WireFormatJMSDefault wireFormat, XMLStreamWriter writer) - throws ContributionWriteException, XMLStreamException { - String prefix = "tuscany"; - writer.writeStartElement(prefix, - getArtifactType().getLocalPart(), - getArtifactType().getNamespaceURI()); - writer.writeNamespace("tuscany", Constants.SCA10_TUSCANY_NS); - - writer.writeEndElement(); - } - - public Class getModelType() { - return WireFormatJMSDefault.class; - } - - public void resolve(WireFormatJMSDefault arg0, ModelResolver arg1) throws ContributionResolveException { - - } - -} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultProviderFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultProviderFactory.java deleted file mode 100644 index fc06425e0d..0000000000 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultProviderFactory.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.wireformat.jmsdefault; - -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.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.provider.WireFormatProviderFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; - -/** - * @version $Rev$ $Date$ - */ -public class WireFormatJMSDefaultProviderFactory implements WireFormatProviderFactory { - private ExtensionPointRegistry registry; - private JMSResourceFactoryExtensionPoint jmsRFEP; - - public WireFormatJMSDefaultProviderFactory(ExtensionPointRegistry registry) { - super(); - this.registry = registry; - jmsRFEP = (JMSResourceFactoryExtensionPoint)registry.getExtensionPoint(JMSResourceFactoryExtensionPoint.class); - } - - /** - */ - public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { - return new WireFormatJMSDefaultReferenceProvider(component, reference, binding); - } - - /** - */ - public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding) { - JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding)binding); - return new WireFormatJMSDefaultServiceProvider(component, service, binding, jmsRF); - } - - /** - * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType() - */ - public Class getModelType() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultReferenceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultReferenceInterceptor.java deleted file mode 100644 index b8b8d668ba..0000000000 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultReferenceInterceptor.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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.wireformat.jmsdefault; - - - - -import java.util.Map; - -import javax.jms.DeliveryMode; -import javax.jms.JMSException; -import javax.jms.Session; - -import org.apache.tuscany.sca.assembly.Reference; -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.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.interfacedef.Operation; -import org.apache.tuscany.sca.interfacedef.java.JavaInterface; -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; - -/** - * - * @version $Rev$ $Date$ - */ -public class WireFormatJMSDefaultReferenceInterceptor implements Interceptor { - - private Invoker next; - private RuntimeWire runtimeWire; - private JMSResourceFactory jmsResourceFactory; - private JMSBinding jmsBinding; - private JMSMessageProcessor requestMessageProcessor; - private JMSMessageProcessor responseMessageProcessor; - private String correlationScheme; - private WireFormat requestWireFormat; - private WireFormat responseWireFormat; - - public WireFormatJMSDefaultReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { - super(); - this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; - this.jmsResourceFactory = jmsResourceFactory; - this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding); - this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding); - this.correlationScheme = jmsBinding.getCorrelationScheme(); - - if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSDefault){ - this.requestWireFormat = jmsBinding.getRequestWireFormat(); - } - - if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSDefault){ - this.responseWireFormat = jmsBinding.getResponseWireFormat(); - } - } - - 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) { - 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; - } - - public void setNext(Invoker next) { - this.next = next; - } -} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultReferenceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultReferenceProvider.java deleted file mode 100644 index 5d3dcd9dd3..0000000000 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultReferenceProvider.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.wireformat.jmsdefault; - -import java.util.List; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.policy.util.PolicyHandler; -import org.apache.tuscany.sca.provider.PolicyProvider; -import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; - -/** - * @version $Rev$ $Date$ - */ -public class WireFormatJMSDefaultReferenceProvider implements WireFormatProvider { - private RuntimeComponent component; - private RuntimeComponentReference reference; - private Binding binding; - - public WireFormatJMSDefaultReferenceProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { - super(); - this.component = component; - this.reference = reference; - this.binding = binding; - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProvider#createInterceptor(org.apache.tuscany.sca.interfacedef.Operation) - */ - public Interceptor createInterceptor() { - return new WireFormatJMSDefaultReferenceInterceptor((JMSBinding)binding, - null, - reference.getRuntimeWire(binding)); - } - - /** - * @see org.apache.tuscany.sca.provider.PolicyProvider#getPhase() - */ - public String getPhase() { - return Phase.REFERENCE_BINDING_WIREFORMAT; - } - -} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultServiceInterceptor.java deleted file mode 100644 index 8dd2f58efe..0000000000 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultServiceInterceptor.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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.wireformat.jmsdefault; - -import javax.jms.JMSException; -import javax.jms.Session; -import javax.naming.NamingException; - -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.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeWire; - -/** - * Policy handler to handle PolicySet related to Logging with the QName - * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy - * - * @version $Rev$ $Date$ - */ -public class WireFormatJMSDefaultServiceInterceptor implements Interceptor { - private Invoker next; - private RuntimeWire runtimeWire; - private JMSResourceFactory jmsResourceFactory; - private JMSBinding jmsBinding; - private JMSMessageProcessor requestMessageProcessor; - private JMSMessageProcessor responseMessageProcessor; - private String correlationScheme; - private WireFormat requestWireFormat; - private WireFormat responseWireFormat; - - public WireFormatJMSDefaultServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { - super(); - this.jmsBinding = jmsBinding; - this.runtimeWire = runtimeWire; - this.jmsResourceFactory = jmsResourceFactory; - this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding); - this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding); - this.correlationScheme = jmsBinding.getCorrelationScheme(); - - if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSDefault){ - this.requestWireFormat = jmsBinding.getRequestWireFormat(); - } - - if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSDefault){ - this.responseWireFormat = jmsBinding.getResponseWireFormat(); - } - } - - 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(); - - if ("onMessage".equals(msg.getOperation().getName())) { - msg.setBody(new Object[]{jmsMsg}); - } else { - 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(responseJMSMsg); - - return msg; - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } - - public Invoker getNext() { - return next; - } - - public void setNext(Invoker next) { - this.next = next; - } -} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultServiceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultServiceProvider.java deleted file mode 100644 index 9bf355c27b..0000000000 --- a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/WireFormatJMSDefaultServiceProvider.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.wireformat.jmsdefault; - -import java.util.List; - -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.interfacedef.Operation; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.policy.util.PolicyHandler; -import org.apache.tuscany.sca.provider.PolicyProvider; -import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; - -/** - * @version $Rev$ $Date$ - */ -public class WireFormatJMSDefaultServiceProvider implements WireFormatProvider { - private RuntimeComponent component; - private RuntimeComponentService service; - private Binding binding; - private JMSResourceFactory jmsResourceFactory; - - public WireFormatJMSDefaultServiceProvider(RuntimeComponent component, RuntimeComponentService service, Binding binding, JMSResourceFactory jmsResourceFactory) { - super(); - this.component = component; - this.service = service; - this.binding = binding; - this.jmsResourceFactory = jmsResourceFactory; - } - - /** - */ - public Interceptor createInterceptor() { - return new WireFormatJMSDefaultServiceInterceptor((JMSBinding)binding, - jmsResourceFactory, - service.getRuntimeWire(binding)); - } - - /** - */ - public String getPhase() { - return Phase.SERVICE_BINDING_WIREFORMAT; - } - -} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectProviderFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectProviderFactory.java new file mode 100644 index 0000000000..5811ca53e0 --- /dev/null +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectProviderFactory.java @@ -0,0 +1,65 @@ +/* + * 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.wireformat.jmsobject; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.provider.WireFormatProvider; +import org.apache.tuscany.sca.provider.WireFormatProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * @version $Rev$ $Date$ + */ +public class WireFormatJMSObjectProviderFactory implements WireFormatProviderFactory { + private ExtensionPointRegistry registry; + + public WireFormatJMSObjectProviderFactory(ExtensionPointRegistry registry) { + super(); + this.registry = registry; + } + + /** + */ + public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding) { + return new WireFormatJMSObjectReferenceProvider(registry, component, reference, binding); + } + + /** + */ + public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding) { + return new WireFormatJMSObjectServiceProvider(registry, component, service, binding); + } + + /** + * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType() + */ + public Class getModelType() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectReferenceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectReferenceInterceptor.java new file mode 100644 index 0000000000..9653c0d51e --- /dev/null +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectReferenceInterceptor.java @@ -0,0 +1,111 @@ +/* + * 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.wireformat.jmsobject; + + +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.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.runtime.RuntimeWire; + +/** + * + * @version $Rev$ $Date$ + */ +public class WireFormatJMSObjectReferenceInterceptor implements Interceptor { + + private Invoker next; + private RuntimeWire runtimeWire; + private JMSResourceFactory jmsResourceFactory; + private JMSBinding jmsBinding; + private JMSMessageProcessor requestMessageProcessor; + private JMSMessageProcessor responseMessageProcessor; + + public WireFormatJMSObjectReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { + super(); + this.jmsBinding = jmsBinding; + this.runtimeWire = runtimeWire; + this.jmsResourceFactory = jmsResourceFactory; + this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding); + this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding); + } + + public Message invoke(Message msg) { + if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSObject){ + msg = invokeRequest(msg); + } + + msg = getNext().invoke(msg); + + if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSObject){ + 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; + } + + public void setNext(Invoker next) { + this.next = next; + } +} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectReferenceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectReferenceProvider.java new file mode 100644 index 0000000000..b993ae9067 --- /dev/null +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectReferenceProvider.java @@ -0,0 +1,94 @@ +/* + * 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.wireformat.jmsobject; + +import java.util.List; + +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.JMSMessageProcessorUtil; +import org.apache.tuscany.sca.binding.jms.provider.XMLTextMessageProcessor; +import org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.WireFormatJMSTextXML; +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.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.WireFormatProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; + +/** + * @version $Rev$ $Date$ + */ +public class WireFormatJMSObjectReferenceProvider implements WireFormatProvider { + private ExtensionPointRegistry registry; + private RuntimeComponent component; + private RuntimeComponentReference reference; + private JMSBinding binding; + private InterfaceContract interfaceContract; + + public WireFormatJMSObjectReferenceProvider(ExtensionPointRegistry registry, + RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding) { + super(); + this.registry = registry; + this.component = component; + this.reference = reference; + this.binding = (JMSBinding)binding; + + // configure the reference based on this wire format + + // currently maintaining the message processor structure which + // contains the details of jms message processing however overried + // any message processors specied in the SCDL in this case + this.binding.setRequestMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME); + this.binding.setResponseMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME); + + // just point to the reference interface contract so no + // databinding transformation takes place + interfaceContract = reference.getInterfaceContract(); + } + + public InterfaceContract getWireFormatInterfaceContract() { + return interfaceContract; + } + + public Interceptor createInterceptor() { + return new WireFormatJMSObjectReferenceInterceptor(binding, + null, + reference.getRuntimeWire(binding)); + } + + public String getPhase() { + return Phase.REFERENCE_BINDING_WIREFORMAT; + } + +} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectServiceInterceptor.java new file mode 100644 index 0000000000..4bfbd2be0e --- /dev/null +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectServiceInterceptor.java @@ -0,0 +1,111 @@ +/* + * 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.wireformat.jmsobject; + +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.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.runtime.RuntimeWire; + +/** + * Policy handler to handle PolicySet related to Logging with the QName + * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy + * + * @version $Rev$ $Date$ + */ +public class WireFormatJMSObjectServiceInterceptor implements Interceptor { + private Invoker next; + private RuntimeWire runtimeWire; + private JMSResourceFactory jmsResourceFactory; + private JMSBinding jmsBinding; + private JMSMessageProcessor requestMessageProcessor; + private JMSMessageProcessor responseMessageProcessor; + + public WireFormatJMSObjectServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { + super(); + this.jmsBinding = jmsBinding; + this.runtimeWire = runtimeWire; + this.jmsResourceFactory = jmsResourceFactory; + this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding); + this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding); + } + + public Message invoke(Message msg) { + if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSObject){ + msg = invokeRequest(msg); + } + + msg = getNext().invoke(msg); + + if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSObject){ + 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) { + // 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 { + Object[] response = {msg.getBody()}; + responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, response); + } + + msg.setBody(responseJMSMsg); + + return msg; + } + + public Invoker getNext() { + return next; + } + + public void setNext(Invoker next) { + this.next = next; + } +} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectServiceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectServiceProvider.java new file mode 100644 index 0000000000..9def71a6e0 --- /dev/null +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectServiceProvider.java @@ -0,0 +1,91 @@ +/* + * 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.wireformat.jmsobject; + +import java.util.List; + +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.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.WireFormatProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * @version $Rev$ $Date$ + */ +public class WireFormatJMSObjectServiceProvider implements WireFormatProvider { + private ExtensionPointRegistry registry; + private RuntimeComponent component; + private RuntimeComponentService service; + private JMSBinding binding; + private InterfaceContract interfaceContract; + + public WireFormatJMSObjectServiceProvider(ExtensionPointRegistry registry, + RuntimeComponent component, + RuntimeComponentService service, + Binding binding) { + super(); + this.registry = registry; + this.component = component; + this.service = service; + this.binding = (JMSBinding)binding; + + // configure the service based on this wire format + + // currently maintaining the message processor structure which + // contains the details of jms message processing however overried + // any message processors specied in the SCDL in this case + this.binding.setRequestMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME); + this.binding.setResponseMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME); + + // just point to the reference interface contract so no + // databinding transformation takes place + interfaceContract = service.getInterfaceContract(); + } + + public InterfaceContract getWireFormatInterfaceContract() { + return interfaceContract; + } + + /** + */ + public Interceptor createInterceptor() { + return new WireFormatJMSObjectServiceInterceptor((JMSBinding)binding, + null, + service.getRuntimeWire(binding)); + } + + /** + */ + public String getPhase() { + return Phase.SERVICE_BINDING_WIREFORMAT; + } + +} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextProviderFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextProviderFactory.java new file mode 100644 index 0000000000..5480cc8165 --- /dev/null +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextProviderFactory.java @@ -0,0 +1,65 @@ +/* + * 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.wireformat.jmstext; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.provider.WireFormatProvider; +import org.apache.tuscany.sca.provider.WireFormatProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * @version $Rev$ $Date$ + */ +public class WireFormatJMSTextProviderFactory implements WireFormatProviderFactory { + private ExtensionPointRegistry registry; + + public WireFormatJMSTextProviderFactory(ExtensionPointRegistry registry) { + super(); + this.registry = registry; + } + + /** + */ + public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding) { + return new WireFormatJMSTextReferenceProvider(registry, component, reference, binding); + } + + /** + */ + public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding) { + return new WireFormatJMSTextServiceProvider(registry, component, service, binding); + } + + /** + * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType() + */ + public Class getModelType() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextReferenceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextReferenceInterceptor.java new file mode 100644 index 0000000000..e317f42266 --- /dev/null +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextReferenceInterceptor.java @@ -0,0 +1,112 @@ +/* + * 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.wireformat.jmstext; + + +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.jmstextxml.WireFormatJMSTextXML; +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.RuntimeWire; + +/** + * + * @version $Rev$ $Date$ + */ +public class WireFormatJMSTextReferenceInterceptor implements Interceptor { + + private Invoker next; + private RuntimeWire runtimeWire; + private JMSResourceFactory jmsResourceFactory; + private JMSBinding jmsBinding; + private JMSMessageProcessor requestMessageProcessor; + private JMSMessageProcessor responseMessageProcessor; + + public WireFormatJMSTextReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { + super(); + this.jmsBinding = jmsBinding; + this.runtimeWire = runtimeWire; + this.jmsResourceFactory = jmsResourceFactory; + this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding); + this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding); + } + + public Message invoke(Message msg) { + if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSText){ + msg = invokeRequest(msg); + } + + msg = getNext().invoke(msg); + + if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSText){ + 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; + } + + public void setNext(Invoker next) { + this.next = next; + } +} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextReferenceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextReferenceProvider.java new file mode 100644 index 0000000000..7e749a96d6 --- /dev/null +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextReferenceProvider.java @@ -0,0 +1,95 @@ +/* + * 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.wireformat.jmstext; + +import java.util.List; + +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.JMSMessageProcessorUtil; +import org.apache.tuscany.sca.binding.jms.provider.XMLTextMessageProcessor; +import org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.WireFormatJMSTextXML; +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.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.WireFormatProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; + +/** + * @version $Rev$ $Date$ + */ +public class WireFormatJMSTextReferenceProvider implements WireFormatProvider { + private ExtensionPointRegistry registry; + private RuntimeComponent component; + private RuntimeComponentReference reference; + private JMSBinding binding; + private InterfaceContract interfaceContract; + + public WireFormatJMSTextReferenceProvider(ExtensionPointRegistry registry, + RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding) { + super(); + this.registry = registry; + this.component = component; + this.reference = reference; + this.binding = (JMSBinding)binding; + + // configure the reference based on this wire format + + // currently maintaining the message processor structure which + // contains the details of jms message processing however overried + // any message processors specied in the SCDL in this case + this.binding.setRequestMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME); + this.binding.setResponseMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME); + + + // just point to the reference interface contract so no + // databinding transformation takes place + interfaceContract = reference.getInterfaceContract(); + } + + public InterfaceContract getWireFormatInterfaceContract() { + return interfaceContract; + } + + public Interceptor createInterceptor() { + return new WireFormatJMSTextReferenceInterceptor(binding, + null, + reference.getRuntimeWire(binding)); + } + + public String getPhase() { + return Phase.REFERENCE_BINDING_WIREFORMAT; + } + +} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextServiceInterceptor.java new file mode 100644 index 0000000000..3dc2d0199d --- /dev/null +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextServiceInterceptor.java @@ -0,0 +1,111 @@ +/* + * 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.wireformat.jmstext; + +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.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.runtime.RuntimeWire; + +/** + * Policy handler to handle PolicySet related to Logging with the QName + * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy + * + * @version $Rev$ $Date$ + */ +public class WireFormatJMSTextServiceInterceptor implements Interceptor { + private Invoker next; + private RuntimeWire runtimeWire; + private JMSResourceFactory jmsResourceFactory; + private JMSBinding jmsBinding; + private JMSMessageProcessor requestMessageProcessor; + private JMSMessageProcessor responseMessageProcessor; + + public WireFormatJMSTextServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { + super(); + this.jmsBinding = jmsBinding; + this.runtimeWire = runtimeWire; + this.jmsResourceFactory = jmsResourceFactory; + this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding); + this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding); + } + + public Message invoke(Message msg) { + if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSText){ + msg = invokeRequest(msg); + } + + msg = getNext().invoke(msg); + + if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSText){ + 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) { + // 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 { + Object[] response = {msg.getBody()}; + responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, response); + } + + msg.setBody(responseJMSMsg); + + return msg; + } + + public Invoker getNext() { + return next; + } + + public void setNext(Invoker next) { + this.next = next; + } +} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextServiceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextServiceProvider.java new file mode 100644 index 0000000000..6f9f0c9da9 --- /dev/null +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextServiceProvider.java @@ -0,0 +1,91 @@ +/* + * 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.wireformat.jmstext; + +import java.util.List; + +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.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.WireFormatProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * @version $Rev$ $Date$ + */ +public class WireFormatJMSTextServiceProvider implements WireFormatProvider { + private ExtensionPointRegistry registry; + private RuntimeComponent component; + private RuntimeComponentService service; + private JMSBinding binding; + private InterfaceContract interfaceContract; + + public WireFormatJMSTextServiceProvider(ExtensionPointRegistry registry, + RuntimeComponent component, + RuntimeComponentService service, + Binding binding) { + super(); + this.registry = registry; + this.component = component; + this.service = service; + this.binding = (JMSBinding)binding; + + // configure the service based on this wire format + + // currently maintaining the message processor structure which + // contains the details of jms message processing however overried + // any message processors specied in the SCDL in this case + this.binding.setRequestMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME); + this.binding.setResponseMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME); + + // just point to the reference interface contract so no + // databinding transformation takes place + interfaceContract = service.getInterfaceContract(); + } + + public InterfaceContract getWireFormatInterfaceContract() { + return interfaceContract; + } + + /** + */ + public Interceptor createInterceptor() { + return new WireFormatJMSTextServiceInterceptor((JMSBinding)binding, + null, + service.getRuntimeWire(binding)); + } + + /** + */ + public String getPhase() { + return Phase.SERVICE_BINDING_WIREFORMAT; + } + +} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLProviderFactory.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLProviderFactory.java new file mode 100644 index 0000000000..6bef4e8160 --- /dev/null +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLProviderFactory.java @@ -0,0 +1,72 @@ +/* + * 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.wireformat.jmstextxml; + +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.jmstextxml.WireFormatJMSTextXML; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.provider.WireFormatProvider; +import org.apache.tuscany.sca.provider.WireFormatProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * @version $Rev$ $Date$ + */ +public class WireFormatJMSTextXMLProviderFactory implements WireFormatProviderFactory { + private ExtensionPointRegistry registry; + private JMSResourceFactoryExtensionPoint jmsRFEP; + + public WireFormatJMSTextXMLProviderFactory(ExtensionPointRegistry registry) { + super(); + this.registry = registry; + jmsRFEP = (JMSResourceFactoryExtensionPoint)registry.getExtensionPoint(JMSResourceFactoryExtensionPoint.class); + } + + /** + */ + public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding) { + return new WireFormatJMSTextXMLReferenceProvider(registry, component, reference, binding); + } + + /** + */ + public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding) { + JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding)binding); + return new WireFormatJMSTextXMLServiceProvider(registry, component, service, binding, jmsRF); + } + + /** + * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType() + */ + public Class getModelType() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLReferenceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLReferenceInterceptor.java new file mode 100644 index 0000000000..86a5bbb4b2 --- /dev/null +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLReferenceInterceptor.java @@ -0,0 +1,125 @@ +/* + * 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.wireformat.jmstextxml; + + + + +import java.util.Map; + +import javax.jms.DeliveryMode; +import javax.jms.JMSException; +import javax.jms.Session; + +import org.apache.tuscany.sca.assembly.Reference; +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.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.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; + +/** + * + * @version $Rev$ $Date$ + */ +public class WireFormatJMSTextXMLReferenceInterceptor implements Interceptor { + + private Invoker next; + private RuntimeWire runtimeWire; + private JMSResourceFactory jmsResourceFactory; + private JMSBinding jmsBinding; + private JMSMessageProcessor requestMessageProcessor; + private JMSMessageProcessor responseMessageProcessor; + + + public WireFormatJMSTextXMLReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { + super(); + this.jmsBinding = jmsBinding; + this.runtimeWire = runtimeWire; + this.jmsResourceFactory = jmsResourceFactory; + this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding); + this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding); + } + + public Message invoke(Message msg) { + if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSTextXML){ + msg = invokeRequest(msg); + } + + msg = getNext().invoke(msg); + + if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSTextXML){ + 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; + } + + public void setNext(Invoker next) { + this.next = next; + } +} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLReferenceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLReferenceProvider.java new file mode 100644 index 0000000000..b97084b5ad --- /dev/null +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLReferenceProvider.java @@ -0,0 +1,110 @@ +/* + * 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.wireformat.jmstextxml; + +import java.util.List; + +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.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.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.WireFormatProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; + +/** + * @version $Rev$ $Date$ + */ +public class WireFormatJMSTextXMLReferenceProvider implements WireFormatProvider { + private ExtensionPointRegistry registry; + private RuntimeComponent component; + private RuntimeComponentReference reference; + private JMSBinding binding; + private InterfaceContract interfaceContract; + + public WireFormatJMSTextXMLReferenceProvider(ExtensionPointRegistry registry, + RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding) { + super(); + this.registry = registry; + this.component = component; + this.reference = reference; + this.binding = (JMSBinding)binding; + + // configure the reference based on this wire format + + // currently maintaining the message processor structure which + // contains the details of jms message processing so set the message + // type here if not set explicitly in SCDL + if (this.binding.getRequestMessageProcessorName().equals(JMSBindingConstants.XML_MP_CLASSNAME) ){ + this.binding.setRequestMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME); + this.binding.setResponseMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME); + } + + // set the binding interface contract to represent the WSDL for the + // xml messages that will be sent + if (reference.getInterfaceContract() != null && + !isOnMessage()) { + WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class); + WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); + BindingWSDLGenerator.generateWSDL(component, reference, wsBinding, registry, null); + interfaceContract = wsBinding.getBindingInterfaceContract(); + interfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); + } else { + interfaceContract = reference.getInterfaceContract(); + } + } + + protected boolean isOnMessage() { + InterfaceContract ic = reference.getInterfaceContract(); + if (ic.getInterface().getOperations().size() != 1) { + return false; + } + return "onMessage".equals(ic.getInterface().getOperations().get(0).getName()); + } + + public InterfaceContract getWireFormatInterfaceContract() { + return interfaceContract; + } + + public Interceptor createInterceptor() { + return new WireFormatJMSTextXMLReferenceInterceptor((JMSBinding)binding, + null, + reference.getRuntimeWire(binding)); + } + + public String getPhase() { + return Phase.REFERENCE_BINDING_WIREFORMAT; + } + +} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLServiceInterceptor.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLServiceInterceptor.java new file mode 100644 index 0000000000..ffec9d67f8 --- /dev/null +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLServiceInterceptor.java @@ -0,0 +1,118 @@ +/* + * 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.wireformat.jmstextxml; + +import javax.jms.JMSException; +import javax.jms.Session; +import javax.naming.NamingException; + +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.jmstextxml.WireFormatJMSTextXML; +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.RuntimeWire; + +/** + * Policy handler to handle PolicySet related to Logging with the QName + * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy + * + * @version $Rev$ $Date$ + */ +public class WireFormatJMSTextXMLServiceInterceptor implements Interceptor { + private Invoker next; + private RuntimeWire runtimeWire; + private JMSResourceFactory jmsResourceFactory; + private JMSBinding jmsBinding; + private JMSMessageProcessor requestMessageProcessor; + private JMSMessageProcessor responseMessageProcessor; + + public WireFormatJMSTextXMLServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) { + super(); + this.jmsBinding = jmsBinding; + this.runtimeWire = runtimeWire; + this.jmsResourceFactory = jmsResourceFactory; + this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding); + this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding); + } + + public Message invoke(Message msg) { + + if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSTextXML){ + msg = invokeRequest(msg); + } + + msg = getNext().invoke(msg); + + if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSTextXML){ + 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(); + + if ("onMessage".equals(msg.getOperation().getName())) { + msg.setBody(new Object[]{jmsMsg}); + } else { + Object requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg); + msg.setBody(requestPayload); + } + + return msg; + } + + public Message invokeResponse(Message msg) { + + // 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()); + } + + msg.setBody(responseJMSMsg); + + return msg; + } + + public Invoker getNext() { + return next; + } + + public void setNext(Invoker next) { + this.next = next; + } +} diff --git a/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLServiceProvider.java b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLServiceProvider.java new file mode 100644 index 0000000000..651a96f596 --- /dev/null +++ b/java/sca/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLServiceProvider.java @@ -0,0 +1,113 @@ +/* + * 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.wireformat.jmstextxml; + +import java.util.List; + +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.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.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Interceptor; +import org.apache.tuscany.sca.invocation.Phase; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.policy.util.PolicyHandler; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.WireFormatProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * @version $Rev$ $Date$ + */ +public class WireFormatJMSTextXMLServiceProvider implements WireFormatProvider { + private ExtensionPointRegistry registry; + private RuntimeComponent component; + private RuntimeComponentService service; + private JMSBinding binding; + private JMSResourceFactory jmsResourceFactory; + private InterfaceContract interfaceContract; + + public WireFormatJMSTextXMLServiceProvider(ExtensionPointRegistry registry, + RuntimeComponent component, + RuntimeComponentService service, + Binding binding, + JMSResourceFactory jmsResourceFactory) { + super(); + this.component = component; + this.service = service; + this.binding = (JMSBinding)binding; + this.jmsResourceFactory = jmsResourceFactory; + + // configure the service based on this wire format + + // currently maintaining the message processor structure which + // contains the details of jms message processing so set the message + // type here if not set explicitly in SCDL + if (this.binding.getRequestMessageProcessorName().equals(JMSBindingConstants.XML_MP_CLASSNAME) ){ + this.binding.setRequestMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME); + this.binding.setResponseMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME); + } + + // set the binding interface contract to represent the WSDL for the + // xml messages that will be sent + if (service.getInterfaceContract() != null && + !isOnMessage()) { + WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class); + WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); + BindingWSDLGenerator.generateWSDL(component, service, wsBinding, registry, null); + interfaceContract = wsBinding.getBindingInterfaceContract(); + interfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); + } else { + interfaceContract = service.getInterfaceContract(); + } + } + + protected boolean isOnMessage() { + InterfaceContract ic = service.getInterfaceContract(); + if (ic.getInterface().getOperations().size() != 1) { + return false; + } + return "onMessage".equals(ic.getInterface().getOperations().get(0).getName()); + } + + public InterfaceContract getWireFormatInterfaceContract() { + return interfaceContract; + } + + public Interceptor createInterceptor() { + return new WireFormatJMSTextXMLServiceInterceptor((JMSBinding)binding, + jmsResourceFactory, + service.getRuntimeWire(binding)); + } + + public String getPhase() { + return Phase.SERVICE_BINDING_WIREFORMAT; + } + +} 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 deleted file mode 100644 index 77898a1083..0000000000 --- a/java/sca/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ /dev/null @@ -1,21 +0,0 @@ -# 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. - -# Implementation class for the artifact processor extension -org.apache.tuscany.sca.binding.jms.wireformat.jmsdefault.WireFormatJMSDefaultProcessor;qname=http://tuscany.apache.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://tuscany.apache.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 56c07992bd..c82d4e7cab 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 @@ -16,5 +16,7 @@ # under the License. # 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.jmstextxml.WireFormatJMSTextXMLProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.WireFormatJMSTextXML org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.WireFormatJMSBytesProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.WireFormatJMSBytes +org.apache.tuscany.sca.binding.jms.wireformat.jmstext.WireFormatJMSTextProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.jmstext.WireFormatJMSText +org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.WireFormatJMSObjectProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.WireFormatJMSObject diff --git a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java index 120bc2735e..6ab439748a 100644 --- a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java +++ b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java @@ -35,6 +35,10 @@ import org.apache.tuscany.sca.assembly.WireFormat; import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl; import org.apache.tuscany.sca.assembly.xml.Constants; import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor; +import org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.OperationSelectorJMSDefault; +import org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.WireFormatJMSObject; +import org.apache.tuscany.sca.binding.jms.wireformat.jmstext.WireFormatJMSText; +import org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.WireFormatJMSTextXML; import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver; @@ -207,18 +211,26 @@ public class JMSBindingProcessor implements StAXArtifactProcessor { } // Read message processor class name + // TODO - maintain this for the time being but move over to + // configuring wire formats instead of message processors String messageProcessorName = reader.getAttributeValue(null, "messageProcessor"); if (messageProcessorName != null && messageProcessorName.length() > 0) { if ("XMLTextMessage".equalsIgnoreCase(messageProcessorName)) { - messageProcessorName = JMSBindingConstants.XML_MP_CLASSNAME; + // may be overwritten be real wire format later + jmsBinding.setRequestWireFormat(new WireFormatJMSTextXML()); + jmsBinding.setResponseWireFormat(new WireFormatJMSTextXML()); } else if ("TextMessage".equalsIgnoreCase(messageProcessorName)) { - messageProcessorName = JMSBindingConstants.TEXT_MP_CLASSNAME; + // may be overwritten be real wire format later + jmsBinding.setRequestWireFormat(new WireFormatJMSText()); + jmsBinding.setResponseWireFormat(new WireFormatJMSText()); } else if ("ObjectMessage".equalsIgnoreCase(messageProcessorName)) { - messageProcessorName = JMSBindingConstants.OBJECT_MP_CLASSNAME; + // may be overwritten be real wire format later + jmsBinding.setRequestWireFormat(new WireFormatJMSObject()); + jmsBinding.setResponseWireFormat(new WireFormatJMSObject()); + } else { + jmsBinding.setRequestMessageProcessorName(messageProcessorName); + jmsBinding.setResponseMessageProcessorName(messageProcessorName); } - jmsBinding.setRequestMessageProcessorName(messageProcessorName); - jmsBinding.setResponseMessageProcessorName(messageProcessorName); - } String requestConnectionName = reader.getAttributeValue(null, "requestConnection"); @@ -276,6 +288,21 @@ public class JMSBindingProcessor implements StAXArtifactProcessor { } } } + + // if no operation selector is specified then assume the default + if (jmsBinding.getOperationSelector() == null){ + jmsBinding.setOperationSelector(new OperationSelectorJMSDefault()); + } + + // if no request wire format specified then assume the default + if (jmsBinding.getRequestWireFormat() == null){ + jmsBinding.setRequestWireFormat(new WireFormatJMSTextXML()); + } + + // if no response wire format specific then assume the default + if (jmsBinding.getResponseWireFormat() == null){ + jmsBinding.setResponseWireFormat(jmsBinding.getRequestWireFormat()); + } validate(); diff --git a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefault.java b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefault.java new file mode 100644 index 0000000000..71d1298c9b --- /dev/null +++ b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefault.java @@ -0,0 +1,45 @@ +/* + * 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.operationselector.jmsdefault; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.assembly.OperationSelector; + +/** + * Implementation for policies that could be injected as parameter + * into the axis2config. + * + * @version $Rev$ $Date$ + */ +public class OperationSelectorJMSDefault implements OperationSelector { + public static final QName OPERATION_SELECTOR_JMS_DEFAULT_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "operationSelector.JMSDefault"); + + public QName getSchemaName() { + return OPERATION_SELECTOR_JMS_DEFAULT_QNAME; + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean unresolved) { + } +} diff --git a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefaultProcessor.java b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefaultProcessor.java new file mode 100644 index 0000000000..4a8e4a1bd2 --- /dev/null +++ b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/OperationSelectorJMSDefaultProcessor.java @@ -0,0 +1,76 @@ +/* + * 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.operationselector.jmsdefault; + + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.monitor.Monitor; + +/** + * + * @version $Rev$ $Date$ + */ +public class OperationSelectorJMSDefaultProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor { + + public QName getArtifactType() { + return OperationSelectorJMSDefault.OPERATION_SELECTOR_JMS_DEFAULT_QNAME; + } + + public OperationSelectorJMSDefaultProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + } + + + public OperationSelectorJMSDefault read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + OperationSelectorJMSDefault wireFormat = new OperationSelectorJMSDefault(); + + return wireFormat; + } + + public void write(OperationSelectorJMSDefault wireFormat, XMLStreamWriter writer) + throws ContributionWriteException, XMLStreamException { + String prefix = "tuscany"; + writer.writeStartElement(prefix, + getArtifactType().getLocalPart(), + getArtifactType().getNamespaceURI()); + writer.writeNamespace("tuscany", Constants.SCA10_TUSCANY_NS); + + writer.writeEndElement(); + } + + public Class getModelType() { + return OperationSelectorJMSDefault.class; + } + + public void resolve(OperationSelectorJMSDefault arg0, ModelResolver arg1) throws ContributionResolveException { + + } + +} diff --git a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytes.java b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytes.java new file mode 100644 index 0000000000..84d1a2740f --- /dev/null +++ b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytes.java @@ -0,0 +1,45 @@ +/* + * 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.wireformat.jmsbytes; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.assembly.WireFormat; + +/** + * Implementation for policies that could be injected as parameter + * into the axis2config. + * + * @version $Rev$ $Date$ + */ +public class WireFormatJMSBytes implements WireFormat { + public static final QName WIRE_FORMAT_JMS_BYTES_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "wireFormat.jmsBytes"); + + public QName getSchemaName() { + return WIRE_FORMAT_JMS_BYTES_QNAME; + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean unresolved) { + } +} diff --git a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProcessor.java b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProcessor.java new file mode 100644 index 0000000000..2d807d49cb --- /dev/null +++ b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/WireFormatJMSBytesProcessor.java @@ -0,0 +1,78 @@ +/* + * 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.wireformat.jmsbytes; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.monitor.Monitor; + +/** + * + * @version $Rev$ $Date$ + */ +public class WireFormatJMSBytesProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor { + + public QName getArtifactType() { + return WireFormatJMSBytes.WIRE_FORMAT_JMS_BYTES_QNAME; + } + + public WireFormatJMSBytesProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + } + + + public WireFormatJMSBytes read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + WireFormatJMSBytes wireFormat = new WireFormatJMSBytes(); + + return wireFormat; + } + + public void write(WireFormatJMSBytes wireFormat, XMLStreamWriter writer) + throws ContributionWriteException, XMLStreamException { + String prefix = "tuscany"; + writer.writeStartElement(prefix, + getArtifactType().getLocalPart(), + getArtifactType().getNamespaceURI()); + writer.writeNamespace("tuscany", Constants.SCA10_TUSCANY_NS); + + writer.writeEndElement(); + } + + public Class getModelType() { + return WireFormatJMSBytes.class; + } + + public void resolve(WireFormatJMSBytes arg0, ModelResolver arg1) throws ContributionResolveException { + + } + +} diff --git a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObject.java b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObject.java new file mode 100644 index 0000000000..7e39f696bd --- /dev/null +++ b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObject.java @@ -0,0 +1,45 @@ +/* + * 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.wireformat.jmsobject; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.assembly.WireFormat; + +/** + * Implementation for policies that could be injected as parameter + * into the axis2config. + * + * @version $Rev$ $Date$ + */ +public class WireFormatJMSObject implements WireFormat { + public static final QName WIRE_FORMAT_JMS_BYTES_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "wireFormat.jmsObject"); + + public QName getSchemaName() { + return WIRE_FORMAT_JMS_BYTES_QNAME; + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean unresolved) { + } +} diff --git a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectProcessor.java b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectProcessor.java new file mode 100644 index 0000000000..806b713931 --- /dev/null +++ b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/WireFormatJMSObjectProcessor.java @@ -0,0 +1,78 @@ +/* + * 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.wireformat.jmsobject; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.monitor.Monitor; + +/** + * + * @version $Rev$ $Date$ + */ +public class WireFormatJMSObjectProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor { + + public QName getArtifactType() { + return WireFormatJMSObject.WIRE_FORMAT_JMS_BYTES_QNAME; + } + + public WireFormatJMSObjectProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + } + + + public WireFormatJMSObject read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + WireFormatJMSObject wireFormat = new WireFormatJMSObject(); + + return wireFormat; + } + + public void write(WireFormatJMSObject wireFormat, XMLStreamWriter writer) + throws ContributionWriteException, XMLStreamException { + String prefix = "tuscany"; + writer.writeStartElement(prefix, + getArtifactType().getLocalPart(), + getArtifactType().getNamespaceURI()); + writer.writeNamespace("tuscany", Constants.SCA10_TUSCANY_NS); + + writer.writeEndElement(); + } + + public Class getModelType() { + return WireFormatJMSObject.class; + } + + public void resolve(WireFormatJMSObject arg0, ModelResolver arg1) throws ContributionResolveException { + + } + +} diff --git a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSText.java b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSText.java new file mode 100644 index 0000000000..fff33df1f4 --- /dev/null +++ b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSText.java @@ -0,0 +1,45 @@ +/* + * 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.wireformat.jmstext; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.assembly.WireFormat; + +/** + * Implementation for policies that could be injected as parameter + * into the axis2config. + * + * @version $Rev$ $Date$ + */ +public class WireFormatJMSText implements WireFormat { + public static final QName WIRE_FORMAT_JMS_BYTES_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "wireFormat.jmsText"); + + public QName getSchemaName() { + return WIRE_FORMAT_JMS_BYTES_QNAME; + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean unresolved) { + } +} diff --git a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextProcessor.java b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextProcessor.java new file mode 100644 index 0000000000..9b675df290 --- /dev/null +++ b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/WireFormatJMSTextProcessor.java @@ -0,0 +1,78 @@ +/* + * 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.wireformat.jmstext; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.monitor.Monitor; + +/** + * + * @version $Rev$ $Date$ + */ +public class WireFormatJMSTextProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor { + + public QName getArtifactType() { + return WireFormatJMSText.WIRE_FORMAT_JMS_BYTES_QNAME; + } + + public WireFormatJMSTextProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + } + + + public WireFormatJMSText read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + WireFormatJMSText wireFormat = new WireFormatJMSText(); + + return wireFormat; + } + + public void write(WireFormatJMSText wireFormat, XMLStreamWriter writer) + throws ContributionWriteException, XMLStreamException { + String prefix = "tuscany"; + writer.writeStartElement(prefix, + getArtifactType().getLocalPart(), + getArtifactType().getNamespaceURI()); + writer.writeNamespace("tuscany", Constants.SCA10_TUSCANY_NS); + + writer.writeEndElement(); + } + + public Class getModelType() { + return WireFormatJMSText.class; + } + + public void resolve(WireFormatJMSText arg0, ModelResolver arg1) throws ContributionResolveException { + + } + +} diff --git a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXML.java b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXML.java new file mode 100644 index 0000000000..23a53b9d96 --- /dev/null +++ b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXML.java @@ -0,0 +1,48 @@ +/* + * 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.wireformat.jmstextxml; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.assembly.WireFormat; + +/** + * + * @version $Rev$ $Date$ + */ +public class WireFormatJMSTextXML implements WireFormat { + public static final QName WIRE_FORMAT_JMS_DEFAULT_QNAME = new QName(Constants.SCA10_TUSCANY_NS, "wireFormat.jmsTextXML"); + + public QName getSchemaName() { + return WIRE_FORMAT_JMS_DEFAULT_QNAME; + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean unresolved) { + } + + @Override + public boolean equals(Object obj) { + return this.getClass() == obj.getClass(); + } +} diff --git a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLProcessor.java b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLProcessor.java new file mode 100644 index 0000000000..8248fc771a --- /dev/null +++ b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/WireFormatJMSTextXMLProcessor.java @@ -0,0 +1,78 @@ +/* + * 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.wireformat.jmstextxml; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; +import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.monitor.Monitor; + +/** + * + * @version $Rev$ $Date$ + */ +public class WireFormatJMSTextXMLProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor { + + public QName getArtifactType() { + return WireFormatJMSTextXML.WIRE_FORMAT_JMS_DEFAULT_QNAME; + } + + public WireFormatJMSTextXMLProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + } + + + public WireFormatJMSTextXML read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + WireFormatJMSTextXML wireFormat = new WireFormatJMSTextXML(); + + return wireFormat; + } + + public void write(WireFormatJMSTextXML wireFormat, XMLStreamWriter writer) + throws ContributionWriteException, XMLStreamException { + String prefix = "tuscany"; + writer.writeStartElement(prefix, + getArtifactType().getLocalPart(), + getArtifactType().getNamespaceURI()); + writer.writeNamespace("tuscany", Constants.SCA10_TUSCANY_NS); + + writer.writeEndElement(); + } + + public Class getModelType() { + return WireFormatJMSTextXML.class; + } + + public void resolve(WireFormatJMSTextXML arg0, ModelResolver arg1) throws ContributionResolveException { + + } + +} diff --git a/java/sca/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/java/sca/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor index ac37a0f26b..e5b8a96783 100644 --- a/java/sca/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor +++ b/java/sca/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -17,3 +17,9 @@ # Implementation class for the artifact processor extension org.apache.tuscany.sca.binding.jms.impl.JMSBindingProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#binding.jms,model=org.apache.tuscany.sca.binding.jms.impl.JMSBinding +org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.WireFormatJMSTextXMLProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#wireFormat.jmsTextXML,model=org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.WireFormatJMSTextXML +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.wireformat.jmstext.WireFormatJMSTextProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#wireFormat.jmsText,model=org.apache.tuscany.sca.binding.jms.wireformat.jmstext.WireFormatJMSText +org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.WireFormatJMSObjectProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#wireFormat.jmsObject,model=org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.WireFormatJMSObject +org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.OperationSelectorJMSDefaultProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#operationSelector.jmsDefault,model=org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.OperationSelectorJMSDefault + diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java index cc7f4626d3..db38945fc1 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java @@ -19,12 +19,24 @@ package org.apache.tuscany.sca.provider; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.invocation.Interceptor; /** * @version $Rev$ $Date$ */ public interface WireFormatProvider { + + /* + * Return the contract that describes the interface that + * is providing data to or accepting data from the + * wire format interceptor. The wire formats job + * is to translate between this interface contract and the + * format on the wire + * @return the wire format interface contract + */ + public InterfaceContract getWireFormatInterfaceContract(); + /** * Create an interceptor for the wire format * @return An interceptor that realize the policySet diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java index 609e2aa89b..a2e7152202 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java @@ -81,6 +81,16 @@ public interface RuntimeWire extends Cloneable { */ InvocationChain getBindingInvocationChain(); + /** + * This invoke method assumes that the binding invocation chain is in force + * and that there will be an operation selector element there to + * determine which operation to call + * @param msg The message + * @return The result + * @throws InvocationTargetException + */ + Object invoke(Message msg) throws InvocationTargetException; + /** * Invoke an operation with given arguments * @param operation The operation diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java index beb86fefe1..4f463b105d 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java @@ -128,6 +128,11 @@ public class EndpointWireImpl implements RuntimeWire { } } + public Object invoke(Message msg) throws InvocationTargetException { + // not called as the endpoint wire only appears on the reference side + return null; + } + public Object invoke(Operation operation, Object[] args) throws InvocationTargetException { // not called as the endpoint wire only appears on the reference side return null; diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java index 842799c277..b6f949f081 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java @@ -147,6 +147,10 @@ public class RuntimeWireImpl implements RuntimeWire { } return null; } + + public Object invoke(Message msg) throws InvocationTargetException { + return getBindingInvocationChain().getHeadInvoker().invoke(msg); + } public Object invoke(Operation operation, Object[] args) throws InvocationTargetException { Message msg = messageFactory.createMessage(); @@ -238,13 +242,7 @@ public class RuntimeWireImpl implements RuntimeWire { } } } - } - - // TODO - add something on the end of the wire to invoke the - // invocation chain. Need to split out the runtime - // wire invoker into conversation, callback interceptors etc - - + } } private void initServiceBindingInvocationChains() { -- cgit v1.2.3