From 6c7ad7c110656f47273dc23228b41e46023492f3 Mon Sep 17 00:00:00 2001 From: antelder Date: Sat, 18 Apr 2009 07:36:53 +0000 Subject: Create 1.5 branch git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@766260 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca-java-1.5/modules/binding-hessian/LICENSE | 205 +++++++++++++ .../sca-java-1.5/modules/binding-hessian/NOTICE | 6 + .../sca-java-1.5/modules/binding-hessian/pom.xml | 107 +++++++ .../sca/binding/hessian/impl/HessianBinding.java | 94 ++++++ .../hessian/impl/HessianBindingException.java | 40 +++ .../hessian/impl/HessianBindingProcessor.java | 135 +++++++++ .../hessian/provider/HessianBindingInvoker.java | 73 +++++ .../provider/HessianBindingProviderFactory.java | 67 +++++ .../provider/HessianReferenceBindingProvider.java | 62 ++++ .../provider/HessianServiceBindingProvider.java | 87 ++++++ .../provider/HessianServiceListenerServlet.java | 335 +++++++++++++++++++++ ...ca.contribution.processor.StAXArtifactProcessor | 19 ++ ...any.sca.contribution.processor.ValidationSchema | 19 ++ ...che.tuscany.sca.provider.BindingProviderFactory | 19 ++ .../src/main/resources/binding-hessian.xsd | 36 +++ .../org/zhulei/test/hessian/first/FirstImpl.java | 19 ++ .../zhulei/test/hessian/first/FirstTestCase.java | 70 +++++ .../java/org/zhulei/test/hessian/first/IFirst.java | 11 + .../org/zhulei/test/hessian/second/ISecond.java | 7 + .../org/zhulei/test/hessian/second/SecondImpl.java | 19 ++ .../zhulei/test/hessian/second/SecondTestCase.java | 72 +++++ .../src/test/resources/first_hessian.composite | 21 ++ .../src/test/resources/second_hessian.composite | 27 ++ 23 files changed, 1550 insertions(+) create mode 100644 branches/sca-java-1.5/modules/binding-hessian/LICENSE create mode 100644 branches/sca-java-1.5/modules/binding-hessian/NOTICE create mode 100644 branches/sca-java-1.5/modules/binding-hessian/pom.xml create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBinding.java create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingException.java create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingProcessor.java create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingInvoker.java create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingProviderFactory.java create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianReferenceBindingProvider.java create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceBindingProvider.java create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceListenerServlet.java create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/main/resources/binding-hessian.xsd create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstImpl.java create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstTestCase.java create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/IFirst.java create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/ISecond.java create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondImpl.java create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondTestCase.java create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/test/resources/first_hessian.composite create mode 100644 branches/sca-java-1.5/modules/binding-hessian/src/test/resources/second_hessian.composite (limited to 'branches/sca-java-1.5/modules/binding-hessian') diff --git a/branches/sca-java-1.5/modules/binding-hessian/LICENSE b/branches/sca-java-1.5/modules/binding-hessian/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/LICENSE @@ -0,0 +1,205 @@ + + 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-hessian/NOTICE b/branches/sca-java-1.5/modules/binding-hessian/NOTICE new file mode 100644 index 0000000000..1325efd8bf --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/NOTICE @@ -0,0 +1,6 @@ +${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-hessian/pom.xml b/branches/sca-java-1.5/modules/binding-hessian/pom.xml new file mode 100644 index 0000000000..45ccadce07 --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/pom.xml @@ -0,0 +1,107 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 1.5-SNAPSHOT + ../pom.xml + + tuscany-binding-hessian + Apache Tuscany SCA Hessian Binding Extension + + + + + org.apache.tuscany.sca + tuscany-core-spi + 1.5-SNAPSHOT + + + + com.caucho + hessian + 3.1.5 + + + org.apache.tuscany.sca + tuscany-host-http + 1.5-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.5-SNAPSHOT + test + + + + javax.servlet + servlet-api + 2.5 + provided + + + + junit + junit + 4.5 + test + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.5-SNAPSHOT + test + + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.5-SNAPSHOT + test + + + + + + + + org.apache.felix + maven-bundle-plugin + + + + ${tuscany.version} + org.apache.tuscany.sca.binding.hessian + ${pom.name} + org.apache.tuscany.sca.binding.hessian* + * + + + + + + + diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBinding.java b/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBinding.java new file mode 100644 index 0000000000..7f90d78424 --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBinding.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.binding.hessian.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.sca.assembly.Binding; + +public class HessianBinding implements Binding { + + // properties required to implement the Tuscany + // binding extension SPI + private String uri = null; + private String name = null; + private boolean unresolved = false; + private List extensions = new ArrayList(); + + public HessianBinding() { + super(); + } + + /** + * Returns the binding URI. + * + * @return the binding URI + */ + public String getURI() { + return this.uri; + } + + /** + * Sets the binding URI. + * + * @param uri the binding URI + */ + public void setURI(String uri) { + this.uri = uri; + } + + /** + * Returns the binding name. + * + * @return the binding name + */ + public String getName() { + return this.name; + } + + /** + * Sets the binding name. + * + * @param name the binding name + */ + public void setName(String name) { + this.name = name; + } + + public boolean isUnresolved() { + return this.unresolved; + } + + public void setUnresolved(boolean unresolved) { + this.unresolved = unresolved; + } + + public List getExtensions() { + return extensions; + } + + /** + * Clone the binding + */ + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingException.java b/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingException.java new file mode 100644 index 0000000000..456f0d11ba --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingException.java @@ -0,0 +1,40 @@ +/* + * 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.hessian.impl; + +public class HessianBindingException extends RuntimeException { + private static final long serialVersionUID = 1L; + + public HessianBindingException() { + super(); + } + + public HessianBindingException(String arg0, Throwable arg1) { + super(arg0, arg1); + } + + public HessianBindingException(String arg0) { + super(arg0); + } + + public HessianBindingException(Throwable arg0) { + super(arg0); + } + +} diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingProcessor.java b/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingProcessor.java new file mode 100644 index 0000000000..f5564b926b --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingProcessor.java @@ -0,0 +1,135 @@ +/* + * 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.hessian.impl; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl; +import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.Problem; +import org.apache.tuscany.sca.monitor.Problem.Severity; +import org.apache.tuscany.sca.policy.PolicyFactory; + +public class HessianBindingProcessor implements StAXArtifactProcessor { + + private QName BINDING_HESSIAN = new QName("http://hessian", "binding.hessian"); + + private PolicyFactory policyFactory; + private PolicyAttachPointProcessor policyProcessor; + private Monitor monitor; + + public HessianBindingProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) { + this.policyFactory = modelFactories.getFactory(PolicyFactory.class); + this.policyProcessor = new PolicyAttachPointProcessor(policyFactory); + this.monitor = monitor; + } + + /** + * Report a error. + * + * @param problems + * @param message + * @param model + */ + private void warning(String message, Object model, Object... messageParameters) { + if (monitor != null) { + Problem problem = + new ProblemImpl(this.getClass().getName(), "binding-hessian-validation-messages", Severity.WARNING, + model, message, (Object[])messageParameters); + monitor.problem(problem); + } + } + + /** + * Report a error. + * + * @param problems + * @param message + * @param model + */ + private void error(String message, Object model, Object... messageParameters) { + if (monitor != null) { + Problem problem = + new ProblemImpl(this.getClass().getName(), "binding-hessian-validation-messages", Severity.ERROR, + model, message, (Object[])messageParameters); + monitor.problem(problem); + } + } + + public QName getArtifactType() { + return BINDING_HESSIAN; + } + + public Class getModelType() { + return HessianBinding.class; + } + + public HessianBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + HessianBinding hessianBinding = new HessianBinding(); + + // Read policies + policyProcessor.readPolicies(hessianBinding, reader); + + // Read binding name + String name = reader.getAttributeValue(null, "name"); + if (name != null) { + hessianBinding.setName(name); + } + + // Read binding URI + String uri = reader.getAttributeValue(null, "uri"); + if (uri != null) { + hessianBinding.setURI(uri); + } + + return hessianBinding; + } + + public void resolve(HessianBinding model, ModelResolver resolver) throws ContributionResolveException { + } + + public void write(HessianBinding hessianBinding, XMLStreamWriter writer) throws ContributionWriteException, + XMLStreamException { + policyProcessor.writePolicyPrefixes(hessianBinding, writer); + writer.writeStartElement(BINDING_HESSIAN.getNamespaceURI(), BINDING_HESSIAN.getLocalPart()); + policyProcessor.writePolicyAttributes(hessianBinding, writer); + + if (hessianBinding.getName() != null) { + writer.writeAttribute("name", hessianBinding.getName()); + } + + if (hessianBinding.getURI() != null) { + writer.writeAttribute("uri", hessianBinding.getURI()); + } + + writer.writeEndElement(); + } + +} diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingInvoker.java b/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingInvoker.java new file mode 100644 index 0000000000..9d6ede2dbc --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingInvoker.java @@ -0,0 +1,73 @@ +/* + * 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.hessian.provider; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.apache.tuscany.sca.binding.hessian.impl.HessianBinding; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.java.JavaOperation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; + +import com.caucho.hessian.client.HessianProxyFactory; + +public class HessianBindingInvoker implements Invoker { + + private String serviceURL; + private Interface homeImpl; + + HessianBindingInvoker(Interface homeImpl, HessianBinding binding) { + this.serviceURL = binding.getURI(); + this.homeImpl = homeImpl; + } + + public Message invoke(Message msg) { + try { + Method method = ((JavaOperation)msg.getOperation()).getJavaMethod(); + Object[] args = msg.getBody(); + + HessianProxyFactory proxyFactory = new HessianProxyFactory(); + Object service = proxyFactory.create(loadClass(homeImpl.toString()), serviceURL); + Object result = null; + result = method.invoke(service, args); + msg.setBody(result); + } catch (Throwable e) { + e.printStackTrace(); + if (e instanceof InvocationTargetException) + e = ((InvocationTargetException)e).getTargetException(); + msg.setFaultBody(e); + } + return msg; + } + + private Class loadClass(String className) { + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + try { + if (loader != null) + return Class.forName(className, false, loader); + else + return Class.forName(className); + } catch (Exception e) { + + } + return null; + } +} diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingProviderFactory.java b/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingProviderFactory.java new file mode 100644 index 0000000000..77a5f6f675 --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingProviderFactory.java @@ -0,0 +1,67 @@ +/* + * 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.hessian.provider; + +import java.util.List; + +import org.apache.tuscany.sca.binding.hessian.impl.HessianBinding; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.host.http.ServletHost; +import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint; +import org.apache.tuscany.sca.invocation.MessageFactory; +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; + +public class HessianBindingProviderFactory implements BindingProviderFactory { + + private MessageFactory messageFactory; + private ServletHost servletHost; + + public HessianBindingProviderFactory(ExtensionPointRegistry extensionPoints) { + ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class); + List hosts = servletHosts.getServletHosts(); + if (!hosts.isEmpty()) { + this.servletHost = hosts.get(0); + } + ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + messageFactory = modelFactories.getFactory(MessageFactory.class); + } + + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component, + RuntimeComponentReference reference, + HessianBinding binding) { + return new HessianReferenceBindingProvider(component, reference, binding); + } + + public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, + RuntimeComponentService service, + HessianBinding binding) { + return new HessianServiceBindingProvider(component, service, binding, messageFactory, servletHost); + } + + public Class getModelType() { + return HessianBinding.class; + } +} diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianReferenceBindingProvider.java b/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianReferenceBindingProvider.java new file mode 100644 index 0000000000..27711932d7 --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianReferenceBindingProvider.java @@ -0,0 +1,62 @@ +/* + * 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.hessian.provider; + +import org.apache.tuscany.sca.binding.hessian.impl.HessianBinding; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; + +public class HessianReferenceBindingProvider implements ReferenceBindingProvider { + + private RuntimeComponentReference reference; + private HessianBinding hessianBinding; + + public HessianReferenceBindingProvider(RuntimeComponent component, + RuntimeComponentReference reference, + HessianBinding binding) { + this.reference = reference; + this.hessianBinding = binding; + } + + public Invoker createInvoker(Operation operation) { + return new HessianBindingInvoker(getBindingInterfaceContract().getInterface(), hessianBinding); + } + + public boolean supportsOneWayInvocation() { + return true; + } + + public InterfaceContract getBindingInterfaceContract() { + return reference.getInterfaceContract(); + } + + public void start() { + + } + + public void stop() { + + } + +} diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceBindingProvider.java b/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceBindingProvider.java new file mode 100644 index 0000000000..3e4922dc13 --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceBindingProvider.java @@ -0,0 +1,87 @@ +/* + * 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.hessian.provider; + +import java.util.logging.Logger; + +import javax.servlet.Servlet; + +import org.apache.tuscany.sca.binding.hessian.impl.HessianBinding; +import org.apache.tuscany.sca.host.http.ServletHost; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeWire; + +public class HessianServiceBindingProvider implements ServiceBindingProvider { + private static final Logger logger = Logger.getLogger(HessianServiceBindingProvider.class.getName()); + + private RuntimeComponent component; + private RuntimeComponentService service; + private HessianBinding hessianBinding; + private MessageFactory messageFactory; + private ServletHost servletHost; + private String servletMapping; + + public HessianServiceBindingProvider(RuntimeComponent component, + RuntimeComponentService service, + HessianBinding binding, + MessageFactory messageFactory, + ServletHost servletHost) { + this.component = component; + this.service = service; + this.hessianBinding = binding; + this.messageFactory = messageFactory; + this.servletHost = servletHost; + } + + public InterfaceContract getBindingInterfaceContract() { + return service.getInterfaceContract(); + } + + public boolean supportsOneWayInvocation() { + return true; + } + + public void start() { + Servlet servlet = null; + Interface homeImpl = service.getInterfaceContract().getInterface(); + RuntimeWire wire = service.getRuntimeWire(hessianBinding); + servlet = new HessianServiceListenerServlet(homeImpl, wire, messageFactory); + + if (servlet == null) { + throw new IllegalStateException("No get or service method found on the service"); + } + + servletMapping = hessianBinding.getURI(); + servletHost.addServletMapping(servletMapping, servlet); + + // Save the actual binding URI in the binding + hessianBinding.setURI(servletHost.getURLMapping(hessianBinding.getURI()).toString()); + } + + public void stop() { + servletHost.removeServletMapping(servletMapping); + } + +} diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceListenerServlet.java b/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceListenerServlet.java new file mode 100644 index 0000000000..de9b4927c6 --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceListenerServlet.java @@ -0,0 +1,335 @@ +/* + * Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved. + * + * The Apache Software License, Version 1.1 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Caucho Technology (http://www.caucho.com/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "Hessian", "Resin", and "Caucho" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * info@caucho.com. + * + * 5. Products derived from this software may not be called "Resin" + * nor may "Resin" appear in their names without prior written + * permission of Caucho Technology. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * @author Scott Ferguson + */ + +package org.apache.tuscany.sca.binding.hessian.provider; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.logging.Logger; + +import javax.servlet.GenericServlet; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.java.JavaOperation; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.runtime.RuntimeWire; + +import com.caucho.hessian.io.AbstractHessianInput; +import com.caucho.hessian.io.AbstractHessianOutput; +import com.caucho.hessian.io.Hessian2Input; +import com.caucho.hessian.io.Hessian2Output; +import com.caucho.hessian.io.HessianOutput; +import com.caucho.hessian.io.SerializerFactory; +import com.caucho.services.server.ServiceContext; + +/** + * Servlet for serving Hessian services. + */ +public class HessianServiceListenerServlet extends GenericServlet { + + private static final Logger logger = Logger.getLogger(HessianServiceListenerServlet.class.getName()); + + private Interface homeImpl; + private RuntimeWire wire; + private MessageFactory messageFactory; + + private SerializerFactory _serializerFactory; + + private Map _operationMap = new Hashtable(); + + public HessianServiceListenerServlet(Interface homeImpl, RuntimeWire wire, MessageFactory messageFactory) { + this.homeImpl = homeImpl; + this.wire = wire; + this.messageFactory = messageFactory; + + List operations = homeImpl.getOperations(); + for (int i = 0; i < operations.size(); i++) { + JavaOperation op = (JavaOperation)operations.get(i); + Method method = op.getJavaMethod(); + if (_operationMap.get(method.getName()) == null) + _operationMap.put(method.getName(), op); + + Class[] param = method.getParameterTypes(); + String mangledName = method.getName() + "__" + param.length; + _operationMap.put(mangledName, op); + _operationMap.put(mangleName(method, false), op); + } + } + + public String getServletInfo() { + return "Tuscany Binding Hessian Servlet"; + } + + /** + * Sets the serializer factory. + */ + public void setSerializerFactory(SerializerFactory factory) { + _serializerFactory = factory; + } + + /** + * Gets the serializer factory. + */ + public SerializerFactory getSerializerFactory() { + if (_serializerFactory == null) + _serializerFactory = new SerializerFactory(); + + return _serializerFactory; + } + + /** + * Sets the serializer send collection java type. + */ + public void setSendCollectionType(boolean sendType) { + getSerializerFactory().setSendCollectionType(sendType); + } + + /** + * Execute a request. The path-info of the request selects the bean. Once + * the bean's selected, it will be applied. + */ + public void service(ServletRequest request, ServletResponse response) throws IOException, ServletException { + HttpServletRequest req = (HttpServletRequest)request; + HttpServletResponse res = (HttpServletResponse)response; + + if (!req.getMethod().equals("POST")) { + res.setStatus(500, "Hessian Requires POST"); + PrintWriter out = res.getWriter(); + res.setContentType("text/html"); + out.println("

Hessian Requires POST

"); + return; + } + + String serviceId = req.getPathInfo(); + String objectId = req.getParameter("id"); + if (objectId == null) + objectId = req.getParameter("ejbid"); + + ServiceContext.begin(req, serviceId, objectId); + + try { + InputStream is = request.getInputStream(); + OutputStream os = response.getOutputStream(); + + Hessian2Input in = new Hessian2Input(is); + AbstractHessianOutput out; + + SerializerFactory serializerFactory = getSerializerFactory(); + + in.setSerializerFactory(serializerFactory); + + int code = in.read(); + + if (code != 'c') { + // XXX: deflate + throw new IOException("expected 'c' in hessian input at " + code); + } + + int major = in.read(); + int minor = in.read(); + + if (major >= 2) + out = new Hessian2Output(os); + else + out = new HessianOutput(os); + + out.setSerializerFactory(serializerFactory); + + invoke(in, out); + + out.close(); + } catch (RuntimeException e) { + throw e; + } catch (ServletException e) { + throw e; + } catch (Throwable e) { + throw new ServletException(e); + } finally { + ServiceContext.end(); + } + } + + private String mangleName(Method method, boolean isFull) { + StringBuffer sb = new StringBuffer(); + sb.append(method.getName()); + Class[] params = method.getParameterTypes(); + for (int i = 0; i < params.length; i++) { + sb.append('_'); + sb.append(mangleClass(params[i], isFull)); + } + return sb.toString(); + } + + private String mangleClass(Class cl, boolean isFull) { + String name = cl.getName(); + if (name.equals("boolean") || name.equals("java.lang.Boolean")) + return "boolean"; + else if (name.equals("int") || name.equals("java.lang.Integer") + || name.equals("short") + || name.equals("java.lang.Short") + || name.equals("byte") + || name.equals("java.lang.Byte")) + return "int"; + else if (name.equals("long") || name.equals("java.lang.Long")) + return "long"; + else if (name.equals("float") || name.equals("java.lang.Float") + || name.equals("double") + || name.equals("java.lang.Double")) + return "double"; + else if (name.equals("java.lang.String") || name.equals("com.caucho.util.CharBuffer") + || name.equals("char") + || name.equals("java.lang.Character") + || name.equals("java.io.Reader")) + return "string"; + else if (name.equals("java.util.Date") || name.equals("com.caucho.util.QDate")) + return "date"; + else if (InputStream.class.isAssignableFrom(cl) || name.equals("[B")) + return "binary"; + else if (cl.isArray()) { + return "[" + mangleClass(cl.getComponentType(), isFull); + } else if (name.equals("org.w3c.dom.Node") || name.equals("org.w3c.dom.Element") + || name.equals("org.w3c.dom.Document")) + return "xml"; + else if (isFull) + return name; + else { + int p = name.lastIndexOf('.'); + if (p > 0) + return name.substring(p + 1); + else + return name; + } + } + + public void invoke(AbstractHessianInput in, AbstractHessianOutput out) throws Exception { + ServiceContext context = ServiceContext.getContext(); + + // backward compatibility for some frameworks that don't read + // the call type first + in.skipOptionalCall(); + + String header; + while ((header = in.readHeader()) != null) { + Object value = in.readObject(); + context.addHeader(header, value); + } + + String methodName = in.readMethod(); + Method method = null; + JavaOperation operation = _operationMap.get(methodName); + if (operation != null) + method = operation.getJavaMethod(); + + if (method != null) { + } else if ("_hessian_getAttribute".equals(methodName)) { + String attrName = in.readString(); + in.completeCall(); + String value = null; + if ("java.api.class".equals(attrName)) + value = homeImpl.toString(); + else if ("java.home.class".equals(attrName)) + value = homeImpl.toString(); + else if ("java.object.class".equals(attrName)) + value = homeImpl.toString(); + out.startReply(); + out.writeObject(value); + out.completeReply(); + return; + } else if (method == null) { + out.startReply(); + out.writeFault("NoSuchMethodException", "The service has no method named: " + in.getMethod(), null); + out.completeReply(); + return; + } + + Class[] args = method.getParameterTypes(); + Object[] values = new Object[args.length]; + + for (int i = 0; i < args.length; i++) { + values[i] = in.readObject(args[i]); + } + + Object result = null; + try { + Message msg = messageFactory.createMessage(); + msg.setOperation(operation); + msg.setBody(values); + result = wire.invoke(operation, msg); + } catch (Throwable e) { + while (e instanceof InvocationTargetException) + e = ((InvocationTargetException)e).getTargetException(); + out.startReply(); + out.writeFault("ServiceException", e.getMessage(), e); + out.completeReply(); + return; + } + + // The complete call needs to be after the invoke to handle a + // trailing InputStream + in.completeCall(); + out.startReply(); + out.writeObject(result); + out.completeReply(); + out.close(); + } + +} diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-1.5/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..1bbe97e514 --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the artifact processor extension +org.apache.tuscany.sca.binding.hessian.impl.HessianBindingProcessor;qname=http://hessian#binding.hessian,model=org.apache.tuscany.sca.binding.hessian.impl.HessianBinding diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/branches/sca-java-1.5/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema new file mode 100644 index 0000000000..dfd4823a13 --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema @@ -0,0 +1,19 @@ +# 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. + +# URI of the XML schema to be used for validation +binding-hessian.xsd diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/branches/sca-java-1.5/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..244449ddf0 --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# 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.hessian.provider.HessianBindingProviderFactory;model=org.apache.tuscany.sca.binding.hessian.impl.HessianBinding diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/main/resources/binding-hessian.xsd b/branches/sca-java-1.5/modules/binding-hessian/src/main/resources/binding-hessian.xsd new file mode 100644 index 0000000000..01d7437878 --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/main/resources/binding-hessian.xsd @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstImpl.java b/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstImpl.java new file mode 100644 index 0000000000..b60c41397b --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstImpl.java @@ -0,0 +1,19 @@ +package org.zhulei.test.hessian.first; + +import java.util.ArrayList; +import java.util.List; + +public class FirstImpl implements IFirst { + + public String getString(String str) { + return str + "_first"; + } + + public List getData(String str1, String str2) { + List list = new ArrayList(); + list.add(str1 + "_first"); + list.add(str2 + "_first"); + return list; + } + +} diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstTestCase.java b/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstTestCase.java new file mode 100644 index 0000000000..919cbe90ff --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstTestCase.java @@ -0,0 +1,70 @@ +/* + * 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.zhulei.test.hessian.first; + +import java.io.IOException; +import java.util.List; + +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.caucho.hessian.client.HessianProxyFactory; + +/** + * + */ +public class FirstTestCase { + private static SCANode node; + + /** + * @throws java.lang.Exception + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception { + node = SCANodeFactory.newInstance().createSCANodeFromClassLoader("first_hessian.composite", null); + node.start(); + } + + @Test + public void testServer() throws IOException { + try { + HessianProxyFactory proxyFactory = new HessianProxyFactory(); + IFirst service = (IFirst)proxyFactory.create(IFirst.class, "http://localhost:8085/hessian1"); + List datas = service.getData("123", "ABC"); + for (int i = 0; i < datas.size(); i++) { + System.out.println(datas.get(i)); + } + } catch (Exception e) { + System.out.println(e.getMessage()); + } + } + + /** + * @throws java.lang.Exception + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + node.stop(); + } + +} diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/IFirst.java b/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/IFirst.java new file mode 100644 index 0000000000..a346214ebb --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/IFirst.java @@ -0,0 +1,11 @@ +package org.zhulei.test.hessian.first; + +import java.util.List; + +public interface IFirst { + + public String getString(String str); + + public List getData(String str1, String str2); + +} diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/ISecond.java b/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/ISecond.java new file mode 100644 index 0000000000..0130d84658 --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/ISecond.java @@ -0,0 +1,7 @@ +package org.zhulei.test.hessian.second; + +public interface ISecond { + + public String getString(String str); + +} diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondImpl.java b/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondImpl.java new file mode 100644 index 0000000000..9df4fb91d6 --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondImpl.java @@ -0,0 +1,19 @@ +package org.zhulei.test.hessian.second; + +import org.osoa.sca.annotations.Reference; +import org.zhulei.test.hessian.first.IFirst; + +public class SecondImpl implements ISecond { + + private IFirst first; + + public String getString(String str) { + return first.getString(str) + "_second"; + } + + @Reference + public void setFirst(IFirst first) { + this.first = first; + } + +} diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondTestCase.java b/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondTestCase.java new file mode 100644 index 0000000000..f390d5b104 --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondTestCase.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.zhulei.test.hessian.second; + +import java.io.IOException; + +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.caucho.hessian.client.HessianProxyFactory; + +/** + * + */ +public class SecondTestCase { + private static SCANode node1; + private static SCANode node2; + + /** + * @throws java.lang.Exception + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception { + node1 = SCANodeFactory.newInstance().createSCANodeFromClassLoader("second_hessian.composite", null); + node1.start(); + + node2 = SCANodeFactory.newInstance().createSCANodeFromClassLoader("first_hessian.composite", null); + node2.start(); + } + + @Test + public void testServer() throws IOException { + try { + HessianProxyFactory proxyFactory = new HessianProxyFactory(); + ISecond service = (ISecond)proxyFactory.create(ISecond.class, "http://localhost:8085/hessian2"); + String str = service.getString("XYZ"); + System.out.println(str); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + } + + /** + * @throws java.lang.Exception + */ + @AfterClass + public static void tearDownAfterClass() throws Exception { + node1.stop(); + node2.stop(); + } + +} diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/test/resources/first_hessian.composite b/branches/sca-java-1.5/modules/binding-hessian/src/test/resources/first_hessian.composite new file mode 100644 index 0000000000..fd3eefaeaa --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/test/resources/first_hessian.composite @@ -0,0 +1,21 @@ + + + + + + + + + + + + + diff --git a/branches/sca-java-1.5/modules/binding-hessian/src/test/resources/second_hessian.composite b/branches/sca-java-1.5/modules/binding-hessian/src/test/resources/second_hessian.composite new file mode 100644 index 0000000000..e502aac8be --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-hessian/src/test/resources/second_hessian.composite @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + -- cgit v1.2.3