From f860c2f35b2f94e379d2ff7d5c13f54cd4a3132a Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:06:42 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835119 13f79535-47bb-0310-9956-ffa450edef68 --- .../modules/implementation-script/DISCLAIMER | 8 + .../modules/implementation-script/LICENSE | 251 ++++++++++++ .../modules/implementation-script/NOTICE | 17 + .../modules/implementation-script/pom.xml | 131 ++++++ .../implementation/spi/AbstractImplementation.java | 101 +++++ .../spi/AbstractStAXArtifactProcessor.java | 78 ++++ .../spi/PropertyValueObjectFactory.java | 226 +++++++++++ .../tuscany/implementation/spi/ResourceHelper.java | 72 ++++ .../script/ScriptArtifactProcessor.java | 95 +++++ .../script/ScriptImplementation.java | 55 +++ .../script/ScriptImplementationProvider.java | 119 ++++++ .../ScriptImplementationProviderFactory.java | 44 ++ .../sca/implementation/script/ScriptInvoker.java | 67 ++++ .../script/ScriptModuleActivator.java | 62 +++ .../script/engines/TuscanyJRubyScriptEngine.java | 445 +++++++++++++++++++++ .../org.apache.tuscany.sca.core.ModuleActivator | 18 + .../script/itests/AbstractSCATestCase.java | 48 +++ .../helloworld/AbstractHelloWorldTestCase.java | 34 ++ .../helloworld/GroovyHelloWorldTestCase.java | 25 ++ .../script/itests/helloworld/HelloWorld.java | 26 ++ .../script/itests/helloworld/HelloWorldProxy.java | 33 ++ .../itests/helloworld/JRubyHelloWorldTestCase.java | 25 ++ .../helloworld/JavaScriptHelloWorldTestCase.java | 25 ++ .../helloworld/JythonHelloWorldTestCase.java | 25 ++ .../properties/AbstractHelloWorldTestCase.java | 34 ++ .../properties/GroovyHelloWorldTestCase.java | 25 ++ .../script/itests/properties/HelloWorld.java | 26 ++ .../script/itests/properties/HelloWorldProxy.java | 33 ++ .../itests/properties/JRubyHelloWorldTestCase.java | 24 ++ .../properties/JavaScriptHelloWorldTestCase.java | 25 ++ .../properties/JythonHelloWorldTestCase.java | 25 ++ .../itests/references/GroovyReferenceTestCase.java | 25 ++ .../script/itests/references/HelloWorldTarget.java | 30 ++ .../itests/references/JRubyReferenceTestCase.java | 25 ++ .../references/JavaScriptReferenceTestCase.java | 25 ++ .../itests/references/JythonReferenceTestCase.java | 25 ++ .../itests/helloworld/GroovyHelloWorld.composite | 32 ++ .../itests/helloworld/JRubyHelloWorld.composite | 32 ++ .../helloworld/JavaScriptHelloWorld.composite | 32 ++ .../itests/helloworld/JythonHelloWorld.composite | 32 ++ .../itests/helloworld/helloworld.componentType | 30 ++ .../script/itests/helloworld/helloworld.groovy | 22 + .../script/itests/helloworld/helloworld.js | 23 ++ .../script/itests/helloworld/helloworld.py | 20 + .../script/itests/helloworld/helloworld.rb | 21 + .../itests/properties/GroovyHelloWorld.composite | 32 ++ .../itests/properties/JRubyHelloWorld.composite | 32 ++ .../properties/JavaScriptHelloWorld.composite | 32 ++ .../itests/properties/JythonHelloWorld.composite | 32 ++ .../itests/properties/helloworld.componentType | 32 ++ .../script/itests/properties/helloworld.groovy | 22 + .../script/itests/properties/helloworld.js | 23 ++ .../script/itests/properties/helloworld.py | 20 + .../script/itests/properties/helloworld.rb | 21 + .../itests/references/GroovyReference.composite | 37 ++ .../itests/references/JRubyReference.composite | 37 ++ .../references/JavaScriptReference.composite | 37 ++ .../itests/references/JythonReference.composite | 37 ++ .../itests/references/reference.componentType | 31 ++ .../script/itests/references/reference.groovy | 22 + .../script/itests/references/reference.js | 22 + .../script/itests/references/reference.py | 20 + .../script/itests/references/reference.rb | 21 + 63 files changed, 3106 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/DISCLAIMER create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/LICENSE create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/NOTICE create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/AbstractImplementation.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/AbstractStAXArtifactProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/PropertyValueObjectFactory.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/ResourceHelper.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptArtifactProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementation.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationProvider.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptModuleActivator.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/engines/TuscanyJRubyScriptEngine.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/AbstractSCATestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/AbstractHelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/GroovyHelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/HelloWorld.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/HelloWorldProxy.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JRubyHelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScriptHelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/AbstractHelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/GroovyHelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/HelloWorld.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/HelloWorldProxy.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JRubyHelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JavaScriptHelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JythonHelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/GroovyReferenceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/HelloWorldTarget.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JRubyReferenceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JavaScriptReferenceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JythonReferenceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/GroovyHelloWorld.composite create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JRubyHelloWorld.composite create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScriptHelloWorld.composite create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JythonHelloWorld.composite create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.componentType create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.groovy create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.js create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.py create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.rb create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/GroovyHelloWorld.composite create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JRubyHelloWorld.composite create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JavaScriptHelloWorld.composite create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JythonHelloWorld.composite create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.componentType create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.groovy create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.js create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.py create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.rb create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/GroovyReference.composite create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JRubyReference.composite create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JavaScriptReference.composite create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JythonReference.composite create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.componentType create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.groovy create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.js create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.py create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.rb (limited to 'sca-java-1.x/branches/sca-java-0.90/modules/implementation-script') diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/DISCLAIMER b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/DISCLAIMER new file mode 100644 index 0000000000..d68a410903 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/DISCLAIMER @@ -0,0 +1,8 @@ +Apache Tuscany is an effort undergoing incubation at The Apache Software +Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is +required of all newly accepted projects until a further review indicates that +the infrastructure, communications, and decision making process have stabilized +in a manner consistent with other successful ASF projects. While incubation +status is not necessarily a reflection of the completeness or stability of the +code, it does indicate that the project has yet to be fully endorsed by the ASF. + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/LICENSE b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/LICENSE new file mode 100644 index 0000000000..4b5ab74408 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/LICENSE @@ -0,0 +1,251 @@ + + 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. + +=============================================================================================================== + +Apache Tuscany SCA for Java Subcomponents +=========================================: + +The Tuscany SCA for Java release includes a number of subcomponents with +separate copyright notices and license terms. Your use of the source +code for the these subcomponents is subject to the terms and +conditions of the following licenses. + +================================================================================================================= + +This module implementation-script temporarily includes one file under the following BSD license: + + Copyright (c) 2006, Sun Microsystems, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + - Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + - 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. + + - Neither the name of the Sun Microsystems, Inc. nor the names of + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + CONTRIBUTORS "AS IS" AND ANY EXPRESS 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 THE + COPYRIGHT OWNER OR 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. + +================================================================================================================= diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/NOTICE b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/NOTICE new file mode 100644 index 0000000000..9a03eabdab --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/NOTICE @@ -0,0 +1,17 @@ +${pom.name} +Copyright (c) 2005 - 2007 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + +Unless otherwise indicated, all distribution made available by the Apache Software Foundation +is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL"). +A copy of the AL is provided with this distribution as the LICENSE file present in the +root directory, and is also available at http://www.apache.org/licenses/. + +This product also includes software under the BSD license +(see the LICENSE file contained in this distribution), with +the following copyright: + +Copyright (c) 2006, Sun Microsystems, Inc. +All rights reserved. diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/pom.xml b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/pom.xml new file mode 100644 index 0000000000..23b2ed27d7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/pom.xml @@ -0,0 +1,131 @@ + + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 0.90-incubating-SNAPSHOT + ../pom.xml + + + tuscany-implementation-script + Apache Tuscany Implementation Script + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.90-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-databinding + 0.90-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + sca-api + 0.90-incubating-SNAPSHOT + compile + + + + org.apache.bsf + bsf-all + 3.0-beta1 + + + + junit + junit + 3.8.1 + test + + + + org.easymock + easymock + 2.2 + test + + + + org.easymock + easymockclassextension + 2.2 + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.90-incubating-SNAPSHOT + test + + + + + + rhino + js + 1.6R5 + compile + + + org.jruby + jruby-complete + + + asm + asm + + + asm + asm-commons + + + jline + jline + + + 1.0RC2 + compile + + + org.python + jython + 2.2-beta1 + compile + + + groovy + groovy-all + 1.0 + compile + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/AbstractImplementation.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/AbstractImplementation.java new file mode 100644 index 0000000000..3b7b7fdbdb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/AbstractImplementation.java @@ -0,0 +1,101 @@ +/* + * 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.implementation.spi; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.assembly.Property; +import org.apache.tuscany.sca.assembly.Reference; +import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.PolicySet; + +/** + * TODO: couldn't something like this class be provided by the runtime? + */ +public abstract class AbstractImplementation implements Implementation { + + private List services = new ArrayList(); + private List references = new ArrayList(); + private List properties = new ArrayList(); + private ConstrainingType constrainingType; + private String uri; + private boolean unresolved = true; + private List intents; + private List policySets; + + public AbstractImplementation() { + } + + public List getProperties() { + return properties; + } + + public List getReferences() { + return references; + } + + public List getServices() { + return services; + } + + public String getURI() { + return uri; + } + + public void setURI(String uri) { + this.uri = uri; + } + + public ConstrainingType getConstrainingType() { + return constrainingType; + } + + public void setConstrainingType(ConstrainingType constrainingType) { + this.constrainingType = constrainingType; + } + + public List getRequiredIntents() { + return intents; + } + + public List getPolicySets() { + return policySets; + } + + public List getExtensions() { + // TODO what is this for? + return null; + } + + public boolean isUnresolved() { + // TODO what is this for? + return unresolved; + } + + public void setUnresolved(boolean unresolved) { + // TODO what is this for? + this.unresolved = unresolved; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/AbstractStAXArtifactProcessor.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/AbstractStAXArtifactProcessor.java new file mode 100644 index 0000000000..275b0ff0a3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/AbstractStAXArtifactProcessor.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.implementation.spi; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.ComponentType; +import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.assembly.Property; +import org.apache.tuscany.sca.assembly.Reference; +import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; + +/** + * TODO: couldn't something like this class be provided by the runtime? + * Each impl shouldn't have to have their own .componentType merging code + */ +public abstract class AbstractStAXArtifactProcessor implements StAXArtifactProcessor { + + private AssemblyFactory assemblyFactory; + + public AbstractStAXArtifactProcessor(AssemblyFactory assemblyFactory) { + this.assemblyFactory = assemblyFactory; + } + + public void resolve(I model, ModelResolver resolver) throws ContributionResolveException { + addSideFileComponentType(model.getURI(), model, resolver); + model.setUnresolved(false); + } + + protected void addSideFileComponentType(String name, Implementation impl, ModelResolver resolver) { + int lastDot = name.lastIndexOf('.'); + if (lastDot < 0) { + return; + } + String sideFileName = name.substring(0, lastDot) + ".componentType"; + + ComponentType componentType = assemblyFactory.createComponentType(); + componentType.setURI(sideFileName); + componentType.setUnresolved(true); + + componentType = resolver.resolveModel(ComponentType.class, componentType); + + if (!componentType.isUnresolved()) { + for (Reference reference : componentType.getReferences()) { + impl.getReferences().add(reference); + } + for (Service service : componentType.getServices()) { + impl.getServices().add(service); + } + for (Property property : componentType.getProperties()) { + impl.getProperties().add(property); + } + if (componentType.getConstrainingType() != null) { + impl.setConstrainingType(componentType.getConstrainingType()); + } + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/PropertyValueObjectFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/PropertyValueObjectFactory.java new file mode 100644 index 0000000000..53385f55b5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/PropertyValueObjectFactory.java @@ -0,0 +1,226 @@ +/* + * 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.implementation.spi; + +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import org.apache.tuscany.sca.assembly.Property; +import org.apache.tuscany.sca.databinding.Mediator; +import org.apache.tuscany.sca.databinding.SimpleTypeMapper; +import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl; +import org.apache.tuscany.sca.factory.ObjectCreationException; +import org.apache.tuscany.sca.factory.ObjectFactory; +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.util.XMLType; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +/** + * TODO: Shouldn't this class be provided by the runtime? + */ +public class PropertyValueObjectFactory { + // protected DataBindingRegistry dbRegistry = new DataBindingRegistryImpl(); + protected Mediator mediator = null; + protected SimpleTypeMapper simpleTypeMapper = new SimpleTypeMapperImpl(); + boolean isSimpleType; + + public PropertyValueObjectFactory(Mediator mediator) { + this.mediator = mediator; + } + + public ObjectFactory createValueFactory(Property property) { + isSimpleType = isSimpleType(property); + Document doc = (Document)property.getValue(); + Element rootElement = doc.getDocumentElement(); + + //FIXME : since scripts use dynamic types we need to generate a dynamic java type using the + //xml structure of the property value. Should this be done in the JavaBeansDataBinding... + Class javaType = null; + + if (property.isMany()) { + if (isSimpleType) { + String value = ""; + if (rootElement.getChildNodes().getLength() > 0) { + value = rootElement.getChildNodes().item(0).getTextContent(); + } + List values = + getSimplePropertyValues(value, javaType); + return new ListObjectFactoryImpl(property, + values, + isSimpleType, + javaType); + } else { + return new ListObjectFactoryImpl(property, + getComplexPropertyValues(doc), + isSimpleType, + javaType); + } + } else { + if (isSimpleType) { + String value = ""; + if (rootElement.getChildNodes().getLength() > 0) { + value = rootElement.getChildNodes().item(0).getTextContent(); + } + return new ObjectFactoryImpl(property, + value, + isSimpleType, + javaType); + } else { + Object value = getComplexPropertyValues(doc).get(0); + return new ObjectFactoryImpl(property, + value, + isSimpleType, + javaType); + } + + } + } + + private boolean isSimpleType(Property property) { + if (property.getXSDType() != null) { + return SimpleTypeMapperImpl.isSimpleXSDType(property.getXSDType()); + } else { + if (property instanceof Document) { + Document doc = (Document)property; + Element element = doc.getDocumentElement(); + if (element.getChildNodes().getLength() == 1 && + element.getChildNodes().item(0).getNodeType() == Element.TEXT_NODE) { + return true; + } + } + } + return false; + } + + private List getSimplePropertyValues(String concatenatedValue, Class javaType) { + List propValues = new ArrayList(); + StringTokenizer st = null; + if ( javaType.getName().equals("java.lang.String")) { + st = new StringTokenizer(concatenatedValue, "\""); + } else { + st = new StringTokenizer(concatenatedValue); + } + String aToken = null; + while (st.hasMoreTokens()) { + aToken = st.nextToken(); + if (aToken.trim().length() > 0) { + propValues.add(aToken); + } + } + return propValues; + } + + private List getComplexPropertyValues(Document document) { + Element rootElement = document.getDocumentElement(); + List propValues = new ArrayList(); + for (int count = 0 ; count < rootElement.getChildNodes().getLength() ; ++count) { + if (rootElement.getChildNodes().item(count).getNodeType() == Document.ELEMENT_NODE) { + propValues.add(rootElement.getChildNodes().item(count)); + } + } + return propValues; + } + + public abstract class ObjectFactoryImplBase implements ObjectFactory { + protected SimpleTypeMapper simpleTypeMapper = new SimpleTypeMapperImpl(); + protected Property property; + protected Object propertyValue; + protected Class javaType; + protected DataType sourceDataType; + protected DataType targetDataType; + boolean isSimpleType; + + public ObjectFactoryImplBase(Property property, Object propertyValue, boolean isSimpleType, Class javaType) { + + this.isSimpleType = isSimpleType; + this.property = property; + this.propertyValue = propertyValue; + this.javaType = javaType; + //FIXME : fix this when we have managed to generate dynamic java types + /*sourceDataType = + new DataTypeImpl(DOMDataBinding.NAME, Node.class, + new XMLType(null, this.property.getXSDType())); + TypeInfo typeInfo = null; + if (this.property.getXSDType() != null) { + if (SimpleTypeMapperExtension.isSimpleXSDType(this.property.getXSDType())) { + typeInfo = new TypeInfo(property.getXSDType(), true, null); + } else { + typeInfo = new TypeInfo(property.getXSDType(), false, null); + } + } else { + typeInfo = new TypeInfo(property.getXSDType(), false, null); + } + + XMLType xmlType = new XMLType(typeInfo); + String dataBinding = null; //(String)property.getExtensions().get(DataBinding.class.getName()); + if (dataBinding != null) { + targetDataType = new DataTypeImpl(dataBinding, javaType, xmlType); + } else { + targetDataType = new DataTypeImpl(dataBinding, javaType, xmlType); + mediator.getDataBindingRegistry().introspectType(targetDataType, null); + }*/ + } + } + + public class ObjectFactoryImpl extends ObjectFactoryImplBase { + public ObjectFactoryImpl(Property property, Object propertyValue, boolean isSimpleType, Class javaType) { + super(property, propertyValue, isSimpleType, javaType); + } + + @SuppressWarnings("unchecked") + public Object getInstance() throws ObjectCreationException { + if (isSimpleType) { + return simpleTypeMapper.toJavaObject(property.getXSDType(), (String)propertyValue, null); + } else { + return mediator.mediate(propertyValue, sourceDataType, targetDataType, null); + //return null; + } + } + } + + public class ListObjectFactoryImpl extends ObjectFactoryImplBase { + public ListObjectFactoryImpl(Property property, ListpropertyValues, boolean isSimpleType, Class javaType) { + super(property, propertyValues, isSimpleType, javaType); + } + + @SuppressWarnings("unchecked") + public List getInstance() throws ObjectCreationException { + if (isSimpleType) { + List values = new ArrayList(); + for (String aValue : (List)propertyValue) { + values.add(simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null)); + } + return values; + } else { + List instances = new ArrayList(); + for (Node aValue : (List)propertyValue) { + instances.add(mediator.mediate(aValue, + sourceDataType, + targetDataType, + null)); + } + return instances; + } + } + } +} + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/ResourceHelper.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/ResourceHelper.java new file mode 100644 index 0000000000..ed2efb64bb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/ResourceHelper.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.implementation.spi; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.URL; + +import org.apache.tuscany.sca.contribution.service.ContributionReadException; + +/** + * TODO: Shouldn't this be using the contrabution service? + */ +public class ResourceHelper { + + public static String readResource(String scriptName) throws ContributionReadException { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL scriptSrcUrl = cl.getResource(scriptName); + if (scriptSrcUrl == null) { + throw new ContributionReadException("No script: " + scriptName); + } + + InputStream is; + try { + is = scriptSrcUrl.openStream(); + } catch (IOException e) { + throw new ContributionReadException(e); + } + + try { + + Reader reader = new InputStreamReader(is, "UTF-8"); + char[] buffer = new char[1024]; + StringBuilder source = new StringBuilder(); + int count; + while ((count = reader.read(buffer)) > 0) { + source.append(buffer, 0, count); + } + + return source.toString(); + + } catch (IOException e) { + throw new ContributionReadException(e); + } finally { + try { + is.close(); + } catch (IOException e) { + // ignore + } + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptArtifactProcessor.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptArtifactProcessor.java new file mode 100644 index 0000000000..731ab2f5d0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptArtifactProcessor.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.implementation.script; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.implementation.spi.AbstractStAXArtifactProcessor; +import org.apache.tuscany.implementation.spi.ResourceHelper; +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; + +/** + * ArtifactProcessor to read the SCDL XML for script implementations + * + * + */ +public class ScriptArtifactProcessor extends AbstractStAXArtifactProcessor { + + private static final QName IMPLEMENTATION_SCRIPT_QNAME = new QName(Constants.SCA10_NS, "implementation.script"); + + public ScriptArtifactProcessor(AssemblyFactory assemblyFactory) { + super(assemblyFactory); + } + + public QName getArtifactType() { + return IMPLEMENTATION_SCRIPT_QNAME; + } + + public Class getModelType() { + return ScriptImplementation.class; + } + + public ScriptImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + String scriptName = reader.getAttributeValue(null, "script"); + + String scriptLanguage = reader.getAttributeValue(null, "language"); + if (scriptLanguage == null || scriptLanguage.length() < 1) { + int i = scriptName.lastIndexOf('.'); + scriptLanguage = scriptName.substring(i+1); + } + + while (reader.hasNext()) { + if (reader.next() == END_ELEMENT && IMPLEMENTATION_SCRIPT_QNAME.equals(reader.getName())) { + break; + } + } + + String scriptSrc = ResourceHelper.readResource(scriptName); + ScriptImplementation scriptImpl = new ScriptImplementation(scriptName, scriptLanguage, scriptSrc); + + // TODO: How to get the script URI? Should use the contrabution service + // the uri is used in the resolve method (perhaps incorrectly?) to get the .componentType sidefile + scriptImpl.setURI(Thread.currentThread().getContextClassLoader().getResource(scriptName).toString()); + + return scriptImpl; + } + + public void write(ScriptImplementation scriptImplementation, XMLStreamWriter writer) throws XMLStreamException { + + writer.writeStartElement(Constants.SCA10_NS, "implementation.script"); + + if (scriptImplementation.getScriptName() != null) { + writer.writeAttribute("script", scriptImplementation.getScriptName()); + } + + if (scriptImplementation.getScriptLanguage() != null) { + writer.writeAttribute("language", scriptImplementation.getScriptLanguage()); + } + + writer.writeEndElement(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementation.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementation.java new file mode 100644 index 0000000000..3b127e2d41 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementation.java @@ -0,0 +1,55 @@ +/* + * 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.implementation.script; + +import org.apache.tuscany.implementation.spi.AbstractImplementation; +import org.apache.tuscany.sca.assembly.Implementation; + +/** + * Represents a Script implementation. + */ +public class ScriptImplementation extends AbstractImplementation implements Implementation { + + protected String scriptName; + protected String scriptSrc; + protected String scriptLanguage; + + public ScriptImplementation(String scriptName, String scriptLanguage, String scriptSrc) { + this.scriptName = scriptName; + this.scriptLanguage = scriptLanguage; + this.scriptSrc = scriptSrc; + } + + public String getScriptName() { + return scriptName; + } + + public String getScriptLanguage() { + return scriptLanguage; + } + + public String getScriptSrc() { + return scriptSrc; + } + + public void setScriptSrc(String scriptSrc) { + this.scriptSrc = scriptSrc; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationProvider.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationProvider.java new file mode 100644 index 0000000000..b15247033b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationProvider.java @@ -0,0 +1,119 @@ +/* + * 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.implementation.script; + +import java.io.StringReader; + +import javax.script.Invocable; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.ScriptException; + +import org.apache.tuscany.implementation.spi.PropertyValueObjectFactory; +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.assembly.Property; +import org.apache.tuscany.sca.assembly.Reference; +import org.apache.tuscany.sca.factory.ObjectCreationException; +import org.apache.tuscany.sca.factory.ObjectFactory; +import org.apache.tuscany.sca.implementation.script.engines.TuscanyJRubyScriptEngine; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * Represents a Script implementation. + */ +public class ScriptImplementationProvider implements ImplementationProvider { + + protected RuntimeComponent component; + protected ScriptImplementation implementation; + protected ScriptEngine scriptEngine; + protected PropertyValueObjectFactory propertyFactory; + + public ScriptImplementationProvider(RuntimeComponent component, ScriptImplementation implementation, PropertyValueObjectFactory propertyFactory) { + this.component = component; + this.implementation = implementation; + this.propertyFactory = propertyFactory; + } + + public Invoker createInvoker(RuntimeComponentService service, Operation operation) { + return new ScriptInvoker(this, operation.getName()); + } + + public Invoker createCallbackInvoker(Operation operation) { + return new ScriptInvoker(this, operation.getName()); + } + + public void start() { + try { + scriptEngine = getScriptEngineByExtension(implementation.getScriptLanguage()); + if (scriptEngine == null) { + throw new ObjectCreationException("no script engine found for language: " + implementation.getScriptLanguage()); + } + if (!(scriptEngine instanceof Invocable)) { + throw new ObjectCreationException("script engine does not support Invocable: " + scriptEngine); + } + + for (Reference reference : implementation.getReferences()) { + scriptEngine.put(reference.getName(), createReferenceProxy(reference.getName(), component)); + } + + for (Property property : implementation.getProperties()) { + ObjectFactory propertyValueFactory = propertyFactory.createValueFactory(property); + if ( propertyValueFactory != null) { + scriptEngine.put(property.getName(), propertyValueFactory.getInstance()); + } + } + + scriptEngine.eval(new StringReader(implementation.getScriptSrc())); + + } catch (ScriptException e) { + throw new ObjectCreationException(e); + } + } + + public void stop() { + } + + @SuppressWarnings("unchecked") + protected Object createReferenceProxy(String name, RuntimeComponent component) { + for (ComponentReference reference : component.getReferences()) { + if (reference.getName().equals(name)) { + Class iface = ((JavaInterface)reference.getInterfaceContract().getInterface()).getJavaClass(); + return component.getService(iface, name); + } + } + throw new IllegalArgumentException("reference " + name + " not found on component: " + component); + } + + /** + * Hack for now to work around a problem with the JRuby script engine + */ + private ScriptEngine getScriptEngineByExtension(String scriptExtn) { + ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); + if ("rb".equals(scriptExtn)) { + return new TuscanyJRubyScriptEngine(); + } else { + return scriptEngineManager.getEngineByExtension(scriptExtn); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationProviderFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationProviderFactory.java new file mode 100644 index 0000000000..a41f8ce3e2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementationProviderFactory.java @@ -0,0 +1,44 @@ +/* + * 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.implementation.script; + +import org.apache.tuscany.implementation.spi.PropertyValueObjectFactory; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.provider.ImplementationProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * Represents a Script implementation. + */ +public class ScriptImplementationProviderFactory implements ImplementationProviderFactory { + + private PropertyValueObjectFactory propertyFactory; + + public ScriptImplementationProviderFactory(PropertyValueObjectFactory propertyFactory) { + this.propertyFactory = propertyFactory; + } + + public ImplementationProvider createImplementationProvider(RuntimeComponent component, ScriptImplementation implementation) { + return new ScriptImplementationProvider(component, implementation, propertyFactory); + } + + public Class getModelType() { + return ScriptImplementation.class; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptInvoker.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptInvoker.java new file mode 100644 index 0000000000..4b75cf3a92 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptInvoker.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.implementation.script; + +import java.lang.reflect.InvocationTargetException; + +import javax.script.Invocable; +import javax.script.ScriptException; + +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; + +/** + * Perform the actual script invocation + */ +public class ScriptInvoker implements Invoker { + + protected ScriptImplementationProvider provider; + protected String operationName; + + /** + * TODO: passing in the impl is a bit of a hack to get at scriptEngine as thats all this uses + * but its not created till the start method which is called after the invokers are created + */ + public ScriptInvoker(ScriptImplementationProvider provider, String operationName) { + this.provider = provider; + this.operationName = operationName; + } + + private Object doInvoke(Object[] objects) throws InvocationTargetException { + try { + + return ((Invocable)provider.scriptEngine).invokeFunction(operationName, objects); + + } catch (ScriptException e) { + throw new InvocationTargetException(e); + } + } + + public Message invoke(Message msg) { + try { + Object resp = doInvoke((Object[])msg.getBody()); + msg.setBody(resp); + } catch (InvocationTargetException e) { + msg.setFaultBody(e.getCause()); + } + return msg; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptModuleActivator.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptModuleActivator.java new file mode 100644 index 0000000000..9a928a9065 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptModuleActivator.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.implementation.script; + +import org.apache.tuscany.implementation.spi.PropertyValueObjectFactory; +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.core.ModuleActivator; +import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; +import org.apache.tuscany.sca.databinding.TransformerExtensionPoint; +import org.apache.tuscany.sca.databinding.impl.MediatorImpl; +import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; + +public class ScriptModuleActivator implements ModuleActivator { + + public void start(ExtensionPointRegistry registry) { + + ModelFactoryExtensionPoint factories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class); + AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class); + + StAXArtifactProcessorExtensionPoint staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); + StAXArtifactProcessor scriptArtifactProcessor = new ScriptArtifactProcessor(assemblyFactory); + staxProcessors.addArtifactProcessor(scriptArtifactProcessor); + + // TODO: could the runtime have a default PropertyValueObjectFactory in the registry + DataBindingExtensionPoint dataBindings = registry.getExtensionPoint(DataBindingExtensionPoint.class); + TransformerExtensionPoint transformers = registry.getExtensionPoint(TransformerExtensionPoint.class); + MediatorImpl mediator = new MediatorImpl(dataBindings, transformers); + PropertyValueObjectFactory propertyFactory = new PropertyValueObjectFactory(mediator); + + ProviderFactoryExtensionPoint providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class); + providerFactories.addProviderFactory(new ScriptImplementationProviderFactory(propertyFactory)); + } + + public void stop(ExtensionPointRegistry registry) { + } + + public Object[] getExtensionPoints() { + return null; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/engines/TuscanyJRubyScriptEngine.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/engines/TuscanyJRubyScriptEngine.java new file mode 100644 index 0000000000..b1a1b05052 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/engines/TuscanyJRubyScriptEngine.java @@ -0,0 +1,445 @@ +/* +* Copyright (c) 2006, Sun Microsystems, Inc. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* - Redistributions of source code must retain the above copyright notice, this +* list of conditions and the following disclaimer. +* +* - 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. +* +* - Neither the name of the Sun Microsystems, Inc. nor the names of +* contributors may be used to endorse or promote products derived from this +* software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +* CONTRIBUTORS "AS IS" AND ANY EXPRESS 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 THE +* COPYRIGHT OWNER OR 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. +*/ +package org.apache.tuscany.sca.implementation.script.engines; + +import java.io.File; +import java.io.Reader; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import javax.script.AbstractScriptEngine; +import javax.script.Bindings; +import javax.script.Compilable; +import javax.script.CompiledScript; +import javax.script.Invocable; +import javax.script.ScriptContext; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineFactory; +import javax.script.ScriptException; +import javax.script.SimpleBindings; + +import org.jruby.Ruby; +import org.jruby.ast.Node; +import org.jruby.internal.runtime.GlobalVariable; +import org.jruby.internal.runtime.GlobalVariables; +import org.jruby.internal.runtime.ReadonlyAccessor; +import org.jruby.javasupport.Java; +import org.jruby.javasupport.JavaObject; +import org.jruby.javasupport.JavaUtil; +import org.jruby.runtime.Block; +import org.jruby.runtime.IAccessor; +import org.jruby.runtime.builtin.IRubyObject; + +import com.sun.script.jruby.JRubyScriptEngineFactory; + +/* + * This class is a copy of the class com.sun.script.ruby.JRubyScriptEngine with some minor modifications + * to work around problems with Tuscany setting SCA properties and references as global variable in JRuby + * Should only need it temporarily till a new BSF release fixes it. + */ +@SuppressWarnings("unchecked") +public class TuscanyJRubyScriptEngine extends AbstractScriptEngine + implements Compilable, Invocable { + + // my factory, may be null + private ScriptEngineFactory factory; + private Ruby runtime; + + public TuscanyJRubyScriptEngine() { + init(System.getProperty("com.sun.script.jruby.loadpath")); + } + + public TuscanyJRubyScriptEngine(String loadPath) { + init(loadPath); + } + + // my implementation for CompiledScript + private class JRubyCompiledScript extends CompiledScript { + // my compiled code + private Node node; + + JRubyCompiledScript (Node node) { + this.node = node; + } + + public ScriptEngine getEngine() { + return TuscanyJRubyScriptEngine.this; + } + + public Object eval(ScriptContext ctx) throws ScriptException { + return evalNode(node, ctx); + } + } + + // Compilable methods + public CompiledScript compile(String script) + throws ScriptException { + Node node = compileScript(script, context); + return new JRubyCompiledScript(node); + } + + public CompiledScript compile (Reader reader) + throws ScriptException { + Node node = compileScript(reader, context); + return new JRubyCompiledScript(node); + } + + // Invocable methods + public Object invokeFunction(String name, Object[] args) + throws ScriptException { + return invokeImpl(null, name, args, Object.class); + } + + public Object invokeMethod(Object obj, String name, Object[] args) + throws ScriptException { + if (obj == null) { + throw new IllegalArgumentException("script object is null"); + } + return invokeImpl(obj, name, args, Object.class); + } + + public Object getInterface(Object obj, Class clazz) { + if (obj == null) { + throw new IllegalArgumentException("script object is null"); + } + return makeInterface(obj, clazz); + } + + public Object getInterface(Class clazz) { + return makeInterface(null, clazz); + } + + private T makeInterface(Object obj, Class clazz) { + if (clazz == null || !clazz.isInterface()) { + throw new IllegalArgumentException("interface Class expected"); + } + final Object thiz = obj; + return (T) Proxy.newProxyInstance( + clazz.getClassLoader(), + new Class[] { clazz }, + new InvocationHandler() { + public Object invoke(Object proxy, Method m, Object[] args) + throws Throwable { + return invokeImpl(thiz, m.getName(), + args, m.getReturnType()); + } + }); + } + + // ScriptEngine methods + public synchronized Object eval(String str, ScriptContext ctx) + throws ScriptException { + Node node = compileScript(str, ctx); + return evalNode(node, ctx); + } + + public synchronized Object eval(Reader reader, ScriptContext ctx) + throws ScriptException { + Node node = compileScript(reader, ctx); + return evalNode(node, ctx); + } + + public ScriptEngineFactory getFactory() { + synchronized (this) { + if (factory == null) { + factory = new JRubyScriptEngineFactory(); + } + } + return factory; + } + + public Bindings createBindings() { + return new SimpleBindings(); + } + + // package-private methods + void setFactory(ScriptEngineFactory factory) { + this.factory = factory; + } + + // internals only below this point + + private Object rubyToJava(IRubyObject value) { + return rubyToJava(value, Object.class); + } + + private Object rubyToJava(IRubyObject value, Class type) { + return JavaUtil.convertArgument( + Java.ruby_to_java(value, value, Block.NULL_BLOCK), + type); + } + + private IRubyObject javaToRuby(Object value) { + if (value instanceof IRubyObject) { + return (IRubyObject) value; + } + IRubyObject result = JavaUtil.convertJavaToRuby(runtime, value); + if (result instanceof JavaObject) { + return runtime.getModule("JavaUtilities").callMethod(runtime.getCurrentContext(), "wrap", result); + } + return result; + } + + private synchronized Node compileScript(String script, ScriptContext ctx) + throws ScriptException { + GlobalVariables oldGlobals = runtime.getGlobalVariables(); + try { + setGlobalVariables(ctx); + String filename = (String) ctx.getAttribute(ScriptEngine.FILENAME); + if (filename == null) { + filename = ""; + } + return runtime.parse(script, filename, null); + } catch (Exception exp) { + throw new ScriptException(exp); + } finally { + if (oldGlobals != null) { + //setGlobalVariables(oldGlobals); + } + } + } + + private synchronized Node compileScript(Reader reader, ScriptContext ctx) + throws ScriptException { + GlobalVariables oldGlobals = runtime.getGlobalVariables(); + try { + setGlobalVariables(ctx); + String filename = (String) ctx.getAttribute(ScriptEngine.FILENAME); + if (filename == null) { + filename = ""; + } + return runtime.parse(reader, filename, null); + } catch (Exception exp) { + throw new ScriptException(exp); + } finally { + if (oldGlobals != null) { + //setGlobalVariables(oldGlobals); + } + } + } + + private void setGlobalVariables(final ScriptContext ctx) { + ctx.setAttribute("context", ctx, ScriptContext.ENGINE_SCOPE); + setGlobalVariables(new GlobalVariables(runtime) { + GlobalVariables parent = runtime.getGlobalVariables(); + + public void define(String name, IAccessor accessor) { + assert name != null; + assert accessor != null; + assert name.startsWith("$"); + synchronized (ctx) { + Bindings engineScope = ctx.getBindings(ScriptContext.ENGINE_SCOPE); + engineScope.put(name, new GlobalVariable(accessor)); + } + } + + + public void defineReadonly(String name, IAccessor accessor) { + assert name != null; + assert accessor != null; + assert name.startsWith("$"); + synchronized (ctx) { + Bindings engineScope = ctx.getBindings(ScriptContext.ENGINE_SCOPE); + engineScope.put(name, new GlobalVariable(new + ReadonlyAccessor(name, accessor))); + } + } + + public boolean isDefined(String name) { + assert name != null; + assert name.startsWith("$"); + synchronized (ctx) { + String modifiedName = name.substring(1); + boolean defined = ctx.getAttributesScope(modifiedName) != -1; + return defined ? true : parent.isDefined(name); + } + } + + public void alias(String name, String oldName) { + assert name != null; + assert oldName != null; + assert name.startsWith("$"); + assert oldName.startsWith("$"); + + if (runtime.getSafeLevel() >= 4) { + throw runtime.newSecurityError("Insecure: can't alias global variable"); + } + + synchronized (ctx) { + int scope = ctx.getAttributesScope(name); + if (scope == -1) { + scope = ScriptContext.ENGINE_SCOPE; + } + + IRubyObject value = get(oldName); + ctx.setAttribute(name, rubyToJava(value), scope); + } + } + + public IRubyObject get(String name) { + assert name != null; + assert name.startsWith("$"); + + synchronized (ctx) { + // skip '$' and try + String modifiedName = name.substring(1); + int scope = ctx.getAttributesScope(modifiedName); + if (scope == -1) { + return parent.get(name); + } + + Object obj = ctx.getAttribute(modifiedName, scope); + if (obj instanceof IAccessor) { + return ((IAccessor)obj).getValue(); + } else { + return javaToRuby(obj); + } + } + } + + public IRubyObject set(String name, IRubyObject value) { + assert name != null; + assert name.startsWith("$"); + + if (runtime.getSafeLevel() >= 4) { + throw runtime.newSecurityError("Insecure: can't change global variable value"); + } + + synchronized (ctx) { + // skip '$' and try + String modifiedName = name.substring(1); + int scope = ctx.getAttributesScope(modifiedName); + if (scope == -1) { + scope = ScriptContext.ENGINE_SCOPE; + } + IRubyObject oldValue = get(name); + Object obj = ctx.getAttribute(modifiedName, scope); + if (obj instanceof IAccessor) { + ((IAccessor)obj).setValue(value); + } else { + ctx.setAttribute(modifiedName, rubyToJava(value), scope); + } + return oldValue; + } + } + + public Iterator getNames() { + List list = new ArrayList(); + synchronized (ctx) { + Iterator iterator = ctx.getScopes().iterator(); + int scope; + while (iterator.hasNext()) { + scope = iterator.next().intValue(); + Bindings b = ctx.getBindings(scope); + if (b != null) { + Iterator bIterator = b.keySet().iterator(); + while (bIterator.hasNext()) { + list.add(bIterator.next()); + } + } + } + } + for (Iterator names = parent.getNames(); names.hasNext();) { + list.add(names.next()); + } + return Collections.unmodifiableList(list).iterator(); + } + }); + } + + private void setGlobalVariables(GlobalVariables globals) { + runtime.setGlobalVariables(globals); + } + + private synchronized Object evalNode(Node node, ScriptContext ctx) + throws ScriptException { + GlobalVariables oldGlobals = runtime.getGlobalVariables(); + try { + setGlobalVariables(ctx); + return rubyToJava(runtime.eval(node)); + } catch (Exception exp) { + throw new ScriptException(exp); + } finally { + if (oldGlobals != null) { + //setGlobalVariables(oldGlobals); + } + } + } + + private void init(String loadPath) { + runtime = Ruby.getDefaultInstance(); + if (loadPath == null) { + loadPath = System.getProperty("java.class.path"); + } + List list = Arrays.asList(loadPath.split(File.pathSeparator)); + runtime.getLoadService().init(list); + runtime.getLoadService().require("java"); + } + + private Object invokeImpl(final Object obj, String method, + Object[] args, Class returnType) + throws ScriptException { + if (method == null) { + throw new NullPointerException("method name is null"); + } + + try { + IRubyObject rubyRecv = obj != null ? + JavaUtil.convertJavaToRuby(runtime, obj) : runtime.getTopSelf(); + + IRubyObject[] rubyArgs = JavaUtil.convertJavaArrayToRuby(runtime, args); + + // Create Ruby proxies for any input arguments that are not primitives. + IRubyObject javaUtilities = runtime.getObject().getConstant("JavaUtilities"); + for (int i = 0; i < rubyArgs.length; i++) { + IRubyObject tmp = rubyArgs[i]; + if (tmp instanceof JavaObject) { + rubyArgs[i] = javaUtilities.callMethod(runtime.getCurrentContext(), "wrap", tmp); + } + } + + IRubyObject result = rubyRecv.callMethod(runtime.getCurrentContext(), method, rubyArgs); + return rubyToJava(result, returnType); + } catch (Exception exp) { + throw new ScriptException(exp); + } + } +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator new file mode 100644 index 0000000000..21c8ad9c32 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator @@ -0,0 +1,18 @@ +# 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 ExtensionActivator +org.apache.tuscany.sca.implementation.script.ScriptModuleActivator diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/AbstractSCATestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/AbstractSCATestCase.java new file mode 100644 index 0000000000..e050cd7083 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/AbstractSCATestCase.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.implementation.script.itests; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public abstract class AbstractSCATestCase extends TestCase { + + protected SCADomain domain; + protected T service; + + @SuppressWarnings("unchecked") + protected void setUp() throws Exception { + domain = SCADomain.newInstance(getCompositeName()); + service = (T) domain.getService(getServiceClass(), "ClientComponent"); + } + + abstract protected Class getServiceClass(); + + protected void tearDown() throws Exception { + domain.close(); + } + + protected String getCompositeName() { + String className = this.getClass().getName(); + return className.substring(0, className.length() - 8).replace('.', '/') + ".composite"; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/AbstractHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/AbstractHelloWorldTestCase.java new file mode 100644 index 0000000000..dedc8bce09 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/AbstractHelloWorldTestCase.java @@ -0,0 +1,34 @@ +/* + * 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.implementation.script.itests.helloworld; + +import org.apache.tuscany.sca.implementation.script.itests.AbstractSCATestCase; + +public abstract class AbstractHelloWorldTestCase extends AbstractSCATestCase { + + public void testCalculator() throws Exception { + assertEquals("Hello petra", service.sayHello("petra")); + } + + @Override + protected Class getServiceClass() { + return HelloWorld.class; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/GroovyHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/GroovyHelloWorldTestCase.java new file mode 100644 index 0000000000..39161a447b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/GroovyHelloWorldTestCase.java @@ -0,0 +1,25 @@ +/* + * 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.implementation.script.itests.helloworld; + + +public class GroovyHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/HelloWorld.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/HelloWorld.java new file mode 100644 index 0000000000..e86119b72e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/HelloWorld.java @@ -0,0 +1,26 @@ +/* + * 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.implementation.script.itests.helloworld; + +public interface HelloWorld { + + public String sayHello(String s); + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/HelloWorldProxy.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/HelloWorldProxy.java new file mode 100644 index 0000000000..9485f39faa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/HelloWorldProxy.java @@ -0,0 +1,33 @@ +/* + * 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.implementation.script.itests.helloworld; + +import org.osoa.sca.annotations.Reference; + +public class HelloWorldProxy implements HelloWorld { + + @Reference + public HelloWorld delegate; + + public String sayHello(String s) { + return delegate.sayHello(s); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JRubyHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JRubyHelloWorldTestCase.java new file mode 100644 index 0000000000..56015b5f7c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JRubyHelloWorldTestCase.java @@ -0,0 +1,25 @@ +/* + * 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.implementation.script.itests.helloworld; + + +public class JRubyHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScriptHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScriptHelloWorldTestCase.java new file mode 100644 index 0000000000..2ccbd4d4b4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScriptHelloWorldTestCase.java @@ -0,0 +1,25 @@ +/* + * 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.implementation.script.itests.helloworld; + + +public class JavaScriptHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java new file mode 100644 index 0000000000..79c204c759 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/helloworld/JythonHelloWorldTestCase.java @@ -0,0 +1,25 @@ +/* + * 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.implementation.script.itests.helloworld; + + +public class JythonHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/AbstractHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/AbstractHelloWorldTestCase.java new file mode 100644 index 0000000000..8d9e7b119f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/AbstractHelloWorldTestCase.java @@ -0,0 +1,34 @@ +/* + * 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.implementation.script.itests.properties; + +import org.apache.tuscany.sca.implementation.script.itests.AbstractSCATestCase; + +public abstract class AbstractHelloWorldTestCase extends AbstractSCATestCase { + + public void testCalculator() throws Exception { + // assertEquals("Hello petra from Tuscany", service.sayHello("petra")); + } + + @Override + protected Class getServiceClass() { + return HelloWorld.class; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/GroovyHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/GroovyHelloWorldTestCase.java new file mode 100644 index 0000000000..996978e196 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/GroovyHelloWorldTestCase.java @@ -0,0 +1,25 @@ +/* + * 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.implementation.script.itests.properties; + + +public class GroovyHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/HelloWorld.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/HelloWorld.java new file mode 100644 index 0000000000..73fcd77b44 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/HelloWorld.java @@ -0,0 +1,26 @@ +/* + * 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.implementation.script.itests.properties; + +public interface HelloWorld { + + public String sayHello(String s); + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/HelloWorldProxy.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/HelloWorldProxy.java new file mode 100644 index 0000000000..bd18153be8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/HelloWorldProxy.java @@ -0,0 +1,33 @@ +/* + * 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.implementation.script.itests.properties; + +import org.osoa.sca.annotations.Reference; + +public class HelloWorldProxy implements HelloWorld { + + @Reference + public HelloWorld delegate; + + public String sayHello(String s) { + return delegate.sayHello(s); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JRubyHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JRubyHelloWorldTestCase.java new file mode 100644 index 0000000000..8220fcade8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JRubyHelloWorldTestCase.java @@ -0,0 +1,24 @@ +/* + * 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.implementation.script.itests.properties; + +public class JRubyHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JavaScriptHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JavaScriptHelloWorldTestCase.java new file mode 100644 index 0000000000..abd3ff311d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JavaScriptHelloWorldTestCase.java @@ -0,0 +1,25 @@ +/* + * 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.implementation.script.itests.properties; + + +public class JavaScriptHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JythonHelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JythonHelloWorldTestCase.java new file mode 100644 index 0000000000..c2f1ce811d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/properties/JythonHelloWorldTestCase.java @@ -0,0 +1,25 @@ +/* + * 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.implementation.script.itests.properties; + + +public class JythonHelloWorldTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/GroovyReferenceTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/GroovyReferenceTestCase.java new file mode 100644 index 0000000000..3f72c6cf45 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/GroovyReferenceTestCase.java @@ -0,0 +1,25 @@ +/* + * 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.implementation.script.itests.references; + +import org.apache.tuscany.sca.implementation.script.itests.helloworld.AbstractHelloWorldTestCase; + +public class GroovyReferenceTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/HelloWorldTarget.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/HelloWorldTarget.java new file mode 100644 index 0000000000..454843ea6c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/HelloWorldTarget.java @@ -0,0 +1,30 @@ +/* + * 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.implementation.script.itests.references; + +import org.apache.tuscany.sca.implementation.script.itests.helloworld.HelloWorld; + +public class HelloWorldTarget implements HelloWorld { + + public String sayHello(String s) { + return "Hello " + s; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JRubyReferenceTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JRubyReferenceTestCase.java new file mode 100644 index 0000000000..3c8b77e39f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JRubyReferenceTestCase.java @@ -0,0 +1,25 @@ +/* + * 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.implementation.script.itests.references; + +import org.apache.tuscany.sca.implementation.script.itests.helloworld.AbstractHelloWorldTestCase; + +public class JRubyReferenceTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JavaScriptReferenceTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JavaScriptReferenceTestCase.java new file mode 100644 index 0000000000..9caf7a715f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JavaScriptReferenceTestCase.java @@ -0,0 +1,25 @@ +/* + * 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.implementation.script.itests.references; + +import org.apache.tuscany.sca.implementation.script.itests.helloworld.AbstractHelloWorldTestCase; + +public class JavaScriptReferenceTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JythonReferenceTestCase.java b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JythonReferenceTestCase.java new file mode 100644 index 0000000000..26c970a56b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/java/org/apache/tuscany/sca/implementation/script/itests/references/JythonReferenceTestCase.java @@ -0,0 +1,25 @@ +/* + * 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.implementation.script.itests.references; + +import org.apache.tuscany.sca.implementation.script.itests.helloworld.AbstractHelloWorldTestCase; + +public class JythonReferenceTestCase extends AbstractHelloWorldTestCase { + // super class does it all getting composite based on this class name +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/GroovyHelloWorld.composite b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/GroovyHelloWorld.composite new file mode 100644 index 0000000000..e1cf7746d8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/GroovyHelloWorld.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JRubyHelloWorld.composite b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JRubyHelloWorld.composite new file mode 100644 index 0000000000..a50fa8d01c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JRubyHelloWorld.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScriptHelloWorld.composite b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScriptHelloWorld.composite new file mode 100644 index 0000000000..2ae739789e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JavaScriptHelloWorld.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JythonHelloWorld.composite b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JythonHelloWorld.composite new file mode 100644 index 0000000000..9b86752993 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/JythonHelloWorld.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.componentType b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.componentType new file mode 100644 index 0000000000..bb0ddd002f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.componentType @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.groovy b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.groovy new file mode 100644 index 0000000000..9f89bd373e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.groovy @@ -0,0 +1,22 @@ +/* + * 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. + */ + +def sayHello(s) { + return "Hello " + s +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.js b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.js new file mode 100644 index 0000000000..eac2ab283f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.js @@ -0,0 +1,23 @@ +/* + * 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. + */ + +function sayHello(s) { + + return "Hello " + s; +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.py b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.py new file mode 100644 index 0000000000..f5dd0f8fcf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.py @@ -0,0 +1,20 @@ +# 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. +# + +def sayHello(s): + return 'Hello ' + s \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.rb b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.rb new file mode 100644 index 0000000000..cd2d3bcaea --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/helloworld/helloworld.rb @@ -0,0 +1,21 @@ +# 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. +# + +def sayHello(s) + return "Hello " + s +end \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/GroovyHelloWorld.composite b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/GroovyHelloWorld.composite new file mode 100644 index 0000000000..08277e117c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/GroovyHelloWorld.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JRubyHelloWorld.composite b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JRubyHelloWorld.composite new file mode 100644 index 0000000000..9eeffe09b0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JRubyHelloWorld.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JavaScriptHelloWorld.composite b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JavaScriptHelloWorld.composite new file mode 100644 index 0000000000..1a733f9ae8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JavaScriptHelloWorld.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JythonHelloWorld.composite b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JythonHelloWorld.composite new file mode 100644 index 0000000000..b03aa0ae14 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/JythonHelloWorld.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.componentType b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.componentType new file mode 100644 index 0000000000..06f261015e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.componentType @@ -0,0 +1,32 @@ + + + + + + + + + Tuscany + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.groovy b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.groovy new file mode 100644 index 0000000000..a7eb446d37 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.groovy @@ -0,0 +1,22 @@ +/* + * 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. + */ + +def sayHello(s) { + return "Hello " + s + " from " + greeter +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.js b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.js new file mode 100644 index 0000000000..64df3ebbef --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.js @@ -0,0 +1,23 @@ +/* + * 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. + */ + +function sayHello(s) { + + return "Hello " + s + " from " + greeter; +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.py b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.py new file mode 100644 index 0000000000..868cfa9eeb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.py @@ -0,0 +1,20 @@ +# 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. +# + +def sayHello(s): + return 'Hello ' + s + ' from ' + greeter \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.rb b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.rb new file mode 100644 index 0000000000..2844f8b8d9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/properties/helloworld.rb @@ -0,0 +1,21 @@ +# 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. +# + +def sayHello(s) + return "Hello " + s + " from " + $greeter +end \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/GroovyReference.composite b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/GroovyReference.composite new file mode 100644 index 0000000000..cbcd11549d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/GroovyReference.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JRubyReference.composite b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JRubyReference.composite new file mode 100644 index 0000000000..9b8bd45837 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JRubyReference.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JavaScriptReference.composite b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JavaScriptReference.composite new file mode 100644 index 0000000000..a74cdfb9e3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JavaScriptReference.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JythonReference.composite b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JythonReference.composite new file mode 100644 index 0000000000..4d6f9ab27c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/JythonReference.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.componentType b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.componentType new file mode 100644 index 0000000000..3edd075126 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.componentType @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.groovy b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.groovy new file mode 100644 index 0000000000..5d2216d583 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.groovy @@ -0,0 +1,22 @@ +/* + * 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. + */ + +def sayHello(s) { + return ref.sayHello(s) +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.js b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.js new file mode 100644 index 0000000000..ad0a932d26 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.js @@ -0,0 +1,22 @@ +/* + * 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. + */ + +function sayHello(s) { + return ref.sayHello(s); +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.py b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.py new file mode 100644 index 0000000000..aee8bf991d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.py @@ -0,0 +1,20 @@ +# 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. +# + +def sayHello(s): + return ref.sayHello(s) diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.rb b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.rb new file mode 100644 index 0000000000..87f0f56082 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/implementation-script/src/test/resources/org/apache/tuscany/sca/implementation/script/itests/references/reference.rb @@ -0,0 +1,21 @@ +# 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. +# + +def sayHello(s) + return $ref.sayHello(s) +end \ No newline at end of file -- cgit v1.2.3