summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy')
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/.ruleset190
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/LICENSE.txt202
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/NOTICE.txt14
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/pom.xml77
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/AsyncGroovyInvoker.java92
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/AsyncMonitor.java34
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyAtomicComponent.java120
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentBuilder.java119
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentType.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentTypeLoader.java43
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyConfiguration.java150
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyImplementation.java45
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyInvoker.java87
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/ImplementationLoader.java110
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/resources/META-INF/sca/groovy.system.scdl40
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/AsyncInvokerTestCase.java77
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/GroovyComponentTypeLoaderTestCase.java37
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ImplementationLoaderTestCase.java102
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/PropertyTestCase.java90
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ScriptInvokeTestCase.java79
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/WireTestCase.java189
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/mock/AsyncTarget.java27
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/mock/Greeting.java25
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/resources/META-INF/sca/default.scdl28
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/resources/org/apache/tuscany/container/groovy/mock/TestScript.groovy1
25 files changed, 2021 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/.ruleset b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/.ruleset
new file mode 100644
index 0000000000..a1547fea92
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/.ruleset
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<ruleset name="pmd-eclipse">
+ <description>PMD Plugin preferences rule set</description>
+
+
+ <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+ <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+ <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+ <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+ <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+ <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+ <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+ <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+ <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<!--<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>-->
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+ <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+ <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+ <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+
+ <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+ <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+ <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+ <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+ <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+ <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+ <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+ <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+ <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+ <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+
+ <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+ <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+ <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+ <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+
+ <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+ <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+
+</ruleset>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/LICENSE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ 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, serviceDefinition marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/NOTICE.txt b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/NOTICE.txt
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+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.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/pom.xml b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/pom.xml
new file mode 100644
index 0000000000..30d90f503b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>groovy</artifactId>
+ <name>Apache Tuscany Groovy Container</name>
+ <description>Apache Tuscany Groovy Container</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>groovy</groupId>
+ <artifactId>groovy</artifactId>
+ <version>1.0-jsr-05</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-full</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>xpp3</groupId>
+ <artifactId>xpp3</artifactId>
+ <version>1.1.3.4-RC8</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/AsyncGroovyInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/AsyncGroovyInvoker.java
new file mode 100644
index 0000000000..f761122847
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/AsyncGroovyInvoker.java
@@ -0,0 +1,92 @@
+/*
+ * 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.container.groovy;
+
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+
+/**
+ * Responsible for performing a non-blocking dispatch on a Groovy component implementation instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class AsyncGroovyInvoker extends GroovyInvoker {
+
+ private InboundWire wire;
+ private AsyncMonitor monitor;
+ private WorkContext workContext;
+ private Object target;
+
+ /**
+ * Creates a new invoker
+ *
+ * @param operation the operation the invoker is associated with
+ * @param wire
+ * @param component the target component
+ * @param monitor the monitor to pass events to
+ * @param workContext
+ */
+ public AsyncGroovyInvoker(String operation,
+ InboundWire wire,
+ GroovyAtomicComponent component,
+ AsyncMonitor monitor,
+ WorkContext workContext) {
+ super(operation, component);
+ this.wire = wire;
+ this.monitor = monitor;
+ this.workContext = workContext;
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object messageId = msg.getMessageId();
+ wire.addMapping(messageId, msg.getFromAddress());
+ workContext.setCurrentMessageId(null);
+ workContext.setCurrentCorrelationId(messageId);
+ invokeTarget(msg.getBody());
+ // async so no return value
+ return null;
+ } catch (Throwable e) {
+ // FIXME need to log exceptions
+ monitor.executionError(e);
+ return null;
+ }
+ }
+
+ public AsyncGroovyInvoker clone() throws CloneNotSupportedException {
+ return (AsyncGroovyInvoker) super.clone();
+ }
+
+ /**
+ * Resolves the target service instance or returns a cached one
+ */
+ protected Object getInstance() throws TargetException {
+ if (!cacheable) {
+ return component.getTargetInstance();
+ } else {
+ if (target == null) {
+ target = component.getTargetInstance();
+ }
+ return target;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/AsyncMonitor.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/AsyncMonitor.java
new file mode 100644
index 0000000000..4da5538990
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/AsyncMonitor.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.container.groovy;
+
+/**
+ * A monitor used to log events during non-blocking invocations
+ * <p/>
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface AsyncMonitor {
+
+ /**
+ * Logs an exception thrown during an invocation
+ */
+ void executionError(Throwable e);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyAtomicComponent.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyAtomicComponent.java
new file mode 100644
index 0000000000..b0ed18382f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyAtomicComponent.java
@@ -0,0 +1,120 @@
+/*
+ * 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.container.groovy;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.extension.AtomicComponentExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import groovy.lang.GroovyObject;
+
+/**
+ * The Groovy atomic component implementation. Groovy implementations may be "scripts" or classes.
+ */
+public class GroovyAtomicComponent extends AtomicComponentExtension {
+ private final Class<? extends GroovyObject> groovyClass;
+ private final List<Class<?>> services;
+ //FIXME properties should move up to AtomicComponentExtension
+ private final Map<String, ObjectFactory> properties;
+ private AsyncMonitor monitor;
+
+ public GroovyAtomicComponent(GroovyConfiguration configuration, AsyncMonitor monitor) {
+ super(configuration.getName(),
+ configuration.getParent(),
+ configuration.getScopeContainer(),
+ configuration.getWireService(),
+ configuration.getWorkContext(),
+ null, configuration.getInitLevel());
+
+ this.groovyClass = configuration.getGroovyClass();
+ this.services = Collections.unmodifiableList(configuration.getServices());
+ this.properties = new HashMap<String, ObjectFactory>();
+ assert groovyClass != null;
+ this.monitor = monitor;
+ }
+
+ public List<Class<?>> getServiceInterfaces() {
+ return services;
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
+ return new GroovyInvoker(operation.getName(), this);
+ }
+
+ public TargetInvoker createAsyncTargetInvoker(InboundWire wire, Operation operation) {
+ return new AsyncGroovyInvoker(operation.getName(), wire, this, monitor, workContext);
+ }
+
+ public Object createInstance() throws ObjectCreationException {
+ GroovyObject instance;
+ try {
+ instance = groovyClass.newInstance();
+ } catch (IllegalAccessException e) {
+ throw new ObjectCreationException(e);
+ } catch (InstantiationException e) {
+ throw new ObjectCreationException(e);
+ }
+
+ // inject properties
+ for (Map.Entry<String, ObjectFactory> property : properties.entrySet()) {
+ instance.setProperty(property.getKey(), property.getValue().getInstance());
+ }
+
+ // inject references
+ for (List<OutboundWire> referenceWires : getOutboundWires().values()) {
+ for (OutboundWire wire : referenceWires) {
+ instance.setProperty(wire.getReferenceName(), wireService.createProxy(wire));
+ }
+ }
+ return instance;
+ }
+
+ public GroovyObject getTargetInstance() throws TargetException {
+ return (GroovyObject) scopeContainer.getInstance(this);
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ //TODO this should return a default service from a wire
+ return scopeContainer.getInstance(this);
+ }
+
+ public Object getServiceInstance(String service) throws TargetException {
+ InboundWire wire = getInboundWire(service);
+ if (wire == null) {
+ TargetException e = new TargetException("ServiceDefinition not found"); // TODO better error message
+ e.setIdentifier(service);
+ throw e;
+ }
+ return wireService.createProxy(wire);
+ }
+
+ public void addPropertyFactory(String name, ObjectFactory<?> factory) {
+ properties.put(name, factory);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentBuilder.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentBuilder.java
new file mode 100644
index 0000000000..4e99b888da
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentBuilder.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.container.groovy;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.builder.BuilderConfigException;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentBuilderExtension;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+import groovy.lang.GroovyClassLoader;
+import groovy.lang.GroovyObject;
+import org.codehaus.groovy.control.CompilationFailedException;
+
+/**
+ * Extension point for creating {@link GroovyAtomicComponent}s from an assembly configuration
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class GroovyComponentBuilder extends ComponentBuilderExtension<GroovyImplementation> {
+
+ protected Class<GroovyImplementation> getImplementationType() {
+ return GroovyImplementation.class;
+ }
+
+ public Component build(CompositeComponent parent,
+ ComponentDefinition<GroovyImplementation> componentDefinition,
+ DeploymentContext deploymentContext)
+ throws BuilderConfigException {
+
+ String name = componentDefinition.getName();
+ GroovyImplementation implementation = componentDefinition.getImplementation();
+ GroovyComponentType componentType = implementation.getComponentType();
+
+ int initLevel = componentType.getInitLevel();
+
+ // get list of services provided by this component
+ Collection<ServiceDefinition> collection = componentType.getServices().values();
+ List<Class<?>> services = new ArrayList<Class<?>>(collection.size());
+ for (ServiceDefinition serviceDefinition : collection) {
+ services.add(serviceDefinition.getServiceContract().getInterfaceClass());
+ }
+
+ // get the Groovy classloader for this deployment component
+ GroovyClassLoader groovyClassLoader = (GroovyClassLoader) deploymentContext.getExtension("groovy.classloader");
+ if (groovyClassLoader == null) {
+ groovyClassLoader = new GroovyClassLoader(deploymentContext.getClassLoader());
+ deploymentContext.putExtension("groovy.classloader", groovyClassLoader);
+ }
+
+ // create the implementation class for the script
+ Class<? extends GroovyObject> groovyClass;
+ try {
+ String script = implementation.getScript();
+ // REVIEW JFM can we cache the class?
+ groovyClass = groovyClassLoader.parseClass(script);
+ } catch (CompilationFailedException e) {
+ BuilderConfigException bce = new BuilderConfigException(e);
+ bce.setIdentifier(name);
+ throw bce;
+ }
+ // TODO deal with init and destroy
+
+ GroovyConfiguration configuration = new GroovyConfiguration();
+ configuration.setName(name);
+ configuration.setGroovyClass(groovyClass);
+ configuration.setParent(parent);
+ // get the scope container for this component's scope
+ Scope scope = componentType.getLifecycleScope();
+ if (Scope.MODULE == scope) {
+ configuration.setScopeContainer(deploymentContext.getModuleScope());
+ } else {
+ configuration.setScopeContainer(scopeRegistry.getScopeContainer(scope));
+ }
+
+
+ configuration.setWireService(wireService);
+ configuration.setWorkContext(workContext);
+ configuration.setInitLevel(initLevel);
+ configuration.setServices(services);
+ GroovyAtomicComponent component = new GroovyAtomicComponent(configuration, null);
+
+ // handle properties
+ for (Property<?> property : componentType.getProperties().values()) {
+ ObjectFactory<?> factory = property.getDefaultValueFactory();
+ if (factory != null) {
+ component.addPropertyFactory(property.getName(), factory);
+ }
+ }
+ return component;
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentType.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentType.java
new file mode 100644
index 0000000000..bd54371fd7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentType.java
@@ -0,0 +1,43 @@
+/*
+ * 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.container.groovy;
+
+import org.apache.tuscany.spi.model.ComponentType;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+/**
+ * Model object representing a Groovy component type
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class GroovyComponentType extends ComponentType<ServiceDefinition, ReferenceDefinition, Property<?>> {
+ private Scope lifecycleScope;
+
+ public Scope getLifecycleScope() {
+ return lifecycleScope;
+ }
+
+ public void setLifecycleScope(Scope lifecycleScope) {
+ this.lifecycleScope = lifecycleScope;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentTypeLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentTypeLoader.java
new file mode 100644
index 0000000000..6da7840fdb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyComponentTypeLoader.java
@@ -0,0 +1,43 @@
+/*
+ * 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.container.groovy;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.ComponentTypeLoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GroovyComponentTypeLoader extends ComponentTypeLoaderExtension<GroovyImplementation> {
+ protected Class<GroovyImplementation> getImplementationClass() {
+ return GroovyImplementation.class;
+ }
+
+ public void load(CompositeComponent parent, GroovyImplementation implementation, DeploymentContext context)
+ throws LoaderException {
+ GroovyComponentType componentType = new GroovyComponentType();
+ // for now, default to module
+ componentType.setLifecycleScope(Scope.MODULE);
+ implementation.setComponentType(componentType);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyConfiguration.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyConfiguration.java
new file mode 100644
index 0000000000..b9ede2d034
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyConfiguration.java
@@ -0,0 +1,150 @@
+/*
+ * 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.container.groovy;
+
+import java.lang.reflect.Member;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.WireService;
+
+import groovy.lang.GroovyObject;
+
+/**
+ * Encapsulates confuration for a Groovy-based atomic component
+ *
+ * @version $Rev$ $Date$
+ */
+public class GroovyConfiguration {
+
+ private CompositeComponent parent;
+ private ScopeContainer scopeContainer;
+ private int initLevel;
+ private Map<String, Member> referenceSites = new HashMap<String, Member>();
+ private Map<String, Member> propertySites = new HashMap<String, Member>();
+ private Map<String, Member> callbackSites = new HashMap<String, Member>();
+ private List<Class<?>> serviceInterfaces = new ArrayList<Class<?>>();
+ private WireService wireService;
+ private WorkContext workContext;
+ private String name;
+ private Class<? extends GroovyObject> groovyClass;
+ private List<Class<?>> services;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Class<? extends GroovyObject> getGroovyClass() {
+ return groovyClass;
+ }
+
+ public void setGroovyClass(Class<? extends GroovyObject> groovyClass) {
+ this.groovyClass = groovyClass;
+ }
+
+ public CompositeComponent getParent() {
+ return parent;
+ }
+
+ public void setParent(CompositeComponent parent) {
+ this.parent = parent;
+ }
+
+ public ScopeContainer getScopeContainer() {
+ return scopeContainer;
+ }
+
+ public void setScopeContainer(ScopeContainer scopeContainer) {
+ this.scopeContainer = scopeContainer;
+ }
+
+ public List<Class<?>> getServiceInterfaces() {
+ return serviceInterfaces;
+ }
+
+ public void addServiceInterface(Class<?> serviceInterface) {
+ serviceInterfaces.add(serviceInterface);
+ }
+
+ public int getInitLevel() {
+ return initLevel;
+ }
+
+ public void setInitLevel(int initLevel) {
+ this.initLevel = initLevel;
+ }
+
+ public List<Class<?>> getServices() {
+ return services;
+ }
+
+ public void setServices(List<Class<?>> services) {
+ this.services = services;
+ }
+
+ public Map<String, Member> getReferenceSite() {
+ return referenceSites;
+ }
+
+ public void addReferenceSite(String name, Member member) {
+ referenceSites.put(name, member);
+ }
+
+ public Map<String, Member> getCallbackSite() {
+ return callbackSites;
+ }
+
+ public void addCallbackSite(String name, Member member) {
+ callbackSites.put(name, member);
+ }
+
+ public Map<String, Member> getPropertySites() {
+ return propertySites;
+ }
+
+ public void addPropertySite(String name, Member member) {
+ propertySites.put(name, member);
+ }
+
+ public WireService getWireService() {
+ return wireService;
+ }
+
+ public void setWireService(WireService wireService) {
+ this.wireService = wireService;
+ }
+
+ public WorkContext getWorkContext() {
+ return workContext;
+ }
+
+ public void setWorkContext(WorkContext workContext) {
+ this.workContext = workContext;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyImplementation.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyImplementation.java
new file mode 100644
index 0000000000..96b4a3bc2d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyImplementation.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import org.apache.tuscany.spi.model.AtomicImplementation;
+
+/**
+ * Model object for a Groovy implementation.
+ */
+public class GroovyImplementation extends AtomicImplementation<GroovyComponentType> {
+
+ //the Groovy source to be executed
+ private String script;
+
+ /**
+ * Returns the Groovy source to be executed.
+ */
+ public String getScript() {
+ return script;
+ }
+
+ /**
+ * Sets the Groovy source to be executed.
+ */
+ public void setScript(String script) {
+ this.script = script;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyInvoker.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyInvoker.java
new file mode 100644
index 0000000000..b6fdbbb0b6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/GroovyInvoker.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import groovy.lang.GroovyObject;
+
+/**
+ * Dispatches to a Groovy implementation instance
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class GroovyInvoker implements TargetInvoker, Cloneable {
+
+ protected GroovyAtomicComponent component;
+ protected String operation;
+ protected boolean cacheable;
+
+ public GroovyInvoker(String operation, GroovyAtomicComponent context) {
+ this.component = context;
+ this.operation = operation;
+ }
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public void setCacheable(boolean cacheable) {
+ this.cacheable = cacheable;
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+
+ /**
+ * Dispatches to the the target.
+ */
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ GroovyObject target = component.getTargetInstance();
+ Object[] args = (Object[]) payload;
+ try {
+ return target.invokeMethod(operation, args);
+ } catch (Exception ex) {
+ throw new InvocationTargetException(ex);
+ }
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBodyWithFault(e.getCause());
+ } catch (Throwable e) {
+ msg.setBodyWithFault(e);
+ }
+ return msg;
+ }
+
+ public GroovyInvoker clone() throws CloneNotSupportedException {
+ return (GroovyInvoker) super.clone();
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/ImplementationLoader.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/ImplementationLoader.java
new file mode 100644
index 0000000000..da93abbd9d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/java/org/apache/tuscany/container/groovy/ImplementationLoader.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.groovy;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+
+/**
+ * Loader for handling <groovy:implementation> elements.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ImplementationLoader extends LoaderExtension<GroovyImplementation> {
+ private static final QName IMPLEMENTATION_GROOVY =
+ new QName("http://incubator.apache.org/tuscany/xmlns/container/groovy/1.0-incubator-M2", "implementation.groovy");
+
+ public ImplementationLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return IMPLEMENTATION_GROOVY;
+ }
+
+ public GroovyImplementation load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+
+ String script = reader.getAttributeValue(null, "script");
+ if (script == null) {
+ throw new MissingResourceException("No script supplied");
+ }
+ String source = loadSource(deploymentContext.getClassLoader(), script);
+
+ LoaderUtil.skipToEndElement(reader);
+
+ GroovyImplementation implementation = new GroovyImplementation();
+ implementation.setScript(source);
+ // no component type support
+ //registry.loadComponentType(parent, implementation, deploymentContext);
+ return implementation;
+ }
+
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ URL url = cl.getResource(resource);
+ if (url == null) {
+ throw new MissingResourceException(resource);
+ }
+ InputStream is;
+ try {
+ is = url.openStream();
+ } catch (IOException e) {
+ MissingResourceException mre = new MissingResourceException(resource, e);
+ mre.setIdentifier(resource);
+ throw mre;
+ }
+ 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) {
+ LoaderException le = new LoaderException(e);
+ le.setIdentifier(resource);
+ throw le;
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/resources/META-INF/sca/groovy.system.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/resources/META-INF/sca/groovy.system.scdl
new file mode 100644
index 0000000000..24fbfd5e25
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/main/resources/META-INF/sca/groovy.system.scdl
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<!--
+ JavaScript configuration for the launcher environment.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
+
+ name="groovy.extension">
+
+ <component name="GroovyLoader">
+ <system:implementation.system class="org.apache.tuscany.container.groovy.ImplementationLoader"/>
+ </component>
+
+ <component name="GroovyComponentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.container.groovy.GroovyComponentTypeLoader"/>
+ </component>
+
+ <component name="GroovyBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.groovy.GroovyComponentBuilder"/>
+ </component>
+
+</composite> \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/AsyncInvokerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/AsyncInvokerTestCase.java
new file mode 100644
index 0000000000..a27bb25484
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/AsyncInvokerTestCase.java
@@ -0,0 +1,77 @@
+/*
+ * 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.container.groovy;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+
+import groovy.lang.GroovyObject;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.groovy.mock.AsyncTarget;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.getCurrentArguments;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import org.easymock.IAnswer;
+import org.easymock.classextension.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AsyncInvokerTestCase extends TestCase {
+
+ public void testInvoke() throws Exception {
+ GroovyObject instance = createMock(GroovyObject.class);
+ expect(instance.invokeMethod("invoke", null)).andReturn(null).once();
+ replay(instance);
+ GroovyAtomicComponent component = EasyMock.createMock(GroovyAtomicComponent.class);
+ expect(component.getTargetInstance()).andReturn(instance);
+ EasyMock.replay(component);
+ AsyncMonitor monitor = createMock(AsyncMonitor.class);
+ replay(monitor);
+
+ WorkScheduler scheduler = createMock(WorkScheduler.class);
+ scheduler.scheduleWork(isA(Runnable.class));
+ expectLastCall().andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ Runnable runnable = (Runnable) getCurrentArguments()[0];
+ runnable.run();
+ return null;
+ }
+ });
+ replay(scheduler);
+ WorkContext context = createMock(WorkContext.class);
+ Method method = AsyncTarget.class.getMethod("invoke");
+ method.setAccessible(true);
+ InboundWire wire = createMock(InboundWire.class);
+ AsyncGroovyInvoker invoker = new AsyncGroovyInvoker("invoke", wire, component, monitor, context);
+ Message msg = new MessageImpl();
+ invoker.invoke(msg);
+ verify(instance);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/GroovyComponentTypeLoaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/GroovyComponentTypeLoaderTestCase.java
new file mode 100644
index 0000000000..bfff4bdef7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/GroovyComponentTypeLoaderTestCase.java
@@ -0,0 +1,37 @@
+/*
+ * 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.container.groovy;
+
+import org.apache.tuscany.spi.model.Scope;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GroovyComponentTypeLoaderTestCase extends TestCase {
+
+ public void testLoad() throws Exception {
+ GroovyComponentTypeLoader loader = new GroovyComponentTypeLoader();
+ GroovyImplementation impl = new GroovyImplementation();
+ loader.load(null, impl, null);
+ GroovyComponentType type = impl.getComponentType();
+ assertEquals(Scope.MODULE, type.getLifecycleScope());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ImplementationLoaderTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ImplementationLoaderTestCase.java
new file mode 100644
index 0000000000..2af0611757
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ImplementationLoaderTestCase.java
@@ -0,0 +1,102 @@
+/*
+ * 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.container.groovy;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+
+import junit.framework.TestCase;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ImplementationLoaderTestCase extends TestCase {
+ private CompositeComponent parent;
+ private XMLStreamReader reader;
+ private DeploymentContext deploymentContext;
+ private ClassLoader classLoader;
+ private LoaderRegistry registry;
+ private ImplementationLoader loader;
+
+ public void testNoScriptAttribute() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn(null);
+ replay(reader);
+ replay(deploymentContext);
+
+ try {
+ loader.load(parent, reader, deploymentContext);
+ fail();
+ } catch (MissingResourceException e) {
+ // ok
+ }
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testNoScriptPresent() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn("foo.groovy");
+ expect(deploymentContext.getClassLoader()).andReturn(classLoader);
+
+ replay(reader);
+ replay(deploymentContext);
+
+ ImplementationLoader mockLoader = new ImplementationLoader(registry) {
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ assertSame(classLoader, cl);
+ assertEquals("foo.groovy", resource);
+ throw new MissingResourceException(resource);
+ }
+ };
+ try {
+ mockLoader.load(parent, reader, deploymentContext);
+ fail();
+ } catch (MissingResourceException e) {
+ assertEquals("foo.groovy", e.getMessage());
+ }
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testLoadScript() throws LoaderException {
+ String script = loader.loadSource(getClass().getClassLoader(),
+ "org/apache/tuscany/container/groovy/mock/TestScript.groovy");
+ assertEquals("Test Script", script);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = createMock(LoaderRegistry.class);
+ loader = new ImplementationLoader(registry);
+
+ parent = createMock(CompositeComponent.class);
+ reader = createMock(XMLStreamReader.class);
+ deploymentContext = createMock(DeploymentContext.class);
+ classLoader = createMock(ClassLoader.class);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/PropertyTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/PropertyTestCase.java
new file mode 100644
index 0000000000..9b828db7eb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/PropertyTestCase.java
@@ -0,0 +1,90 @@
+/*
+ * 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.container.groovy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+
+import groovy.lang.GroovyClassLoader;
+import groovy.lang.GroovyObject;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.groovy.mock.Greeting;
+import static org.apache.tuscany.test.ArtifactFactory.createWireService;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.getCurrentArguments;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import org.easymock.IAnswer;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class PropertyTestCase extends TestCase {
+
+ private static final String SCRIPT = "import org.apache.tuscany.container.groovy.mock.Greeting;"
+ + "class Foo implements Greeting{"
+ + " String property;"
+ + " public String greet(String name){"
+ + " return property; "
+ + " }"
+ + "}";
+
+ private ScopeContainer scopeContainer;
+ private Class<? extends GroovyObject> implClass;
+
+ /**
+ * Tests injecting a simple property type on a Groovy implementation instance
+ */
+ public void testPropertyInjection() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Greeting.class);
+ GroovyConfiguration configuration = new GroovyConfiguration();
+ configuration.setName("source");
+ configuration.setGroovyClass(implClass);
+ configuration.setServices(services);
+ configuration.setScopeContainer(scopeContainer);
+ configuration.setWireService(createWireService());
+ GroovyAtomicComponent component = new GroovyAtomicComponent(configuration, null);
+ ObjectFactory<?> factory = createMock(ObjectFactory.class);
+ expect((String) factory.getInstance()).andReturn("bar");
+ replay(factory);
+ component.addPropertyFactory("property", factory);
+ Greeting greeting = (Greeting) component.getServiceInstance();
+ assertEquals("bar", greeting.greet("foo"));
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+ GroovyClassLoader cl = new GroovyClassLoader(getClass().getClassLoader());
+ implClass = cl.parseClass(SCRIPT);
+ scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getInstance(isA(AtomicComponent.class))).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return ((AtomicComponent) getCurrentArguments()[0]).createInstance();
+ }
+ });
+ replay(scopeContainer);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ScriptInvokeTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ScriptInvokeTestCase.java
new file mode 100644
index 0000000000..f0ae7deb33
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/ScriptInvokeTestCase.java
@@ -0,0 +1,79 @@
+/*
+ * 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.container.groovy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+
+import groovy.lang.GroovyClassLoader;
+import groovy.lang.GroovyObject;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.groovy.mock.Greeting;
+import static org.apache.tuscany.test.ArtifactFactory.createWireService;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.getCurrentArguments;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import org.easymock.IAnswer;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class ScriptInvokeTestCase extends TestCase {
+
+ private static final String SCRIPT = "def greet(name) { return name }";
+
+ private Class<? extends GroovyObject> implClass;
+ private ScopeContainer scopeContainer;
+
+ /**
+ * Tests the invocation of a Groovy "script" as opposed to a class
+ */
+ public void testBasicScriptInvocation() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Greeting.class);
+ GroovyConfiguration configuration = new GroovyConfiguration();
+ configuration.setName("source");
+ configuration.setGroovyClass(implClass);
+ configuration.setServices(services);
+ configuration.setScopeContainer(scopeContainer);
+ configuration.setWireService(createWireService());
+ GroovyAtomicComponent context = new GroovyAtomicComponent(configuration, null);
+ GroovyObject object = (GroovyObject) context.getServiceInstance();
+ assertEquals("foo", object.invokeMethod("greet", "foo"));
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+ GroovyClassLoader cl = new GroovyClassLoader(getClass().getClassLoader());
+ implClass = cl.parseClass(SCRIPT);
+ scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getInstance(isA(AtomicComponent.class))).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return ((AtomicComponent) getCurrentArguments()[0]).createInstance();
+ }
+ });
+ replay(scopeContainer);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/WireTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/WireTestCase.java
new file mode 100644
index 0000000000..79f37f514c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/WireTestCase.java
@@ -0,0 +1,189 @@
+/*
+ * 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.container.groovy;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import groovy.lang.GroovyClassLoader;
+import groovy.lang.GroovyObject;
+import junit.framework.TestCase;
+import org.apache.tuscany.container.groovy.mock.Greeting;
+import static org.apache.tuscany.test.ArtifactFactory.createInboundWire;
+import static org.apache.tuscany.test.ArtifactFactory.createOutboundWire;
+import static org.apache.tuscany.test.ArtifactFactory.createWireService;
+import static org.apache.tuscany.test.ArtifactFactory.terminateWire;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.getCurrentArguments;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reportMatcher;
+import static org.easymock.EasyMock.verify;
+import org.easymock.IAnswer;
+import org.easymock.IArgumentMatcher;
+
+/**
+ * @version $$Rev$$ $$Date$$
+ */
+public class WireTestCase extends TestCase {
+
+ private static final String SCRIPT = "import org.apache.tuscany.container.groovy.mock.Greeting;"
+ + "class Foo implements Greeting{"
+ + " Greeting wire;"
+ + " "
+ + " void setWire(Greeting ref){"
+ + " wire = ref;"
+ + " };"
+ + " "
+ + " String greet(String name){"
+ + " return wire.greet(name); "
+ + " };"
+ + "}";
+
+ private static final String SCRIPT2 = "import org.apache.tuscany.container.groovy.mock.Greeting;"
+ + "class Foo implements Greeting{"
+ + " public String greet(String name){"
+ + " return name; "
+ + " }"
+ + "}";
+
+ private Class<? extends GroovyObject> implClass1;
+ private Class<? extends GroovyObject> implClass2;
+ private ScopeContainer scopeContainer;
+
+ /**
+ * Tests a basic invocation down a source wire
+ */
+ public void testReferenceWireInvocation() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Greeting.class);
+ GroovyConfiguration configuration = new GroovyConfiguration();
+ configuration.setName("source");
+ configuration.setGroovyClass(implClass1);
+ configuration.setServices(services);
+ configuration.setScopeContainer(scopeContainer);
+ configuration.setWireService(createWireService());
+ GroovyAtomicComponent component = new GroovyAtomicComponent(configuration, null);
+ OutboundWire wire = createOutboundWire("wire", Greeting.class);
+ terminateWire(wire);
+
+ TargetInvoker invoker = createMock(TargetInvoker.class);
+ expect(invoker.isCacheable()).andReturn(false);
+ Message response = new MessageImpl();
+ response.setBody("foo");
+ expect(invoker.invoke(eqMessage())).andReturn(response);
+ replay(invoker);
+
+ for (OutboundInvocationChain chain : wire.getInvocationChains().values()) {
+ chain.setTargetInvoker(invoker);
+ }
+ component.addOutboundWire(wire);
+ Greeting greeting = (Greeting) component.getServiceInstance();
+ assertEquals("foo", greeting.greet("foo"));
+ verify(invoker);
+ }
+
+ // todo this could be generalized and moved to test module
+ public static Message eqMessage() {
+ reportMatcher(new IArgumentMatcher() {
+ public boolean matches(Object object) {
+ if (!(object instanceof Message)) {
+ return false;
+ }
+ final Message msg = (Message) object;
+ Object[] body = (Object[]) msg.getBody();
+ return "foo".equals(body[0]);
+ }
+
+ public void appendTo(StringBuffer stringBuffer) {
+ }
+ });
+ return null;
+ }
+
+
+ /**
+ * Tests a basic invocation to a target
+ */
+ public void testTargetInvocation() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Greeting.class);
+ GroovyConfiguration configuration = new GroovyConfiguration();
+ configuration.setName("source");
+ configuration.setGroovyClass(implClass2);
+ configuration.setServices(services);
+ configuration.setScopeContainer(scopeContainer);
+ configuration.setWireService(createWireService());
+ GroovyAtomicComponent component = new GroovyAtomicComponent(configuration, null);
+ Operation<Type> operation = new Operation<Type>("greet", null, null, null, false, null);
+ TargetInvoker invoker = component.createTargetInvoker(null, operation);
+ assertEquals("foo", invoker.invokeTarget(new String[]{"foo"}));
+ }
+
+
+ /**
+ * Tests a basic invocation down a target wire
+ */
+ public void testTargetWireInvocation() throws Exception {
+ List<Class<?>> services = new ArrayList<Class<?>>();
+ services.add(Greeting.class);
+ GroovyConfiguration configuration = new GroovyConfiguration();
+ configuration.setName("source");
+ configuration.setGroovyClass(implClass2);
+ configuration.setServices(services);
+ configuration.setScopeContainer(scopeContainer);
+ configuration.setWireService(createWireService());
+ GroovyAtomicComponent component = new GroovyAtomicComponent(configuration, null);
+ InboundWire wire = createInboundWire("Greeting", Greeting.class);
+ terminateWire(wire);
+ for (InboundInvocationChain chain : wire.getInvocationChains().values()) {
+ chain.setTargetInvoker(component.createTargetInvoker(null, chain.getOperation()));
+ }
+ component.addInboundWire(wire);
+ Greeting greeting = (Greeting) component.getServiceInstance("Greeting");
+ assertEquals("foo", greeting.greet("foo"));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ GroovyClassLoader cl = new GroovyClassLoader(getClass().getClassLoader());
+ implClass1 = cl.parseClass(SCRIPT);
+ implClass2 = cl.parseClass(SCRIPT2);
+ scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getInstance(isA(AtomicComponent.class))).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return ((AtomicComponent) getCurrentArguments()[0]).createInstance();
+ }
+ });
+ replay(scopeContainer);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/mock/AsyncTarget.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/mock/AsyncTarget.java
new file mode 100644
index 0000000000..8918c3dfd5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/mock/AsyncTarget.java
@@ -0,0 +1,27 @@
+/*
+ * 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.container.groovy.mock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface AsyncTarget {
+
+ void invoke();
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/mock/Greeting.java b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/mock/Greeting.java
new file mode 100644
index 0000000000..b975491f16
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/java/org/apache/tuscany/container/groovy/mock/Greeting.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.container.groovy.mock;
+
+public interface Greeting {
+
+ String setWire(Greeting ref);
+ String greet(String name);
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/resources/META-INF/sca/default.scdl b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..2a04ae7a6c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/resources/META-INF/sca/default.scdl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:groovy="http://incubator.apache.org/tuscany/xmlns/container/groovy/1.0-incubator-M2"
+ name="groovy.test">
+
+ <component name="Greeting">
+ <groovy:implementation.groovy script="Foo.groovy"/>
+ </component>
+
+</composite>
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/resources/org/apache/tuscany/container/groovy/mock/TestScript.groovy b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/resources/org/apache/tuscany/container/groovy/mock/TestScript.groovy
new file mode 100644
index 0000000000..f0b0a3a9d4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/services/containers/container.groovy/src/test/resources/org/apache/tuscany/container/groovy/mock/TestScript.groovy
@@ -0,0 +1 @@
+Test Script \ No newline at end of file