diff options
Diffstat (limited to '')
54 files changed, 0 insertions, 5728 deletions
diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/LICENSE b/branches/sca-java-1.5/modules/binding-jms-runtime/LICENSE deleted file mode 100644 index 8aa906c321..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/LICENSE +++ /dev/null @@ -1,205 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. - - - diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/NOTICE b/branches/sca-java-1.5/modules/binding-jms-runtime/NOTICE deleted file mode 100644 index fdfa0e9faa..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/NOTICE +++ /dev/null @@ -1,6 +0,0 @@ -${pom.name} -Copyright (c) 2005 - 2008 The Apache Software Foundation - -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). - diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/pom.xml b/branches/sca-java-1.5/modules/binding-jms-runtime/pom.xml deleted file mode 100644 index 7952d794a4..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/pom.xml +++ /dev/null @@ -1,142 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * 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. ---> -<project> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-modules</artifactId> - <version>1.5-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - <artifactId>tuscany-binding-jms-runtime</artifactId> - <name>Apache Tuscany SCA JMS Binding Runtime</name> - - <dependencies> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-binding-jms</artifactId> - <version>1.5-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-jms</artifactId> - <version>1.5-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-sca-api</artifactId> - <version>1.5-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-core-spi</artifactId> - <version>1.5-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-core</artifactId> - <version>1.5-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-interface-java</artifactId> - <version>1.5-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-interface-wsdl</artifactId> - <version>1.5-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-databinding-axiom</artifactId> - <version>1.5-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-binding-ws-wsdlgen</artifactId> - <version>1.5-SNAPSHOT</version> - </dependency> - - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jms_1.1_spec</artifactId> - <version>1.1</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jms_1.1_spec</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-implementation-java-runtime</artifactId> - <version>1.5-SNAPSHOT</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.apache.tuscany.sca</groupId> - <artifactId>tuscany-host-embedded</artifactId> - <version>1.5-SNAPSHOT</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.5</version> - <scope>test</scope> - </dependency> - - </dependencies> - - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - - <configuration> - <instructions> - <Bundle-Version>${tuscany.version}</Bundle-Version> - <Bundle-SymbolicName>org.apache.tuscany.sca.binding.jms.runtime</Bundle-SymbolicName> - <Bundle-Description>${pom.name}</Bundle-Description> - <Export-Package>org.apache.tuscany.sca.binding.jms.provider*</Export-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - -</project> diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java deleted file mode 100644 index 6801270ee1..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java +++ /dev/null @@ -1,133 +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.context; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.Session; -import javax.naming.NamingException; - -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; -import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory; - - -/** - * Context that the JMS binding puts on the Tuscany wire - * - * @version $Rev$ $Date$ - */ -public class JMSBindingContext { - - private Message jmsMsg; - private Session jmsSession; - private Session jmsResponseSession; - private Destination requestDestination; - private Destination replyToDestination; - private JMSResourceFactory jmsResourceFactory; - private long timeToLive; - - public Message getJmsMsg() { - return jmsMsg; - } - - public void setJmsMsg(Message jmsMsg) { - this.jmsMsg = jmsMsg; - } - - public synchronized Session getJmsSession() { - if (jmsSession == null) { - try { - jmsSession = getJmsResourceFactory().createSession(); - } catch (Exception e) { - throw new JMSBindingException(e); - } - } - return jmsSession; - } - - public synchronized void closeJmsSession() { - if (jmsSession != null) { - try { - jmsSession.close(); - } catch (Exception e) { - throw new JMSBindingException(e); - } finally { - jmsSession = null; - } - } - } - - public synchronized Session getJmsResponseSession() { - if (jmsResponseSession == null) { - try { - jmsResponseSession = getJmsResourceFactory().createResponseSession(); - } catch (Exception e) { - throw new JMSBindingException(e); - } - } - return jmsResponseSession; - } - - public synchronized void closeJmsResponseSession() { - if (jmsResponseSession != null) { - try { - jmsResponseSession.close(); - } catch (Exception e) { - throw new JMSBindingException(e); - } finally { - jmsResponseSession = null; - } - } - } - - public Destination getRequestDestination() { - return requestDestination; - } - - public void setRequestDestination(Destination requestDestination) { - this.requestDestination = requestDestination; - } - - public Destination getReplyToDestination() { - return replyToDestination; - } - - public void setReplyToDestination(Destination replyToDestination) { - this.replyToDestination = replyToDestination; - } - - // TODO - difficult to get the resource factory into all the JMS providers - // so it's here for the moment - public JMSResourceFactory getJmsResourceFactory() { - return jmsResourceFactory; - } - - public void setJmsResourceFactory(JMSResourceFactory jmsResourceFactory) { - this.jmsResourceFactory = jmsResourceFactory; - } - - public long getTimeToLive() { - return timeToLive; - } - - public void setTimeToLive(long timeToLive) { - this.timeToLive = timeToLive; - } -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java deleted file mode 100644 index a361d8159b..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java +++ /dev/null @@ -1,180 +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.headers; - - - - -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 HeaderReferenceInterceptor 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 HeaderReferenceInterceptor(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(); - - } - - public Message invoke(Message msg) { - - return next.invoke(invokeRequest(msg)); - - } - - public Message invokeRequest(Message tuscanyMsg) { - try { - // get the jms context - JMSBindingContext context = tuscanyMsg.getBindingContext(); - javax.jms.Message jmsMsg = tuscanyMsg.getBody(); - - Operation operation = tuscanyMsg.getOperation(); - String operationName = operation.getName(); - RuntimeComponentReference reference = (RuntimeComponentReference)runtimeWire.getSource().getContract(); - - requestMessageProcessor.setOperationName(jmsBinding.getNativeOperationName(operationName), jmsMsg); - - if (jmsBinding.getOperationJMSDeliveryMode(operationName) != null) { - if (jmsBinding.getOperationJMSDeliveryMode(operationName)) { - jmsMsg.setJMSDeliveryMode(DeliveryMode.PERSISTENT); - } else { - jmsMsg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); - } - } - - if (jmsBinding.getOperationJMSCorrelationId(operationName) != null) { - jmsMsg.setJMSCorrelationID(jmsBinding.getOperationJMSCorrelationId(operationName)); - } - - if (jmsBinding.getOperationJMSPriority(operationName) != null) { - jmsMsg.setJMSPriority(jmsBinding.getOperationJMSPriority(operationName)); - } - - if (jmsBinding.getOperationJMSType(operationName) != null) { - jmsMsg.setJMSType(jmsBinding.getOperationJMSType(operationName)); - } - - ReferenceParameters parameters = tuscanyMsg.getFrom().getReferenceParameters(); - - Object conversationID = parameters.getConversationID(); - if (conversationID != null) { - jmsMsg.setStringProperty(JMSBindingConstants.CONVERSATION_ID_PROPERTY, conversationID.toString()); - } - - if (tuscanyMsg.getFrom().getCallbackEndpoint() != null) { - - if (parameters.getCallbackID() != null) { - jmsMsg.setStringProperty(JMSBindingConstants.CALLBACK_ID_PROPERTY, parameters.getCallbackID().toString()); - } - - String callbackDestName = getCallbackDestinationName(reference); - if (callbackDestName != null) { - jmsMsg.setStringProperty(JMSBindingConstants.CALLBACK_Q_PROPERTY, callbackDestName); - } - } - - for (String propName : jmsBinding.getPropertyNames()) { - Object value = jmsBinding.getProperty(propName); - jmsMsg.setObjectProperty(propName, value); - } - - Map<String, Object> operationProperties = jmsBinding.getOperationProperties(operationName); - if (operationProperties != null) { - for (String propName : operationProperties.keySet()) { - Object value = operationProperties.get(propName); - jmsMsg.setObjectProperty(propName, value); - } - } - - if (jmsBinding.getOperationJMSTimeToLive(operationName) != null) { - context.setTimeToLive(jmsBinding.getOperationJMSTimeToLive(operationName) * 2); - } else { - context.setTimeToLive(JMSBindingConstants.DEFAULT_TIME_TO_LIVE); - } - - return tuscanyMsg; - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } - - - protected String getCallbackDestinationName(RuntimeComponentReference reference) { - RuntimeComponentService s = (RuntimeComponentService)reference.getCallbackService(); - JMSBinding b = s.getBinding(JMSBinding.class); - if (b != null) { - JMSBindingServiceBindingProvider bp = (JMSBindingServiceBindingProvider)s.getBindingProvider(b); - return bp.getDestinationName(); - } - return null; - } - - - public Invoker getNext() { - return next; - } - - public void setNext(Invoker next) { - this.next = next; - } - - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.java deleted file mode 100644 index 64d01b2863..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.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.operationselector.jmsdefault.runtime; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.OperationSelectorJMSDefault; -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.OperationSelectorProvider; -import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory; -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 OperationSelectorJMSDefaultProviderFactory implements OperationSelectorProviderFactory<OperationSelectorJMSDefault> { - private ExtensionPointRegistry registry; - - public OperationSelectorJMSDefaultProviderFactory(ExtensionPointRegistry registry) { - super(); - this.registry = registry; - } - - /** - */ - public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { - return null; - } - - /** - */ - public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding) { - return new OperationSelectorJMSDefaultServiceProvider(component, service, binding); - } - - /** - * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType() - */ - public Class getModelType() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java deleted file mode 100644 index bb67c3a67a..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java +++ /dev/null @@ -1,224 +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.runtime; - -import java.io.ByteArrayInputStream; -import java.io.StringReader; -import java.util.List; - -import javax.jms.BytesMessage; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.TextMessage; -import javax.jms.Session; -import javax.jms.Topic; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.impl.builder.StAXOMBuilder; -import org.apache.tuscany.sca.binding.jms.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.core.assembly.EndpointReferenceImpl; -import org.apache.tuscany.sca.interfacedef.Operation; -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.RuntimeComponentService; -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 OperationSelectorJMSDefaultServiceInterceptor implements Interceptor { - - private static final String ON_MESSAGE_METHOD_NAME = "onMessage"; - - private Invoker next; - private RuntimeWire runtimeWire; - private JMSResourceFactory jmsResourceFactory; - private JMSBinding jmsBinding; - private JMSMessageProcessor requestMessageProcessor; - private JMSMessageProcessor responseMessageProcessor; - private RuntimeComponentService service; - private List<Operation> serviceOperations; - - - public OperationSelectorJMSDefaultServiceInterceptor(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.service = (RuntimeComponentService)runtimeWire.getTarget().getContract(); - this.serviceOperations = service.getInterfaceContract().getInterface().getOperations(); - } - - public Message invoke(Message msg) { - return next.invoke(invokeRequest(msg)); - } - - public Message invokeRequest(Message msg) { - try { - // get the jms context - JMSBindingContext context = msg.getBindingContext(); - javax.jms.Message jmsMsg = context.getJmsMsg(); - - String operationName = requestMessageProcessor.getOperationName(jmsMsg); - Operation operation = getTargetOperation(operationName, jmsMsg); - msg.setOperation(operation); - - ReferenceParameters parameters = msg.getFrom().getReferenceParameters(); - - if (service.getInterfaceContract().getCallbackInterface() != null) { - - String callbackdestName = jmsMsg.getStringProperty(JMSBindingConstants.CALLBACK_Q_PROPERTY); - if (callbackdestName == null && msg.getOperation().isNonBlocking()) { - // if the request has a replyTo but this service operation is oneway but the service uses callbacks - // then use the replyTo as the callback destination - Destination replyTo = jmsMsg.getJMSReplyTo(); - if (replyTo != null) { - callbackdestName = (replyTo instanceof Queue) ? ((Queue)replyTo).getQueueName() : ((Topic)replyTo).getTopicName(); - } - } - - if (callbackdestName != null) { - // append "jms:" to make it an absolute uri so the invoker can determine it came in on the request - // as otherwise the invoker should use the uri from the service callback binding - parameters.setCallbackReference(new EndpointReferenceImpl("jms:" + callbackdestName)); - } - - String callbackID = jmsMsg.getStringProperty(JMSBindingConstants.CALLBACK_ID_PROPERTY); - if (callbackID != null) { - parameters.setCallbackID(callbackID); - } - } - - return msg; - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } - - protected Operation getTargetOperation(String operationName, javax.jms.Message jmsMsg) { - Operation operation = null; - - if (serviceOperations.size() == 1) { - - // SCA JMS Binding Specification - Rule 1.5.1 line 203 - operation = serviceOperations.get(0); - - } else if (operationName != null) { - - // SCA JMS Binding Specification - Rule 1.5.1 line 205 - for (Operation op : serviceOperations) { - if (op.getName().equals(operationName)) { - operation = op; - break; - } - } - } else if (jmsBinding.getRequestWireFormat() instanceof WireFormatJMSTextXML) { - - OMElement rootElement; - String operationFromPayload; - - try { - if (jmsMsg instanceof TextMessage) { - String xmlPayload = ((TextMessage) jmsMsg).getText(); - - if (xmlPayload != null) { - XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xmlPayload)); - StAXOMBuilder builder = new StAXOMBuilder(reader); - rootElement = builder.getDocumentElement(); - operationFromPayload = rootElement.getLocalName(); - for (Operation op : serviceOperations) { - if (op.getName().equals(operationFromPayload)) { - operation = op; - break; - } - } - } - } else if (jmsMsg instanceof BytesMessage) { - long noOfBytes = ((BytesMessage) jmsMsg).getBodyLength(); - byte[] bytes = new byte[(int) noOfBytes]; - ((BytesMessage) jmsMsg).readBytes(bytes); - - if (bytes != null) { - XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(bytes)); - StAXOMBuilder builder = new StAXOMBuilder(reader); - rootElement = builder.getDocumentElement(); - operationFromPayload = rootElement.getLocalName(); - for (Operation op : serviceOperations) { - if (op.getName().equals(operationFromPayload)) { - operation = op; - break; - } - } - } - } - - } catch (XMLStreamException e) { - //let's ignore this in case the client doesn't want to use a wrapped xml message - } catch (JMSException e) { - throw new JMSBindingException(e); - } - - // If operation is still null we attempt the last rule - if (operation == null) { - - // SCA JMS Binding Specification - Rule 1.5.1 line 207 - for (Operation op : serviceOperations) { - if (op.getName().equals(ON_MESSAGE_METHOD_NAME)) { - operation = op; - break; - } - } - } - } - - if (operation == null) { - throw new JMSBindingException("Can't find operation " + (operationName != null ? operationName : ON_MESSAGE_METHOD_NAME)); - } - - return operation; - } - - public Invoker getNext() { - return next; - } - - public void setNext(Invoker next) { - this.next = next; - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.java deleted file mode 100644 index 1cceb4e382..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.java +++ /dev/null @@ -1,59 +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.runtime; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.provider.OperationSelectorProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; - -/** - * @version $Rev$ $Date$ - */ -public class OperationSelectorJMSDefaultServiceProvider implements OperationSelectorProvider { - private RuntimeComponent component; - private RuntimeComponentService service; - private Binding binding; - - public OperationSelectorJMSDefaultServiceProvider(RuntimeComponent component, RuntimeComponentService service, Binding binding) { - super(); - this.component = component; - this.service = service; - this.binding = binding; - } - - /** - */ - public Interceptor createInterceptor() { - return new OperationSelectorJMSDefaultServiceInterceptor((JMSBinding)binding, - null, - service.getRuntimeWire(binding)); - } - - /** - */ - public String getPhase() { - return Phase.SERVICE_BINDING_OPERATION_SELECTOR; - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java deleted file mode 100644 index e2fc49834e..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java +++ /dev/null @@ -1,136 +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.provider; - -import java.lang.reflect.InvocationTargetException; -import java.util.logging.Logger; - -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.ObjectMessage; -import javax.jms.Session; - -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.osoa.sca.ServiceRuntimeException; - -/** - * Base MessageProcessor for the JMSBinding. - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractMessageProcessor implements JMSMessageProcessor { - private static final Logger logger = Logger.getLogger(AbstractMessageProcessor.class.getName()); - - protected String operationPropertyName; - protected boolean xmlFormat = true; - - public AbstractMessageProcessor(JMSBinding jmsBinding) { - this.operationPropertyName = jmsBinding.getOperationSelectorPropertyName(); - } - - /* - * (non-Javadoc) - * - * @see org.apache.tuscany.binding.jms.OperationAndDataBinding#getOperationName(javax.jms.Message) - */ - public String getOperationName(Message message) { - try { - - return message.getStringProperty(operationPropertyName); - - } catch (JMSException e) { - throw new JMSBindingException("Exception retreiving operation name from message", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.apache.tuscany.binding.jms.OperationAndDataBinding#setOperationName(javax.jms.Message, java.lang.String) - */ - public void setOperationName(String operationName, Message message) { - try { - - message.setStringProperty(operationPropertyName, operationName); - - } catch (JMSException e) { - throw new JMSBindingException("Exception setting the operation name on message", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.apache.tuscany.binding.jms.OperationAndDataBinding#extractPayload(javax.jms.Session, java.lang.Object) - */ - public Message insertPayloadIntoJMSMessage(Session session, Object o) { - return createJMSMessage(session, o); - } - - /* - * (non-Javadoc) - * - * @see org.apache.tuscany.binding.jms.OperationAndDataBinding#extractPayload(javax.jms.Message) - */ - public Object extractPayloadFromJMSMessage(Message msg) { - try { - if (msg.getBooleanProperty(JMSBindingConstants.FAULT_PROPERTY)) { - Object exc = ((ObjectMessage)msg).getObject(); - if (exc instanceof RuntimeException) { - throw new ServiceRuntimeException("remote service exception, see nested exception", (Throwable)exc); - } else { - return new InvocationTargetException((Throwable) exc); - } - } - } catch (JMSException e) { - throw new JMSBindingException(e); - } - return extractPayload(msg); - } - - public Message createFaultMessage(Session session, Throwable o) { - if (session == null) { - logger.fine("no response session to create fault message: " + String.valueOf(o)); - return null; - } - try { - - ObjectMessage message = session.createObjectMessage(); - String causeMsg; - if (o instanceof RuntimeException) { - message.setObject(new RuntimeException(o.getMessage())); - } else { - // for a checked exception return the checked exception - message.setObject(o); - } - message.setBooleanProperty(JMSBindingConstants.FAULT_PROPERTY, true); - return message; - - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } - - protected abstract Object extractPayload(Message msg); - - protected abstract Message createJMSMessage(Session session, Object o); - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java deleted file mode 100644 index 057b58ca11..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java +++ /dev/null @@ -1,85 +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.provider; - -import java.util.logging.Logger; - -import javax.jms.BytesMessage; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.Session; -import javax.jms.TextMessage; - -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; - -/** - * MessageProcessor for sending/receiving javax.jms.BytesMessage with the JMSBinding. - * - * @version $Rev$ $Date$ - */ -public class BytesMessageProcessor extends AbstractMessageProcessor { - private static final Logger logger = Logger.getLogger(AbstractMessageProcessor.class.getName()); - - public BytesMessageProcessor(JMSBinding jmsBinding) { - super(jmsBinding); - } - - @Override - protected Object extractPayload(Message msg) { - try { - - if (!(msg instanceof BytesMessage)) { - throw new IllegalStateException("expecting JMS BytesMessage: " + msg); - } - - long noOfBytes = ((BytesMessage)msg).getBodyLength(); - byte [] bytes = new byte[(int)noOfBytes]; - ((BytesMessage)msg).readBytes(bytes); - return bytes; - - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } - - @Override - protected Message createJMSMessage(Session session, Object o) { - if (session == null) { - logger.fine("no response session to create message: " + String.valueOf(o)); - return null; - } - try { - - // TODO - an experiment. How to enforce a single - // byte array parameter - BytesMessage message = session.createBytesMessage(); - - if (o != null){ - message.writeBytes((byte[])o); - } - - return message; - - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.java deleted file mode 100644 index 1de85ea773..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.java +++ /dev/null @@ -1,30 +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.provider;
-
-import org.apache.tuscany.sca.binding.jms.impl.JMSBinding;
-
-public class DefaultJMSResourceFactoryExtensionPoint implements JMSResourceFactoryExtensionPoint {
-
- public JMSResourceFactory createJMSResourceFactory(JMSBinding binding) {
- return new JMSResourceFactoryImpl(binding.getConnectionFactoryName(), binding.getResponseConnectionFactoryName(), binding.getInitialContextFactoryName(), binding.getJndiURL());
- }
-
-}
diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java deleted file mode 100644 index c9a11dc41e..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.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.provider; - -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.host.jms.JMSHostExtensionPoint; -import org.apache.tuscany.sca.host.jms.JMSServiceListenerFactory; -import org.apache.tuscany.sca.provider.BindingProviderFactory; -import org.apache.tuscany.sca.provider.ReferenceBindingProvider; -import org.apache.tuscany.sca.provider.ServiceBindingProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; - -/** - * A factory from creating the JMS binding provider. - * - * @version $Rev$ $Date$ - */ -public class JMSBindingProviderFactory implements BindingProviderFactory<JMSBinding> { - - private ExtensionPointRegistry extensionPoints; - private JMSResourceFactoryExtensionPoint jmsRFEP; - private JMSServiceListenerFactory serviceListenerFactory; - - public JMSBindingProviderFactory(ExtensionPointRegistry extensionPoints) { - this.extensionPoints = extensionPoints; - - jmsRFEP = (JMSResourceFactoryExtensionPoint)extensionPoints.getExtensionPoint(JMSResourceFactoryExtensionPoint.class); - if (jmsRFEP == null) { - jmsRFEP = new DefaultJMSResourceFactoryExtensionPoint(); - extensionPoints.addExtensionPoint(jmsRFEP); - } - - JMSHostExtensionPoint jmsHostExtensionPoint = (JMSHostExtensionPoint)extensionPoints.getExtensionPoint(JMSHostExtensionPoint.class); - serviceListenerFactory = jmsHostExtensionPoint.getJMSServiceListenerFactory(); - } - - public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component, RuntimeComponentReference reference, JMSBinding binding) { - JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory(binding); - return new JMSBindingReferenceBindingProvider(component, reference, binding, extensionPoints, jmsRF); - } - - public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, RuntimeComponentService service, JMSBinding binding) { - JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory(binding); - return new JMSBindingServiceBindingProvider(component, service, binding, binding, serviceListenerFactory, extensionPoints, jmsRF); - } - - public Class<JMSBinding> getModelType() { - return JMSBinding.class; - } -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java deleted file mode 100644 index 0e44b84ea0..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java +++ /dev/null @@ -1,170 +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.provider; - -import java.util.ArrayList; -import java.util.List; - -import javax.jms.JMSException; - -import org.apache.tuscany.sca.binding.jms.headers.HeaderReferenceInterceptor; -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.transport.TransportReferenceInterceptor; -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.InvocationChain; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; -import org.apache.tuscany.sca.provider.ReferenceBindingProviderRRB; -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.RuntimeWire; - -/** - * Implementation of the JMS reference binding provider. - * - * @version $Rev$ $Date$ - */ -public class JMSBindingReferenceBindingProvider implements ReferenceBindingProviderRRB { - - private RuntimeComponentReference reference; - private JMSBinding jmsBinding; - private JMSResourceFactory jmsResourceFactory; - private RuntimeComponent component; - private InterfaceContract interfaceContract; - private ExtensionPointRegistry extensions; - - private ProviderFactoryExtensionPoint providerFactories; - - private WireFormatProviderFactory requestWireFormatProviderFactory; - private WireFormatProvider requestWireFormatProvider; - - private WireFormatProviderFactory responseWireFormatProviderFactory; - private WireFormatProvider responseWireFormatProvider; - - public JMSBindingReferenceBindingProvider(RuntimeComponent component, RuntimeComponentReference reference, JMSBinding binding, ExtensionPointRegistry extensions, JMSResourceFactory jmsResourceFactory) { - this.reference = reference; - this.jmsBinding = binding; - this.extensions = extensions; - this.component = component; - this.jmsResourceFactory = jmsResourceFactory; - - // Get the factories/providers for operation selection - this.providerFactories = extensions.getExtensionPoint(ProviderFactoryExtensionPoint.class); - - // Get the factories/providers for wire format - this.requestWireFormatProviderFactory = - (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getRequestWireFormat().getClass()); - if (this.requestWireFormatProviderFactory != null){ - this.requestWireFormatProvider = requestWireFormatProviderFactory.createReferenceWireFormatProvider(component, reference, jmsBinding); - } - - this.responseWireFormatProviderFactory = - (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getResponseWireFormat().getClass()); - if (this.responseWireFormatProviderFactory != null){ - this.responseWireFormatProvider = responseWireFormatProviderFactory.createReferenceWireFormatProvider(component, reference, jmsBinding); - } - - // create an interface contract that reflects both request and response - // wire formats - try { - interfaceContract = (InterfaceContract)reference.getInterfaceContract().clone(); - - requestWireFormatProvider.configureWireFormatInterfaceContract(interfaceContract); - responseWireFormatProvider.configureWireFormatInterfaceContract(interfaceContract); - } catch (CloneNotSupportedException ex){ - interfaceContract = reference.getInterfaceContract(); - } - } - - public Invoker createInvoker(Operation operation) { - - if (jmsBinding.getDestinationName() == null) { - if (!reference.isCallback()) { - throw new JMSBindingException("No destination specified for reference " + reference.getName()); - } - } - - Invoker invoker = null; - invoker = new RRBJMSBindingInvoker(jmsBinding, operation, jmsResourceFactory, reference); - - return invoker; - } - - public boolean supportsOneWayInvocation() { - return true; - } - - public InterfaceContract getBindingInterfaceContract() { - return interfaceContract; - } - - public void start() { - - } - - public void stop() { - try { - jmsResourceFactory.closeConnection(); - jmsResourceFactory.closeResponseConnection(); - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } - - /* - * set up the reference binding wire with the right set of jms reference - * interceptors - */ - public void configureBindingChain(RuntimeWire runtimeWire) { - - InvocationChain bindingChain = runtimeWire.getBindingInvocationChain(); - - // add transport interceptor - bindingChain.addInterceptor(Phase.REFERENCE_BINDING_TRANSPORT, - new TransportReferenceInterceptor(jmsBinding, - jmsResourceFactory, - runtimeWire) ); - - // add request wire format - 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()); - } - - // add the header processor that comes after the wire formatter but before the - // policy interceptors - bindingChain.addInterceptor(Phase.REFERENCE_BINDING_WIREFORMAT, - new HeaderReferenceInterceptor(jmsBinding, - jmsResourceFactory, - runtimeWire) ); - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java deleted file mode 100644 index 4a86a92b0e..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java +++ /dev/null @@ -1,214 +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.provider; - -import java.util.logging.Logger; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; -import org.apache.tuscany.sca.binding.jms.transport.TransportServiceInterceptor; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.host.jms.JMSServiceListener; -import org.apache.tuscany.sca.host.jms.JMSServiceListenerDetails; -import org.apache.tuscany.sca.host.jms.JMSServiceListenerFactory; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.invocation.InvocationChain; -import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.provider.OperationSelectorProvider; -import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory; -import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; -import org.apache.tuscany.sca.provider.ServiceBindingProviderRRB; -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.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; - -/** - * Implementation of the JMS service binding provider. - * - * @version $Rev$ $Date$ - */ -public class JMSBindingServiceBindingProvider implements ServiceBindingProviderRRB, JMSServiceListenerDetails { - private static final Logger logger = Logger.getLogger(JMSBindingServiceBindingProvider.class.getName()); - - private RuntimeComponentService service; - private Binding targetBinding; - private JMSBinding jmsBinding; - private JMSResourceFactory jmsResourceFactory; - private JMSServiceListenerFactory serviceListenerFactory; - private JMSServiceListener serviceListener; - - private RuntimeComponent component; - private InterfaceContract interfaceContract; - - private ProviderFactoryExtensionPoint providerFactories; - private ModelFactoryExtensionPoint modelFactories; - - private MessageFactory messageFactory; - - private OperationSelectorProviderFactory operationSelectorProviderFactory; - private OperationSelectorProvider operationSelectorProvider; - - private WireFormatProviderFactory requestWireFormatProviderFactory; - private WireFormatProvider requestWireFormatProvider; - - private WireFormatProviderFactory responseWireFormatProviderFactory; - private WireFormatProvider responseWireFormatProvider; - - public JMSBindingServiceBindingProvider(RuntimeComponent component, RuntimeComponentService service, Binding targetBinding, JMSBinding binding, JMSServiceListenerFactory serviceListenerFactory, ExtensionPointRegistry extensionPoints, JMSResourceFactory jmsResourceFactory) { - this.component = component; - this.service = service; - this.jmsBinding = binding; - this.serviceListenerFactory = serviceListenerFactory; - this.targetBinding = targetBinding; - this.jmsResourceFactory = jmsResourceFactory; - - // Set the default destination when using a connection factory. - // If an activation spec is being used, do not set the destination - // because the activation spec provides the destination. - if (jmsBinding.getDestinationName() == null && - (jmsBinding.getActivationSpecName() == null || jmsBinding.getActivationSpecName().equals(""))) { - if (!service.isCallback()) { - // use the SCA service name as the default destination name - jmsBinding.setDestinationName(service.getName()); - } - } - - // Get Message factory - modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); - messageFactory = modelFactories.getFactory(MessageFactory.class); - - // Get the factories/providers for operation selection - this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class); - this.operationSelectorProviderFactory = - (OperationSelectorProviderFactory)providerFactories.getProviderFactory(jmsBinding.getOperationSelector().getClass()); - if (this.operationSelectorProviderFactory != null){ - this.operationSelectorProvider = operationSelectorProviderFactory.createServiceOperationSelectorProvider(component, service, jmsBinding); - } - - // Get the factories/providers for wire format - this.requestWireFormatProviderFactory = - (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getRequestWireFormat().getClass()); - if (this.requestWireFormatProviderFactory != null){ - this.requestWireFormatProvider = requestWireFormatProviderFactory.createServiceWireFormatProvider(component, service, jmsBinding); - } - - this.responseWireFormatProviderFactory = - (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getResponseWireFormat().getClass()); - if (this.responseWireFormatProviderFactory != null){ - this.responseWireFormatProvider = responseWireFormatProviderFactory.createServiceWireFormatProvider(component, service, jmsBinding); - } - - // create an interface contract that reflects both request and response - // wire formats - try { - interfaceContract = (InterfaceContract)service.getInterfaceContract().clone(); - - requestWireFormatProvider.configureWireFormatInterfaceContract(interfaceContract); - responseWireFormatProvider.configureWireFormatInterfaceContract(interfaceContract); - } catch (CloneNotSupportedException ex){ - interfaceContract = service.getInterfaceContract(); - } - } - - public InterfaceContract getBindingInterfaceContract() { - return interfaceContract; - } - - public boolean supportsOneWayInvocation() { - return true; - } - - public void start() { - try { - - this.serviceListener = serviceListenerFactory.createJMSServiceListener(this); - serviceListener.start(); - - } catch (Exception e) { - throw new JMSBindingException("Error starting JMSServiceBinding", e); - } - } - - public void stop() { - try { - serviceListener.stop(); - } catch (Exception e) { - throw new JMSBindingException("Error stopping JMSServiceBinding", e); - } - } - - public String getDestinationName() { - return serviceListener.getDestinationName(); - } - - /* - * Adds JMS specific interceptors to the binding chain - */ - public void configureBindingChain(RuntimeWire runtimeWire) { - - InvocationChain bindingChain = runtimeWire.getBindingInvocationChain(); - - // add transport interceptor - bindingChain.addInterceptor(Phase.SERVICE_BINDING_TRANSPORT, - new TransportServiceInterceptor(jmsBinding, - jmsResourceFactory, - runtimeWire) ); - - // add operation selector interceptor - bindingChain.addInterceptor(operationSelectorProvider.getPhase(), - operationSelectorProvider.createInterceptor()); - - // add request wire format - 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()); - } - } - - public RuntimeComponent getComponent() { - return component; - } - - public RuntimeComponentService getService() { - return service; - } - - public Binding getTargetBinding() { - return targetBinding; - } - - public JMSBinding getJmsBinding() { - return jmsBinding; - } - - public MessageFactory getMessageFactory() { - return messageFactory; - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessor.java deleted file mode 100644 index 821b9d7873..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessor.java +++ /dev/null @@ -1,55 +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.provider; - -import javax.jms.Message; -import javax.jms.Session; - -/** - * Interface for a component that does operation selection and message payload processing - * - * @version $Rev$ $Date$ - */ -public interface JMSMessageProcessor { - - /** - * Get the operation name from a JMS Message - */ - String getOperationName(Message message); - - /** - * Set the operation name on a JMS Message - */ - void setOperationName(String operationName, Message message); - - /** - * Extracts the payload from a JMS Message - */ - Object extractPayloadFromJMSMessage(Message msg); - - /** - * Create a JMS Message containing the payload - */ - Message insertPayloadIntoJMSMessage(Session session, Object payload); - - /** - * Create a JMS Message for reporting an exception - */ - Message createFaultMessage(Session session, Throwable responsePayload); -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java deleted file mode 100644 index 699b1cb176..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java +++ /dev/null @@ -1,75 +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.provider; - -import java.lang.reflect.Constructor; - -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; - -/** - * Utility methods to load JMS message processors. - * - * @version $Rev: $ $Date: $ - */ -public class JMSMessageProcessorUtil { - - /** - * Used to create instances of the JMSResourceFactory and RequestMessageProcessor and ResponseMessageProcessor from - * string based class name provided in the configuration - * - * @param cl ClassLoader - * @param className the string based class name to load and instantiate - * @return the new object - */ - private static Object instantiate(ClassLoader cl, String className, JMSBinding binding) { - Object instance; - if (cl == null) { - cl = binding.getClass().getClassLoader(); - } - - try { - Class<?> clazz; - - try { - clazz = cl.loadClass(className); - } catch (ClassNotFoundException e) { - clazz = binding.getClass().getClassLoader().loadClass(className); - } - - Constructor<?> constructor = clazz.getDeclaredConstructor(new Class[] {JMSBinding.class}); - instance = constructor.newInstance(binding); - - } catch (Throwable e) { - throw new JMSBindingException("Exception instantiating OperationAndDataBinding class", e); - } - - return instance; - } - - public static JMSMessageProcessor getRequestMessageProcessor(JMSBinding binding) { - return (JMSMessageProcessor)instantiate(null, binding.getRequestMessageProcessorName(), binding); - } - - public static JMSMessageProcessor getResponseMessageProcessor(JMSBinding binding) { - return (JMSMessageProcessor)instantiate(null, binding.getResponseMessageProcessorName(), binding); - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java deleted file mode 100644 index 7062d0455d..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java +++ /dev/null @@ -1,92 +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.provider;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Session;
-import javax.naming.NamingException;
-
-public interface JMSResourceFactory {
-
- /*
- * This is a simple implementation where a connection is created per binding Ideally the resource factory should be
- * able to leverage the host environment to provide connection pooling if it can. E.g. if Tuscany is running inside
- * an AppServer Then we could leverage the JMS resources it provides
- *
- * @see org.apache.tuscany.binding.jms.JMSResourceFactory#getConnection()
- */
- public abstract Connection getConnection() throws NamingException, JMSException;
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.tuscany.binding.jms.JMSResourceFactory#createSession()
- */
- public abstract Session createSession() throws JMSException, NamingException;
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.tuscany.binding.jms.JMSResourceFactory#startConnection()
- */
- public abstract void startConnection() throws JMSException, NamingException;
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.tuscany.binding.jms.JMSResourceFactory#closeConnection()
- */
- public abstract void closeConnection() throws JMSException;
-
- public abstract Destination lookupDestination(String destName) throws NamingException;
-
- /**
- * You can create a destination in ActiveMQ (and have it appear in JNDI) by putting "dynamicQueues/" in front of the queue name being looked up
- */
- public abstract Destination createDestination(String jndiName) throws NamingException;
-
- /*
- * This is a simple implementation where a connection is created per binding Ideally the resource factory should be
- * able to leverage the host environment to provide connection pooling if it can. E.g. if Tuscany is running inside
- * an AppServer Then we could leverage the JMS resources it provides
- *
- * @see org.apache.tuscany.binding.jms.JMSResourceFactory#getConnection()
- */
- public abstract Connection getResponseConnection() throws NamingException, JMSException;
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.tuscany.binding.jms.JMSResourceFactory#createSession()
- */
- public abstract Session createResponseSession() throws JMSException, NamingException;
-
-
- public abstract void closeResponseConnection() throws JMSException;
-
- /*
- * Indicates whether connections obtained using getConnection() or getResponseConnection()
- * must be closed after each use. This is necessary in environments where connections are
- * shared with other users, or where connections cannot be held across transaction boundaries.
- */
- public abstract boolean isConnectionClosedAfterUse();
-}
diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.java deleted file mode 100644 index 57fbfb3215..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.java +++ /dev/null @@ -1,28 +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.provider;
-
-import org.apache.tuscany.sca.binding.jms.impl.JMSBinding;
-
-public interface JMSResourceFactoryExtensionPoint {
-
- JMSResourceFactory createJMSResourceFactory(JMSBinding binding);
-
-}
diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java deleted file mode 100644 index 5e9cce0c98..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java +++ /dev/null @@ -1,269 +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.provider; - -import java.util.Properties; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Session; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; - -/** - * Abstracts away any JMS provide specific feature from the JMS binding - * - * @version $Rev$ $Date$ - */ -public class JMSResourceFactoryImpl implements JMSResourceFactory { - - protected String initialContextFactoryName; - protected String connectionFactoryName = "ConnectionFactory"; - protected String jndiURL; - - protected Connection connection; - protected Context context; - protected boolean isConnectionStarted; - private Connection responseConnection; - private String responseConnectionFactoryName; - - public JMSResourceFactoryImpl(String connectionFactoryName, String responseConnectionFactoryName, String initialContextFactoryName, String jndiURL) { - if (connectionFactoryName != null && connectionFactoryName.trim().length() > 0) { - this.connectionFactoryName = connectionFactoryName.trim(); - } - if (responseConnectionFactoryName != null && responseConnectionFactoryName.trim().length() > 0) { - this.responseConnectionFactoryName = responseConnectionFactoryName.trim(); - } - if (initialContextFactoryName != null && initialContextFactoryName.trim().length() > 0) { - this.initialContextFactoryName = initialContextFactoryName.trim(); - } - if (jndiURL != null) { - this.jndiURL = jndiURL.trim(); - } - } - - /* - * This is a simple implementation where a connection is created per binding Ideally the resource factory should be - * able to leverage the host environment to provide connection pooling if it can. E.g. if Tuscany is running inside - * an AppServer Then we could leverage the JMS resources it provides - * - * @see org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory#getConnection() - */ - public Connection getConnection() throws NamingException, JMSException { - if (connection == null) { - createConnection(); - } - return connection; - } - - /* - * (non-Javadoc) - * - * @see org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory#createSession() - */ - public Session createSession() throws JMSException, NamingException { - return getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE); - } - - /* - * (non-Javadoc) - * - * @see org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory#startConnection() - */ - public void startConnection() throws JMSException, NamingException { - if (!isConnectionStarted) { - getConnection().start(); - isConnectionStarted = true; - } - } - - /* - * (non-Javadoc) - * - * @see org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory#closeConnection() - */ - public void closeConnection() throws JMSException { - if (connection != null) { - try { - connection.close(); - } catch (JMSException e) { - // if using an embedded broker then when shutting down Tuscany the broker may get closed - // before this stop method is called. I can't see how to detect that so for now just - // ignore the exception if the message is that the transport is already disposed - if (!e.getMessage().contains("disposed")) { - throw e; - } - } - } - } - - protected void createConnection() throws NamingException, JMSException { - ConnectionFactory connectionFactory = (ConnectionFactory)jndiLookUp(connectionFactoryName); - if (connectionFactory == null) { - throw new JMSBindingException("connection factory not found: " + connectionFactoryName); - } - connection = connectionFactory.createConnection(); - } - - protected synchronized Context getInitialContext() throws NamingException { - if (context == null) { - Properties props = new Properties(); - - if (initialContextFactoryName != null) { - props.setProperty(Context.INITIAL_CONTEXT_FACTORY, initialContextFactoryName); - } - if (jndiURL != null) { - props.setProperty(Context.PROVIDER_URL, jndiURL); - } - - initJREEnvironment(props); - - context = new InitialContext(props); - } - return context; - } - - /** - * If using the WAS JMS Client with a non-IBM JRE then an additional - * environment property needs to be set to initialize the ORB correctly. - * See: http://www-1.ibm.com/support/docview.wss?uid=swg24012804 - */ - protected void initJREEnvironment(Properties props) { - if ("com.ibm.websphere.naming.WsnInitialContextFactory".equals(props.get(Context.INITIAL_CONTEXT_FACTORY))) { - String vendor = System.getProperty("java.vendor"); - if (vendor == null || !vendor.contains("IBM")) { - props.setProperty("com.ibm.CORBA.ORBInit", "com.ibm.ws.sib.client.ORB"); - } - } - } - - /* (non-Javadoc) - * @see org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory#lookupDestination(java.lang.String) - */ - public Destination lookupDestination(String destName) throws NamingException { - if (destName == null) { - return null; - } - - Destination dest = (Destination)jndiLookUp(destName); - if (dest == null) { - dest = lookupPhysical(destName); - } - return dest; - } - - protected Destination lookupPhysical(String jndiName) { - - // TODO: the SCA JMS spec says a destination name may be a non-jndi plain destination name - -// Session session = null; -// try { -// -// Destination dest; -// session = createSession(); -// dest = session.createQueue(jndiName); -// return dest; -// -// } catch (JMSException e) { -// throw new JMSBindingException(e); -// } catch (NamingException e) { -// throw new JMSBindingException(e); -// } finally { -// if (session != null) { -// try { -// session.close(); -// } catch (JMSException e) { -// throw new JMSBindingException(e); -// } -// } -// } - return null; - } - - /* (non-Javadoc) - * @see org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory#createDestination(java.lang.String) - */ - public Destination createDestination(String jndiName) throws NamingException { - return lookupDestination("dynamicQueues/" + jndiName); - } - - protected Object jndiLookUp(String name) { - Object o = null; - try { - o = getInitialContext().lookup("java:comp/env/" + name); - } catch (Exception ex) { - // ignore - } - if (o == null) { - try { - o = getInitialContext().lookup(name); - } catch (NamingException ex) { - // ignore - } - } - return o; - } - - public Session createResponseSession() throws JMSException, NamingException { - return getResponseConnection().createSession(false, Session.AUTO_ACKNOWLEDGE); - } - - public Connection getResponseConnection() throws NamingException, JMSException { - if (responseConnection == null) { - if (responseConnectionFactoryName != null) { - ConnectionFactory connectionFactory = (ConnectionFactory)jndiLookUp(responseConnectionFactoryName); - if (connectionFactory == null) { - throw new JMSBindingException("connection factory not found: " + responseConnectionFactoryName); - } - responseConnection = connectionFactory.createConnection(); - } else { - // if no response connection is defined in the SCDL use the request connection - responseConnection = getConnection(); - } - } - return responseConnection; - } - - public void closeResponseConnection() throws JMSException { - if (responseConnection != null && !responseConnection.equals(connection)) { - try { - responseConnection.close(); - } catch (JMSException e) { - // if using an embedded broker then when shutting down Tuscany the broker may get closed - // before this stop method is called. I can't see how to detect that so for now just - // ignore the exception if the message is that the transport is already disposed - if (!e.getMessage().contains("disposed")) { - throw e; - } - } - } - } - - public boolean isConnectionClosedAfterUse() { - // It is assumed this resource factory is used in an environment - // where the connection can be held for the life of the binding. - return false; - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java deleted file mode 100644 index 97d3d861f4..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java +++ /dev/null @@ -1,99 +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.provider; - -import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; -import java.util.logging.Logger; - -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.ObjectMessage; -import javax.jms.Session; - -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; -import org.osoa.sca.ServiceRuntimeException; - -/** - * MessageProcessor for sending/receiving Serializable objects with the JMSBinding. - * - * @version $Rev$ $Date$ - */ -public class ObjectMessageProcessor extends AbstractMessageProcessor { - private static final Logger logger = Logger.getLogger(ObjectMessageProcessor.class.getName()); - - public ObjectMessageProcessor(JMSBinding jmsBinding) { - super(jmsBinding); - } - - @Override - protected Object extractPayload(Message msg) { - try { - - return ((ObjectMessage)msg).getObject(); - - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } - - @Override - protected Message createJMSMessage(Session session, Object o) { - if (session == null) { - logger.fine("no response session to create message: " + String.valueOf(o)); - return null; - } - try { - - ObjectMessage message = session.createObjectMessage(); - - if (o != null){ - if (!(o instanceof Serializable)) { - throw new IllegalStateException("JMS ObjectMessage payload not Serializable: " + o); - } - - message.setObject((Serializable)o); - } - - return message; - - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } - - @Override - public Object extractPayloadFromJMSMessage(Message msg) { - try { - Object o = ((ObjectMessage)msg).getObject(); - if (o instanceof Throwable ) { - if (o instanceof RuntimeException) { - throw new ServiceRuntimeException("remote service exception, see nested exception", (RuntimeException)o); - } else { - return new InvocationTargetException((Throwable) o); - } - } - } catch (JMSException e) { - throw new JMSBindingException(e); - } - return extractPayload(msg); - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java deleted file mode 100644 index e2b75de5b9..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java +++ /dev/null @@ -1,274 +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.provider; - -import java.lang.reflect.InvocationTargetException; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Session; -import javax.naming.NamingException; - -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.interfacedef.Operation; -import org.apache.tuscany.sca.interfacedef.util.FaultException; -import org.apache.tuscany.sca.invocation.DataExchangeSemantics; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeWire; -import org.osoa.sca.ServiceRuntimeException; - -/** - * Invoker for the JMS binding. - * - * @version $Rev$ $Date$ - */ -public class RRBJMSBindingInvoker implements Invoker, DataExchangeSemantics { - - protected Operation operation; - protected String operationName; - - protected JMSBinding jmsBinding; - protected JMSResourceFactory jmsResourceFactory; - protected JMSMessageProcessor requestMessageProcessor; - protected JMSMessageProcessor responseMessageProcessor; - protected Destination bindingRequestDest; - protected Destination bindingReplyDest; - protected RuntimeComponentReference reference; - protected RuntimeWire runtimeWire; - - public RRBJMSBindingInvoker(JMSBinding jmsBinding, Operation operation, JMSResourceFactory jmsResourceFactory, RuntimeComponentReference reference) { - - this.operation = operation; - operationName = operation.getName(); - - this.jmsBinding = jmsBinding; - this.jmsResourceFactory = jmsResourceFactory; - this.reference = reference; - this.runtimeWire = reference.getRuntimeWire(jmsBinding); - this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding); - this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding); - - try { - // If this is a callback reference, the destination is determined dynamically based on - // properties of the inbound service request. We should not look for or require a - // statically-configured destination unless a message is received that does not have - // the necessary properties. - if (!reference.isCallback()) { - bindingRequestDest = lookupDestination(); - } - bindingReplyDest = lookupResponseDestination(); - } catch (NamingException e) { - throw new JMSBindingException(e); - } - } - - /** - * Looks up the Destination Queue for the JMS Binding - * - * @return The Destination Queue - * @throws NamingException Failed to lookup Destination Queue - * @throws JMSBindingException Failed to lookup Destination Queue - * @see #lookupDestinationQueue(boolean) - */ - protected Destination lookupDestination() throws NamingException, JMSBindingException { - return lookupDestinationQueue(false); - } - - /** - * Looks up the Destination Response Queue for the JMS Binding - * - * @return The Destination Response Queue - * @throws NamingException Failed to lookup Destination Response Queue - * @throws JMSBindingException Failed to lookup Destination Response Queue - * @see #lookupDestinationQueue(boolean) - */ - protected Destination lookupResponseDestination() throws NamingException, JMSBindingException { - return lookupDestinationQueue(true); - } - - /** - * Looks up the Destination Queue for the JMS Binding. - * <p> - * What happens in the look up will depend on the create mode specified for the JMS Binding: - * <ul> - * <li>always - the JMS queue is always created. It is an error if the queue already exists - * <li>ifnotexist - the JMS queue is created if it does not exist. It is not an error if the queue already exists - * <li>never - the JMS queue is never created. It is an error if the queue does not exist - * </ul> - * See the SCA JMS Binding specification for more information. - * <p> - * - * @param isReponseQueue <code>true</code> if we are creating a response queue. - * <code>false</code> if we are creating a request queue - * @return The Destination queue. - * @throws NamingException Failed to lookup JMS queue - * @throws JMSBindingException Failed to lookup JMS Queue. Probable cause is that - * the JMS queue's current existence/non-existence is not compatible with - * the create mode specified on the binding - */ - protected Destination lookupDestinationQueue(boolean isReponseQueue) throws NamingException, JMSBindingException { - String queueName; - String queueType; - String qCreateMode; - - if (isReponseQueue) { - queueName = jmsBinding.getResponseDestinationName(); - queueType = "JMS Response Destination "; - qCreateMode = jmsBinding.getResponseDestinationCreate(); - if (queueName == null) { - return null; - } - } else { - queueName = jmsBinding.getDestinationName(); - queueType = "JMS Destination "; - qCreateMode = jmsBinding.getDestinationCreate(); - } - - Destination dest = jmsResourceFactory.lookupDestination(queueName); - - if (qCreateMode.equals(JMSBindingConstants.CREATE_ALWAYS)) { - // In this mode, the queue must not already exist as we are creating it - if (dest != null) { - throw new JMSBindingException(queueType + queueName - + " already exists but has create mode of \"" - + qCreateMode - + "\" while registering binding " - + jmsBinding.getName() - + " invoker"); - } - // Create the queue - dest = jmsResourceFactory.createDestination(queueName); - - } else if (qCreateMode.equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) { - // In this mode, the queue may nor may not exist. It will be created if it does not exist - if (dest == null) { - dest = jmsResourceFactory.createDestination(queueName); - } - - } else if (qCreateMode.equals(JMSBindingConstants.CREATE_NEVER)) { - // In this mode, the queue must have already been created. - if (dest == null) { - throw new JMSBindingException(queueType + queueName - + " not found but create mode of \"" - + qCreateMode - + "\" while registering binding " - + jmsBinding.getName() - + " invoker"); - } - } - - // Make sure we ended up with a queue - if (dest == null) { - throw new JMSBindingException(queueType + queueName - + " not found with create mode of \"" - + qCreateMode - + "\" while registering binding " - + jmsBinding.getName() - + " invoker"); - } - - return dest; - } - - public org.apache.tuscany.sca.invocation.Message invoke(org.apache.tuscany.sca.invocation.Message tuscanyMsg) { - try { - // populate the message context with JMS binding information - JMSBindingContext context = new JMSBindingContext(); - context.setJmsResourceFactory(jmsResourceFactory); - tuscanyMsg.setBindingContext(context); - - // get a jms session to cover the creation and sending of the message - Session session = context.getJmsSession(); - - context.setRequestDestination(getRequestDestination(tuscanyMsg, session)); - context.setReplyToDestination(getReplyToDestination(session)); - - try { - tuscanyMsg = runtimeWire.getBindingInvocationChain().getHeadInvoker().invoke(tuscanyMsg); - } catch (ServiceRuntimeException e) { - if (e.getCause() instanceof InvocationTargetException) { - if ((e.getCause().getCause() instanceof RuntimeException)) { - tuscanyMsg.setFaultBody(e.getCause()); - } else { - tuscanyMsg.setFaultBody(((InvocationTargetException)e.getCause()).getTargetException()); - } - } else if (e.getCause() instanceof FaultException) { - tuscanyMsg.setFaultBody(e.getCause()); - } else { - tuscanyMsg.setFaultBody(e); - } - } catch (IllegalStateException e) { - tuscanyMsg.setFaultBody(e); - } catch (Throwable e) { - tuscanyMsg.setFaultBody(e); - } finally { - context.closeJmsSession(); - if (jmsResourceFactory.isConnectionClosedAfterUse()) { - jmsResourceFactory.closeConnection(); - } - } - - return tuscanyMsg; - } catch (Exception e) { - throw new JMSBindingException(e); - } - } - - protected Destination getRequestDestination(org.apache.tuscany.sca.invocation.Message tuscanyMsg, Session session) throws JMSBindingException, NamingException, JMSException { - Destination requestDestination; - if (reference.isCallback()) { - String toURI = tuscanyMsg.getTo().getURI(); - if (toURI != null && toURI.startsWith("jms:")) { - // the msg to uri contains the callback destination name - // this is an jms physical name not a jndi name so need to use session.createQueue - requestDestination = session.createQueue(toURI.substring(4)); - } else { - requestDestination = lookupDestination(); - } - } else { - requestDestination = bindingRequestDest; - } - - return requestDestination; - } - - protected Destination getReplyToDestination(Session session) throws JMSException, JMSBindingException, NamingException { - Destination replyToDest; - if (operation.isNonBlocking()) { - replyToDest = null; - } else { - if (bindingReplyDest != null) { - replyToDest = bindingReplyDest; - } else { - replyToDest = session.createTemporaryQueue(); - } - } - return replyToDest; - } - - public boolean allowsPassByReference() { - // JMS always pass by value - return true; - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.java deleted file mode 100644 index c1b5e6562d..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.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.provider; - -import java.util.logging.Logger; - -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.Session; -import javax.jms.TextMessage; - -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; - -/** - * MessageProcessor for sending/receiving javax.jms.TextMessage with the JMSBinding. - * - * @version $Rev$ $Date$ - */ -public class TextMessageProcessor extends AbstractMessageProcessor { - private static final Logger logger = Logger.getLogger(TextMessageProcessor.class.getName()); - - public TextMessageProcessor(JMSBinding jmsBinding) { - super(jmsBinding); - } - - @Override - protected Object extractPayload(Message msg) { - try { - - if (!(msg instanceof TextMessage)) { - throw new IllegalStateException("expecting JMS TextMessage: " + msg); - } - - return ((TextMessage)msg).getText(); - - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } - - @Override - protected Message createJMSMessage(Session session, Object o) { - if (session == null) { - logger.fine("no response session to create message: " + String.valueOf(o)); - return null; - } - try { - - TextMessage message = session.createTextMessage(); - - if (o != null){ - message.setText(String.valueOf(o)); - } - - return message; - - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java deleted file mode 100644 index 8794f80126..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java +++ /dev/null @@ -1,129 +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.provider; - -import java.io.StringReader; -import java.util.logging.Logger; - -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.impl.builder.StAXOMBuilder; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; -import org.apache.tuscany.sca.interfacedef.util.FaultException; - -/** - * MessageProcessor for sending/receiving XML javax.jms.TextMessage with the JMSBinding. - * - * @version $Rev$ $Date$ - */ -public class XMLTextMessageProcessor extends AbstractMessageProcessor { - private static final Logger logger = Logger.getLogger(XMLTextMessageProcessor.class.getName()); - - public XMLTextMessageProcessor(JMSBinding jmsBinding) { - super(jmsBinding); - } - - @Override - protected Object extractPayload(Message msg) { - try { - - String xml = ((TextMessage)msg).getText(); - Object os; - if (xml != null) { - XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml)); - StAXOMBuilder builder = new StAXOMBuilder(reader); - os = builder.getDocumentElement(); - } else { - os = null; - } - return os; - - } catch (XMLStreamException e) { - throw new JMSBindingException(e); - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } - - @Override - public Object extractPayloadFromJMSMessage(Message msg) { - if (msg instanceof TextMessage) { - return extractPayload(msg); - } else { - return super.extractPayloadFromJMSMessage(msg); - } - } - - @Override - protected Message createJMSMessage(Session session, Object o) { - if (session == null) { - logger.fine("no response session to create message: " + String.valueOf(o)); - return null; - } - try { - - TextMessage message = session.createTextMessage(); - - if (o instanceof OMElement) { - message.setText(o.toString()); - } else if ((o instanceof Object[]) && ((Object[])o)[0] instanceof OMElement) { - message.setText(((Object[])o)[0].toString()); - } else if (o != null) { - throw new IllegalStateException("expecting OMElement payload: " + o); - } - - return message; - - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } - - @Override - public Message createFaultMessage(Session session, Throwable o) { - if (session == null) { - logger.fine("no response session to create fault message: " + String.valueOf(o)); - return null; - } - if (o instanceof FaultException) { - try { - - TextMessage message = session.createTextMessage(); - message.setText(String.valueOf(((FaultException)o).getFaultInfo())); - message.setBooleanProperty(JMSBindingConstants.FAULT_PROPERTY, true); - return message; - - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } else { - return super.createFaultMessage(session, o); - } - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java deleted file mode 100644 index 8382e3874f..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java +++ /dev/null @@ -1,167 +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.transport; - -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.naming.NamingException; - -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.RuntimeComponentReference; -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 TransportReferenceInterceptor implements Interceptor { - - private Invoker next; - private RuntimeWire runtimeWire; - private JMSResourceFactory jmsResourceFactory; - private JMSBinding jmsBinding; - private JMSMessageProcessor requestMessageProcessor; - private JMSMessageProcessor responseMessageProcessor; - private RuntimeComponentReference reference; - - public TransportReferenceInterceptor(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.reference = (RuntimeComponentReference)runtimeWire.getSource().getContract(); - } - - public Message invoke(Message msg) { - Message responseMsg = invokeRequest(msg); - - // get the jms context - JMSBindingContext context = msg.getBindingContext(); - - if (context.getReplyToDestination() == null) { - responseMsg.setBody(null); - } else { - responseMsg = invokeResponse(msg); - } - - return responseMsg; - } - - public Message invokeRequest(Message msg) { - try { - // get the jms context - JMSBindingContext context = msg.getBindingContext(); - Session session = context.getJmsSession(); - - MessageProducer producer = session.createProducer(context.getRequestDestination()); - - // Set JMS header attributes in producer, not message. - String opName = msg.getOperation().getName(); - if (jmsBinding.getOperationJMSTimeToLive(msg.getOperation().getName()) != null) { - producer.setTimeToLive(jmsBinding.getOperationJMSTimeToLive(msg.getOperation().getName())); - } - Integer priority = jmsBinding.getOperationJMSPriority( opName ); - if (priority != null) { - producer.setPriority(priority.intValue()); - } - Boolean deliveryModePersistent = jmsBinding.getOperationJMSDeliveryMode(opName); - if (deliveryModePersistent != null) { - if (deliveryModePersistent.booleanValue()) - producer.setDeliveryMode(javax.jms.DeliveryMode.PERSISTENT); - else - producer.setDeliveryMode(javax.jms.DeliveryMode.NON_PERSISTENT); - } - - try { - producer.send((javax.jms.Message)msg.getBody()); - } finally { - producer.close(); - } - return msg; - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } - - public Message invokeResponse(Message msg) { - JMSBindingContext context = msg.getBindingContext(); - try { - Session session = context.getJmsResponseSession(); - - javax.jms.Message requestMessage = (javax.jms.Message)msg.getBody(); - - String msgSelector = "JMSCorrelationID = '" + - requestMessage.getJMSMessageID() + - "'"; - MessageConsumer consumer = session.createConsumer(context.getReplyToDestination(), msgSelector); - - javax.jms.Message replyMsg; - try { - context.getJmsResourceFactory().startConnection(); - //jmsResourceFactory.startConnection(); - replyMsg = consumer.receive(context.getTimeToLive()); - } finally { - consumer.close(); - } - if (replyMsg == null) { - throw new JMSBindingException("No reply message received on " + - context.getReplyToDestination() + - " for message id " + - requestMessage.getJMSMessageID()); - } - - msg.setBody(replyMsg); - return msg; - } catch (JMSException e) { - throw new JMSBindingException(e); - } catch (NamingException e) { - throw new JMSBindingException(e); - } finally { - try { - context.closeJmsResponseSession(); - if (jmsResourceFactory.isConnectionClosedAfterUse()) - jmsResourceFactory.closeResponseConnection(); - } catch (JMSException e) { - } - } - } - - public Invoker getNext() { - return next; - } - - public void setNext(Invoker next) { - this.next = next; - } -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java deleted file mode 100644 index 6cc7fff593..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java +++ /dev/null @@ -1,190 +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.transport; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.naming.NamingException; - -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.core.assembly.EndpointReferenceImpl; -import org.apache.tuscany.sca.interfacedef.Operation; -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.EndpointReference; -import org.apache.tuscany.sca.runtime.ReferenceParameters; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -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 TransportServiceInterceptor implements Interceptor { - private static final Logger logger = Logger.getLogger(TransportServiceInterceptor.class.getName()); - - private Invoker next; - private RuntimeWire runtimeWire; - private JMSResourceFactory jmsResourceFactory; - private JMSBinding jmsBinding; - private JMSMessageProcessor requestMessageProcessor; - private JMSMessageProcessor responseMessageProcessor; - private RuntimeComponentService service; - private String correlationScheme; - - - public TransportServiceInterceptor(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.service = (RuntimeComponentService)runtimeWire.getTarget().getContract(); - this.correlationScheme = jmsBinding.getCorrelationScheme(); - } - - public Message invoke(Message msg) { - try { - return invokeResponse(next.invoke(invokeRequest(msg))); - } catch (Throwable e) { - logger.log(Level.SEVERE, "Exception invoking service '" + service.getName(), e); - JMSBindingContext context = msg.getBindingContext(); - javax.jms.Message replyJMSMsg = responseMessageProcessor.createFaultMessage(context.getJmsResponseSession(), - (Throwable)e); - msg.setBody(replyJMSMsg); - invokeResponse(msg); - return msg; - } finally { - try { - ((JMSBindingContext)msg.getBindingContext()).closeJmsResponseSession(); - if (jmsResourceFactory.isConnectionClosedAfterUse()) - jmsResourceFactory.closeResponseConnection(); - } catch (JMSException e) { - } - } - } - - public Message invokeRequest(Message msg) { - try { - JMSBindingContext context = msg.getBindingContext(); - javax.jms.Message requestJMSMsg = context.getJmsMsg(); - - EndpointReference from = new EndpointReferenceImpl(null); - msg.setFrom(from); - from.setCallbackEndpoint(new EndpointReferenceImpl("/")); // TODO: whats this for? - ReferenceParameters parameters = from.getReferenceParameters(); - - String conversationID = requestJMSMsg.getStringProperty(JMSBindingConstants.CONVERSATION_ID_PROPERTY); - if (conversationID != null) { - parameters.setConversationID(conversationID); - } - - return msg; - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } - - public Message invokeResponse(Message msg) { - try { - - //if operation is oneway, return back. - Operation operation = msg.getOperation(); - if (operation != null && operation.isNonBlocking()) { - return msg; - } - - JMSBindingContext context = msg.getBindingContext(); - Session session = context.getJmsResponseSession(); - javax.jms.Message requestJMSMsg = context.getJmsMsg(); - javax.jms.Message responseJMSMsg = msg.getBody(); - - Destination replyDest = requestJMSMsg.getJMSReplyTo(); - if (replyDest == null) { - if (jmsBinding.getResponseDestinationName() != null) { - try { - replyDest = jmsResourceFactory.lookupDestination(jmsBinding.getResponseDestinationName()); - } catch (NamingException e) { - throw new JMSBindingException("Exception lookingup response destination", e); - } - } - } - - if (replyDest == null) { - // assume no reply is expected - if (msg.getBody() != null) { - logger.log(Level.FINE, "JMS service '" + service.getName() + "' dropped response as request has no replyTo"); - } - 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(replyDest); - - // Set jms header attributes in producer, not message. - int deliveryMode = requestJMSMsg.getJMSDeliveryMode(); - producer.setDeliveryMode(deliveryMode); - int deliveryPriority = requestJMSMsg.getJMSPriority(); - producer.setPriority(deliveryPriority); - - producer.send((javax.jms.Message)msg.getBody()); - - producer.close(); - context.closeJmsResponseSession(); - - 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/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.java deleted file mode 100644 index aa5df2b8bb..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.java +++ /dev/null @@ -1,66 +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.runtime; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.WireFormatJMSBytes; -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 WireFormatJMSBytesProviderFactory implements WireFormatProviderFactory<WireFormatJMSBytes> { - private ExtensionPointRegistry registry; - - public WireFormatJMSBytesProviderFactory(ExtensionPointRegistry registry) { - super(); - this.registry = registry; - } - - /** - */ - public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding) { - return new WireFormatJMSBytesReferenceProvider(registry, component, reference, binding); - } - - /** - */ - public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding) { - return new WireFormatJMSBytesServiceProvider(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/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.java deleted file mode 100644 index d08707a1ba..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.java +++ /dev/null @@ -1,123 +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.runtime; - - -import java.lang.reflect.InvocationTargetException; -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.jmsbytes.WireFormatJMSBytes; -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 WireFormatJMSBytesReferenceInterceptor implements Interceptor { - - private Invoker next; - private RuntimeWire runtimeWire; - private JMSResourceFactory jmsResourceFactory; - private JMSBinding jmsBinding; - private JMSMessageProcessor requestMessageProcessor; - private JMSMessageProcessor responseMessageProcessor; - - public WireFormatJMSBytesReferenceInterceptor(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 WireFormatJMSBytes){ - msg = invokeRequest(msg); - } - - msg = getNext().invoke(msg); - - if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSBytes){ - msg = invokeResponse(msg); - } - - return msg; - } - - public Message invokeRequest(Message msg) { - try { - // get the jms context - JMSBindingContext context = msg.getBindingContext(); - Session session = context.getJmsSession(); - - Object[] requestParams = msg.getBody(); - javax.jms.Message requestMsg = null; - if (requestParams != null && requestParams.length > 0 ){ - requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, requestParams[0]); - } else { - requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, null); - } - 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 = responseMessageProcessor.extractPayloadFromJMSMessage((javax.jms.Message)msg.getBody()); - if (response instanceof InvocationTargetException) { - msg.setFaultBody(((InvocationTargetException) response).getCause()); - } else { - if (response != null){ - msg.setBody(response); - } else { - msg.setBody(null); - } - } - } - - return msg; - } - - public Invoker getNext() { - return next; - } - - public void setNext(Invoker next) { - this.next = next; - } -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java deleted file mode 100644 index 98e52c0be8..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java +++ /dev/null @@ -1,97 +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.runtime; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.WireFormatJMSBytes; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -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 JMSBinding binding; - private InterfaceContract interfaceContract; - - public WireFormatJMSBytesReferenceProvider(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 - if (this.binding.getRequestWireFormat() instanceof WireFormatJMSBytes){ - this.binding.setRequestMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME); - } - if (this.binding.getResponseWireFormat() instanceof WireFormatJMSBytes){ - this.binding.setResponseMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME); - } - - // just point to the reference interface contract so no - // databinding transformation takes place - interfaceContract = reference.getInterfaceContract(); - } - - public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ - - if (this.interfaceContract != null ) { - if (this.binding.getRequestWireFormat() instanceof WireFormatJMSBytes){ - // set the request data transformation - interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface()); - } - if (this.binding.getResponseWireFormat() instanceof WireFormatJMSBytes){ - // set the response data transformation - interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface()); - } - } - - return interfaceContract; - } - - public Interceptor createInterceptor() { - return new WireFormatJMSBytesReferenceInterceptor(binding, - null, - reference.getRuntimeWire(binding)); - } - - public String getPhase() { - return Phase.REFERENCE_BINDING_WIREFORMAT; - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.java deleted file mode 100644 index 5128309233..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.java +++ /dev/null @@ -1,114 +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.runtime; - -import javax.jms.Session; - -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.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.jmsbytes.WireFormatJMSBytes; -import org.apache.tuscany.sca.interfacedef.Operation; -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 WireFormatJMSBytesServiceInterceptor implements Interceptor { - private Invoker next; - private RuntimeWire runtimeWire; - private JMSResourceFactory jmsResourceFactory; - private JMSBinding jmsBinding; - private JMSMessageProcessor requestMessageProcessor; - private JMSMessageProcessor responseMessageProcessor; - - public WireFormatJMSBytesServiceInterceptor(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 WireFormatJMSBytes){ - msg = invokeRequest(msg); - } - - msg = getNext().invoke(msg); - - //if it's oneway return back - Operation operation = msg.getOperation(); - if (operation != null && operation.isNonBlocking()) { - return msg; - } - - if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSBytes){ - msg = invokeResponse(msg); - } - - return msg; - } - - public Message invokeRequest(Message msg) { - // get the jms context - JMSBindingContext context = msg.getBindingContext(); - javax.jms.Message jmsMsg = context.getJmsMsg(); - - Object requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg); - msg.setBody(new Object[]{requestPayload}); - - return msg; - } - - public Message invokeResponse(Message msg) { - // get the jms context - JMSBindingContext context = msg.getBindingContext(); - Session session = context.getJmsResponseSession(); - - 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/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java deleted file mode 100644 index 318ed0cf04..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java +++ /dev/null @@ -1,101 +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.runtime; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.WireFormatJMSBytes; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -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 JMSBinding binding; - private InterfaceContract interfaceContract; - - public WireFormatJMSBytesServiceProvider(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 override - // any message processors specified in the SCDL in this case - if (this.binding.getRequestWireFormat() instanceof WireFormatJMSBytes){ - this.binding.setRequestMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME); - } - if (this.binding.getResponseWireFormat() instanceof WireFormatJMSBytes){ - 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 configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ - - if (this.interfaceContract != null ) { - if (this.binding.getRequestWireFormat() instanceof WireFormatJMSBytes){ - // set the request data transformation - interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface()); - } - if (this.binding.getResponseWireFormat() instanceof WireFormatJMSBytes){ - // set the response data transformation - interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface()); - } - } - - return interfaceContract; - } - - /** - */ - public Interceptor createInterceptor() { - return new WireFormatJMSBytesServiceInterceptor((JMSBinding)binding, - null, - service.getRuntimeWire(binding)); - } - - /** - */ - public String getPhase() { - return Phase.SERVICE_BINDING_WIREFORMAT; - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.java deleted file mode 100644 index 9e92bf40bf..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.java +++ /dev/null @@ -1,66 +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.jmsobject.runtime; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.WireFormatJMSObject; -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<WireFormatJMSObject> { - 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/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java deleted file mode 100644 index 6ba62d7681..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java +++ /dev/null @@ -1,118 +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.jmsobject.runtime; - - -import java.lang.reflect.InvocationTargetException; -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.jmsobject.WireFormatJMSObject; -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 = msg.getBindingContext(); - 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 = responseMessageProcessor.extractPayloadFromJMSMessage((javax.jms.Message)msg.getBody()); - - if (response instanceof InvocationTargetException) { - msg.setFaultBody(((InvocationTargetException) response).getCause()); - } else { - if (response != null){ - msg.setBody(response); - } else { - msg.setBody(null); - } - } - } - - return msg; - } - - public Invoker getNext() { - return next; - } - - public void setNext(Invoker next) { - this.next = next; - } -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java deleted file mode 100644 index 644c9ebc38..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java +++ /dev/null @@ -1,97 +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.jmsobject.runtime; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.WireFormatJMSObject; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.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 override - // any message processors specified in the SCDL in this case - if (this.binding.getRequestWireFormat() instanceof WireFormatJMSObject){ - this.binding.setRequestMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME); - } - if (this.binding.getResponseWireFormat() instanceof WireFormatJMSObject){ - 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 configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ - - if (this.interfaceContract != null ) { - if (this.binding.getRequestWireFormat() instanceof WireFormatJMSObject){ - // set the request data transformation - interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface()); - } - if (this.binding.getResponseWireFormat() instanceof WireFormatJMSObject){ - // set the response data transformation - interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface()); - } - } - - return interfaceContract; - } - - public Interceptor createInterceptor() { - return new WireFormatJMSObjectReferenceInterceptor(binding, - null, - reference.getRuntimeWire(binding)); - } - - public String getPhase() { - return Phase.REFERENCE_BINDING_WIREFORMAT; - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java deleted file mode 100644 index b063f8d53b..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java +++ /dev/null @@ -1,120 +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.jmsobject.runtime; - -import javax.jms.Session; - -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.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.jmsobject.WireFormatJMSObject; -import org.apache.tuscany.sca.interfacedef.Operation; -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 it's oneway return back - Operation operation = msg.getOperation(); - if (operation != null && operation.isNonBlocking()) { - return msg; - } - - if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSObject){ - msg = invokeResponse(msg); - } - - return msg; - } - - public Message invokeRequest(Message msg) { - // get the jms context - JMSBindingContext context = msg.getBindingContext(); - javax.jms.Message jmsMsg = context.getJmsMsg(); - - Object requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg); - - if (requestPayload != null && requestPayload.getClass().isArray()) { - msg.setBody(requestPayload); - } else if (requestPayload == null) { - msg.setBody(new Object[0]); - } else { - msg.setBody(new Object[] {requestPayload}); - } - - return msg; - } - - public Message invokeResponse(Message msg) { - // get the jms context - JMSBindingContext context = msg.getBindingContext(); - Session session = context.getJmsResponseSession(); - - javax.jms.Message responseJMSMsg = null; - 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/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java deleted file mode 100644 index e5887ec1b7..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java +++ /dev/null @@ -1,102 +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.jmsobject.runtime; - - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.WireFormatJMSObject; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.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 override - // any message processors specified in the SCDL in this case - if (this.binding.getRequestWireFormat() instanceof WireFormatJMSObject){ - this.binding.setRequestMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME); - } - if (this.binding.getResponseWireFormat() instanceof WireFormatJMSObject){ - 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 configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ - - if (this.interfaceContract != null ) { - if (this.binding.getRequestWireFormat() instanceof WireFormatJMSObject){ - // set the request data transformation - interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface()); - } - if (this.binding.getResponseWireFormat() instanceof WireFormatJMSObject){ - // set the response data transformation - interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface()); - } - } - - 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/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.java deleted file mode 100644 index 555dfb47b5..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.java +++ /dev/null @@ -1,66 +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.jmstext.runtime; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.wireformat.jmstext.WireFormatJMSText; -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<WireFormatJMSText> { - 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/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.java deleted file mode 100644 index 49e745ffaa..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.java +++ /dev/null @@ -1,125 +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.jmstext.runtime; - - -import java.lang.reflect.InvocationTargetException; -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.jmstext.WireFormatJMSText; -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 = msg.getBindingContext(); - Session session = context.getJmsSession(); - - Object[] requestParams = msg.getBody(); - javax.jms.Message requestMsg = null; - if (requestParams != null && requestParams.length > 0 ){ - requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, requestParams[0]); - } else { - requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, null); - } - 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 = responseMessageProcessor.extractPayloadFromJMSMessage((javax.jms.Message)msg.getBody()); - - if (response instanceof InvocationTargetException) { - msg.setFaultBody(((InvocationTargetException) response).getCause()); - } else { - if (response != null){ - msg.setBody(response); - } else { - msg.setBody(null); - } - } - } - - return msg; - } - - public Invoker getNext() { - return next; - } - - public void setNext(Invoker next) { - this.next = next; - } -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java deleted file mode 100644 index 24d963010c..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java +++ /dev/null @@ -1,99 +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.jmstext.runtime; - - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.wireformat.jmstext.WireFormatJMSText; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.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 override - // any message processors specified in the SCDL in this case - if (this.binding.getRequestWireFormat() instanceof WireFormatJMSText){ - this.binding.setRequestMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME); - } - if (this.binding.getResponseWireFormat() instanceof WireFormatJMSText){ - 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 configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ - - if (this.interfaceContract != null ) { - if (this.binding.getRequestWireFormat() instanceof WireFormatJMSText){ - // set the request data transformation - interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface()); - } - if (this.binding.getResponseWireFormat() instanceof WireFormatJMSText){ - // set the response data transformation - interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface()); - } - } - - return interfaceContract; - } - - public Interceptor createInterceptor() { - return new WireFormatJMSTextReferenceInterceptor(binding, - null, - reference.getRuntimeWire(binding)); - } - - public String getPhase() { - return Phase.REFERENCE_BINDING_WIREFORMAT; - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.java deleted file mode 100644 index cf9e49afef..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.java +++ /dev/null @@ -1,114 +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.jmstext.runtime; - -import javax.jms.Session; - -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.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.jmstext.WireFormatJMSText; -import org.apache.tuscany.sca.interfacedef.Operation; -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 it's oneway return back - Operation operation = msg.getOperation(); - if (operation != null && operation.isNonBlocking()) { - return msg; - } - - if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSText){ - msg = invokeResponse(msg); - } - - return msg; - } - - public Message invokeRequest(Message msg) { - // get the jms context - JMSBindingContext context = msg.getBindingContext(); - javax.jms.Message jmsMsg = context.getJmsMsg(); - - Object requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg); - msg.setBody(new Object[]{requestPayload}); - - return msg; - } - - public Message invokeResponse(Message msg) { - // get the jms context - JMSBindingContext context = msg.getBindingContext(); - Session session = context.getJmsResponseSession(); - - 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/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java deleted file mode 100644 index 3f759ff73b..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java +++ /dev/null @@ -1,101 +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.jmstext.runtime; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.wireformat.jmstext.WireFormatJMSText; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.provider.WireFormatProvider; -import org.apache.tuscany.sca.runtime.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 override - // any message processors specified in the SCDL in this case - if (this.binding.getRequestWireFormat() instanceof WireFormatJMSText){ - this.binding.setRequestMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME); - } - if (this.binding.getResponseWireFormat() instanceof WireFormatJMSText){ - 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 configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ - - if (this.interfaceContract != null ) { - if (this.binding.getRequestWireFormat() instanceof WireFormatJMSText){ - // set the request data transformation - interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface()); - } - if (this.binding.getResponseWireFormat() instanceof WireFormatJMSText){ - // set the response data transformation - interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface()); - } - } - - 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/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.java deleted file mode 100644 index 44f490ee37..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.java +++ /dev/null @@ -1,72 +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.jmstextxml.runtime; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory; -import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactoryExtensionPoint; -import org.apache.tuscany.sca.binding.jms.wireformat.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<WireFormatJMSTextXML> { - 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/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java deleted file mode 100644 index adf3fda98c..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java +++ /dev/null @@ -1,128 +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.jmstextxml.runtime; - - - - -import javax.jms.JMSException; -import javax.jms.Session; -import javax.xml.namespace.QName; - -import org.apache.axiom.om.OMElement; -import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; -import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessor; -import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil; -import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory; -import org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.WireFormatJMSTextXML; -import org.apache.tuscany.sca.interfacedef.util.FaultException; -import org.apache.tuscany.sca.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Invoker; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.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 = msg.getBindingContext(); - 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){ - javax.jms.Message jmsMsg = (javax.jms.Message)msg.getBody(); - Object response = responseMessageProcessor.extractPayloadFromJMSMessage(jmsMsg); - if (response != null ){ - msg.setBody(response); - try { - if (jmsMsg.getBooleanProperty(JMSBindingConstants.FAULT_PROPERTY)) { - FaultException e = new FaultException("remote exception", response); - OMElement om = (OMElement) response; - e.setFaultName(new QName(om.getNamespace().getNamespaceURI(), om.getLocalName())); - msg.setFaultBody(e); - } - } catch (JMSException e) { - throw new JMSBindingException(e); - } - } else { - msg.setBody(null); - } - } - - return msg; - } - - public Invoker getNext() { - return next; - } - - public void setNext(Invoker next) { - this.next = next; - } -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java deleted file mode 100644 index 1365cf951e..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java +++ /dev/null @@ -1,121 +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.jmstextxml.runtime; - -import org.apache.axiom.om.OMElement; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.wireformat.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.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Phase; -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 - // - // defaults to JMSBindingConstants.XML_MP_CLASSNAME so no need to set it -/* - if (this.binding.getRequestWireFormat() instanceof WireFormatJMSTextXML){ - this.binding.setRequestMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME); - } - if (this.binding.getResponseWireFormat() instanceof WireFormatJMSTextXML){ - this.binding.setResponseMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME); - } -*/ - - // create a local interface contract that is configured specifically to - // deal with the data format that this wire format is expecting to sent to - // and receive from the databinding interceptor. The request/response parts of - // this interface contract will be copied into the binding interface contract - // as required - 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()); - } - - 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 configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ - - if (this.interfaceContract != null && - !isOnMessage()) { - if (this.binding.getRequestWireFormat() instanceof WireFormatJMSTextXML){ - // set the request data transformation - interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface()); - } - if (this.binding.getResponseWireFormat() instanceof WireFormatJMSTextXML){ - // set the response data transformation - interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface()); - } - } - - 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/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.java deleted file mode 100644 index 9236055542..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.java +++ /dev/null @@ -1,119 +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.jmstextxml.runtime; - -import javax.jms.Session; - -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.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.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 it's oneway return back - Operation operation = msg.getOperation(); - if (operation != null && operation.isNonBlocking()) { - return msg; - } - - if (jmsBinding.getResponseWireFormat() instanceof WireFormatJMSTextXML){ - msg = invokeResponse(msg); - } - - return msg; - } - - public Message invokeRequest(Message msg) { - // get the jms context - JMSBindingContext context = msg.getBindingContext(); - 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(new Object[]{requestPayload}); - } - - return msg; - } - - public Message invokeResponse(Message msg) { - - // get the jms context - JMSBindingContext context = msg.getBindingContext(); - Session session = context.getJmsResponseSession(); - - 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/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java deleted file mode 100644 index bccbb669b2..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java +++ /dev/null @@ -1,123 +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.jmstextxml.runtime; - -import org.apache.axiom.om.OMElement; -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; -import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory; -import org.apache.tuscany.sca.binding.jms.wireformat.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.invocation.Interceptor; -import org.apache.tuscany.sca.invocation.Phase; -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 - // defaults to JMSBindingConstants.XML_MP_CLASSNAME so no need to set it -/* - if (this.binding.getRequestWireFormat() instanceof WireFormatJMSTextXML){ - this.binding.setRequestMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME); - } - if (this.binding.getResponseWireFormat() instanceof WireFormatJMSTextXML){ - this.binding.setResponseMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME); - } -*/ - - // create a local interface contract that is configured specifically to - // deal with the data format that this wire format is expecting to sent to - // and receive from the databinding interceptor. The request/response parts of - // this interface contract will be copied into the binding interface contract - // as required - 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()); - } - - 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 configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ - - if (this.interfaceContract != null && - !isOnMessage()) { - if (this.binding.getRequestWireFormat() instanceof WireFormatJMSTextXML){ - // set the request data transformation - interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface()); - } - if (this.binding.getResponseWireFormat() instanceof WireFormatJMSTextXML){ - // set the response data transformation - interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface()); - } - } - - 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/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory deleted file mode 100644 index dec0991984..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory +++ /dev/null @@ -1,19 +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 binding extension
-org.apache.tuscany.sca.binding.jms.provider.JMSBindingProviderFactory;model=org.apache.tuscany.sca.binding.jms.impl.JMSBinding
diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory deleted file mode 100644 index 99438fcd06..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory +++ /dev/null @@ -1,19 +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 binding extension
-org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.runtime.OperationSelectorJMSDefaultProviderFactory;model=org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.OperationSelectorJMSDefault
diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory b/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory deleted file mode 100644 index 02ae135f16..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory +++ /dev/null @@ -1,22 +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 binding extension
-org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.runtime.WireFormatJMSTextXMLProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.WireFormatJMSTextXML
-org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.runtime.WireFormatJMSBytesProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.WireFormatJMSBytes
-org.apache.tuscany.sca.binding.jms.wireformat.jmstext.runtime.WireFormatJMSTextProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.jmstext.WireFormatJMSText
-org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.runtime.WireFormatJMSObjectProviderFactory;model=org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.WireFormatJMSObject
diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java deleted file mode 100644 index fb80362457..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java +++ /dev/null @@ -1,43 +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; - -import org.osoa.sca.annotations.Reference; -import org.osoa.sca.annotations.Service; - -/** - * This class implements the HelloWorld service. - * - * @version $Rev$ $Date$ - */ -@Service(HelloWorldService.class) -public class HelloWorldClientImpl implements HelloWorldService { - - private HelloWorldService serviceA; - - @Reference - public void setServiceA(HelloWorldService service) { - this.serviceA = service; - } - - public String sayHello(String name) { - return serviceA.sayHello(name); - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java deleted file mode 100644 index 515da3144a..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java +++ /dev/null @@ -1,31 +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; - -import org.osoa.sca.annotations.Remotable; - -/** - * Interface for the HelloWorld Service. - * - * @version $Rev$ $Date$ - */ -@Remotable -public interface HelloWorldService { - String sayHello(String name); -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java deleted file mode 100644 index a8808c1bd1..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java +++ /dev/null @@ -1,32 +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; - -/** - * Implementation of the HelloWorldService. - * - * @version $Rev$ $Date$ - */ -public class HelloWorldServiceImpl implements HelloWorldService { - - public String sayHello(String name) { - return "jmsHello " + name; - } - -} diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java b/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java deleted file mode 100644 index efd64361dd..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java +++ /dev/null @@ -1,237 +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;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jms.TextMessage;
-
-import org.apache.tuscany.sca.binding.jms.impl.JMSBinding;
-import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
-import org.apache.tuscany.sca.interfacedef.Interface;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
-import org.apache.tuscany.sca.runtime.RuntimeComponentService;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
-import org.easymock.EasyMock;
-import org.junit.Test;
-
-/**
- * This unit test is used to ensure that a JMS Message delivered to a Component will select the correct operation based
- * on the details in section 1.5 of the JMS Binding specification.
- *
- * @version $Rev$ $Date$
- */
-public class OperationSelectionTestCaseFIXME {
- /**
- * This test attempts to invoke a Service with a Single method where scaOperationName is not specified in the JMS
- * Message
- * <p>
- * Expected behaviour is that the single method will be invoked as scaOperationName is ignored
- *
- * @throws Exception Failed
- */
- @Test
- public void testServiceWithOnlyOneOperationScaOperationNameNotSpecified() throws Exception {
- // Create the operation we should match
- final Operation expectedOperation = newOperation("myOperation");
-
- // Create the list of operations for the Service
- final List<Operation> operations = new ArrayList<Operation>();
- operations.add(expectedOperation);
-
- // The name of the Operation in the JMS Message - not specified
- final String scaOperationName = null;
-
- // Do the test
- doTestJMSBinding(expectedOperation, operations, scaOperationName);
- }
-
- /**
- * This test attempts to invoke a Service with a Single method where scaOperationName in the JMS Message matches the
- * method name on the Service
- * <p>
- * Expected behaviour is that the single method will be invoked as scaOperationName is ignored
- *
- * @throws Exception Failed
- */
- @Test
- public void testServiceWithOnlyOneOperationScaOperationNameMatches() throws Exception {
- // Create the operation we should match
- final Operation expectedOperation = newOperation("myOperation");
-
- // Create the list of operations for the Service
- final List<Operation> operations = new ArrayList<Operation>();
- operations.add(expectedOperation);
-
- // The name of the Operation in the JMS Message - matches operation name
- final String scaOperationName = expectedOperation.getName();
-
- // Do the test
- doTestJMSBinding(expectedOperation, operations, scaOperationName);
- }
-
- /**
- * This test attempts to invoke a Service with a Single method where scaOperationName in the JMS Message is
- * different the method name on the Service
- * <p>
- * Expected behaviour is that the single method will be invoked as scaOperationName is ignored
- *
- * @throws Exception Failed
- */
- @Test
- public void testServiceWithOnlyOneOperationScaOperationNameDifferent() throws Exception {
- // Create the operation we should match
- final Operation expectedOperation = newOperation("myOperation");
-
- // Create the list of operations for the Service
- final List<Operation> operations = new ArrayList<Operation>();
- operations.add(expectedOperation);
-
- // The name of the Operation in the JMS Message - different to operation name
- final String scaOperationName = "Does Not Match Opeation Name";
-
- // Do the test
- doTestJMSBinding(expectedOperation, operations, scaOperationName);
- }
-
- /**
- * This test attempts to invoke a Service with a multiple operations where scaOperationName specified in the JMS
- * Message matches an operation name
- * <p>
- * Expected behaviour is that the named method will be invoked.
- *
- * @throws Exception Failed
- */
- @Test
- public void testServiceWithMultipleOperationsScaOperationNameSpecified() throws Exception {
- // Create the list of operations for the Service
- final List<Operation> operations = new ArrayList<Operation>();
- for (int i = 0; i < 5; i++) {
- operations.add(newOperation("operation" + i));
- }
-
- // Now try and invoke each operation
- for (Operation expectedOperation : operations) {
- // The name of the Operation in the JMS Message
- final String scaOperationName = expectedOperation.getName();
-
- // Do the test
- doTestJMSBinding(expectedOperation, operations, scaOperationName);
- }
- }
-
- /**
- * This test attempts to invoke a Service with a multiple operations where scaOperationName specified in the JMS
- * Message is not set so we invoke the onMessage() method
- * <p>
- * Expected behaviour is that the onMessage() method should be used instead
- *
- * @throws Exception Failed
- */
- @Test
- public void testServiceWithMultipleOperationsScaOperationNotSpecified() throws Exception {
- // Create the list of operations for the Service
- final List<Operation> operations = new ArrayList<Operation>();
- for (int i = 0; i < 5; i++) {
- operations.add(newOperation("operation" + i));
- }
-
- // Add the onMessage operation to the Service Contract
- final Operation onMessageOperation = newOperation("onMessage");
- operations.add(onMessageOperation);
-
- // The name of the Operation in the JMS Message is not set so it will attempt
- // to invoke the onMessage() method
- final String scaOperationName = null;
-
- // Do the test
- doTestJMSBinding(onMessageOperation, operations, scaOperationName);
- }
-
- /**
- * This is the test method that will attempt to unit test invoking a Service with the specified operations using a
- * JMS Message with the specified scaOperationName to ensure that it invokes the expectedOperation
- *
- * @param expectedOperation The Operation we are expecting to be invoked over JMS
- * @param operations The list of Operations supported by the Service
- * @param scaOperationName The value to set scaOperationName in the JMS Message
- * @throws Exception Failed
- */
- private void doTestJMSBinding(Operation expectedOperation, List<Operation> operations, String scaOperationName)
- throws Exception {
- // Create the test JMS Binding
- final JMSBinding jmsBinding = new JMSBinding();
- JMSResourceFactory jmsResourceFactory = null;
-
- // Extra information for the method we are invoking
- final String operationParams = "Hello";
- final Object operationReturnValue = "Operation Success";
-
- // Mock up the Service. Basically, it is going to call:
- // List<Operation> opList = service.getInterfaceContract().getInterface().getOperations();
- final InterfaceContract ifaceContract = EasyMock.createStrictMock(InterfaceContract.class);
- final RuntimeComponentService service = EasyMock.createStrictMock(RuntimeComponentService.class);
- final Interface iface = EasyMock.createStrictMock(Interface.class);
- EasyMock.expect(iface.getOperations()).andReturn(operations);
- EasyMock.expect(ifaceContract.getInterface()).andReturn(iface);
- EasyMock.expect(service.getInterfaceContract()).andReturn(ifaceContract);
-
- // Mock up getting and invoking the RuntimeWire. It is going to call:
- // service.getRuntimeWire(jmsBinding).invoke(operation, (Object[])requestPayload);
- final RuntimeWire runtimeWire = EasyMock.createStrictMock(RuntimeWire.class);
- EasyMock.expect(service.getRuntimeWire(jmsBinding)).andReturn(runtimeWire);
- EasyMock.expect(runtimeWire.invoke(expectedOperation, new Object[] {operationParams}))
- .andReturn(operationReturnValue);
-
- // Create the JMS Binding Listener
- // final DefaultJMSBindingListener bindingListener = new DefaultJMSBindingListener(jmsBinding, jmsResourceFactory, service, null);
-
- // Simulate a message
- final TextMessage requestJMSMsg = EasyMock.createStrictMock(TextMessage.class);
- EasyMock.expect(requestJMSMsg.getStringProperty("scaOperationName")).andReturn(scaOperationName);
- EasyMock.expect(requestJMSMsg.getText()).andReturn(operationParams);
- EasyMock.expect(requestJMSMsg.getJMSReplyTo()).andReturn(null);
-
- // Lets put all the mocks into replay mode
- // EasyMock.replay(iface);
- EasyMock.replay(ifaceContract);
- EasyMock.replay(service);
- EasyMock.replay(requestJMSMsg);
- EasyMock.replay(runtimeWire);
-
- // Do the test
- // bindingListener.onMessage(requestJMSMsg);
-
- // Verify our Mock objects
- // EasyMock.verify(iface);
- // EasyMock.verify(ifaceContract);
- // EasyMock.verify(service);
- // EasyMock.verify(requestJMSMsg);
- // EasyMock.verify(runtimeWire);
- }
-
- private static Operation newOperation(String name) {
- Operation operation = new OperationImpl();
- operation.setName(name);
- return operation;
- }
-}
diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/resources/simple/client.composite b/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/resources/simple/client.composite deleted file mode 100644 index dcea428493..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/resources/simple/client.composite +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
- -->
-<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
- name="RPCComposite">
-
- <component name="HelloWorldClient">
- <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldClientImpl"/>
- <reference name="serviceA" />
- </component>
-
- <reference name="serviceA" promote="HelloWorldClient/serviceA">
- <interface.java interface="org.apache.tuscany.sca.binding.jms.HelloWorldService" />
- <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61616">
- <destination name="DestQueueA"/>
- <response>
- <destination name="RespQueueA"/>
- </response>
- </binding.jms>
- </reference>
-
-</composite>
diff --git a/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/resources/simple/service.composite b/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/resources/simple/service.composite deleted file mode 100644 index 44b7b29610..0000000000 --- a/branches/sca-java-1.5/modules/binding-jms-runtime/src/test/resources/simple/service.composite +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
- -->
-<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
- name="RPCComposite">
-
- <component name="HelloWorldService">
- <implementation.java class="org.apache.tuscany.sca.binding.jms.HelloWorldServiceImpl"/>
- <service name="HelloWorldService">
- <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory" jndiURL="tcp://localhost:61616">
- <destination name="DestQueueA" create="always"/>
- <response>
- <destination name="RespQueueA" create="always"/>
- </response>
- </binding.jms>
- </service>
- </component>
-
-</composite>
|