summaryrefslogtreecommitdiffstats
path: root/sandbox/ant
diff options
context:
space:
mode:
authordims <dims@13f79535-47bb-0310-9956-ffa450edef68>2008-06-17 00:23:01 +0000
committerdims <dims@13f79535-47bb-0310-9956-ffa450edef68>2008-06-17 00:23:01 +0000
commitbdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch)
tree38a92061c0793434c4be189f1d70c3458b6bc41d /sandbox/ant
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/ant')
-rw-r--r--sandbox/ant/TUSCANY-217/pom.xml52
-rw-r--r--sandbox/ant/TUSCANY-217/src/main/resources/sca.module23
-rw-r--r--sandbox/ant/TUSCANY-217/src/main/resources/wsdl/AccountService.wsdl392
-rw-r--r--sandbox/ant/TUSCANY-217/src/main/webapp/WEB-INF/web.xml21
-rw-r--r--sandbox/ant/TUSCANY-217/target/TUSCANY-217-SNAPSHOT.warbin0 -> 6494 bytes
-rw-r--r--sandbox/ant/ajax/ajaxchat/pom.xml67
-rw-r--r--sandbox/ant/ajax/ajaxchat/src/main/java/sample/ChatService.java28
-rw-r--r--sandbox/ant/ajax/ajaxchat/src/main/java/sample/ChatServiceImpl.java36
-rw-r--r--sandbox/ant/ajax/ajaxchat/src/main/resources/chat.composite37
-rw-r--r--sandbox/ant/ajax/ajaxchat/src/main/webapp/META-INF/sca-contribution.xml22
-rw-r--r--sandbox/ant/ajax/ajaxchat/src/main/webapp/META-INF/sca-deployables/chat.composite37
-rw-r--r--sandbox/ant/ajax/ajaxchat/src/main/webapp/WEB-INF/web.xml44
-rw-r--r--sandbox/ant/ajax/ajaxchat/src/main/webapp/chat.html41
-rw-r--r--sandbox/ant/ajax/binding.ajax/DISCLAIMER8
-rw-r--r--sandbox/ant/ajax/binding.ajax/LICENSE205
-rw-r--r--sandbox/ant/ajax/binding.ajax/LICENSE.txt202
-rw-r--r--sandbox/ant/ajax/binding.ajax/NOTICE6
-rw-r--r--sandbox/ant/ajax/binding.ajax/pom.xml76
-rw-r--r--sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AbstractBinding.java78
-rw-r--r--sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxBinding.java30
-rw-r--r--sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxBindingSCDLProcessor.java73
-rw-r--r--sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxModuleActivator.java79
-rw-r--r--sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxReferenceBindingProvider.java73
-rw-r--r--sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxReferenceInvoker.java88
-rw-r--r--sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxServiceBindingProvider.java71
-rw-r--r--sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxServlet.java444
-rw-r--r--sandbox/ant/ajax/binding.ajax/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator18
-rw-r--r--sandbox/ant/container.easy/NOTICE.txt14
-rw-r--r--sandbox/ant/container.easy/pom.xml68
-rw-r--r--sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/AsyncInvoker.java210
-rw-r--r--sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/AsyncMonitor.java31
-rw-r--r--sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponent.java117
-rw-r--r--sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentBuilder.java83
-rw-r--r--sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentType.java62
-rw-r--r--sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentTypeLoader.java71
-rw-r--r--sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyImplementation.java47
-rw-r--r--sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyImplementationLoader.java85
-rw-r--r--sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInstance.java31
-rw-r--r--sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInstanceFactory.java71
-rw-r--r--sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInvoker.java53
-rw-r--r--sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/AsyncInvokerTestCase.java207
-rw-r--r--sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentBuilderTestCase.java104
-rw-r--r--sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTestCase.java142
-rw-r--r--sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTypeLoaderTestCase.java141
-rw-r--r--sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTypeTestCase.java37
-rw-r--r--sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyImplementationLoaderTestCase.java76
-rw-r--r--sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyImplementationTestCase.java28
-rw-r--r--sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInstanceFactoryTestCase.java55
-rw-r--r--sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java61
-rw-r--r--sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/mock/AsyncTarget.java26
-rw-r--r--sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/mock/MockInstanceFactory.java30
-rw-r--r--sandbox/ant/container.easy/src/test/resources/org/apache/tuscany/container/easy/foo.componentType9
-rw-r--r--sandbox/ant/container.easy/src/test/resources/org/apache/tuscany/container/easy/foo.mock1
-rw-r--r--sandbox/ant/container.jsr223/pom.xml83
-rw-r--r--sandbox/ant/container.jsr223/src/main/java/org/apache/tuscany/container/jsr223/ScriptImplementationLoader.java81
-rw-r--r--sandbox/ant/container.jsr223/src/main/java/org/apache/tuscany/container/jsr223/ScriptInstance.java50
-rw-r--r--sandbox/ant/container.jsr223/src/main/java/org/apache/tuscany/container/jsr223/ScriptInstanceFactory.java75
-rw-r--r--sandbox/ant/container.jsr223/src/main/resources/META-INF/sca/default.scdl40
-rw-r--r--sandbox/ant/container.jsr223/src/main/resources/META-INF/sca/script.system.scdl40
-rw-r--r--sandbox/ant/container.jsr223/src/test/java/org/apache/tuscany/container/jsr223/FunctionTestCase.java39
-rw-r--r--sandbox/ant/container.jsr223/src/test/java/org/apache/tuscany/container/jsr223/ScriptImplementationLoaderTestCase.java133
-rw-r--r--sandbox/ant/container.jsr223/src/test/java/org/apache/tuscany/container/jsr223/ScriptInstanceFactoryTestCase.java91
-rw-r--r--sandbox/ant/container.jsr223/src/test/java/org/apache/tuscany/container/jsr223/ScriptInstanceTestCase.java65
-rw-r--r--sandbox/ant/container.python/NOTICE.txt14
-rw-r--r--sandbox/ant/container.python/pom.xml78
-rw-r--r--sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonComponent.java113
-rw-r--r--sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonComponentBuilder.java74
-rw-r--r--sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonComponentType.java61
-rw-r--r--sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonComponentTypeLoader.java76
-rw-r--r--sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonImplementation.java37
-rw-r--r--sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonImplementationLoader.java123
-rw-r--r--sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonInvoker.java54
-rw-r--r--sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonScript.java116
-rw-r--r--sandbox/ant/container.python/src/main/resources/META-INF/sca/py.system.scdl40
-rw-r--r--sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/HelloWorldService.java25
-rw-r--r--sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonComponentBuilderTestCase.java23
-rw-r--r--sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonComponentTestCase.java94
-rw-r--r--sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonComponentTypeLoaderTestCase.java87
-rw-r--r--sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonComponentTypeTestCase.java36
-rw-r--r--sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonImplementationLoaderTestCase.java110
-rw-r--r--sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonImplementationTestCase.java33
-rw-r--r--sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonInvokerTestCase.java62
-rw-r--r--sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonScriptTestCase.java82
-rw-r--r--sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/function/HelloWorldTestCase.java46
-rw-r--r--sandbox/ant/container.python/src/test/resources/org/apache/tuscany/container/python/PythonScriptTestCase.py6
-rw-r--r--sandbox/ant/container.python/src/test/resources/org/apache/tuscany/container/python/function/HelloWorld.componentType9
-rw-r--r--sandbox/ant/container.python/src/test/resources/org/apache/tuscany/container/python/function/helloworld.py6
-rw-r--r--sandbox/ant/container.python/src/test/resources/org/apache/tuscany/container/python/function/helloworld.scdl29
-rw-r--r--sandbox/ant/container.rhino/NOTICE.txt14
-rw-r--r--sandbox/ant/container.rhino/pom.xml68
-rw-r--r--sandbox/ant/container.rhino/src/main/java/org/apache/tuscany/container/rhino/JavaScriptImplementationLoader.java81
-rw-r--r--sandbox/ant/container.rhino/src/main/java/org/apache/tuscany/container/rhino/RhinoFunctionInvoker.java88
-rw-r--r--sandbox/ant/container.rhino/src/main/java/org/apache/tuscany/container/rhino/RhinoScriptInstance.java103
-rw-r--r--sandbox/ant/container.rhino/src/main/java/org/apache/tuscany/container/rhino/RhinoScriptInstanceFactory.java145
-rw-r--r--sandbox/ant/container.rhino/src/main/resources/META-INF/sca/default.scdl40
-rw-r--r--sandbox/ant/container.rhino/src/main/resources/META-INF/sca/script.system.scdl40
-rw-r--r--sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/RhinoFunctionInvokerTestCase.java160
-rw-r--r--sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/RhinoScriptInstanceTestCase.java52
-rw-r--r--sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/RhinoScriptTestCase.java85
-rw-r--r--sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/ScriptImplementationLoaderTestCase.java133
-rw-r--r--sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/mock/Foo.java34
-rw-r--r--sandbox/ant/container.rhino/src/test/resources/org/apache/tuscany/container/script/foo.componentType9
-rw-r--r--sandbox/ant/container.rhino/src/test/resources/org/apache/tuscany/container/script/foo.mock1
-rw-r--r--sandbox/ant/container.ruby/LICENSE.txt202
-rw-r--r--sandbox/ant/container.ruby/NOTICE.txt14
-rw-r--r--sandbox/ant/container.ruby/pom.xml76
-rw-r--r--sandbox/ant/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyImplementationLoader.java81
-rw-r--r--sandbox/ant/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyInstance.java63
-rw-r--r--sandbox/ant/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyInstanceFactory.java89
-rw-r--r--sandbox/ant/container.ruby/src/main/resources/META-INF/sca/default.scdl40
-rw-r--r--sandbox/ant/container.ruby/src/main/resources/META-INF/sca/script.system.scdl40
-rw-r--r--sandbox/ant/container.ruby/src/test/java/org/apache/tuscany/container/ruby/RubyScriptTestCase.java82
-rw-r--r--sandbox/ant/container.ruby/src/test/java/org/apache/tuscany/container/ruby/ScriptImplementationLoaderTestCase.java133
-rw-r--r--sandbox/ant/container.ruby/src/test/java/org/apache/tuscany/container/ruby/mock/Foo.java34
-rw-r--r--sandbox/ant/container.ruby/src/test/resources/org/apache/tuscany/container/script/foo.componentType9
-rw-r--r--sandbox/ant/container.ruby/src/test/resources/org/apache/tuscany/container/script/foo.mock1
-rw-r--r--sandbox/ant/container.script/NOTICE.txt14
-rw-r--r--sandbox/ant/container.script/doc/sca-java-container-script.xml119
-rw-r--r--sandbox/ant/container.script/pom.xml89
-rw-r--r--sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/ScriptImplementationLoader.java81
-rw-r--r--sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/ScriptInstance.java52
-rw-r--r--sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/ScriptInstanceFactory.java94
-rw-r--r--sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/AsyncInvoker.java210
-rw-r--r--sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/AsyncMonitor.java31
-rw-r--r--sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperComponent.java117
-rw-r--r--sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentBuilder.java83
-rw-r--r--sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentType.java62
-rw-r--r--sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentTypeLoader.java71
-rw-r--r--sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperImplementation.java47
-rw-r--r--sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperImplementationLoader.java85
-rw-r--r--sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperInstance.java31
-rw-r--r--sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperInstanceFactory.java71
-rw-r--r--sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperInvoker.java53
-rw-r--r--sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/jsr223/JSR223BSFEngine.java118
-rw-r--r--sandbox/ant/container.script/src/main/resources/META-INF/sca/default.scdl40
-rw-r--r--sandbox/ant/container.script/src/main/resources/META-INF/sca/script.system.scdl40
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/ScriptImplementationLoaderTestCase.java132
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/ScriptInstanceFactoryTestCase.java69
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/ScriptInstanceTestCase.java30
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/AsyncInvokerTestCase.java211
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentBuilderTestCase.java107
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentTestCase.java145
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentTypeLoaderTestCase.java144
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentTypeTestCase.java37
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperImplementationLoaderTestCase.java78
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperImplementationTestCase.java30
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperInstanceFactoryTestCase.java56
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperInvokerTestCase.java64
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/mock/AsyncTarget.java26
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/mock/MockInstanceFactory.java30
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/jsr223/JSR223BSFEngineTestCase.java45
-rw-r--r--sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/mock/MockBSFEngine.java27
-rw-r--r--sandbox/ant/container.script/src/test/resources/org/apache/tuscany/container/script/foo.componentType9
-rw-r--r--sandbox/ant/container.script/src/test/resources/org/apache/tuscany/container/script/foo.mock1
-rw-r--r--sandbox/ant/container.script/src/test/resources/org/apache/tuscany/container/script/helper/foo.componentType9
-rw-r--r--sandbox/ant/container.script/src/test/resources/org/apache/tuscany/container/script/helper/foo.mock1
-rw-r--r--sandbox/ant/implementation-das/pom.xml85
-rw-r--r--sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementation.java62
-rw-r--r--sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementationActivator.java52
-rw-r--r--sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASInvoker.java60
-rw-r--r--sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASInvokerFactory.java50
-rw-r--r--sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DataAccessEngine.java52
-rw-r--r--sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DataAccessEngineManager.java70
-rw-r--r--sandbox/ant/implementation-das/src/main/resources/META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator20
-rw-r--r--sandbox/ant/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/company/CompanyService.java32
-rw-r--r--sandbox/ant/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/company/CompanyServiceTestCase.java57
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/CompanyConfig.xml52
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/company.composite31
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/das.composite28
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/log/log.ctrlbin0 -> 48 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/log/log1.datbin0 -> 1048576 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/log/logmirror.ctrlbin0 -> 48 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c10.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c101.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c111.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c121.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c130.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c141.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c150.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c161.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c171.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c180.datbin0 -> 24576 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c191.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1a1.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1b1.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1c0.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1d1.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1e0.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1f1.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c20.datbin0 -> 24576 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c200.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c211.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c221.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c230.datbin0 -> 151552 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c241.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c251.datbin0 -> 12288 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c260.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c271.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c281.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c290.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2a1.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2b1.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2c1.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2d0.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2e1.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2f0.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c300.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c31.datbin0 -> 16384 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c311.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c320.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c331.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c340.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c351.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c360.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c371.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c380.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c391.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3a0.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3b1.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3c0.datbin0 -> 24576 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3d1.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3e0.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3f1.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c400.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c41.datbin0 -> 16384 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c411.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c420.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c431.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c440.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c451.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c460.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c471.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c481.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c490.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c4a1.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c51.datbin0 -> 16384 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c60.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c71.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c81.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c90.datbin0 -> 24576 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/ca1.datbin0 -> 24576 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/cb1.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/cc0.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/cd1.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/ce1.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/seg0/cf0.datbin0 -> 8192 bytes
-rw-r--r--sandbox/ant/implementation-das/src/test/resources/dastest/service.properties22
-rw-r--r--sandbox/ant/performance/README10
-rw-r--r--sandbox/ant/performance/helloworld-ws-java-run/pom.xml79
-rw-r--r--sandbox/ant/performance/helloworld-ws-java-run/src/test/java/helloworld/HelloWorldTestCase.java46
-rw-r--r--sandbox/ant/performance/helloworld-ws-java/pom.xml43
-rw-r--r--sandbox/ant/performance/helloworld-ws-java/src/main/java/helloworld/HelloWorldImpl.java33
-rw-r--r--sandbox/ant/performance/helloworld-ws-java/src/main/java/helloworld/HelloWorldService.java30
-rw-r--r--sandbox/ant/performance/helloworld-ws-java/src/main/resources/META-INF/sca-deployables/application.composite35
-rw-r--r--sandbox/ant/performance/helloworld-ws-js-run/pom.xml94
-rw-r--r--sandbox/ant/performance/helloworld-ws-js-run/src/test/java/helloworld/HelloWorldTestCase.java46
-rw-r--r--sandbox/ant/performance/helloworld-ws-js/pom.xml101
-rw-r--r--sandbox/ant/performance/helloworld-ws-js/src/main/resources/META-INF/sca-deployables/application.composite44
-rw-r--r--sandbox/ant/performance/helloworld-ws-js/src/main/resources/helloworld.wsdl79
-rw-r--r--sandbox/ant/performance/helloworld.jmx86
-rw-r--r--sandbox/ant/relax-ws/DISCLAIMER8
-rw-r--r--sandbox/ant/relax-ws/LICENSE205
-rw-r--r--sandbox/ant/relax-ws/NOTICE8
-rw-r--r--sandbox/ant/relax-ws/pom.xml70
-rw-r--r--sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/Convert2Wsdl.java342
-rw-r--r--sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSDocumentProcessor.java90
-rw-r--r--sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSModel.java41
-rw-r--r--sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSModelResolver.java151
-rw-r--r--sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSWSDLLocator.java83
-rw-r--r--sandbox/ant/relax-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor19
-rw-r--r--sandbox/ant/relax-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver18
-rw-r--r--sandbox/ant/relax-ws/src/test/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSTestCase.java44
-rw-r--r--sandbox/ant/relax-ws/src/test/resources/org/apache/tuscany/sca/interfacedef/relaxws/helloworld.rws21
-rw-r--r--sandbox/ant/sample.php/pom.xml74
-rw-r--r--sandbox/ant/sample.php/src/main/java/helloworld/HelloWorldClient.java35
-rw-r--r--sandbox/ant/sample.php/src/main/java/helloworld/HelloWorldService.java25
-rw-r--r--sandbox/ant/sample.php/src/main/resources/HelloWorld.componentType9
-rw-r--r--sandbox/ant/sample.php/src/main/resources/HelloWorld.php7
-rw-r--r--sandbox/ant/sample.php/src/main/resources/META-INF/sca/default.scdl27
-rw-r--r--sandbox/ant/sample.php/src/test/java/helloworld/HelloWorldTestCase.java56
-rw-r--r--sandbox/ant/sample.script.async/LICENSE.txt202
-rw-r--r--sandbox/ant/sample.script.async/NOTICE.txt14
-rw-r--r--sandbox/ant/sample.script.async/pom.xml74
-rw-r--r--sandbox/ant/sample.script.async/src/main/java/sample/AsyncClient.java40
-rw-r--r--sandbox/ant/sample.script.async/src/main/java/sample/AsyncService.java28
-rw-r--r--sandbox/ant/sample.script.async/src/main/java/sample/ClientComponent.java38
-rw-r--r--sandbox/ant/sample.script.async/src/main/resources/AsyncServiceImpl.componentType8
-rw-r--r--sandbox/ant/sample.script.async/src/main/resources/AsyncServiceImpl.js7
-rw-r--r--sandbox/ant/sample.script.async/src/main/resources/META-INF/sca/default.scdl33
-rw-r--r--sandbox/ant/sample.script.async/src/test/java/sample/AsyncTestCase.java54
-rw-r--r--sandbox/ant/tuscany-container-rhino/LICENSE.txt777
-rw-r--r--sandbox/ant/tuscany-container-rhino/README.txt35
-rw-r--r--sandbox/ant/tuscany-container-rhino/pom.xml68
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/assembly/JavaScriptImplementation.java74
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/builder/JavaScriptContextFactoryBuilder.java62
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/builder/JavaScriptTargetWireBuilder.java40
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/config/JavaScriptContextFactory.java111
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/context/CopyOfJavaScriptComponentContext.java165
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/context/JavaScriptComponentContext.java144
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/e4x/E4XInterceptor.java65
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/e4x/E4XPolicyBuilder.java117
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/loader/JavaScriptImplementationLoader.java169
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/rhino/RhinoFunctionInvoker.java79
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/rhino/RhinoScript.java194
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/rhino/RhinoScriptInstance.java82
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/main/resources/system.fragment37
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/builder/JavaScriptContextFactoryBuilderTestCase.java121
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/e4x/E4XInterceptorTestCase.java131
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/e4x/E4XPolicyBuilderTestCase.java325
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/AbstractJavaScriptTestCase.java46
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/BasicTestCase.java27
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/E4XServiceRefsTestCase.java31
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/E4XTestCase.java29
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/HelloWorld.java26
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/InitializationTestCase.java33
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/PropertiesTestCase.java33
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/ServiceRefsTestCase.java27
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/TestMethods.java30
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/rhino/Foo.java16
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/rhino/RhinoFunctionInvokerTestCase.java173
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/rhino/RhinoScriptInstanceTestCase.java47
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/rhino/RhinoScriptTestCase.java80
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/org/apache/tuscany/container/rhino/e4x/helloworld.wsdl97
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/sca.module66
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldE4XProxyImpl.componentType13
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldE4XProxyImpl.js28
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl1.componentType9
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl1.js20
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl2.componentType11
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl2.js20
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl4.componentType9
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl4.js26
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl5.componentType9
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl5.js29
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldProxyImpl.componentType13
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldProxyImpl.js20
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/tests/e4x.componentType9
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/tests/e4x.js28
-rw-r--r--sandbox/ant/tuscany-container-rhino/src/test/resources/wsdl/helloworld.wsdl97
339 files changed, 18046 insertions, 0 deletions
diff --git a/sandbox/ant/TUSCANY-217/pom.xml b/sandbox/ant/TUSCANY-217/pom.xml
new file mode 100644
index 0000000000..10d5311fc9
--- /dev/null
+++ b/sandbox/ant/TUSCANY-217/pom.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.samples</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>TUSCANY-217</artifactId>
+ <packaging>war</packaging>
+ <name>TUSCANY-217</name>
+ <description>TUSCANY-217 breaks bigbank webclient</description>
+ <version>SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>5.0.18</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>5.0.18</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/ant/TUSCANY-217/src/main/resources/sca.module b/sandbox/ant/TUSCANY-217/src/main/resources/sca.module
new file mode 100644
index 0000000000..20cfb88db8
--- /dev/null
+++ b/sandbox/ant/TUSCANY-217/src/main/resources/sca.module
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+
+ name="TUSCANY-217">
+
+ <import.wsdl wsdlLocation="wsdl/AccountService.wsdl"/>
+
+</module>
diff --git a/sandbox/ant/TUSCANY-217/src/main/resources/wsdl/AccountService.wsdl b/sandbox/ant/TUSCANY-217/src/main/resources/wsdl/AccountService.wsdl
new file mode 100644
index 0000000000..4874d52aea
--- /dev/null
+++ b/sandbox/ant/TUSCANY-217/src/main/resources/wsdl/AccountService.wsdl
@@ -0,0 +1,392 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+-->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:account="http://www.bigbank.com/account"
+ targetNamespace="http://www.bigbank.com/account"
+ name="AccountService">
+
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.bigbank.com/account"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:account="http://www.bigbank.com/account"
+
+ > <!-- xmlns:sdojava="commonj.sdo/java" sdojava:package="org.apache.tuscany.samples.bigbank.account" -->
+
+
+ <xsd:complexType name="DataGraphRoot"> <!-- This was added temporarily for DAS
+ changes are on the way to lift this requirement -->
+ <xsd:sequence>
+ <xsd:element name="customerProfileData" type="account:CustomerProfileData" maxOccurs="unbounded" minOccurs="0" />
+ <xsd:element name="StockSummaries" type="account:StockSummary" maxOccurs="unbounded" minOccurs="0" />
+ <xsd:element name="AccountSummaries" type="account:AccountSummary" maxOccurs="unbounded" minOccurs="0" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <xsd:element name="getAccountReport">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerID"
+ type="xsd:int" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="getAccountReportResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="accountReport"
+ type="account:AccountReport" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="AccountReport">
+ <xsd:sequence>
+ <xsd:element name="accountSummaries"
+ type="account:AccountSummary" maxOccurs="unbounded" />
+ <xsd:element name="stockSummaries"
+ type="account:StockSummary" maxOccurs="unbounded" />
+
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="AccountSummary">
+ <xsd:attribute name="accountNumber" type="xsd:string" />
+ <xsd:attribute name="accountType" type="xsd:string" />
+ <xsd:attribute name="balance" type="xsd:float" />
+ </xsd:complexType>
+
+ <xsd:complexType name="StockSummary">
+ <xsd:attribute name="purchaseLotNumber" type="xsd:int" />
+ <!-- unique id for this purchase -->
+ <xsd:attribute name="symbol" type="xsd:string" />
+ <xsd:attribute name="quantity" type="xsd:int" />
+ <xsd:attribute name="purchaseDate" type="xsd:dateTime" />
+ <xsd:attribute name="purchasePrice" type="xsd:float" />
+ <xsd:attribute name="currentPrice" type="xsd:float" />
+ <xsd:attribute name="company" type="xsd:string" />
+ <xsd:attribute name="highPrice" type="xsd:float" />
+ <xsd:attribute name="lowPrice" type="xsd:float" />
+
+ </xsd:complexType>
+
+ <!-- Profile in data base -->
+ <xsd:element name="getCustomerProfile">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="loginID" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="CustomerProfileData">
+ <xsd:sequence>
+ <xsd:element name="firstName" type="xsd:string" />
+ <xsd:element name="lastName" type="xsd:string" />
+ <xsd:element name="address" type="xsd:string" />
+ <xsd:element name="email" type="xsd:string" />
+ <xsd:element name="loginID" type="xsd:string" />
+ <xsd:element name="password" type="xsd:string" />
+ <xsd:element name="id" type="xsd:int" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="getCustomerProfileResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerProfile"
+ type="account:CustomerProfileData" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="withdraw">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="accountNumber"
+ type="xsd:string" />
+ <xsd:element name="amount" type="xsd:float" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="withdrawResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="balance" type="xsd:float" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="deposit">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="accountNumber"
+ type="xsd:string" />
+ <xsd:element name="amount" type="xsd:float" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="depositResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="balance" type="xsd:float" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="purchaseStock">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="id" type="xsd:int" />
+ <xsd:element name="stock" type="account:StockSummary" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="purchaseStockResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="purchaseSummary"
+ type="account:StockSummary" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+
+
+ <xsd:element name="sellStock">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="purchaseLotNumber"
+ type="xsd:int" /><!-- unique id for this purchase -->
+ <xsd:element name="quantity" type="xsd:int" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="createAccount">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerProfile"
+ type="account:CustomerProfileData" />
+ <xsd:element name="createSavings"
+ type="xsd:boolean" />
+ <xsd:element name="createCheckings"
+ type="xsd:boolean" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="createAccountResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerProfile"
+ type="account:CustomerProfileData" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ </xsd:element>
+
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="getAccountReportRequest">
+ <wsdl:part element="account:getAccountReport"
+ name="getAccountReportRequest" />
+ </wsdl:message>
+ <wsdl:message name="getAccountReportResponse">
+ <wsdl:part element="account:getAccountReportResponse"
+ name="getAccountReportResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="getCustomerProfileRequest">
+ <wsdl:part element="account:getCustomerProfile"
+ name="getCustomerProfile" />
+ </wsdl:message>
+ <wsdl:message name="getCustomerProfileResponse">
+ <wsdl:part element="account:getCustomerProfileResponse"
+ name="getCustomerProfileResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="withdrawRequest">
+ <wsdl:part element="account:withdraw" name="withdrawRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="withdrawResponse">
+ <wsdl:part element="account:withdrawResponse"
+ name="withdrawResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="depositRequest">
+ <wsdl:part element="account:deposit" name="depositRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="depositResponse">
+ <wsdl:part element="account:depositResponse"
+ name="depositResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="purchaseStockRequest">
+ <wsdl:part element="account:purchaseStock"
+ name="purchaseStockRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="purchaseStockResponse">
+ <wsdl:part element="account:purchaseStockResponse"
+ name="purchaseStockResponse" />
+ </wsdl:message>
+
+ <wsdl:message name="sellStockRequest">
+ <wsdl:part element="account:sellStock" name="sellStockRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="createAccountRequest">
+ <wsdl:part element="account:createAccount" name="createAccountRequest" />
+ </wsdl:message>
+
+ <wsdl:message name="createAccountResponse">
+ <wsdl:part element="account:createAccountResponse" name="createAccountResponse" />
+ </wsdl:message>
+
+ <wsdl:portType name="AccountService">
+ <wsdl:operation name="getAccountReport">
+ <wsdl:input message="account:getAccountReportRequest" />
+ <wsdl:output message="account:getAccountReportResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="getCustomerProfile">
+ <wsdl:input message="account:getCustomerProfileRequest" />
+ <wsdl:output message="account:getCustomerProfileResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="withdraw">
+ <wsdl:input message="account:withdrawRequest" />
+ <wsdl:output message="account:withdrawResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="deposit">
+ <wsdl:input message="account:depositRequest" />
+ <wsdl:output message="account:depositResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="purchaseStock">
+ <wsdl:input message="account:purchaseStockRequest" />
+ <wsdl:output message="account:purchaseStockResponse" />
+ </wsdl:operation>
+
+ <wsdl:operation name="sellStock">
+ <wsdl:input message="account:sellStockRequest" />
+ <wsdl:output message="account:purchaseStockResponse" />
+ </wsdl:operation>
+
+
+ <wsdl:operation name="createAccount">
+ <wsdl:input message="account:createAccountRequest" />
+ <wsdl:output message="account:createAccountResponse" />
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+
+
+ <wsdl:binding name="AccountServiceSOAP" type="account:AccountService">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="getAccountReport">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/getAccountReport" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getCustomerProfile">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/getCustomerProfile" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="withdraw">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/withdraw" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="deposit">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/deposit" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="purchaseStock">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/purchaseStock" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="sellStock">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/sellStock" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ <wsdl:operation name="createAccount">
+ <soap:operation
+ soapAction="http://www.bigbank.com/account/createAccount" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+ </wsdl:binding>
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="account:AccountServiceSOAP"
+ name="AccountServiceSOAP">
+ <soap:address
+ location="http://aBadEndpointURL" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/sandbox/ant/TUSCANY-217/src/main/webapp/WEB-INF/web.xml b/sandbox/ant/TUSCANY-217/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..c329b3903e
--- /dev/null
+++ b/sandbox/ant/TUSCANY-217/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+
+ <display-name>TUSCANY-217</display-name>
+
+</web-app>
diff --git a/sandbox/ant/TUSCANY-217/target/TUSCANY-217-SNAPSHOT.war b/sandbox/ant/TUSCANY-217/target/TUSCANY-217-SNAPSHOT.war
new file mode 100644
index 0000000000..b175aa251b
--- /dev/null
+++ b/sandbox/ant/TUSCANY-217/target/TUSCANY-217-SNAPSHOT.war
Binary files differ
diff --git a/sandbox/ant/ajax/ajaxchat/pom.xml b/sandbox/ant/ajax/ajaxchat/pom.xml
new file mode 100644
index 0000000000..b7b671f843
--- /dev/null
+++ b/sandbox/ant/ajax/ajaxchat/pom.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-chat-webapp</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany Chat Sample WebApp</name>
+
+ <repositories>
+ <repository>
+ <id>apache.incubator</id>
+ <url>http://people.apache.org/repo/m2-incubating-repository</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ajax</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
diff --git a/sandbox/ant/ajax/ajaxchat/src/main/java/sample/ChatService.java b/sandbox/ant/ajax/ajaxchat/src/main/java/sample/ChatService.java
new file mode 100644
index 0000000000..1fb9d292cd
--- /dev/null
+++ b/sandbox/ant/ajax/ajaxchat/src/main/java/sample/ChatService.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package sample;
+
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
+
+@Service
+@Remotable
+public interface ChatService {
+
+ public void chat(String msg);
+
+}
diff --git a/sandbox/ant/ajax/ajaxchat/src/main/java/sample/ChatServiceImpl.java b/sandbox/ant/ajax/ajaxchat/src/main/java/sample/ChatServiceImpl.java
new file mode 100644
index 0000000000..7d0bfb3307
--- /dev/null
+++ b/sandbox/ant/ajax/ajaxchat/src/main/java/sample/ChatServiceImpl.java
@@ -0,0 +1,36 @@
+/*
+ * 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 sample;
+
+import org.osoa.sca.annotations.Scope;
+
+@Scope("COMPOSITE")
+public class ChatServiceImpl implements ChatService {
+
+ ChatService chatters;
+
+ public void chat(String msg) {
+ chatters.chat(msg);
+ }
+
+ public void setChatters(ChatService chatters) {
+ this.chatters = chatters;
+ }
+}
diff --git a/sandbox/ant/ajax/ajaxchat/src/main/resources/chat.composite b/sandbox/ant/ajax/ajaxchat/src/main/resources/chat.composite
new file mode 100644
index 0000000000..3ee7716899
--- /dev/null
+++ b/sandbox/ant/ajax/ajaxchat/src/main/resources/chat.composite
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="Chat">
+
+ <service name="ChatService" promote="ChatComponent">
+ <interface.java interface="sample.ChatService"/>
+ <binding.ajax/>
+ </service>
+
+ <component name="ChatComponent">
+ <implementation.java class="sample.ChatServiceImpl"/>
+ </component>
+
+ <reference name="ChatReference" promote="ChatComponent/chatters">
+ <interface.java interface="sample.ChatService" />
+ <binding.ajax/>
+ </reference>
+
+</composite>
diff --git a/sandbox/ant/ajax/ajaxchat/src/main/webapp/META-INF/sca-contribution.xml b/sandbox/ant/ajax/ajaxchat/src/main/webapp/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e5a7845149
--- /dev/null
+++ b/sandbox/ant/ajax/ajaxchat/src/main/webapp/META-INF/sca-contribution.xml
@@ -0,0 +1,22 @@
+<?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.
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0">
+ <deployable composite="chat"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/ant/ajax/ajaxchat/src/main/webapp/META-INF/sca-deployables/chat.composite b/sandbox/ant/ajax/ajaxchat/src/main/webapp/META-INF/sca-deployables/chat.composite
new file mode 100644
index 0000000000..3ee7716899
--- /dev/null
+++ b/sandbox/ant/ajax/ajaxchat/src/main/webapp/META-INF/sca-deployables/chat.composite
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="Chat">
+
+ <service name="ChatService" promote="ChatComponent">
+ <interface.java interface="sample.ChatService"/>
+ <binding.ajax/>
+ </service>
+
+ <component name="ChatComponent">
+ <implementation.java class="sample.ChatServiceImpl"/>
+ </component>
+
+ <reference name="ChatReference" promote="ChatComponent/chatters">
+ <interface.java interface="sample.ChatService" />
+ <binding.ajax/>
+ </reference>
+
+</composite>
diff --git a/sandbox/ant/ajax/ajaxchat/src/main/webapp/WEB-INF/web.xml b/sandbox/ant/ajax/ajaxchat/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..6b4a066903
--- /dev/null
+++ b/sandbox/ant/ajax/ajaxchat/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
+Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <display-name>Tuscany Chat Sample</display-name>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>chat.html</welcome-file>
+ </welcome-file-list>
+
+
+ <!-- the Tuscany system listener and servlet -->
+
+ <listener>
+ <listener-class>org.apache.tuscany.sca.webapp.TuscanyContextListener</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>TuscanyServlet</servlet-name>
+ <servlet-class>org.apache.tuscany.sca.webapp.TuscanyServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TuscanyServlet</servlet-name>
+ <url-pattern>/SCA/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
diff --git a/sandbox/ant/ajax/ajaxchat/src/main/webapp/chat.html b/sandbox/ant/ajax/ajaxchat/src/main/webapp/chat.html
new file mode 100644
index 0000000000..60fdf062f2
--- /dev/null
+++ b/sandbox/ant/ajax/ajaxchat/src/main/webapp/chat.html
@@ -0,0 +1,41 @@
+<html>
+ <head>
+ <title>Tuscany AJAX Chat Sample</TITLE>
+
+ <script type="text/javascript" src="SCA/SCADomain/scaDomain.js"></script>
+
+ <script language="JavaScript">
+
+ ChatReference.chat = function(msg) {
+ var chatLog = document.getElementById('chatLog');
+ chatLog.innerHTML = msg + '<br>' + chatLog.innerHTML;
+ }
+
+ function sendChat() {
+ var chatText = document.getElementById("chatText");
+ var nickName = document.getElementById("nickName").value;
+ var msg = nickName + ": " + chatText.value
+ chatText.value = "";
+ chatText.focus();
+ ChatService.chat(msg);
+ }
+ </script>
+
+ </head>
+ <body onLoad="scaDomain.open()">
+
+ <h2>Tuscany AJAX Chat Sample</h2>
+
+ A simple client to chat between multiple web browsers:<br><br>
+
+ Nickname: <input type="text" id="nickName" size="10"/>
+ <br><br>
+
+ Enter text: <input type="text" id="chatText" size="80" onEnter="sendChat()"/>
+ <input type="button" value="Send" onclick="sendChat()" />
+
+ <br><br>
+ <div id="chatLog" style="overflow:auto; height:400px; border:1px solid"></div>
+
+ </body>
+</html>
diff --git a/sandbox/ant/ajax/binding.ajax/DISCLAIMER b/sandbox/ant/ajax/binding.ajax/DISCLAIMER
new file mode 100644
index 0000000000..d68a410903
--- /dev/null
+++ b/sandbox/ant/ajax/binding.ajax/DISCLAIMER
@@ -0,0 +1,8 @@
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
diff --git a/sandbox/ant/ajax/binding.ajax/LICENSE b/sandbox/ant/ajax/binding.ajax/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/ant/ajax/binding.ajax/LICENSE
@@ -0,0 +1,205 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+
diff --git a/sandbox/ant/ajax/binding.ajax/LICENSE.txt b/sandbox/ant/ajax/binding.ajax/LICENSE.txt
new file mode 100644
index 0000000000..75b52484ea
--- /dev/null
+++ b/sandbox/ant/ajax/binding.ajax/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, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/sandbox/ant/ajax/binding.ajax/NOTICE b/sandbox/ant/ajax/binding.ajax/NOTICE
new file mode 100644
index 0000000000..94481d6cfa
--- /dev/null
+++ b/sandbox/ant/ajax/binding.ajax/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2007 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sandbox/ant/ajax/binding.ajax/pom.xml b/sandbox/ant/ajax/binding.ajax/pom.xml
new file mode 100644
index 0000000000..0aa0e4df9c
--- /dev/null
+++ b/sandbox/ant/ajax/binding.ajax/pom.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-ajax</artifactId>
+ <name>Apache Tuscany Binding for AJAX clients</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.directwebremoting</groupId>
+ <artifactId>dwr</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version> <!-- to keep compatible with older servlet containers -->
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AbstractBinding.java b/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AbstractBinding.java
new file mode 100644
index 0000000000..c5388017fc
--- /dev/null
+++ b/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AbstractBinding.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ajax;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Helper for implementing Bindings, implements all the
+ * standard getters and setters on the binding interface.
+ * TODO: I'd really like this to be provided by Tuscany somewhere
+ */
+public class AbstractBinding implements Binding {
+
+ private String name;
+ private String uri;
+ private List<Object> extensions;
+ private boolean unresolved;
+ private List<Intent> requiredIntents;
+ private List<PolicySet> policySets;
+
+ public String getName() {
+ return name;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public List<Object> getExtensions() {
+ return extensions;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+}
diff --git a/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxBinding.java b/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxBinding.java
new file mode 100644
index 0000000000..ae5f87b433
--- /dev/null
+++ b/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxBinding.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ajax;
+
+/**
+ * The runtime representation of the <binding.ajax> SCDL
+ *
+ * Empty as <binding.ajax> doesn't use any additional
+ * attributes or elements (yet).
+ */
+public class AjaxBinding extends AbstractBinding {
+
+}
diff --git a/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxBindingSCDLProcessor.java b/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxBindingSCDLProcessor.java
new file mode 100644
index 0000000000..a7f86c91fe
--- /dev/null
+++ b/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxBindingSCDLProcessor.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ajax;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+
+/**
+ * A StAXArtifactProcessor to handle the <binding.ajax> SCDL
+ */
+public class AjaxBindingSCDLProcessor implements StAXArtifactProcessor {
+
+ public static QName AJAX_BINDING_QNAME = new QName(Constants.SCA10_NS, "binding.ajax");
+
+ public QName getArtifactType() {
+ return AJAX_BINDING_QNAME;
+ }
+ public Class getModelType() {
+ return AjaxBinding.class;
+ }
+
+ public Object read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ AjaxBinding dwrBinding = new AjaxBinding();
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && AJAX_BINDING_QNAME.equals(reader.getName())) {
+ break;
+ }
+ }
+ return dwrBinding;
+ }
+
+ public void write(Object arg0, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+ writer.writeStartElement(Constants.SCA10_NS, AJAX_BINDING_QNAME.getLocalPart());
+
+ writer.writeEndElement();
+ }
+
+
+ public void resolve(Object arg0, ModelResolver arg1) throws ContributionResolveException {
+ // not needed by Ajax binding
+ }
+
+}
diff --git a/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxModuleActivator.java b/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxModuleActivator.java
new file mode 100644
index 0000000000..26b4d9228a
--- /dev/null
+++ b/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxModuleActivator.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.sca.binding.ajax;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ModuleActivator;
+import org.apache.tuscany.sca.http.ServletHost;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * Register the ajax binding SCDL processor and the
+ * ajax service and reference providers with the Tuscany runtime.
+ */
+public class AjaxModuleActivator implements ModuleActivator {
+
+ public void start(ExtensionPointRegistry registry) {
+
+ // Add the ajax binding SCDL processor to the runtime
+ StAXArtifactProcessorExtensionPoint staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessors.addArtifactProcessor(new AjaxBindingSCDLProcessor());
+
+ final ServletHost servletHost = registry.getExtensionPoint(ServletHost.class);
+
+ // Add a ajax provider factory
+ ProviderFactoryExtensionPoint providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+
+ providerFactories.addProviderFactory(new BindingProviderFactory() {
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent rc, RuntimeComponentReference rcr, Binding b) {
+ return new AjaxReferenceBindingProvider(rc, rcr, b, servletHost);
+ }
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent rc, RuntimeComponentService rcs, Binding b) {
+ return new AjaxServiceBindingProvider(rc, rcs, b, servletHost);
+ }
+ public Class getModelType() {
+ return AjaxBinding.class;
+ }} );
+ }
+
+ public void stop(ExtensionPointRegistry registry) {
+ // Remove the ajax binding SCDL processor from the runtime
+ StAXArtifactProcessorExtensionPoint staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ staxProcessors.removeArtifactProcessor((StAXArtifactProcessor)staxProcessors.getProcessor(AjaxBindingSCDLProcessor.class));
+
+ // Remove the ajax provider factory from the runtime
+ ProviderFactoryExtensionPoint providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+ providerFactories.removeProviderFactory(providerFactories.getProviderFactory(AjaxBinding.class));
+ }
+
+ public Object[] getExtensionPoints() {
+ return null; // not needed for ajax binding
+ }
+
+}
diff --git a/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxReferenceBindingProvider.java b/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxReferenceBindingProvider.java
new file mode 100644
index 0000000000..424a1e10c4
--- /dev/null
+++ b/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxReferenceBindingProvider.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ajax;
+
+import static org.apache.tuscany.sca.binding.ajax.AjaxServiceBindingProvider.SERVLET_PATH;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+public class AjaxReferenceBindingProvider implements ReferenceBindingProvider {
+
+ protected RuntimeComponent runtimeComponent;
+ protected RuntimeComponentReference runtimeComponentReference;
+ protected Binding binding;
+ protected ServletHost servletHost;
+
+ public AjaxReferenceBindingProvider(RuntimeComponent rc, RuntimeComponentReference rcr, Binding b, ServletHost servletHost) {
+ this.runtimeComponent = rc;
+ this.runtimeComponentReference = rcr;
+ this.binding = b;
+ this.servletHost = servletHost;
+ }
+
+ public Invoker createInvoker(Operation operation, boolean arg1) {
+ return new AjaxReferenceInvoker(binding.getName(), operation);
+ }
+
+ public void start() {
+
+ // there is no "getServlet" method on ServletHost so this has to use remove/add
+
+ AjaxServlet servlet = (AjaxServlet) servletHost.removeServletMapping(SERVLET_PATH);
+ if (servlet == null) {
+ servlet = new AjaxServlet();
+ }
+
+ servlet.addReference(binding.getName());
+
+ servletHost.addServletMapping(SERVLET_PATH, servlet);
+ }
+
+ public void stop() {
+ servletHost.removeServletMapping(SERVLET_PATH);
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return runtimeComponentReference.getInterfaceContract();
+ }
+
+}
diff --git a/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxReferenceInvoker.java b/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxReferenceInvoker.java
new file mode 100644
index 0000000000..e52a0058de
--- /dev/null
+++ b/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxReferenceInvoker.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ajax;
+
+import java.util.Collection;
+
+import org.apache.tuscany.sca.core.invocation.MessageImpl;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.directwebremoting.ScriptBuffer;
+import org.directwebremoting.WebContext;
+import org.directwebremoting.WebContextFactory;
+import org.directwebremoting.proxy.dwr.Util;
+
+public class AjaxReferenceInvoker implements Invoker {
+
+ protected String referenceFunction;
+
+ AjaxReferenceInvoker(String referenceName, Operation operation) {
+ this.referenceFunction = referenceName + "." + operation.getName();
+ }
+
+ public Message invoke(Message requestMsg) {
+
+ invoke((Object[])requestMsg.getBody());
+
+ // Ajax references can not return anything
+ return new MessageImpl();
+ }
+
+ public void invoke(Object[] args) {
+
+ // TODO: this only works if its the same thread as request
+ WebContext wctx = WebContextFactory.get();
+ String currentPage = wctx.getCurrentPage();
+
+ // Get a DWR Util proxy for all the browsers on the current page:
+ Collection sessions = wctx.getScriptSessionsByPage(currentPage);
+ Util utilAll = new Util(sessions);
+
+ ScriptBuffer referenceInvoke = getInvokeFragment(args, wctx);
+
+ // add the reference call to the Util proxy which will cause DWR to
+ // asynchronously send it to be run on each active browser client
+ utilAll.addScript(referenceInvoke);
+ }
+
+ /**
+ * Creates a fragment of JavaScript code to invoke the reference function
+ * Eg: "<referenceName>.<operationName>(arg1, arg2,...);"
+ */
+ protected ScriptBuffer getInvokeFragment(Object[] args, WebContext wctx) {
+
+ ScriptBuffer sb = new ScriptBuffer();
+ sb.appendScript(referenceFunction);
+ sb.appendScript("(");
+ if (args != null) {
+ for (int i = 0; i < args.length; i++) {
+ sb.appendData(args[i]);
+ if (i < (args.length - 1)) {
+ sb.appendScript(", ");
+ }
+ }
+ }
+ sb.appendScript(");");
+
+ return sb;
+ }
+
+}
diff --git a/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxServiceBindingProvider.java b/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxServiceBindingProvider.java
new file mode 100644
index 0000000000..1555a75be1
--- /dev/null
+++ b/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxServiceBindingProvider.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ajax;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+public class AjaxServiceBindingProvider implements ServiceBindingProvider {
+
+ protected RuntimeComponent runtimeComponent;
+ protected RuntimeComponentService runtimeComponentService;
+ protected Binding binding;
+ protected ServletHost servletHost;
+
+ public static final String SERVLET_PATH = AjaxServlet.AJAX_SERVLET_PATH + "/*";
+
+ public AjaxServiceBindingProvider(RuntimeComponent rc, RuntimeComponentService rcs, Binding b, ServletHost servletHost) {
+ this.runtimeComponent = rc;
+ this.runtimeComponentService = rcs;
+ this.binding = b;
+ this.servletHost = servletHost;
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return runtimeComponentService.getInterfaceContract();
+ }
+
+ public void start() {
+
+ // there is no "getServlet" method on ServletHost so this has to use remove/add
+
+ AjaxServlet servlet = (AjaxServlet) servletHost.removeServletMapping(SERVLET_PATH);
+ if (servlet == null) {
+ servlet = new AjaxServlet();
+ }
+
+ Class<?> type = ((JavaInterface)runtimeComponentService.getInterfaceContract().getInterface()).getJavaClass();
+ Object instance = runtimeComponent.createSelfReference(type).getService();
+
+ servlet.addService(binding.getName(), type, instance);
+
+ servletHost.addServletMapping(SERVLET_PATH, servlet);
+ }
+
+ public void stop() {
+ servletHost.removeServletMapping(SERVLET_PATH);
+ }
+
+}
diff --git a/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxServlet.java b/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxServlet.java
new file mode 100644
index 0000000000..c4209bfbf7
--- /dev/null
+++ b/sandbox/ant/ajax/binding.ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxServlet.java
@@ -0,0 +1,444 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.ajax;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.directwebremoting.Container;
+import org.directwebremoting.create.AbstractCreator;
+import org.directwebremoting.extend.CreatorManager;
+import org.directwebremoting.extend.Handler;
+import org.directwebremoting.extend.Remoter;
+import org.directwebremoting.servlet.DwrServlet;
+import org.directwebremoting.servlet.EngineHandler;
+import org.directwebremoting.servlet.PathConstants;
+import org.directwebremoting.servlet.UrlProcessor;
+
+/**
+ * Tuscany customized DWR Servlet to implement support for the Ajax binding
+ *
+ * Handles requests for SCA services and references that use <binding.ajax>,
+ * and also the HTTP GET for the Tuscany ajax system script "scaDomain.js"
+ */
+public class AjaxServlet extends DwrServlet {
+ private static final long serialVersionUID = 1L;
+
+ transient protected Map<String, ServiceHolder> services;
+ transient protected List<String> referenceNames;
+ transient protected boolean initialized;
+ transient protected Map<String, String> initParams;
+
+ protected static final String SCADOMAIN_SCRIPT_PATH = "/scaDomain.js";
+ public static final String AJAX_SERVLET_PATH = "/SCADomain";
+
+ public AjaxServlet() {
+ this.services = new HashMap<String, ServiceHolder>();
+ this.referenceNames = new ArrayList<String>();
+
+ this.initParams = new HashMap<String, String>();
+ // maybe use <binding.ajax> attributes to define the init params
+ initParams.put("activeReverseAjaxEnabled", "true");
+ }
+
+ @Override
+ public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
+ super.service(patchRequest((HttpServletRequest)req), res);
+ }
+
+ /**
+ * Initialize the servlet
+ * There is a single instance of this servlet which is registered
+ * for multiple path mappings, but the init should only run once.
+ */
+ @Override
+ public void init(ServletConfig servletConfig) throws ServletException {
+ if (!initialized) {
+ super.init(patchConfig(servletConfig));
+ addScriptHandler();
+ initServices();
+ initialized = true;
+ }
+ }
+
+ /**
+ * Add in the handler to process the http get for /sca/scaDomain.js
+ *
+ * This wrappers the DWR Engine handler which returns the DWR engine.js script,
+ * this wrappers that handler so as to add Tuscany specific header and footer code
+ * to the DWR engine.js to define the Tuscany SCADomain control functions and
+ * functions for each SCA service and reference that use <binding.dwr>.
+ */
+ protected void addScriptHandler() {
+
+ UrlProcessor urlProcessor = (UrlProcessor)getContainer().getBean(UrlProcessor.class.getName());
+
+ final EngineHandler engineHandler =
+ (EngineHandler)getContainer().getBean(PathConstants.URL_PREFIX + "/engine.js");
+
+ final Handler scaDomainScriptHandler = new Handler() {
+ public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ PrintWriter out = response.getWriter();
+ out.println("/** Apache Tuscany scaDomain.js Header */");
+
+ engineHandler.handle(request, response);
+
+ tuscanyFooter(request, out);
+ }
+
+ };
+
+ // add the scaDomainScriptHandler to the urlProcessor
+ // bit of a hack, there's probably cleaner way to get it registered
+ urlProcessor.afterContainerSetup(new Container() {
+ public Object getBean(String name) {
+ return scaDomainScriptHandler;
+ }
+ public Collection getBeanNames() {
+ return Arrays.asList(new String[] {PathConstants.URL_PREFIX + SCADOMAIN_SCRIPT_PATH});
+ }
+ });
+ }
+
+ /**
+ * Adds the JavaScript defining SCADomain, its control functions,
+ * and functions for all the available SCA services and references.
+ */
+ protected void tuscanyFooter(HttpServletRequest request, PrintWriter out) {
+ out.println("/** Apache Tuscany scaDomain.js Footer */");
+ out.println();
+ out.println("function scaDomain() { }");
+ out.println();
+
+ // Alter the value of these variables in DWR engine.js to add in this servlet's path
+ out.println("dwr.engine._ModePlainCall = '" + AJAX_SERVLET_PATH + "/call/plaincall/';");
+ out.println("dwr.engine._ModeHtmlCall = '" + AJAX_SERVLET_PATH + "/call/htmlcall/';");
+ out.println("dwr.engine._ModePlainPoll = '" + AJAX_SERVLET_PATH + "/call/plainpoll/';");
+ out.println("dwr.engine._ModeHtmlPoll = '" + AJAX_SERVLET_PATH + "/call/htmlpoll/';");
+
+ out.println();
+ out.println("// SCA sevices");
+
+ // Use the DWR remoter to generate the JavaScipt function for each SCA service
+ Remoter remoter = (Remoter)getContainer().getBean(Remoter.class.getName());
+
+ String path = request.getContextPath() + request.getServletPath();
+
+ for (String serviceName : services.keySet()) {
+ String serviceScript = remoter.generateInterfaceScript(serviceName, path);
+ out.println(serviceScript);
+ }
+
+ if (referenceNames.size() > 0) {
+
+ out.println("// SCA reverse ajax control functions");
+ out.println();
+ out.println("scaDomain.open = function() { dwr.engine.setActiveReverseAjax(true); };");
+ out.println("scaDomain.close = function() { dwr.engine.setActiveReverseAjax(false); };");
+
+ out.println();
+ out.println("// SCA references");
+ out.println();
+
+ // the JavaScript function for SCA references has an
+ // empty impl as it uses DWR severside "push"
+ for (String referenceName : referenceNames) {
+ out.println("function " + referenceName + "() { }");
+ }
+ }
+
+ out.println();
+ out.println("/** End of Apache Tuscany scaDomain.js */");
+ out.println();
+ }
+
+ /**
+ * Add an SCA reference to be added to the DWR runtime
+ */
+ public void addReference(String name) {
+ referenceNames.add(name);
+ }
+
+ /**
+ * Add an SCA service to be added to the DWR runtime
+ */
+ public void addService(String name, final Class type, final Object instance) {
+ ServiceHolder holder = new ServiceHolder();
+ holder.name = name;
+ holder.type = type;
+ holder.instance = instance;
+ services.put(name, holder);
+ }
+
+ /**
+ * Defines each SCA service proxy instance to DWR
+ */
+ protected void initServices() {
+ CreatorManager creatorManager = (CreatorManager)getContainer().getBean(CreatorManager.class.getName());
+
+ for (final ServiceHolder holder : services.values()) {
+ creatorManager.addCreator(holder.name, new AbstractCreator() {
+ public Class getType() {
+ return holder.type;
+ }
+
+ public Object getInstance() throws InstantiationException {
+ return holder.instance;
+ }
+ });
+ }
+ }
+
+ // utility class to aid passing around services
+ class ServiceHolder {
+ String name;
+ Class type;
+ Object instance;
+ }
+
+ /**
+ * Patch the ServletConfig to enable setting init params for DWR
+ * and so DWR can't see the Tuscany servlet's init params.
+ */
+ protected ServletConfig patchConfig(final ServletConfig servletConfig) {
+ ServletConfig patchedContext = new ServletConfig() {
+ public String getInitParameter(String name) {
+ return initParams.get(name);
+ }
+ public Enumeration getInitParameterNames() {
+ return Collections.enumeration(initParams.keySet());
+ }
+ public ServletContext getServletContext() {
+ return servletConfig.getServletContext();
+ }
+ public String getServletName() {
+ return servletConfig.getServletName();
+ }
+ };
+ return patchedContext;
+ }
+
+ /**
+ * This changes the value returned from getPathInfo so that it does not include
+ * the path prefix of this Servlet. The DWR servlet expects its handlers to be
+ * at the root, eg /call/plaincall/, so they aren't found if the value request
+ * getPathInfo returns includes this servlets path, eg /SCADomain/call/plaincall/
+ */
+ protected HttpServletRequest patchRequest(final HttpServletRequest req) {
+
+ final String translatedPath = req.getPathInfo().substring(AJAX_SERVLET_PATH.length());
+
+ HttpServletRequest patchedRequest = new HttpServletRequest() {
+ public Object getAttribute(String arg0) {
+ return req.getAttribute(arg0);
+ }
+ public Enumeration getAttributeNames() {
+ return req.getAttributeNames();
+ }
+ public String getCharacterEncoding() {
+ return req.getCharacterEncoding();
+ }
+ public int getContentLength() {
+ return req.getContentLength();
+ }
+ public String getContentType() {
+ return req.getContentType();
+ }
+ public ServletInputStream getInputStream() throws IOException {
+ return req.getInputStream();
+ }
+ public String getLocalAddr() {
+ return req.getLocalAddr();
+ }
+ public String getLocalName() {
+ return req.getLocalName();
+ }
+ public int getLocalPort() {
+ return req.getLocalPort();
+ }
+ public Locale getLocale() {
+ return req.getLocale();
+ }
+ public Enumeration getLocales() {
+ return req.getLocales();
+ }
+ public String getParameter(String arg0) {
+ return req.getParameter(arg0);
+ }
+ public Map getParameterMap() {
+ return req.getParameterMap();
+ }
+ public Enumeration getParameterNames() {
+ return req.getParameterNames();
+ }
+ public String[] getParameterValues(String arg0) {
+ return req.getParameterValues(arg0);
+ }
+ public String getProtocol() {
+ return req.getProtocol();
+ }
+ public BufferedReader getReader() throws IOException {
+ return req.getReader();
+ }
+ @SuppressWarnings("deprecation")
+ public String getRealPath(String arg0) {
+ return req.getRealPath(arg0);
+ }
+ public String getRemoteAddr() {
+ return req.getRemoteAddr();
+ }
+ public String getRemoteHost() {
+ return req.getRemoteHost();
+ }
+ public int getRemotePort() {
+ return req.getRemotePort();
+ }
+ public RequestDispatcher getRequestDispatcher(String arg0) {
+ return req.getRequestDispatcher(arg0);
+ }
+ public String getScheme() {
+ return req.getScheme();
+ }
+ public String getServerName() {
+ return req.getServerName();
+ }
+ public int getServerPort() {
+ return req.getServerPort();
+ }
+ public boolean isSecure() {
+ return req.isSecure();
+ }
+ public void removeAttribute(String arg0) {
+ req.removeAttribute(arg0);
+ }
+ public void setAttribute(String arg0, Object arg1) {
+ req.setAttribute(arg0, arg1);
+ }
+ public void setCharacterEncoding(String arg0) throws UnsupportedEncodingException {
+ req.setCharacterEncoding(arg0);
+ }
+ public String getAuthType() {
+ return req.getAuthType();
+ }
+ public String getContextPath() {
+ return req.getContextPath();
+ }
+ public Cookie[] getCookies() {
+ return req.getCookies();
+ }
+ public long getDateHeader(String arg0) {
+ return req.getDateHeader(arg0);
+ }
+ public String getHeader(String arg0) {
+ return req.getHeader(arg0);
+ }
+ public Enumeration getHeaderNames() {
+ return req.getHeaderNames();
+ }
+ public Enumeration getHeaders(String arg0) {
+ return req.getHeaders(arg0);
+ }
+ public int getIntHeader(String arg0) {
+ return req.getIntHeader(arg0);
+ }
+ public String getMethod() {
+ return req.getMethod();
+ }
+ public String getPathInfo() {
+
+ // *** return the translated path
+
+ return translatedPath;
+ }
+ public String getPathTranslated() {
+ return req.getPathTranslated();
+ }
+ public String getQueryString() {
+ return req.getQueryString();
+ }
+ public String getRemoteUser() {
+ return req.getRemoteUser();
+ }
+ public String getRequestURI() {
+ return req.getRequestURI();
+ }
+ public StringBuffer getRequestURL() {
+ return req.getRequestURL();
+ }
+ public String getRequestedSessionId() {
+ return req.getRequestedSessionId();
+ }
+ public String getServletPath() {
+ return req.getServletPath();
+ }
+ public HttpSession getSession() {
+ return req.getSession();
+ }
+ public HttpSession getSession(boolean arg0) {
+ return req.getSession(arg0);
+ }
+ public Principal getUserPrincipal() {
+ return req.getUserPrincipal();
+ }
+ public boolean isRequestedSessionIdFromCookie() {
+ return req.isRequestedSessionIdFromCookie();
+ }
+ public boolean isRequestedSessionIdFromURL() {
+ return req.isRequestedSessionIdFromURL();
+ }
+ @SuppressWarnings("deprecation")
+ public boolean isRequestedSessionIdFromUrl() {
+ return req.isRequestedSessionIdFromUrl();
+ }
+ public boolean isRequestedSessionIdValid() {
+ return req.isRequestedSessionIdValid();
+ }
+ public boolean isUserInRole(String arg0) {
+ return req.isUserInRole(arg0);
+ }
+
+ };
+ return patchedRequest;
+ }
+}
diff --git a/sandbox/ant/ajax/binding.ajax/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/sandbox/ant/ajax/binding.ajax/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
new file mode 100644
index 0000000000..8c73319db1
--- /dev/null
+++ b/sandbox/ant/ajax/binding.ajax/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# Implementation class for the ExtensionActivator
+org.apache.tuscany.sca.binding.ajax.AjaxModuleActivator
diff --git a/sandbox/ant/container.easy/NOTICE.txt b/sandbox/ant/container.easy/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sandbox/ant/container.easy/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/sandbox/ant/container.easy/pom.xml b/sandbox/ant/container.easy/pom.xml
new file mode 100644
index 0000000000..4408b9f1ad
--- /dev/null
+++ b/sandbox/ant/container.easy/pom.xml
@@ -0,0 +1,68 @@
+<?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>easy-container</artifactId>
+ <name>Apache Tuscany Easy Container</name>
+ <description>Apache Tuscany Easy Container</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>core</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</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/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/AsyncInvoker.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/AsyncInvoker.java
new file mode 100644
index 0000000000..e5786e8a51
--- /dev/null
+++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/AsyncInvoker.java
@@ -0,0 +1,210 @@
+/*
+ * 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.easy;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.component.TargetException;
+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.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+import org.osoa.sca.SCA;
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * Responsible for performing a non-blocking dispatch on a component implementation instance
+ *
+ * TODO: Pretty much a direct copy of what the groovy container does for async
+ */
+public class AsyncInvoker extends EasyInvoker {
+
+ private static final ContextBinder BINDER = new ContextBinder();
+ private static final Message RESPONSE = new AsyncInvoker.ImmutableMessage();
+
+ private InboundWire wire;
+ private WorkScheduler workScheduler;
+ private AsyncMonitor monitor;
+ private WorkContext workContext;
+ private Object target;
+ private Object messageId;
+
+ /**
+ * Creates a new invoker
+ *
+ * @param operation the operation the invoker is associated with
+ * @param wire
+ * @param component the target component
+ * @param workScheduler the work scheduler to run the invocation
+ * @param monitor the monitor to pass events to
+ * @param workContext
+ */
+ public AsyncInvoker(String operation,
+ InboundWire wire,
+ EasyComponent component,
+ WorkScheduler workScheduler,
+ AsyncMonitor monitor,
+ WorkContext workContext) {
+ super(operation, component);
+ this.wire = wire;
+ this.workScheduler = workScheduler;
+ this.monitor = monitor;
+ this.workContext = workContext;
+ }
+
+ // Override invocation methods to defer invocation to work item
+ // Both methods return null to indicate asynchrony; result will
+ // be conveyed by callback
+ @Override
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ final CompositeContext currentContext = CurrentCompositeContext.getContext();
+ // Schedule the invocation of the next interceptor in a new Work instance
+ try {
+ workScheduler.scheduleWork(new Runnable() {
+ private Object currentMessageId = messageId;
+
+ public void run() {
+ workContext.setCurrentMessageId(null);
+ workContext.setCurrentCorrelationId(currentMessageId);
+ CompositeContext oldContext = CurrentCompositeContext.getContext();
+ try {
+ BINDER.setContext(currentContext);
+ // REVIEW response must be null for one-way and non-null for callback
+ AsyncInvoker.super.invokeTarget(payload);
+ } catch (Exception e) {
+ // REVIEW uncomment when it is available
+ // monitor.executionError(e);
+ e.printStackTrace();
+ } finally {
+ BINDER.setContext(oldContext);
+ }
+ }
+ });
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ return RESPONSE;
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ // can't just call overriden invoke because it would bypass async
+ try {
+ messageId = msg.getMessageId();
+ wire.addMapping(messageId, msg.getFromAddress());
+ return (Message) invokeTarget(msg.getBody());
+ } catch (Throwable e) {
+ // FIXME need to log exceptions
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public AsyncInvoker clone() {
+ AsyncInvoker invoker = (AsyncInvoker) super.clone();
+ invoker.workScheduler = this.workScheduler;
+ invoker.monitor = this.monitor;
+ return invoker;
+ }
+
+ /**
+ * Resolves the target service instance or returns a cached one
+ */
+ protected Object getInstance() throws TargetException {
+ if (!isCacheable()) {
+ return component.getTargetInstance();
+ } else {
+ if (target == null) {
+ target = component.getTargetInstance();
+ }
+ return target;
+ }
+ }
+
+ protected static class ContextBinder extends SCA {
+ public void setContext(CompositeContext context) {
+ setCompositeContext(context);
+ }
+
+ public void start() {
+ throw new AssertionError();
+ }
+
+ public void stop() {
+ throw new AssertionError();
+ }
+ }
+
+ /**
+ * A dummy message passed back on an invocation
+ */
+ protected static class ImmutableMessage implements Message {
+
+ public Object getBody() {
+ return null;
+ }
+
+ public void setBody(Object body) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setTargetInvoker(TargetInvoker invoker) {
+ throw new UnsupportedOperationException();
+ }
+
+ public TargetInvoker getTargetInvoker() {
+ return null;
+ }
+
+ public Object getFromAddress() {
+ return null;
+ }
+
+ public void setFromAddress(Object fromAddress) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getMessageId() {
+ return null;
+ }
+
+ public void setMessageId(Object messageId) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getCorrelationId() {
+ return null;
+ }
+
+ public void setCorrelationId(Object correlationId) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isFault() {
+ return false;
+ }
+
+ public void setBodyWithFault(Object fault) {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/AsyncMonitor.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/AsyncMonitor.java
new file mode 100644
index 0000000000..ce39877dff
--- /dev/null
+++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/AsyncMonitor.java
@@ -0,0 +1,31 @@
+/*
+ * 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.easy;
+
+/**
+ * A monitor used to log events during non-blocking invocations
+ */
+public interface AsyncMonitor {
+
+ /**
+ * Logs an exception thrown during an invocation
+ */
+ void executionError(Exception e);
+
+}
diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponent.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponent.java
new file mode 100644
index 0000000000..62e812a782
--- /dev/null
+++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponent.java
@@ -0,0 +1,117 @@
+/*
+ * 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.easy;
+
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.extension.AtomicComponentExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * A component implementation for script languages.
+ */
+public class EasyComponent extends AtomicComponentExtension {
+
+ private final List<Class<?>> services;
+
+ private final Map<String, Object> properties;
+
+ protected EasyInstanceFactory instanceFactory;
+
+ public EasyComponent(String name, EasyInstanceFactory instanceFactory, Map<String, Object> properties, List<Class<?>> services, CompositeComponent parent, ScopeContainer scopeContainer,
+ WireService wireService, WorkContext workContext, WorkScheduler workScheduler) {
+
+ super(name, parent, scopeContainer, wireService, workContext, workScheduler, 0);
+
+ this.instanceFactory = instanceFactory;
+ this.services = services;
+ this.scope = scopeContainer.getScope();
+ this.properties = properties;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object createInstance() throws ObjectCreationException {
+
+ Map<String, Object> context = new HashMap<String, Object>(getProperties());
+
+ for (List<OutboundWire> referenceWires : getOutboundWires().values()) {
+ for (OutboundWire wire : referenceWires) {
+ Object wireProxy = wireService.createProxy(wire);
+ context.put(wire.getReferenceName(), wireProxy);
+ }
+ }
+
+ return instanceFactory.createInstance(services, context);
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
+ Method[] methods = operation.getServiceContract().getInterfaceClass().getMethods();
+ Method method = findMethod(operation, methods);
+ return new EasyInvoker(method.getName(), this);
+ }
+
+ public TargetInvoker createAsyncTargetInvoker(InboundWire wire, Operation operation) {
+ return new AsyncInvoker(operation.getName(), wire, this, workScheduler, null, workContext);
+ }
+
+ // TODO: move all the following up to AtomicComponentExtension?
+
+ public List<Class<?>> getServiceInterfaces() {
+ return services;
+ }
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ public Object getTargetInstance() throws TargetException {
+ return scopeContainer.getInstance(this);
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return getServiceInstance(null);
+ }
+
+ @SuppressWarnings("unchecked")
+ 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);
+ }
+
+}
diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentBuilder.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentBuilder.java
new file mode 100644
index 0000000000..fd46c77934
--- /dev/null
+++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentBuilder.java
@@ -0,0 +1,83 @@
+/*
+ * 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.easy;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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.component.ScopeContainer;
+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.PropertyValue;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+/**
+ * Extension point for creating {@link ScriptComponent}s from an assembly configuration
+ */
+public class EasyComponentBuilder extends ComponentBuilderExtension<EasyImplementation> {
+
+ public EasyComponentBuilder() {
+ }
+
+ protected Class<EasyImplementation> getImplementationType() {
+ return EasyImplementation.class;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Component build(CompositeComponent parent, ComponentDefinition<EasyImplementation> componentDefinition,
+ DeploymentContext deploymentContext) throws BuilderConfigException {
+
+ String name = componentDefinition.getName();
+ EasyImplementation implementation = componentDefinition.getImplementation();
+ EasyComponentType componentType = implementation.getComponentType();
+
+ // 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 properties for the component
+ Map<String, Object> properties = new HashMap<String, Object>();
+ for (PropertyValue propertyValue : componentDefinition.getPropertyValues().values()) {
+ properties.put(propertyValue.getName(), propertyValue.getValueFactory().getInstance());
+ }
+
+ // TODO: have ComponentBuilderExtension pass ScopeContainer in on build method?
+ ScopeContainer scopeContainer;
+ Scope scope = componentType.getLifecycleScope();
+ if (Scope.MODULE == scope) {
+ scopeContainer = deploymentContext.getModuleScope();
+ } else {
+ scopeContainer = scopeRegistry.getScopeContainer(scope);
+ }
+
+ return new EasyComponent(name, implementation.getScriptInstanceFactory(), properties, services, parent, scopeContainer, wireService, workContext, workScheduler);
+ }
+
+}
diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentType.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentType.java
new file mode 100644
index 0000000000..aa3882a0aa
--- /dev/null
+++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentType.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.easy;
+
+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;
+
+/**
+ * A componentType for script components
+ * TODO: need lifecycle methods init/destroy
+ * TODO: really need a generic componentType that supports scope and lifecycle
+ */
+public class EasyComponentType extends ComponentType<ServiceDefinition, ReferenceDefinition, Property<?>> {
+
+ private Scope lifecycleScope = Scope.MODULE;
+
+ public EasyComponentType() {
+ }
+
+ @SuppressWarnings("unchecked")
+ public EasyComponentType(ComponentType ct) {
+ // TODO: A bit hacky but this is so the generic .componentType XML side file can be used for now
+ setInitLevel(ct.getInitLevel());
+ for (Object property : ct.getProperties().values()) {
+ add((Property) property);
+ }
+ for (Object reference : ct.getReferences().values()) {
+ add((ReferenceDefinition) reference);
+ }
+ for (Object service : ct.getServices().values()) {
+ add((ServiceDefinition) service);
+ }
+ }
+
+ public Scope getLifecycleScope() {
+ return lifecycleScope;
+ }
+
+ public void setLifecycleScope(Scope lifecycleScope) {
+ this.lifecycleScope = lifecycleScope;
+ }
+
+}
diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentTypeLoader.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentTypeLoader.java
new file mode 100644
index 0000000000..ada889e0a1
--- /dev/null
+++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyComponentTypeLoader.java
@@ -0,0 +1,71 @@
+/*
+ * 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.easy;
+
+import java.net.URL;
+
+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.ComponentType;
+
+/**
+ * ComponentType loader for script components
+ */
+public class EasyComponentTypeLoader extends ComponentTypeLoaderExtension<EasyImplementation> {
+
+ public EasyComponentTypeLoader() {
+ }
+
+ @Override
+ protected Class<EasyImplementation> getImplementationClass() {
+ return EasyImplementation.class;
+ }
+
+ // TODO: must be possible to move all the following up in to ComponentTypeLoaderExtension
+
+ public void load(CompositeComponent parent, EasyImplementation implementation, DeploymentContext deploymentContext) throws LoaderException {
+ String sideFile = getSideFileName(implementation.getResourceName());
+ URL resource = implementation.getScriptInstanceFactory().getClassLoader().getResource(sideFile);
+ EasyComponentType componentType;
+ if (resource == null) {
+ throw new IllegalArgumentException("missing .componentType side file: " + sideFile);
+ // TODO: or else implement introspection
+ } else {
+ componentType = loadFromSidefile(resource, deploymentContext);
+ }
+ implementation.setComponentType(componentType);
+ }
+
+ protected EasyComponentType loadFromSidefile(URL url, DeploymentContext deploymentContext) throws LoaderException {
+ ComponentType ct = loaderRegistry.load(null, null, url, ComponentType.class, deploymentContext);
+ EasyComponentType scriptComponentType = new EasyComponentType(ct);
+ return scriptComponentType;
+ }
+
+ protected String getSideFileName(String resourceName) {
+ int lastDot = resourceName.lastIndexOf('.');
+ if (lastDot != -1) {
+ resourceName = resourceName.substring(0, lastDot);
+ }
+ return resourceName + ".componentType";
+ }
+
+}
diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyImplementation.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyImplementation.java
new file mode 100644
index 0000000000..891838d1c6
--- /dev/null
+++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyImplementation.java
@@ -0,0 +1,47 @@
+/*
+ * 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.easy;
+
+import org.apache.tuscany.spi.model.AtomicImplementation;
+
+/**
+ * Model object for a script implementation.
+ */
+public class EasyImplementation extends AtomicImplementation<EasyComponentType> {
+
+ private String resourceName;
+
+ private EasyInstanceFactory scriptInstanceFactory;
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public EasyInstanceFactory getScriptInstanceFactory() {
+ return scriptInstanceFactory;
+ }
+
+ public void setScriptInstanceFactory(EasyInstanceFactory scriptInstanceFactory) {
+ this.scriptInstanceFactory = scriptInstanceFactory;
+ }
+}
diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyImplementationLoader.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyImplementationLoader.java
new file mode 100644
index 0000000000..79d38f1f35
--- /dev/null
+++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyImplementationLoader.java
@@ -0,0 +1,85 @@
+/*
+ * 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.easy;
+
+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 org.apache.tuscany.spi.annotation.Autowire;
+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.MissingResourceException;
+import org.osoa.sca.annotations.Constructor;
+
+/**
+ * Loader for handling implementation.script elements.
+ *
+ * <implementation.script script="path/foo.py" class="myclass">
+ *
+ */
+public abstract class EasyImplementationLoader extends LoaderExtension<EasyImplementation> {
+
+ @Constructor( { "registry" })
+ public EasyImplementationLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public abstract QName getXMLType();
+
+ 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/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInstance.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInstance.java
new file mode 100644
index 0000000000..8e80103f04
--- /dev/null
+++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInstance.java
@@ -0,0 +1,31 @@
+/*
+ * 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.easy;
+
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * An invokable instance of a script
+ *
+ * Basically just a wrapper around a BSF engine with an optional script class object.
+ */
+public interface EasyInstance {
+
+ public Object invokeTarget(String operationName, Object[] args) throws InvocationTargetException;
+}
diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInstanceFactory.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInstanceFactory.java
new file mode 100644
index 0000000000..403eeb6daf
--- /dev/null
+++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInstanceFactory.java
@@ -0,0 +1,71 @@
+/*
+ * 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.easy;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * ScriptInstanceFactory creates ScriptInstances for a script
+ */
+public abstract class EasyInstanceFactory<T extends EasyInstance> {
+
+ protected String resourceName;
+
+ protected ClassLoader classLoader;
+
+ public EasyInstanceFactory(String resourceName, ClassLoader classLoader) {
+ this.resourceName = resourceName;
+ this.classLoader = classLoader;
+ }
+
+ /**
+ * Create a new invokeable instance of the script
+ * @param services
+ *
+ * @param context
+ * objects to add to scope of the script instance
+ * @return a RhinoScriptInstance
+ * TODO: services should be on the constructor not on this method
+ */
+ public abstract T createInstance(List<Class> services, Map<String, Object> context);
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ protected Map<String, Class> getResponseClasses(List<Class> services) {
+ Map<String, Class> responseClasses = new HashMap<String, Class>();
+ if (services != null) {
+ for (Class s : services) {
+ for (Method m : s.getMethods()) {
+ responseClasses.put(m.getName(), m.getReturnType());
+ }
+ }
+ }
+ return responseClasses;
+ }
+
+}
diff --git a/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInvoker.java b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInvoker.java
new file mode 100644
index 0000000000..37ba4c5c2d
--- /dev/null
+++ b/sandbox/ant/container.easy/src/main/java/org/apache/tuscany/container/easy/EasyInvoker.java
@@ -0,0 +1,53 @@
+/*
+ * 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.easy;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.extension.TargetInvokerExtension;
+
+/**
+ * TargetInvoker that calls a function on a ScriptInstance
+ */
+public class EasyInvoker extends TargetInvokerExtension {
+
+ protected EasyComponent component;
+
+ protected String functionName;
+
+ public EasyInvoker(String functionName, EasyComponent component) {
+ this.functionName = functionName;
+ this.component = component;
+ }
+
+ /**
+ * Invoke the function
+ */
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ EasyInstance target = (EasyInstance) component.getTargetInstance();
+ try {
+
+ return target.invokeTarget(functionName, (Object[]) payload);
+
+ } catch (Exception e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+}
diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/AsyncInvokerTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/AsyncInvokerTestCase.java
new file mode 100644
index 0000000000..b49a74ce57
--- /dev/null
+++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/AsyncInvokerTestCase.java
@@ -0,0 +1,207 @@
+/*
+ * 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.easy;
+
+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 java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.easy.AsyncInvoker.ContextBinder;
+import org.apache.tuscany.container.easy.AsyncInvoker.ImmutableMessage;
+import org.apache.tuscany.container.easy.mock.AsyncTarget;
+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 org.easymock.IAnswer;
+import org.easymock.classextension.EasyMock;
+
+/**
+ */
+public class AsyncInvokerTestCase extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testInvoke() throws Exception {
+ EasyInstance instance = createMock(EasyInstance.class);
+ expect(instance.invokeTarget("invoke", null)).andReturn(null).once();
+ replay(instance);
+ EasyComponent component = EasyMock.createMock(EasyComponent.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);
+ AsyncInvoker invoker = new AsyncInvoker("invoke", wire, component, scheduler, monitor, context);
+ Message msg = new MessageImpl();
+ invoker.invoke(msg);
+ verify(instance);
+ }
+
+ public void testClone() {
+ AsyncInvoker invoker = new AsyncInvoker(null, null, null,null,null,null);
+ assertNotNull(invoker.clone());
+ }
+
+ public void testGetInstance() {
+ EasyComponent component = EasyMock.createMock(EasyComponent.class);
+ expect(component.getTargetInstance()).andReturn("petra");
+ EasyMock.replay(component);
+ AsyncInvoker invoker = new AsyncInvoker(null, null, component,null,null,null);
+ assertEquals("petra", invoker.getInstance());
+ }
+
+ public void testGetInstanceCacheable() {
+ EasyComponent component = EasyMock.createMock(EasyComponent.class);
+ expect(component.getTargetInstance()).andReturn("petra");
+ EasyMock.replay(component);
+ AsyncInvoker invoker = new AsyncInvoker(null, null, component,null,null,null);
+ invoker.setCacheable(true);
+ assertEquals("petra", invoker.getInstance());
+ }
+
+ public void testGetBody() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertNull(message.getBody());
+ }
+
+ public void testSetBody() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setBody(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetTargetInvoker() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertNull(message.getTargetInvoker());
+ }
+
+ public void testSetTargetInvoker() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setTargetInvoker(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetFromAddress() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertNull(message.getFromAddress());
+ }
+
+ public void testSetFromAddress() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setFromAddress(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetMessageId() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertNull(message.getMessageId());
+ }
+
+ public void testSetMessageId() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setMessageId(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetCorrelationId() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertNull(message.getCorrelationId());
+ }
+
+ public void testSetCorrelationId() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setCorrelationId(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testIsFault() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertFalse(message.isFault());
+ }
+
+ public void testSetBodyWithFault() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setBodyWithFault(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testContextBinder() {
+ ContextBinder contextBinder = new AsyncInvoker.ContextBinder();
+ contextBinder.setContext(null);
+ try {
+ contextBinder.start();
+ fail();
+ } catch (AssertionError e) {
+ // expected
+ }
+ try {
+ contextBinder.stop();
+ fail();
+ } catch (AssertionError e) {
+ // expected
+ }
+ }
+}
diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentBuilderTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentBuilderTestCase.java
new file mode 100644
index 0000000000..89858da541
--- /dev/null
+++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentBuilderTestCase.java
@@ -0,0 +1,104 @@
+package org.apache.tuscany.container.easy;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.component.scope.ModuleScopeObjectFactory;
+import org.apache.tuscany.core.component.scope.ScopeRegistryImpl;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.PropertyValue;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+import org.easymock.IAnswer;
+
+public class EasyComponentBuilderTestCase extends TestCase {
+
+ public void testGetImplementationType() {
+ EasyComponentBuilder builder = new EasyComponentBuilder();
+ assertEquals(EasyImplementation.class, builder.getImplementationType());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testBuild() {
+ EasyComponentBuilder builder = new EasyComponentBuilder();
+ ScopeRegistry scopeRegistry = new ScopeRegistryImpl();
+ scopeRegistry.registerFactory(Scope.COMPOSITE, new ModuleScopeObjectFactory(scopeRegistry));
+ builder.setScopeRegistry(scopeRegistry);
+ DeploymentContext deploymentContext = createMock(DeploymentContext.class);
+ final ScopeContainer scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.COMPOSITE;
+ }
+ });
+ expect(deploymentContext.getModuleScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return scopeContainer;
+ }
+ });
+ replay(deploymentContext);
+ ComponentDefinition<EasyImplementation> impl = new ComponentDefinition<EasyImplementation>(new EasyImplementation());
+ EasyComponentType componentType = new EasyComponentType();
+ componentType.setLifecycleScope(Scope.COMPOSITE);
+ ServiceDefinition service = new ServiceDefinition();
+ ServiceContract serviceContract = new JavaServiceContract();
+ service.setServiceContract(serviceContract);
+ componentType.add(service);
+ impl.getImplementation().setComponentType(componentType);
+
+ PropertyValue pv = new PropertyValue("foo", "", "");
+ ObjectFactory pvFactory = createMock(ObjectFactory.class);
+ expect(pvFactory.getInstance()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return null;
+ }
+ });
+ replay(pvFactory);
+ pv.setValueFactory(pvFactory);
+ impl.add(pv);
+
+ Component component = builder.build(null, impl, deploymentContext);
+ assertNotNull(component);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testBuildModuleScope() {
+ EasyComponentBuilder builder = new EasyComponentBuilder();
+ DeploymentContext deploymentContext = createMock(DeploymentContext.class);
+ final ScopeContainer scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.MODULE;
+ }
+ });
+ expect(deploymentContext.getModuleScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return scopeContainer;
+ }
+ });
+ replay(deploymentContext);
+ ComponentDefinition<EasyImplementation> impl = new ComponentDefinition<EasyImplementation>(new EasyImplementation());
+ EasyComponentType componentType = new EasyComponentType();
+ ServiceDefinition service = new ServiceDefinition();
+ ServiceContract serviceContract = new JavaServiceContract();
+ service.setServiceContract(serviceContract);
+ componentType.add(service);
+ impl.getImplementation().setComponentType(componentType);
+ Component component = builder.build(null, impl, deploymentContext);
+ assertNotNull(component);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+}
diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTestCase.java
new file mode 100644
index 0000000000..9f5c2a2f14
--- /dev/null
+++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTestCase.java
@@ -0,0 +1,142 @@
+package org.apache.tuscany.container.easy;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.easy.mock.MockInstanceFactory;
+import org.apache.tuscany.core.wire.InboundWireImpl;
+import org.apache.tuscany.core.wire.OutboundWireImpl;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.RuntimeWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+import org.easymock.IAnswer;
+
+public class EasyComponentTestCase extends TestCase {
+
+ private ScopeContainer scopeContainer;
+
+ @SuppressWarnings("unchecked")
+ public void testCreateTargetInvoker() {
+ EasyComponent component = new EasyComponent(null,null, null, null, null, scopeContainer, null, null, null);
+
+ Operation operation = new Operation("hashCode", null,null,null,false,null);
+ ServiceContract contract = new ServiceContract(List.class){};
+ operation.setServiceContract(contract);
+ TargetInvoker invoker = component.createTargetInvoker("hashCode", operation);
+
+ assertNotNull(invoker);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testCreateInstance() throws IOException {
+ EasyComponent pc = new EasyComponent(null,createBSFEasy(), new HashMap(), null, null, scopeContainer, null, null, null);
+ Object o = pc.createInstance();
+ assertNotNull(o);
+ assertTrue(o instanceof EasyInstance);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testCreateInstanceWithRef() throws IOException {
+ WireService wireService = createMock(WireService.class);
+ expect(wireService.createProxy(isA(RuntimeWire.class))).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.MODULE;
+ }
+ });
+
+ EasyComponent pc = new EasyComponent(null,createBSFEasy(), new HashMap(), null, null, scopeContainer, wireService, null, null);
+ OutboundWire wire = new OutboundWireImpl();
+ wire.setReferenceName("foo");
+ pc.addOutboundWire(wire);
+ Object o = pc.createInstance();
+ assertNotNull(o);
+ assertTrue(o instanceof EasyInstance);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testGetServiceInstance() {
+ WireService wireService = createMock(WireService.class);
+ expect(wireService.createProxy(isA(RuntimeWire.class))).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return "foo";
+ }
+ });
+ replay(wireService);
+ EasyComponent pc = new EasyComponent(null,null, null, null, null, scopeContainer, wireService, null, null);
+ InboundWire wire = new InboundWireImpl();
+ pc.addInboundWire(wire);
+ assertEquals("foo", pc.getServiceInstance());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testGetServiceInstanceFail() {
+ EasyComponent pc = new EasyComponent(null,null, null, null, null, scopeContainer, null, null, null);
+ try {
+ pc.getServiceInstance();
+ fail();
+ } catch (TargetException e) {
+ // expected
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testGetproperties() {
+ EasyComponent pc = new EasyComponent(null,null, new HashMap(), null, null, scopeContainer, null, null, null);
+ assertNotNull(pc.getProperties());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testGetServiceInterfaces() {
+ List services = new ArrayList();
+ EasyComponent pc = new EasyComponent(null,null,null, services, null, scopeContainer, null, null, null);
+ assertEquals(services, pc.getServiceInterfaces());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testCreateAsyncTargetInvoker() {
+ EasyComponent pc = new EasyComponent(null,null,null, new ArrayList<Class<?>>(), null, scopeContainer, null, null, null);
+ assertNotNull(pc.createAsyncTargetInvoker(null, new Operation("foo", null,null,null)));
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.MODULE;
+ }
+ });
+ }
+
+ public EasyInstanceFactory createBSFEasy() throws IOException {
+// URL scriptURL = getClass().getResource("foo.mock");
+// InputStream is = scriptURL.openStream();
+// StringBuilder sb = new StringBuilder();
+// int i = 0;
+// while ((i = is.read()) != -1) {
+// sb.append((char) i);
+// }
+// is.close();
+// String script = sb.toString();
+ MockInstanceFactory bsfEasy = new MockInstanceFactory("foo.mock", null);
+ return bsfEasy;
+ }
+}
diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTypeLoaderTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTypeLoaderTestCase.java
new file mode 100644
index 0000000000..2a86172a5e
--- /dev/null
+++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTypeLoaderTestCase.java
@@ -0,0 +1,141 @@
+/*
+ * 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.easy;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.stream.XMLStreamException;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.easy.mock.MockInstanceFactory;
+import org.apache.tuscany.core.loader.LoaderRegistryImpl;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+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.model.ComponentType;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.apache.tuscany.spi.model.Scope;
+import org.easymock.IAnswer;
+
+/**
+ *
+ */
+public class EasyComponentTypeLoaderTestCase extends TestCase {
+
+ public void testGetSideFileName() {
+ EasyComponentTypeLoader loader = new EasyComponentTypeLoader();
+ assertEquals("BSFEasyTestCase.componentType", loader.getSideFileName("BSFEasyTestCase.mock"));
+ }
+
+ public void testGetSideFileNameNoDot() {
+ EasyComponentTypeLoader loader = new EasyComponentTypeLoader();
+ assertEquals("BSFEasyTestCase.componentType", loader.getSideFileName("BSFEasyTestCase"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testLoadFromSideFile() throws MalformedURLException, LoaderException, XMLStreamException {
+ EasyComponentTypeLoader loader = new EasyComponentTypeLoader();
+ LoaderRegistry loaderRegistry = new LoaderRegistryImpl() {
+ public <MO extends ModelObject> MO load(CompositeComponent parent, ModelObject mo, URL url, Class<MO> type, DeploymentContext ctx) throws LoaderException {
+ return (MO) new ComponentType();
+ }
+ };
+ loader.setLoaderRegistry(loaderRegistry);
+ loader.loadFromSidefile(null, null);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testLoad() throws LoaderException {
+ EasyInstanceFactory bsfEasy = new MockInstanceFactory("org/apache/tuscany/container/easy/foo.mock", getClass().getClassLoader());
+ EasyComponentTypeLoader loader = new EasyComponentTypeLoader();
+ LoaderRegistry loaderRegistry = new LoaderRegistryImpl() {
+ public <MO extends ModelObject> MO load(CompositeComponent parent,
+ ModelObject mo,
+ URL url,
+ Class<MO> type,
+ DeploymentContext ctx) throws LoaderException {
+ return (MO) new ComponentType();
+ }
+ };
+ loader.setLoaderRegistry(loaderRegistry);
+ EasyImplementation implementation = new EasyImplementation();
+ implementation.setResourceName("org/apache/tuscany/container/easy/foo.mock");
+ implementation.setScriptInstanceFactory(bsfEasy);
+ DeploymentContext deploymentContext = createMock(DeploymentContext.class);
+ final ScopeContainer scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.MODULE;
+ }
+ });
+ expect(deploymentContext.getModuleScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return scopeContainer;
+ }
+ });
+ replay(deploymentContext);
+ loader.load(null, implementation, deploymentContext);
+ assertNotNull(implementation.getComponentType());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testLoadMissingSideFile() throws LoaderException {
+ EasyInstanceFactory bsfEasy = new MockInstanceFactory("org/apche/tuscany/container/easy/foo.mock", getClass().getClassLoader());
+ EasyComponentTypeLoader loader = new EasyComponentTypeLoader();
+ EasyImplementation implementation = new EasyImplementation();
+ implementation.setResourceName("org/apache/tuscany/container/easy/doesntExist");
+ implementation.setScriptInstanceFactory(bsfEasy);
+ DeploymentContext deploymentContext = createMock(DeploymentContext.class);
+ final ScopeContainer scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.MODULE;
+ }
+ });
+ expect(deploymentContext.getModuleScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return scopeContainer;
+ }
+ });
+ replay(deploymentContext);
+ try {
+ loader.load(null, implementation, deploymentContext);
+ fail();
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ public void testGetImplementationClass() {
+ EasyComponentTypeLoader loader = new EasyComponentTypeLoader();
+ assertEquals(EasyImplementation.class, loader.getImplementationClass());
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+}
diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTypeTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTypeTestCase.java
new file mode 100644
index 0000000000..5d9b436bc3
--- /dev/null
+++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyComponentTypeTestCase.java
@@ -0,0 +1,37 @@
+package org.apache.tuscany.container.easy;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.easy.EasyComponentType;
+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;
+
+public class EasyComponentTypeTestCase extends TestCase {
+
+ public void testLifecycleScope() {
+ EasyComponentType ct = new EasyComponentType();
+ assertEquals(Scope.MODULE, ct.getLifecycleScope());
+ ct.setLifecycleScope(Scope.COMPOSITE);
+ assertEquals(Scope.COMPOSITE, ct.getLifecycleScope());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testComponentTypeConstructor() {
+ ComponentType ct = new ComponentType();
+ Property property = new Property();
+ ct.add(property);
+ ReferenceDefinition reference = new ReferenceDefinition();
+ ct.add(reference);
+ ServiceDefinition service = new ServiceDefinition();
+ ct.add(service);
+
+ EasyComponentType pct = new EasyComponentType(ct);
+
+ assertEquals(property, pct.getProperties().values().iterator().next());
+ assertEquals(reference, pct.getReferences().values().iterator().next());
+ assertEquals(service, pct.getServices().values().iterator().next());
+ }
+}
diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyImplementationLoaderTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyImplementationLoaderTestCase.java
new file mode 100644
index 0000000000..f655015ad4
--- /dev/null
+++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyImplementationLoaderTestCase.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.easy;
+
+import static org.easymock.classextension.EasyMock.createMock;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+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 org.apache.tuscany.spi.model.ModelObject;
+
+/**
+ *
+ */
+public class EasyImplementationLoaderTestCase extends TestCase {
+
+ private LoaderRegistry registry;
+
+ private EasyImplementationLoader loader;
+
+ public void testLoadSource() throws LoaderException {
+ String script = loader.loadSource(getClass().getClassLoader(), "org/apache/tuscany/container/easy/foo.mock");
+ assertTrue(script.startsWith("hello"));
+ }
+
+ public void testLoadSourceMissingResource() throws LoaderException {
+ try {
+ loader.loadSource(getClass().getClassLoader(), "doesnt.exist");
+ fail();
+ } catch (MissingResourceException e) {
+ // expected
+ }
+ }
+
+ public void testGetXMLType() throws LoaderException {
+ assertEquals("http://foo", loader.getXMLType().getNamespaceURI());
+ assertEquals("bar", loader.getXMLType().getLocalPart());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = createMock(LoaderRegistry.class);
+ loader = new EasyImplementationLoader(registry){
+ public QName getXMLType() {
+ return new QName("http://foo", "bar");
+ }
+// @Override
+ public EasyImplementation load(CompositeComponent arg0, ModelObject arg1, XMLStreamReader arg2, DeploymentContext arg3) throws XMLStreamException, LoaderException {
+ return null;
+ }};
+ }
+}
diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyImplementationTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyImplementationTestCase.java
new file mode 100644
index 0000000000..9a7ec25315
--- /dev/null
+++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyImplementationTestCase.java
@@ -0,0 +1,28 @@
+package org.apache.tuscany.container.easy;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.easy.mock.MockInstanceFactory;
+
+public class EasyImplementationTestCase extends TestCase {
+
+ private EasyInstanceFactory bsfEasy;
+
+ public void testGetBSFEasy() {
+ EasyImplementation impl = new EasyImplementation();
+ impl.setScriptInstanceFactory(bsfEasy);
+ assertEquals(bsfEasy, impl.getScriptInstanceFactory());
+ }
+
+ public void testGetResourceName() {
+ EasyImplementation impl = new EasyImplementation();
+ impl.setResourceName("foo");
+ assertEquals("foo", impl.getResourceName());
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ bsfEasy = new MockInstanceFactory("BSFEasyTestCase", null);
+ }
+
+}
diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInstanceFactoryTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInstanceFactoryTestCase.java
new file mode 100644
index 0000000000..c96d8425eb
--- /dev/null
+++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInstanceFactoryTestCase.java
@@ -0,0 +1,55 @@
+package org.apache.tuscany.container.easy;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.easy.mock.MockInstanceFactory;
+
+public class EasyInstanceFactoryTestCase extends TestCase {
+
+ public void testCreateInstance() throws InvocationTargetException {
+ MockInstanceFactory factory = new MockInstanceFactory("foo.mock", getClass().getClassLoader());
+ Map<String, Object> context = new HashMap<String, Object>();
+ context.put("foo", "bar");
+ EasyInstance instance = factory.createInstance(null, context);
+ assertNotNull(instance);
+ }
+
+ public void testCreateInstanceNoClass() throws InvocationTargetException {
+ MockInstanceFactory factory = new MockInstanceFactory("foo.mock", getClass().getClassLoader());
+ Map<String, Object> context = new HashMap<String, Object>();
+ context.put("foo", "bar");
+ EasyInstance instance = factory.createInstance(null, context);
+ assertNotNull(instance);
+ }
+
+ public void testCreateInstanceRuby() throws InvocationTargetException {
+ MockInstanceFactory factory = new MockInstanceFactory("foo.mock", getClass().getClassLoader());
+ Map<String, Object> context = new HashMap<String, Object>();
+ context.put("foo", "bar");
+ EasyInstance instance = factory.createInstance(null, context);
+ assertNotNull(instance);
+ }
+
+ public void testGetters() throws InvocationTargetException {
+ MockInstanceFactory factory = new MockInstanceFactory("foo", getClass().getClassLoader());
+ assertEquals("foo", factory.getResourceName());
+ assertEquals(getClass().getClassLoader(), factory.getClassLoader());
+ }
+
+ public void testGetResponseClasses() {
+ MockInstanceFactory factory = new MockInstanceFactory("foo", getClass().getClassLoader());
+ Map<String, Class> classes = factory.getResponseClasses(Arrays.asList( new Class[]{ Runnable.class}));
+ assertEquals(1, classes.size());
+ assertEquals("run", classes.keySet().iterator().next());
+ assertEquals(void.class, classes.get("run"));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+}
diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java
new file mode 100644
index 0000000000..bdd5c4a875
--- /dev/null
+++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/EasyInvokerTestCase.java
@@ -0,0 +1,61 @@
+package org.apache.tuscany.container.easy;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+
+import java.lang.reflect.InvocationTargetException;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.model.Scope;
+import org.easymock.IAnswer;
+
+public class EasyInvokerTestCase extends TestCase {
+
+ private EasyComponent component;
+
+ public void testInvokeTarget() throws InvocationTargetException {
+ EasyInvoker invoker = new EasyInvoker("hello", component);
+ assertEquals("hello petra", invoker.invokeTarget(null));
+ }
+
+ public void testInvokeTargetException() throws InvocationTargetException, SecurityException, NoSuchMethodException {
+ EasyInvoker badInvoker = new EasyInvoker("bang", component);
+ try {
+ badInvoker.invokeTarget(null);
+ fail();
+ } catch (InvocationTargetException e) {
+ // expected
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ ScopeContainer scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.MODULE;
+ }
+ });
+ expect(scopeContainer.getInstance(isA(AtomicComponent.class))).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return new EasyInstance(){
+ public Object invokeTarget(String operationName, Object[] args) throws InvocationTargetException {
+ if ("bang".equals(operationName)) {
+ throw new RuntimeException("bang");
+ }
+ return "hello petra";
+ }};
+ }
+ });
+ replay(scopeContainer);
+
+ this.component = new EasyComponent(null, null, null, null, null, scopeContainer, null, null, null);
+ }
+}
diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/mock/AsyncTarget.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/mock/AsyncTarget.java
new file mode 100644
index 0000000000..b7317ddcab
--- /dev/null
+++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/mock/AsyncTarget.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.easy.mock;
+
+/**
+ */
+public interface AsyncTarget {
+
+ void invoke();
+}
diff --git a/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/mock/MockInstanceFactory.java b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/mock/MockInstanceFactory.java
new file mode 100644
index 0000000000..b7c7b3f755
--- /dev/null
+++ b/sandbox/ant/container.easy/src/test/java/org/apache/tuscany/container/easy/mock/MockInstanceFactory.java
@@ -0,0 +1,30 @@
+package org.apache.tuscany.container.easy.mock;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.container.easy.EasyInstance;
+import org.apache.tuscany.container.easy.EasyInstanceFactory;
+
+public class MockInstanceFactory extends EasyInstanceFactory<MockInstance> {
+
+ public MockInstanceFactory(String scriptName, ClassLoader classLoader) {
+ super(scriptName, classLoader);
+ }
+
+ @Override
+ public MockInstance createInstance(List<Class> services, Map<String, Object> context) {
+ return new MockInstance();
+ }
+
+}
+
+class MockInstance implements EasyInstance {
+
+ public Object invokeTarget(String operationName, Object[] args) throws InvocationTargetException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/sandbox/ant/container.easy/src/test/resources/org/apache/tuscany/container/easy/foo.componentType b/sandbox/ant/container.easy/src/test/resources/org/apache/tuscany/container/easy/foo.componentType
new file mode 100644
index 0000000000..9c37e1cb3e
--- /dev/null
+++ b/sandbox/ant/container.easy/src/test/resources/org/apache/tuscany/container/easy/foo.componentType
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="not.used"/>
+ </service>
+
+</componentType>
diff --git a/sandbox/ant/container.easy/src/test/resources/org/apache/tuscany/container/easy/foo.mock b/sandbox/ant/container.easy/src/test/resources/org/apache/tuscany/container/easy/foo.mock
new file mode 100644
index 0000000000..b6fc4c620b
--- /dev/null
+++ b/sandbox/ant/container.easy/src/test/resources/org/apache/tuscany/container/easy/foo.mock
@@ -0,0 +1 @@
+hello \ No newline at end of file
diff --git a/sandbox/ant/container.jsr223/pom.xml b/sandbox/ant/container.jsr223/pom.xml
new file mode 100644
index 0000000000..89450eee2e
--- /dev/null
+++ b/sandbox/ant/container.jsr223/pom.xml
@@ -0,0 +1,83 @@
+<?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>container-jsr223</artifactId>
+ <name>Apache Tuscany Script Container using JSR-223</name>
+ <description>Apache Tuscany Script Container using JSR-223</description>
+
+ <repositories>
+ <repository>
+ <!-- Hmm, there must be a better way to get this -->
+ <id>jsr223</id>
+ <url>http://dist.codehaus.org/mule/dependencies/maven2</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>easy-container</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>script</groupId>
+ <artifactId>jsr223</artifactId>
+ <version>1.0</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>
+
+ <dependency>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ <version>1.6R2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/sandbox/ant/container.jsr223/src/main/java/org/apache/tuscany/container/jsr223/ScriptImplementationLoader.java b/sandbox/ant/container.jsr223/src/main/java/org/apache/tuscany/container/jsr223/ScriptImplementationLoader.java
new file mode 100644
index 0000000000..950820fbcd
--- /dev/null
+++ b/sandbox/ant/container.jsr223/src/main/java/org/apache/tuscany/container/jsr223/ScriptImplementationLoader.java
@@ -0,0 +1,81 @@
+/*
+ * 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.jsr223;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.container.easy.EasyImplementation;
+import org.apache.tuscany.container.easy.EasyImplementationLoader;
+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.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.osoa.sca.annotations.Constructor;
+
+/**
+ * Loader for handling implementation.script elements.
+ *
+ * <implementation.script script="path/foo.py" class="myclass">
+ *
+ */
+public class ScriptImplementationLoader extends EasyImplementationLoader {
+
+ private static final QName IMPLEMENTATION_SCRIPT = new QName(XML_NAMESPACE_1_0, "implementation.script");
+
+ @Constructor( { "registry" })
+ public ScriptImplementationLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return IMPLEMENTATION_SCRIPT;
+ }
+
+ @Override
+ public EasyImplementation load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
+ String scriptName = reader.getAttributeValue(null, "script");
+ if (scriptName == null) {
+ throw new MissingResourceException("implementation element has no 'script' attribute");
+ }
+
+ String className = reader.getAttributeValue(null, "class");
+
+ LoaderUtil.skipToEndElement(reader);
+
+ ClassLoader cl = deploymentContext.getClassLoader();
+ String scriptSource = loadSource(cl, scriptName);
+
+ ScriptInstanceFactory instanceFactory = new ScriptInstanceFactory(scriptName, className, scriptSource, cl);
+
+ EasyImplementation implementation = new EasyImplementation();
+ implementation.setResourceName(scriptName);
+ implementation.setScriptInstanceFactory(instanceFactory);
+
+ registry.loadComponentType(parent, implementation, deploymentContext);
+
+ return implementation;
+ }
+}
diff --git a/sandbox/ant/container.jsr223/src/main/java/org/apache/tuscany/container/jsr223/ScriptInstance.java b/sandbox/ant/container.jsr223/src/main/java/org/apache/tuscany/container/jsr223/ScriptInstance.java
new file mode 100644
index 0000000000..67a380f0d8
--- /dev/null
+++ b/sandbox/ant/container.jsr223/src/main/java/org/apache/tuscany/container/jsr223/ScriptInstance.java
@@ -0,0 +1,50 @@
+/*
+ * 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.jsr223;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.script.Invocable;
+
+import org.apache.tuscany.container.easy.EasyInstance;
+
+/**
+ * An invokable instance of a script
+ *
+ * Basically just a wrapper around a BSF engine with an optional script class object.
+ */
+public class ScriptInstance implements EasyInstance {
+
+ protected Invocable invocableEngine;
+
+ public ScriptInstance(Invocable invocableEngine) {
+ this.invocableEngine = invocableEngine;
+ }
+
+ public Object invokeTarget(String operationName, Object[] args) throws InvocationTargetException {
+ try {
+
+ return invocableEngine.call(operationName, args);
+
+ } catch (Exception e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+}
diff --git a/sandbox/ant/container.jsr223/src/main/java/org/apache/tuscany/container/jsr223/ScriptInstanceFactory.java b/sandbox/ant/container.jsr223/src/main/java/org/apache/tuscany/container/jsr223/ScriptInstanceFactory.java
new file mode 100644
index 0000000000..11e2728fd3
--- /dev/null
+++ b/sandbox/ant/container.jsr223/src/main/java/org/apache/tuscany/container/jsr223/ScriptInstanceFactory.java
@@ -0,0 +1,75 @@
+/*
+ * 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.jsr223;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.script.Invocable;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+
+import org.apache.tuscany.container.easy.EasyInstanceFactory;
+import org.apache.tuscany.spi.ObjectCreationException;
+
+/**
+ * ScriptInstanceFactory creates ScriptInstances for a script
+ */
+public class ScriptInstanceFactory extends EasyInstanceFactory<ScriptInstance>{
+
+ private String className;
+
+ private String scriptSource;
+
+ public ScriptInstanceFactory(String resourceName, String className, String scriptSource, ClassLoader classLoader) {
+ super(resourceName, classLoader);
+ this.className = className;
+ this.scriptSource = scriptSource;
+ }
+
+ /**
+ * Create a new invokeable instance of the script
+ *
+ * @param context
+ * objects to add to scope of the script instance
+ * @return a RhinoScriptInstance
+ */
+ public ScriptInstance createInstance(List<Class> services, Map<String, Object> context) {
+ try {
+
+ ScriptEngineManager engineMgr = new ScriptEngineManager();
+ ScriptEngine engine = engineMgr.getEngineByExtension(getScriptExtension());
+ engine.eval(scriptSource);
+ return new ScriptInstance((Invocable) engine);
+
+ } catch (ScriptException e) {
+ throw new ObjectCreationException(e);
+ }
+ }
+
+ protected String getScriptExtension() {
+ int lastDot = resourceName.lastIndexOf('.');
+ if (lastDot == -1) {
+ return null;
+ }
+ return resourceName.substring(lastDot+1);
+ }
+
+}
diff --git a/sandbox/ant/container.jsr223/src/main/resources/META-INF/sca/default.scdl b/sandbox/ant/container.jsr223/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..7d9ef5a64e
--- /dev/null
+++ b/sandbox/ant/container.jsr223/src/main/resources/META-INF/sca/default.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://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+
+ name="org.apache.tuscany.container.jsr223.ScriptImplementation">
+
+ <component name="jsr223.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.container.jsr223.ScriptImplementationLoader"/>
+ </component>
+
+ <component name="jsr223.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.container.easy.EasyComponentTypeLoader"/>
+ </component>
+
+ <component name="jsr223.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.easy.EasyComponentBuilder"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/container.jsr223/src/main/resources/META-INF/sca/script.system.scdl b/sandbox/ant/container.jsr223/src/main/resources/META-INF/sca/script.system.scdl
new file mode 100644
index 0000000000..7d9ef5a64e
--- /dev/null
+++ b/sandbox/ant/container.jsr223/src/main/resources/META-INF/sca/script.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://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+
+ name="org.apache.tuscany.container.jsr223.ScriptImplementation">
+
+ <component name="jsr223.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.container.jsr223.ScriptImplementationLoader"/>
+ </component>
+
+ <component name="jsr223.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.container.easy.EasyComponentTypeLoader"/>
+ </component>
+
+ <component name="jsr223.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.easy.EasyComponentBuilder"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/container.jsr223/src/test/java/org/apache/tuscany/container/jsr223/FunctionTestCase.java b/sandbox/ant/container.jsr223/src/test/java/org/apache/tuscany/container/jsr223/FunctionTestCase.java
new file mode 100644
index 0000000000..d7ce7399a1
--- /dev/null
+++ b/sandbox/ant/container.jsr223/src/test/java/org/apache/tuscany/container/jsr223/FunctionTestCase.java
@@ -0,0 +1,39 @@
+/*
+ * 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.jsr223;
+
+import java.lang.reflect.InvocationTargetException;
+
+import junit.framework.TestCase;
+
+public class FunctionTestCase extends TestCase {
+
+ public void testBasicInvoke() {
+ String src = "function foo(s) { return 'foo ' + s; }";
+ ScriptInstanceFactory factory = new ScriptInstanceFactory("test.js", null, src, null);
+ ScriptInstance inst = factory.createInstance(null, null);
+ Object o;
+ try {
+ o = inst.invokeTarget("foo", new Object[] { "petra" });
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ assertEquals("foo petra", o);
+ }
+}
diff --git a/sandbox/ant/container.jsr223/src/test/java/org/apache/tuscany/container/jsr223/ScriptImplementationLoaderTestCase.java b/sandbox/ant/container.jsr223/src/test/java/org/apache/tuscany/container/jsr223/ScriptImplementationLoaderTestCase.java
new file mode 100644
index 0000000000..4ece8956ab
--- /dev/null
+++ b/sandbox/ant/container.jsr223/src/test/java/org/apache/tuscany/container/jsr223/ScriptImplementationLoaderTestCase.java
@@ -0,0 +1,133 @@
+/*
+ * 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.jsr223;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.jsr223.ScriptImplementationLoader;
+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;
+
+/**
+ *
+ */
+public class ScriptImplementationLoaderTestCase extends TestCase {
+ private CompositeComponent parent;
+
+ private XMLStreamReader reader;
+
+ private DeploymentContext deploymentContext;
+
+ private ClassLoader classLoader;
+
+ private LoaderRegistry registry;
+
+ private ScriptImplementationLoader loader;
+
+ public void testLoadNoScriptAttribute() 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 testLoad() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn("foo.mock");
+ expect(reader.getAttributeValue(null, "class")).andReturn(null);
+ expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
+ expect(deploymentContext.getClassLoader()).andReturn(classLoader);
+
+ replay(reader);
+ replay(deploymentContext);
+
+ ScriptImplementationLoader mockLoader = new ScriptImplementationLoader(registry) {
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ assertSame(classLoader, cl);
+ assertEquals("foo.mock", resource);
+ return "bar";
+ }
+ };
+ mockLoader.load(parent, reader, deploymentContext);
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testLoadNoScriptPresent() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn("foo.py");
+ expect(reader.getAttributeValue(null, "class")).andReturn(null);
+ expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
+ expect(deploymentContext.getClassLoader()).andReturn(classLoader);
+
+ replay(reader);
+ replay(deploymentContext);
+
+ ScriptImplementationLoader mockLoader = new ScriptImplementationLoader(registry) {
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ assertSame(classLoader, cl);
+ assertEquals("foo.py", resource);
+ throw new MissingResourceException(resource);
+ }
+ };
+ try {
+ mockLoader.load(parent, reader, deploymentContext);
+ fail();
+ } catch (MissingResourceException e) {
+ assertEquals("foo.py", e.getMessage());
+ }
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testGetXMLType() throws LoaderException {
+ assertEquals(XML_NAMESPACE_1_0, loader.getXMLType().getNamespaceURI());
+ assertEquals("implementation.script", loader.getXMLType().getLocalPart());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = createMock(LoaderRegistry.class);
+ loader = new ScriptImplementationLoader(registry);
+
+ parent = createMock(CompositeComponent.class);
+ reader = createMock(XMLStreamReader.class);
+ deploymentContext = createMock(DeploymentContext.class);
+ classLoader = createMock(ClassLoader.class);
+ }
+}
diff --git a/sandbox/ant/container.jsr223/src/test/java/org/apache/tuscany/container/jsr223/ScriptInstanceFactoryTestCase.java b/sandbox/ant/container.jsr223/src/test/java/org/apache/tuscany/container/jsr223/ScriptInstanceFactoryTestCase.java
new file mode 100644
index 0000000000..6ec5b54285
--- /dev/null
+++ b/sandbox/ant/container.jsr223/src/test/java/org/apache/tuscany/container/jsr223/ScriptInstanceFactoryTestCase.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.jsr223;
+
+import java.lang.reflect.InvocationTargetException;
+
+import junit.framework.TestCase;
+
+public class ScriptInstanceFactoryTestCase extends TestCase {
+
+// public void testCreateInstance() throws InvocationTargetException {
+// BSFManager.registerScriptingEngine("mock", MockBSFEngine.class.getName(), new String[] {"mock"});
+// ScriptInstanceFactory factory = new ScriptInstanceFactory("foo.mock", "bar", "baz", getClass().getClassLoader());
+// Map<String, Object> context = new HashMap<String, Object>();
+// context.put("foo", "bar");
+// ScriptInstance instance = factory.createInstance(null, context);
+// assertNotNull(instance);
+// assertNotNull(instance.bsfEngine);
+//// assertNotNull(instance.clazz);
+// }
+//
+// public void testCreateInstanceNoClass() throws InvocationTargetException {
+// BSFManager.registerScriptingEngine("mock", MockBSFEngine.class.getName(), new String[] {"mock"});
+// ScriptInstanceFactory factory = new ScriptInstanceFactory("foo.mock", null, "baz", getClass().getClassLoader());
+// Map<String, Object> context = new HashMap<String, Object>();
+// context.put("foo", "bar");
+// ScriptInstance instance = factory.createInstance(null, context);
+// assertNotNull(instance);
+// assertNotNull(instance.bsfEngine);
+// }
+//
+// public void testCreateInstanceRuby() throws InvocationTargetException {
+// BSFManager.registerScriptingEngine("ruby", MockBSFEngine.class.getName(), new String[] {"mock"});
+// ScriptInstanceFactory factory = new ScriptInstanceFactory("foo.mock", "bar", "baz", getClass().getClassLoader());
+// Map<String, Object> context = new HashMap<String, Object>();
+// context.put("foo", "bar");
+// ScriptInstance instance = factory.createInstance(null, context);
+// assertNotNull(instance);
+// assertNotNull(instance.bsfEngine);
+//// assertNotNull(instance.clazz);
+// }
+//
+// public void testBadCreateInstance() throws InvocationTargetException {
+// ScriptInstanceFactory factory = new ScriptInstanceFactory("foo", "bar", "baz", getClass().getClassLoader());
+// Map<String, Object> context = new HashMap<String, Object>();
+// try {
+// factory.createInstance(null, context);
+// fail();
+// } catch (ObjectCreationException e) {
+// // expected
+// }
+// }
+//
+ public void testGetters() throws InvocationTargetException {
+ ScriptInstanceFactory factory = new ScriptInstanceFactory("foo", "bar", "baz", getClass().getClassLoader());
+// assertEquals("foo", factory.getScriptName());
+// assertEquals("bar", factory.getClassName());
+// assertEquals("baz", factory.getScriptSource());
+ assertEquals(getClass().getClassLoader(), factory.getClassLoader());
+ }
+
+ public void testGetScriptExtension() throws InvocationTargetException {
+ ScriptInstanceFactory factory = new ScriptInstanceFactory("x.js", null, null, null);
+ assertEquals("js", factory.getScriptExtension());
+ }
+
+ public void testNullGetScriptExtension() throws InvocationTargetException {
+ ScriptInstanceFactory factory = new ScriptInstanceFactory("x", null, null, null);
+ assertEquals(null, factory.getScriptExtension());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+}
diff --git a/sandbox/ant/container.jsr223/src/test/java/org/apache/tuscany/container/jsr223/ScriptInstanceTestCase.java b/sandbox/ant/container.jsr223/src/test/java/org/apache/tuscany/container/jsr223/ScriptInstanceTestCase.java
new file mode 100644
index 0000000000..bd38e02c2f
--- /dev/null
+++ b/sandbox/ant/container.jsr223/src/test/java/org/apache/tuscany/container/jsr223/ScriptInstanceTestCase.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.jsr223;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.script.Invocable;
+import javax.script.ScriptException;
+
+import junit.framework.TestCase;
+
+import org.easymock.IAnswer;
+
+public class ScriptInstanceTestCase extends TestCase {
+
+ public void testInvokeTarget() throws InvocationTargetException, ScriptException, NoSuchMethodException {
+ Invocable invocable = createMock(Invocable.class);
+ expect(invocable.call("foo", null)).andReturn("foo petra");
+ replay(invocable);
+ ScriptInstance instance = new ScriptInstance(invocable);
+ assertEquals("foo petra", instance.invokeTarget("foo", null));
+ }
+
+ public void testInvokeTargetException() throws InvocationTargetException, ScriptException, NoSuchMethodException {
+ Invocable invocable = createMock(Invocable.class);
+ expect(invocable.call("foo", null)).andStubAnswer(new IAnswer<Object>() {
+ public Object answer() throws Throwable {
+ throw new RuntimeException("bang");
+ }
+ });
+ replay(invocable);
+ ScriptInstance instance = new ScriptInstance(invocable);
+ try {
+ instance.invokeTarget("foo", null);
+ fail();
+ } catch (InvocationTargetException e) {
+ assertEquals("bang", e.getCause().getMessage());
+ }
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+}
diff --git a/sandbox/ant/container.python/NOTICE.txt b/sandbox/ant/container.python/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sandbox/ant/container.python/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/sandbox/ant/container.python/pom.xml b/sandbox/ant/container.python/pom.xml
new file mode 100644
index 0000000000..1b31cab18b
--- /dev/null
+++ b/sandbox/ant/container.python/pom.xml
@@ -0,0 +1,78 @@
+<?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.containers</groupId>
+ <artifactId>containers</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-python</artifactId>
+ <name>Apache Tuscany Python Container</name>
+ <description>Apache Tuscany Python Container</description>
+
+ <repositories>
+ <repository>
+ <id>ant</id>
+ <url>http://people.apache.org/~antelder/maven2</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>core</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>jython</groupId>
+ <artifactId>jython</artifactId>
+ <version>2.2a1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany</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/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonComponent.java b/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonComponent.java
new file mode 100644
index 0000000000..4376c48b82
--- /dev/null
+++ b/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonComponent.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.python;
+
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+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 org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * A component implementation for the Python language.
+ */
+public class PythonComponent extends AtomicComponentExtension {
+
+ private final List<Class<?>> services;
+
+ private final Map<String, Object> properties;
+
+ private PythonScript rhinoScript;
+
+ public PythonComponent(String name, PythonScript rhinoScript, List<Class<?>> services, CompositeComponent parent, ScopeContainer scopeContainer,
+ WireService wireService, WorkContext workContext) {
+
+ super(name, parent, scopeContainer, wireService, workContext, null, 0);
+
+ this.rhinoScript = rhinoScript;
+ this.services = services;
+ this.scope = scopeContainer.getScope();
+ this.properties = new HashMap<String, Object>();
+ }
+
+ public Object createInstance() throws ObjectCreationException {
+
+ Map<String, Object> context = new HashMap<String, Object>(getProperties());
+
+ for (List<OutboundWire> referenceWires : getOutboundWires().values()) {
+ for (OutboundWire wire : referenceWires) {
+ Object wireProxy = wireService.createProxy(wire);
+ context.put(wire.getReferenceName(), wireProxy);
+ }
+ }
+
+ Object instance = rhinoScript.createInstance(context);
+
+ return instance;
+ }
+
+ public TargetInvoker createTargetInvoker(String serviceName, Operation operation) {
+ Method[] methods = operation.getServiceContract().getInterfaceClass().getMethods();
+ Method method = findMethod(operation, methods);
+ return new PythonInvoker(method, this);
+ }
+
+ // TODO: move all the following up to AtomicComponentExtension?
+
+ public List<Class<?>> getServiceInterfaces() {
+ return services;
+ }
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ public Object getTargetInstance() throws TargetException {
+ return scopeContainer.getInstance(this);
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return getServiceInstance(null);
+ }
+
+ @SuppressWarnings("unchecked")
+ 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);
+ }
+
+}
diff --git a/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonComponentBuilder.java b/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonComponentBuilder.java
new file mode 100644
index 0000000000..d460f77bc6
--- /dev/null
+++ b/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonComponentBuilder.java
@@ -0,0 +1,74 @@
+/*
+ * 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.python;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+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.component.ScopeContainer;
+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.Scope;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+/**
+ * Extension point for creating {@link PythonComponent}s from an assembly configuration
+ */
+public class PythonComponentBuilder extends ComponentBuilderExtension<PythonImplementation> {
+
+ public PythonComponentBuilder() {
+ }
+
+ protected Class<PythonImplementation> getImplementationType() {
+ return PythonImplementation.class;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Component build(CompositeComponent parent, ComponentDefinition<PythonImplementation> componentDefinition,
+ DeploymentContext deploymentContext) throws BuilderConfigException {
+
+ String name = componentDefinition.getName();
+ PythonImplementation implementation = componentDefinition.getImplementation();
+ PythonComponentType componentType = implementation.getComponentType();
+
+ // 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());
+ }
+
+ // TODO: have ComponentBuilderExtension pass ScopeContainer in on build method?
+ ScopeContainer scopeContainer;
+ Scope scope = componentType.getLifecycleScope();
+ if (Scope.MODULE == scope) {
+ scopeContainer = deploymentContext.getModuleScope();
+ } else {
+ scopeContainer = scopeRegistry.getScopeContainer(scope);
+ }
+
+ return new PythonComponent(name, implementation.getJythonScript(), services, parent, scopeContainer, wireService, workContext);
+ }
+
+}
diff --git a/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonComponentType.java b/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonComponentType.java
new file mode 100644
index 0000000000..640ff297c5
--- /dev/null
+++ b/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonComponentType.java
@@ -0,0 +1,61 @@
+/*
+ * 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.python;
+
+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;
+
+/**
+ * A componentType for Python components
+ * TODO: really need a generic componentType that supports scope and lifecycle
+ */
+public class PythonComponentType extends ComponentType<ServiceDefinition, ReferenceDefinition, Property<?>> {
+
+ private Scope lifecycleScope = Scope.MODULE;
+
+ public PythonComponentType() {
+ }
+
+ @SuppressWarnings("unchecked")
+ public PythonComponentType(ComponentType ct) {
+ // TODO: A bit hacky but this is so the non-python .componentType XML side file can be used for now
+ setInitLevel(ct.getInitLevel());
+ for (Object property : ct.getProperties().values()) {
+ add((Property) property);
+ }
+ for (Object reference : ct.getReferences().values()) {
+ add((ReferenceDefinition) reference);
+ }
+ for (Object service : ct.getServices().values()) {
+ add((ServiceDefinition) service);
+ }
+ }
+
+ public Scope getLifecycleScope() {
+ return lifecycleScope;
+ }
+
+ public void setLifecycleScope(Scope lifecycleScope) {
+ this.lifecycleScope = lifecycleScope;
+ }
+
+}
diff --git a/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonComponentTypeLoader.java b/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonComponentTypeLoader.java
new file mode 100644
index 0000000000..1f1456594e
--- /dev/null
+++ b/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonComponentTypeLoader.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.python;
+
+import java.net.URL;
+
+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.ComponentType;
+
+/**
+ * ComponentType loader for Python components
+ */
+public class PythonComponentTypeLoader extends ComponentTypeLoaderExtension<PythonImplementation> {
+
+ public PythonComponentTypeLoader() {
+ }
+
+ @Override
+ protected Class<PythonImplementation> getImplementationClass() {
+ return PythonImplementation.class;
+ }
+
+ protected String getResourceName(PythonImplementation implementation) {
+ return implementation.getJythonScript().getModuleName();
+ }
+
+ // TODO: must be possible to move all the following up in to ComponentTypeLoaderExtension
+
+ public void load(CompositeComponent parent, PythonImplementation implementation, DeploymentContext deploymentContext) throws LoaderException {
+ String sideFile = getSideFileName(implementation);
+ URL resource = implementation.getJythonScript().getClassLoader().getResource(sideFile);
+ PythonComponentType componentType;
+ if (resource == null) {
+ throw new IllegalArgumentException("missing .componentType side file: " + sideFile);
+ // TODO: or else implement intospection
+ } else {
+ componentType = loadFromSidefile(resource, deploymentContext);
+ }
+ implementation.setComponentType(componentType);
+ }
+
+ protected PythonComponentType loadFromSidefile(URL url, DeploymentContext deploymentContext) throws LoaderException {
+ ComponentType ct = loaderRegistry.load(null, url, ComponentType.class, deploymentContext);
+ PythonComponentType pythonComponentType = new PythonComponentType(ct);
+ return pythonComponentType;
+ }
+
+ protected String getSideFileName(PythonImplementation implementation) {
+ String baseName = getResourceName(implementation);
+ int lastDot = baseName.lastIndexOf('.');
+ if (lastDot != -1) {
+ baseName = baseName.substring(0, lastDot);
+ }
+ return baseName + ".componentType";
+ }
+
+}
diff --git a/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonImplementation.java b/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonImplementation.java
new file mode 100644
index 0000000000..df35801e88
--- /dev/null
+++ b/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonImplementation.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.python;
+
+import org.apache.tuscany.spi.model.AtomicImplementation;
+
+/**
+ * Model object for a Python implementation.
+ */
+public class PythonImplementation extends AtomicImplementation<PythonComponentType> {
+
+ private PythonScript pythonScript;
+
+ public PythonScript getJythonScript() {
+ return pythonScript;
+ }
+
+ public void setPythonScript(PythonScript pythonScript) {
+ this.pythonScript = pythonScript;
+ }
+}
diff --git a/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonImplementationLoader.java b/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonImplementationLoader.java
new file mode 100644
index 0000000000..61a6cbd4b6
--- /dev/null
+++ b/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonImplementationLoader.java
@@ -0,0 +1,123 @@
+/*
+ * 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.python;
+
+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;
+import org.osoa.sca.annotations.Constructor;
+
+/**
+ * Loader for handling python elements.
+ *
+ * <py:implementation.python module="path/foo.py" class="myclass">
+ *
+ */
+public class PythonImplementationLoader extends LoaderExtension<PythonImplementation> {
+
+ private static final QName IMPLEMENTATION_PYTHON = new QName("http://tuscany.apache.org/xmlns/python/1.0", "implementation.python");
+
+ @Constructor( { "registry" })
+ public PythonImplementationLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return IMPLEMENTATION_PYTHON;
+ }
+
+ public PythonImplementation load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException {
+
+ String moduleName = reader.getAttributeValue(null, "module");
+ if (moduleName == null) {
+ throw new MissingResourceException("implementation element has no module attribute");
+ }
+
+ String className = reader.getAttributeValue(null, "class");
+
+ LoaderUtil.skipToEndElement(reader);
+
+ PythonImplementation implementation = new PythonImplementation();
+
+ ClassLoader cl = deploymentContext.getClassLoader();
+ String pythonSource = loadSource(cl, moduleName);
+
+ PythonScript pythonScript = new PythonScript(moduleName, className, pythonSource, cl);
+ implementation.setPythonScript(pythonScript);
+
+ registry.loadComponentType(parent, implementation, deploymentContext);
+
+ Class iface = implementation.getComponentType().getServices().values().iterator().next().getServiceContract().getInterfaceClass();
+ // TODO: service interfaces should be on PythonScript constructor but loadComponentType requires the script name to work out the sidefile name
+ pythonScript.setServiceInterface(iface);
+
+ 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/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonInvoker.java b/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonInvoker.java
new file mode 100644
index 0000000000..62f7a6c847
--- /dev/null
+++ b/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonInvoker.java
@@ -0,0 +1,54 @@
+/*
+ * 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.python;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.extension.TargetInvokerExtension;
+
+/**
+ * Dispatches to a PythonScript implementation instance
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class PythonInvoker extends TargetInvokerExtension {
+
+ private PythonComponent context;
+
+ private Method method;
+
+ public PythonInvoker(Method method, PythonComponent context) {
+ this.method = method;
+ this.context = context;
+ }
+
+ /**
+ * Invokes a function on a script instance
+ */
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ Object target = context.getTargetInstance();
+ try {
+ return method.invoke(target, (Object[]) payload);
+ } catch (Exception e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+}
diff --git a/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonScript.java b/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonScript.java
new file mode 100644
index 0000000000..1eab532582
--- /dev/null
+++ b/sandbox/ant/container.python/src/main/java/org/apache/tuscany/container/python/PythonScript.java
@@ -0,0 +1,116 @@
+/*
+ * 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.python;
+
+import java.util.Map;
+
+import org.python.core.Py;
+import org.python.core.PyObject;
+import org.python.core.PySystemState;
+import org.python.util.PythonInterpreter;
+
+/**
+ * JythonScript represents a compiled Jython script
+ */
+public class PythonScript {
+
+ protected String moduleName;
+
+ protected String className;
+
+ protected String script;
+
+ protected Class iface;
+
+ protected ClassLoader classLoader;
+
+ private PyObject pythonClass;
+
+ /**
+ * Create a new RhinoInvoker.
+ *
+ * @param scriptName
+ * the name of the script. Can be anything, only used in messages to identify the script
+ * @param script
+ * the complete script
+ * @param context
+ * name-value pairs that are added in to the scope where the script is compiled. May be null. The value objects are made available to
+ * the script by using a variable with the name.
+ * @param classLoader
+ * the ClassLoader Rhino should use to locate any user Java classes used in the script
+ */
+ public PythonScript(String moduleName, String className, String script, ClassLoader classLoader) {
+ this.moduleName = moduleName;
+ this.className = className;
+ this.script = script;
+ this.classLoader = classLoader;
+
+ }
+
+ private void initScript(String moduleName, String className, String script) {
+ PythonInterpreter interpreter = new PythonInterpreter();
+ PySystemState sys = Py.getSystemState();
+ PySystemState.add_package(iface.getPackage().getName(), null);
+ sys.setClassLoader(classLoader);
+ interpreter.exec(script);
+
+ pythonClass = interpreter.get(className);
+ if (pythonClass == null) {
+ throw new RuntimeException("No callable (class or function) " + "named " + className + " in " + moduleName);
+ }
+ }
+
+ /**
+ * Create a new invokeable instance of the script
+ *
+ * @param context
+ * objects to add to scope of the script instance
+ * @return a RhinoScriptInstance
+ */
+ public Object createInstance(Map<String, Object> context) {
+ initScript(moduleName, className, script);
+
+ PyObject instance = pythonClass.__call__();
+ Object o = instance.__tojava__(iface);
+ if (o == Py.NoConversion) {
+ throw new RuntimeException("The value from " + className + " must extend " + iface.getName());
+ }
+ return o;
+ }
+
+ public String getModuleName() {
+ return moduleName;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public String getScript() {
+ return script;
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ public void setServiceInterface(Class iface) {
+ this.iface = iface;
+ }
+}
diff --git a/sandbox/ant/container.python/src/main/resources/META-INF/sca/py.system.scdl b/sandbox/ant/container.python/src/main/resources/META-INF/sca/py.system.scdl
new file mode 100644
index 0000000000..e124d8677d
--- /dev/null
+++ b/sandbox/ant/container.python/src/main/resources/META-INF/sca/py.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://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+
+ name="org.apache.tuscany.launcher.PythonImplementation">
+
+ <component name="python.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.container.python.PythonImplementationLoader"/>
+ </component>
+
+ <component name="python.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.container.python.PythonComponentTypeLoader"/>
+ </component>
+
+ <component name="python.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.python.PythonComponentBuilder"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/HelloWorldService.java b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/HelloWorldService.java
new file mode 100644
index 0000000000..50ba1c3695
--- /dev/null
+++ b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/HelloWorldService.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.python;
+
+public interface HelloWorldService {
+
+ String sayHello(String s);
+
+}
diff --git a/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonComponentBuilderTestCase.java b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonComponentBuilderTestCase.java
new file mode 100644
index 0000000000..86e77920dc
--- /dev/null
+++ b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonComponentBuilderTestCase.java
@@ -0,0 +1,23 @@
+package org.apache.tuscany.container.python;
+
+import junit.framework.TestCase;
+
+public class PythonComponentBuilderTestCase extends TestCase {
+
+ public void testGetImplementationType() {
+ PythonComponentBuilder builder = new PythonComponentBuilder();
+ assertEquals(PythonImplementation.class, builder.getImplementationType());
+ }
+
+ public void testBuild() {
+// PythonComponentBuilder builder = new PythonComponentBuilder();
+// CompositeComponent parent = createMock(CompositeComponent.class);
+// Component component = builder.build(parent, componentDefinition, deploymentContext);
+// assertNotNull(component);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+}
diff --git a/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonComponentTestCase.java b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonComponentTestCase.java
new file mode 100644
index 0000000000..3a1f6081ba
--- /dev/null
+++ b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonComponentTestCase.java
@@ -0,0 +1,94 @@
+package org.apache.tuscany.container.python;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.easymock.IAnswer;
+
+public class PythonComponentTestCase extends TestCase {
+
+ private ScopeContainer scopeContainer;
+
+ @SuppressWarnings("unchecked")
+ public void testCreateTargetInvoker() {
+ PythonComponent pc = new PythonComponent(null,null,null, null, scopeContainer, null, null);
+
+ Operation operation = new Operation("hashCode", null,null,null,false,null);
+ ServiceContract contract = new ServiceContract(List.class){};
+ operation.setServiceContract(contract);
+ TargetInvoker invoker = pc.createTargetInvoker("hashCode", operation);
+
+ assertNotNull(invoker);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testCreateInstance() throws IOException {
+ PythonComponent pc = new PythonComponent(null,createPythonScript(),null, null, scopeContainer, null, null);
+ Object o = pc.createInstance();
+ assertNotNull(o);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testGetServiceInstance() {
+ PythonComponent pc = new PythonComponent(null,null,null, null, scopeContainer, null, null);
+ try {
+ pc.getServiceInstance();
+ fail();
+ } catch (TargetException e) {
+ // expected
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testGetproperties() {
+ PythonComponent pc = new PythonComponent(null,null,null, null, scopeContainer, null, null);
+ assertNotNull(pc.getProperties());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testGetServiceInterfaces() {
+ List services = new ArrayList();
+ PythonComponent pc = new PythonComponent(null,null,services, null, scopeContainer, null,null);
+ assertEquals(services, pc.getServiceInterfaces());
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected void setUp() {
+ this.scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.MODULE;
+ }
+ });
+ }
+
+ public PythonScript createPythonScript() throws IOException {
+ URL scriptURL = getClass().getResource("PythonScriptTestCase.py");
+ InputStream is = scriptURL.openStream();
+ StringBuilder sb = new StringBuilder();
+ int i = 0;
+ while ((i = is.read()) != -1) {
+ sb.append((char) i);
+ }
+ is.close();
+ String script = sb.toString();
+ PythonScript pythonScript = new PythonScript("PythonScriptTestCase", "hello", script, null);
+ pythonScript.setServiceInterface(HelloWorldService.class);
+ return pythonScript;
+ }
+}
diff --git a/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonComponentTypeLoaderTestCase.java b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonComponentTypeLoaderTestCase.java
new file mode 100644
index 0000000000..73a6e9b849
--- /dev/null
+++ b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonComponentTypeLoaderTestCase.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.python;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.stream.XMLStreamException;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.loader.LoaderException;
+
+/**
+ *
+ */
+public class PythonComponentTypeLoaderTestCase extends TestCase {
+
+ private String script;
+
+ public void testGetSideFileName() {
+ PythonScript pythonScript = new PythonScript("PythonScriptTestCase", "hello", script, null);
+ PythonComponentTypeLoader loader = new PythonComponentTypeLoader();
+ PythonImplementation implementation = new PythonImplementation();
+ implementation.setPythonScript(pythonScript);
+ assertEquals("PythonScriptTestCase.componentType", loader.getSideFileName(implementation));
+ }
+
+ public void testLoadFromSideFile() throws MalformedURLException, LoaderException, XMLStreamException {
+// PythonComponentTypeLoader loader = new PythonComponentTypeLoader();
+// LoaderRegistry loaderRegistry = createMock(LoaderRegistry.class);
+// expect(loaderRegistry.load(isA(CompositeComponent.class),isA(URL.class),isA(Class.class),isA(DeploymentContext.class))).andStubAnswer(new IAnswer() {
+// public Object answer() throws Throwable {
+// return new ComponentType();
+// }
+// });
+// loader.setLoaderRegistry(loaderRegistry);
+//
+// URL url = new URL("http://foo");
+// DeploymentContext deploymentContext = createMock(DeploymentContext.class);
+// loader.loadFromSidefile(url, deploymentContext);
+ }
+
+ public void testGetImplementationClass() {
+ PythonComponentTypeLoader loader = new PythonComponentTypeLoader();
+ assertEquals(PythonImplementation.class, loader.getImplementationClass());
+ }
+
+ public void testGetResourceName() {
+ PythonComponentTypeLoader loader = new PythonComponentTypeLoader();
+ PythonImplementation implementation = new PythonImplementation();
+ PythonScript pythonScript = new PythonScript("PythonScriptTestCase", "hello", script, null);
+ implementation.setPythonScript(pythonScript);
+ assertEquals("PythonScriptTestCase", loader.getResourceName(implementation));
+ }
+
+ @Override
+ public void setUp() throws IOException {
+ URL scriptURL = getClass().getResource("PythonScriptTestCase.py");
+ InputStream is = scriptURL.openStream();
+ StringBuilder sb = new StringBuilder();
+ int i = 0;
+ while ((i = is.read()) != -1) {
+ sb.append((char) i);
+ }
+ is.close();
+ script = sb.toString();
+ }
+}
diff --git a/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonComponentTypeTestCase.java b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonComponentTypeTestCase.java
new file mode 100644
index 0000000000..3ae4b73e60
--- /dev/null
+++ b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonComponentTypeTestCase.java
@@ -0,0 +1,36 @@
+package org.apache.tuscany.container.python;
+
+import junit.framework.TestCase;
+
+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;
+
+public class PythonComponentTypeTestCase extends TestCase {
+
+ public void testLifecycleScope() {
+ PythonComponentType ct = new PythonComponentType();
+ assertEquals(Scope.MODULE, ct.getLifecycleScope());
+ ct.setLifecycleScope(Scope.COMPOSITE);
+ assertEquals(Scope.COMPOSITE, ct.getLifecycleScope());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testComponentTypeConstructor() {
+ ComponentType ct = new ComponentType();
+ Property property = new Property();
+ ct.add(property);
+ ReferenceDefinition reference = new ReferenceDefinition();
+ ct.add(reference);
+ ServiceDefinition service = new ServiceDefinition();
+ ct.add(service);
+
+ PythonComponentType pct = new PythonComponentType(ct);
+
+ assertEquals(property, pct.getProperties().values().iterator().next());
+ assertEquals(reference, pct.getReferences().values().iterator().next());
+ assertEquals(service, pct.getServices().values().iterator().next());
+ }
+}
diff --git a/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonImplementationLoaderTestCase.java b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonImplementationLoaderTestCase.java
new file mode 100644
index 0000000000..f84d217334
--- /dev/null
+++ b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonImplementationLoaderTestCase.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.python;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+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;
+
+/**
+ *
+ */
+public class PythonImplementationLoaderTestCase extends TestCase {
+ private CompositeComponent parent;
+
+ private XMLStreamReader reader;
+
+ private DeploymentContext deploymentContext;
+
+ private ClassLoader classLoader;
+
+ private LoaderRegistry registry;
+
+ private PythonImplementationLoader loader;
+
+ public void testNoModuleAttribute() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "module")).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, "module")).andReturn("foo.py");
+ expect(reader.getAttributeValue(null, "class")).andReturn(null);
+ expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
+ expect(deploymentContext.getClassLoader()).andReturn(classLoader);
+
+ replay(reader);
+ replay(deploymentContext);
+
+ PythonImplementationLoader mockLoader = new PythonImplementationLoader(registry) {
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ assertSame(classLoader, cl);
+ assertEquals("foo.py", resource);
+ throw new MissingResourceException(resource);
+ }
+ };
+ try {
+ mockLoader.load(parent, reader, deploymentContext);
+ fail();
+ } catch (MissingResourceException e) {
+ assertEquals("foo.py", e.getMessage());
+ }
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testLoadScript() throws LoaderException {
+ String script = loader.loadSource(getClass().getClassLoader(), "org/apache/tuscany/container/python/PythonScriptTestCase.py");
+ assertTrue(script.startsWith("from org.apache.tuscany.container.python"));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = createMock(LoaderRegistry.class);
+ loader = new PythonImplementationLoader(registry);
+
+ parent = createMock(CompositeComponent.class);
+ reader = createMock(XMLStreamReader.class);
+ deploymentContext = createMock(DeploymentContext.class);
+ classLoader = createMock(ClassLoader.class);
+ }
+}
diff --git a/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonImplementationTestCase.java b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonImplementationTestCase.java
new file mode 100644
index 0000000000..a2af619795
--- /dev/null
+++ b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonImplementationTestCase.java
@@ -0,0 +1,33 @@
+package org.apache.tuscany.container.python;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+public class PythonImplementationTestCase extends TestCase {
+
+ private PythonScript pythonScript;
+
+ public void testGetPythonScript() {
+ PythonImplementation impl = new PythonImplementation();
+ impl.setPythonScript(pythonScript);
+ assertEquals(pythonScript, impl.getJythonScript());
+ }
+
+ public void setUp() throws IOException {
+ URL scriptURL = getClass().getResource("PythonScriptTestCase.py");
+ assert scriptURL != null;
+ InputStream is = scriptURL.openStream();
+ StringBuilder sb = new StringBuilder();
+ int i = 0;
+ while ((i = is.read()) != -1) {
+ sb.append((char) i);
+ }
+ is.close();
+ String script = sb.toString();
+ pythonScript = new PythonScript("PythonScriptTestCase", "hello", script, null);
+ }
+
+}
diff --git a/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonInvokerTestCase.java b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonInvokerTestCase.java
new file mode 100644
index 0000000000..03a9151a47
--- /dev/null
+++ b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonInvokerTestCase.java
@@ -0,0 +1,62 @@
+package org.apache.tuscany.container.python;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.model.Scope;
+import org.easymock.IAnswer;
+
+public class PythonInvokerTestCase extends TestCase {
+
+ private PythonComponent context;
+
+ private Method method;
+
+ private ScopeContainer scopeContainer;
+
+ public void testInvokeTarget() throws InvocationTargetException {
+ PythonInvoker invoker = new PythonInvoker(method, context);
+ Object o = invoker.invokeTarget(new Object[] { "petra" });
+ assertEquals("hello petra", o);
+ }
+
+ public void testInvokeTargetException() throws InvocationTargetException, SecurityException, NoSuchMethodException {
+ PythonInvoker invoker = new PythonInvoker(method, context);
+ try {
+ invoker.invokeTarget(null);
+ fail();
+ } catch (InvocationTargetException e) {
+ // expected
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getInstance(isA(AtomicComponent.class))).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return "hello ";
+ }
+ });
+ expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.MODULE;
+ }
+ });
+ replay(scopeContainer);
+
+ context = new PythonComponent(null, null, null, null, scopeContainer, null, null);
+ method = String.class.getDeclaredMethod("concat", new Class[] { String.class });
+ }
+}
diff --git a/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonScriptTestCase.java b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonScriptTestCase.java
new file mode 100644
index 0000000000..560b623e9a
--- /dev/null
+++ b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonScriptTestCase.java
@@ -0,0 +1,82 @@
+/*
+ * 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.python;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+public class PythonScriptTestCase extends TestCase {
+
+ protected String script;
+
+ public void testCreateInstance() {
+ PythonScript pythonScript = new PythonScript("PythonScriptTestCase", "hello", script, null);
+ pythonScript.setServiceInterface(HelloWorldService.class);
+ HelloWorldService helloworld = (HelloWorldService) pythonScript.createInstance(null);
+
+ assertEquals("Hello petra", helloworld.sayHello("petra"));
+ }
+
+ public void testCreateInstanceBadIface() {
+ PythonScript pythonScript = new PythonScript("PythonScriptTestCase", "hello", script, null);
+ pythonScript.setServiceInterface(String.class);
+ try {
+ pythonScript.createInstance(null);
+ fail();
+ } catch (RuntimeException e) {
+ // expected
+ }
+ }
+
+ public void testCreateInstanceBadClassName() {
+ PythonScript pythonScript = new PythonScript("PythonScriptTestCase", "badClass", script, null);
+ pythonScript.setServiceInterface(String.class);
+ try {
+ pythonScript.createInstance(null);
+ assertTrue("expecting bad class exception", false);
+ } catch (RuntimeException e) {
+ // expected
+ }
+ }
+
+ public void testGetters() {
+ PythonScript pythonScript = new PythonScript("PythonScriptTestCase", "hello", script, null);
+ assertEquals(null, pythonScript.getClassLoader());
+ assertEquals("hello", pythonScript.getClassName());
+ assertEquals(script, pythonScript.getScript());
+ }
+
+ @Override
+ public void setUp() throws IOException {
+ URL scriptURL = getClass().getResource("PythonScriptTestCase.py");
+ InputStream is = scriptURL.openStream();
+ StringBuilder sb = new StringBuilder();
+ int i = 0;
+ while ((i = is.read()) != -1) {
+ sb.append((char) i);
+ }
+ is.close();
+ script = sb.toString();
+
+ }
+
+}
diff --git a/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/function/HelloWorldTestCase.java b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/function/HelloWorldTestCase.java
new file mode 100644
index 0000000000..38f15adafd
--- /dev/null
+++ b/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/function/HelloWorldTestCase.java
@@ -0,0 +1,46 @@
+/*
+ * 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.python.function;
+
+
+import org.apache.tuscany.container.python.HelloWorldService;
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * This shows how to test the HelloWorld service component.
+ */
+public class HelloWorldTestCase extends SCATestCase {
+
+ private HelloWorldService helloWorldService;
+
+ protected void setUp() throws Exception {
+ addExtension("PythonContainer", getClass().getClassLoader().getResource("META-INF/sca/py.system.scdl"));
+ setApplicationSCDL("org/apache/tuscany/container/python/function/helloworld.scdl");
+ super.setUp();
+
+ CompositeContext context = CurrentCompositeContext.getContext();
+ helloWorldService = context.locateService(HelloWorldService.class, "HelloWorldComponent");
+ }
+
+ public void testHelloWorld() throws Exception {
+ assertEquals(helloWorldService.sayHello("petra"), "Hello petra");
+ }
+}
diff --git a/sandbox/ant/container.python/src/test/resources/org/apache/tuscany/container/python/PythonScriptTestCase.py b/sandbox/ant/container.python/src/test/resources/org/apache/tuscany/container/python/PythonScriptTestCase.py
new file mode 100644
index 0000000000..5ce69aca61
--- /dev/null
+++ b/sandbox/ant/container.python/src/test/resources/org/apache/tuscany/container/python/PythonScriptTestCase.py
@@ -0,0 +1,6 @@
+from org.apache.tuscany.container.python import HelloWorldService
+
+class hello(HelloWorldService):
+
+ def sayHello(self, val1):
+ return "Hello " + val1
diff --git a/sandbox/ant/container.python/src/test/resources/org/apache/tuscany/container/python/function/HelloWorld.componentType b/sandbox/ant/container.python/src/test/resources/org/apache/tuscany/container/python/function/HelloWorld.componentType
new file mode 100644
index 0000000000..432c9badc0
--- /dev/null
+++ b/sandbox/ant/container.python/src/test/resources/org/apache/tuscany/container/python/function/HelloWorld.componentType
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="org.apache.tuscany.container.python.HelloWorldService"/>
+ </service>
+
+</componentType>
diff --git a/sandbox/ant/container.python/src/test/resources/org/apache/tuscany/container/python/function/helloworld.py b/sandbox/ant/container.python/src/test/resources/org/apache/tuscany/container/python/function/helloworld.py
new file mode 100644
index 0000000000..5ce69aca61
--- /dev/null
+++ b/sandbox/ant/container.python/src/test/resources/org/apache/tuscany/container/python/function/helloworld.py
@@ -0,0 +1,6 @@
+from org.apache.tuscany.container.python import HelloWorldService
+
+class hello(HelloWorldService):
+
+ def sayHello(self, val1):
+ return "Hello " + val1
diff --git a/sandbox/ant/container.python/src/test/resources/org/apache/tuscany/container/python/function/helloworld.scdl b/sandbox/ant/container.python/src/test/resources/org/apache/tuscany/container/python/function/helloworld.scdl
new file mode 100644
index 0000000000..97461b3ae3
--- /dev/null
+++ b/sandbox/ant/container.python/src/test/resources/org/apache/tuscany/container/python/function/helloworld.scdl
@@ -0,0 +1,29 @@
+<?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:py="http://tuscany.apache.org/xmlns/python/1.0"
+
+ name="HelloWorldComposite">
+
+ <component name="HelloWorldComponent">
+ <py:implementation.python module="org/apache/tuscany/container/python/function/HelloWorld.py" class="hello" />
+ </component>
+
+</composite>
diff --git a/sandbox/ant/container.rhino/NOTICE.txt b/sandbox/ant/container.rhino/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sandbox/ant/container.rhino/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/sandbox/ant/container.rhino/pom.xml b/sandbox/ant/container.rhino/pom.xml
new file mode 100644
index 0000000000..8c5543efc5
--- /dev/null
+++ b/sandbox/ant/container.rhino/pom.xml
@@ -0,0 +1,68 @@
+<?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>tuscany-rhino</artifactId>
+ <name>Apache Tuscany Rhino JavaScript Container</name>
+ <description>Apache Tuscany Rhino JavaScript Container</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>easy-container</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ <version>1.6R2</version>
+ <scope>compile</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/sandbox/ant/container.rhino/src/main/java/org/apache/tuscany/container/rhino/JavaScriptImplementationLoader.java b/sandbox/ant/container.rhino/src/main/java/org/apache/tuscany/container/rhino/JavaScriptImplementationLoader.java
new file mode 100644
index 0000000000..74ecda04ab
--- /dev/null
+++ b/sandbox/ant/container.rhino/src/main/java/org/apache/tuscany/container/rhino/JavaScriptImplementationLoader.java
@@ -0,0 +1,81 @@
+/*
+ * 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.rhino;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.container.easy.EasyImplementation;
+import org.apache.tuscany.container.easy.EasyImplementationLoader;
+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.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.osoa.sca.annotations.Constructor;
+
+/**
+ * Loader for handling implementation.script elements.
+ *
+ * <implementation.script script="path/foo.py" class="myclass">
+ *
+ */
+public class JavaScriptImplementationLoader extends EasyImplementationLoader {
+
+ private static final QName IMPLEMENTATION_SCRIPT = new QName(XML_NAMESPACE_1_0, "implementation.js");
+
+ @Constructor( { "registry" })
+ public JavaScriptImplementationLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return IMPLEMENTATION_SCRIPT;
+ }
+
+ @Override
+ public EasyImplementation load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
+ String scriptName = reader.getAttributeValue(null, "script");
+ if (scriptName == null) {
+ throw new MissingResourceException("implementation element has no 'script' attribute");
+ }
+
+ String className = reader.getAttributeValue(null, "class");
+
+ LoaderUtil.skipToEndElement(reader);
+
+ ClassLoader cl = deploymentContext.getClassLoader();
+ String scriptSource = loadSource(cl, scriptName);
+
+ RhinoScriptInstanceFactory instanceFactory = new RhinoScriptInstanceFactory(scriptName, className, scriptSource, cl);
+
+ EasyImplementation implementation = new EasyImplementation();
+ implementation.setResourceName(scriptName);
+ implementation.setScriptInstanceFactory(instanceFactory);
+
+ registry.loadComponentType(parent, implementation, deploymentContext);
+
+ return implementation;
+ }
+}
diff --git a/sandbox/ant/container.rhino/src/main/java/org/apache/tuscany/container/rhino/RhinoFunctionInvoker.java b/sandbox/ant/container.rhino/src/main/java/org/apache/tuscany/container/rhino/RhinoFunctionInvoker.java
new file mode 100644
index 0000000000..3b0e132d94
--- /dev/null
+++ b/sandbox/ant/container.rhino/src/main/java/org/apache/tuscany/container/rhino/RhinoFunctionInvoker.java
@@ -0,0 +1,88 @@
+/*
+ * 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.rhino;
+
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Function;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.Wrapper;
+
+/**
+ * An invoker for a specific function in a JavaScript script
+ */
+public class RhinoFunctionInvoker {
+
+ private Scriptable instanceScope;
+
+ private Function function;
+
+ private Class responseClass;
+
+ public RhinoFunctionInvoker(Scriptable instanceScope, Function function, Class responseClass) {
+ this.instanceScope = instanceScope;
+ this.function = function;
+ this.responseClass = responseClass;
+ }
+
+ public Object invoke(Object[] args) {
+ Context cx = Context.enter();
+ try {
+
+ Object[] jsArgs = toJavaScript(args, instanceScope, cx);
+ Object jsResponse = function.call(cx, instanceScope, instanceScope, jsArgs);
+ Object response = fromJavaScript(jsResponse);
+ return response;
+
+ }
+ finally {
+ Context.exit();
+ }
+ }
+
+ protected Object[] toJavaScript(Object[] arg, Scriptable scope, Context cx) throws RuntimeException {
+ Object[] jsArgs;
+ if (arg == null) {
+ jsArgs = new Object[0];
+ } else {
+ jsArgs = new Object[arg.length];
+ for (int i = 0; i < jsArgs.length; i++) {
+ jsArgs[i] = Context.toObject(arg[i], scope);
+ }
+ }
+
+ return jsArgs;
+ }
+
+ protected Object fromJavaScript(Object o) {
+ Object response;
+ if (Context.getUndefinedValue().equals(o)) {
+ response = null;
+ } else if (o instanceof Wrapper) {
+ response = ((Wrapper) o).unwrap();
+ } else {
+ if (responseClass != null) {
+ response = Context.jsToJava(o, responseClass);
+ } else {
+ response = Context.jsToJava(o, String.class);
+ }
+ }
+ return response;
+ }
+
+}
diff --git a/sandbox/ant/container.rhino/src/main/java/org/apache/tuscany/container/rhino/RhinoScriptInstance.java b/sandbox/ant/container.rhino/src/main/java/org/apache/tuscany/container/rhino/RhinoScriptInstance.java
new file mode 100644
index 0000000000..66e76855d6
--- /dev/null
+++ b/sandbox/ant/container.rhino/src/main/java/org/apache/tuscany/container/rhino/RhinoScriptInstance.java
@@ -0,0 +1,103 @@
+/*
+ * 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.rhino;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.tuscany.container.easy.EasyInstance;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Function;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.UniqueTag;
+
+/**
+ * An invokeable instance of a JavaScript script.
+ */
+public class RhinoScriptInstance implements EasyInstance {
+
+ private Scriptable scriptScope;
+
+ private Scriptable instanceScope;
+
+ private Map<String, Class> responseClasses;
+
+ public RhinoScriptInstance(Scriptable scriptScope, Scriptable instanceScope, Map<String, Object> context, Map<String, Class> responseClasses) {
+ this.scriptScope = scriptScope;
+ this.instanceScope = instanceScope;
+ this.responseClasses = responseClasses;
+ if (this.responseClasses == null) {
+ this.responseClasses = new HashMap<String, Class>();
+ }
+ addContexts(instanceScope, context);
+ }
+
+ public Object invokeTarget(String operationName, Object[] args) throws InvocationTargetException {
+ RhinoFunctionInvoker invoker = createRhinoFunctionInvoker(operationName);
+ return invoker.invoke(args);
+ }
+
+
+ public RhinoFunctionInvoker createRhinoFunctionInvoker(String functionName) {
+ Function function = getFunction(functionName);
+ Class responseClass = responseClasses.get(functionName);
+ RhinoFunctionInvoker invoker = new RhinoFunctionInvoker(instanceScope, function, responseClass);
+ return invoker;
+ }
+
+ /**
+ * Add the context to the scope. This will make the objects available to a script by using the name it was added with.
+ */
+ protected void addContexts(Scriptable scope, Map contexts) {
+ if (contexts != null) {
+ Context.enter();
+ try {
+ for (Iterator i = contexts.keySet().iterator(); i.hasNext();) {
+ String name = (String) i.next();
+ Object value = contexts.get(name);
+ if (value != null) {
+ scope.put(name, scope, Context.toObject(value, scope));
+ }
+ }
+ } finally {
+ Context.exit();
+ }
+ }
+ }
+
+ /**
+ * Get the Rhino Function object for the named script function
+ */
+ protected Function getFunction(String functionName) {
+
+ Object handleObj = scriptScope.get(functionName, instanceScope);
+ if (UniqueTag.NOT_FOUND.equals(handleObj)) {
+ // Bit of a hack so E4X scripts don't need to define a function for every operation
+ handleObj = scriptScope.get("process", instanceScope);
+ }
+ if (!(handleObj instanceof Function)) {
+ throw new RuntimeException("script function '" + functionName + "' is undefined or not a function");
+ }
+
+ return (Function) handleObj;
+ }
+
+}
diff --git a/sandbox/ant/container.rhino/src/main/java/org/apache/tuscany/container/rhino/RhinoScriptInstanceFactory.java b/sandbox/ant/container.rhino/src/main/java/org/apache/tuscany/container/rhino/RhinoScriptInstanceFactory.java
new file mode 100644
index 0000000000..ea55669696
--- /dev/null
+++ b/sandbox/ant/container.rhino/src/main/java/org/apache/tuscany/container/rhino/RhinoScriptInstanceFactory.java
@@ -0,0 +1,145 @@
+/*
+ * 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.rhino;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.container.easy.EasyInstanceFactory;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.ContextFactory;
+import org.mozilla.javascript.ImporterTopLevel;
+import org.mozilla.javascript.Script;
+import org.mozilla.javascript.Scriptable;
+
+/**
+ * A RhinoScript represents a compiled JavaScript script
+ */
+public class RhinoScriptInstanceFactory extends EasyInstanceFactory<RhinoScriptInstance> {
+
+ protected String scriptSource;
+
+ protected Scriptable scriptScope;
+
+ protected Map<String, Class> responseClasses;
+
+ private String className;
+
+ /*
+ * Enable dynamic scopes so a script can be used concurrently with a global shared scope and individual execution scopes. See
+ * http://www.mozilla.org/rhino/scopes.html
+ */
+ private static class MyFactory extends ContextFactory {
+ protected boolean hasFeature(Context cx, int featureIndex) {
+ if (featureIndex == Context.FEATURE_DYNAMIC_SCOPE) {
+ return true;
+ }
+ return super.hasFeature(cx, featureIndex);
+ }
+ }
+
+ static {
+ ContextFactory.initGlobal(new MyFactory());
+ }
+
+ public RhinoScriptInstanceFactory(String resourceName, String className, String scriptSource, ClassLoader classLoader) {
+ super(resourceName, classLoader);
+ this.className = className;
+ this.scriptSource = scriptSource;
+ this.responseClasses = new HashMap<String, Class>();
+ initScriptScope(resourceName, scriptSource, null, classLoader);
+ }
+
+ @Override
+ public RhinoScriptInstance createInstance(List<Class> services, Map<String, Object> context) {
+ // TODO services should really be on the constructor of this class, not on this method
+ // and the responseClasses done in the constructor/init
+ Scriptable instanceScope = createInstanceScope(context);
+ RhinoScriptInstance rsi = new RhinoScriptInstance(scriptScope, instanceScope, context, getResponseClasses(services));
+ return rsi;
+ }
+
+ /**
+ * Initialize the Rhino Scope for this script instance
+ */
+ public Scriptable createInstanceScope(Map<String, Object> context) {
+ Context cx = Context.enter();
+ try {
+
+ Scriptable instanceScope = cx.newObject(scriptScope);
+ instanceScope.setPrototype(scriptScope);
+ instanceScope.setParentScope(null);
+
+ addContexts(instanceScope, context);
+
+ return instanceScope;
+
+ } finally {
+ Context.exit();
+ }
+ }
+
+ /**
+ * Create a Rhino scope and compile the script into it
+ */
+ public void initScriptScope(String fileName, String scriptCode, Map context, ClassLoader cl) {
+ Context cx = Context.enter();
+ try {
+ if (cl != null) {
+ // TODO: broken with the way the tuscany launcher now uses class loaders
+ // cx.setApplicationClassLoader(cl);
+ }
+ this.scriptScope = new ImporterTopLevel(cx, true);
+ Script compiledScript = cx.compileString(scriptCode, fileName, 1, null);
+ compiledScript.exec(cx, scriptScope);
+ addContexts(scriptScope, context);
+
+ } finally {
+ Context.exit();
+ }
+ }
+
+ /**
+ * Add the context to the scope. This will make the objects available to a script by using the name it was added with.
+ */
+ protected void addContexts(Scriptable scope, Map contexts) {
+ if (contexts != null) {
+ for (Iterator i = contexts.keySet().iterator(); i.hasNext();) {
+ String name = (String) i.next();
+ Object value = contexts.get(name);
+ if (value != null) {
+ scope.put(name, scope, Context.toObject(value, scope));
+ }
+ }
+ }
+ }
+
+ /**
+ * Set the Java type of a response value. JavaScript is dynamically typed so Rhino cannot always work out what the intended Java type of a
+ * response should be, for example should the statement "return 42" be a Java int, or Integer or Double etc. When Rhino can't determine the type
+ * it will default to returning a String, using this method enables overriding the Rhino default to use a specific Java type.
+ */
+ public void setResponseClass(String functionName, Class responseClasses) {
+ this.responseClasses.put(functionName, responseClasses);
+ }
+
+}
diff --git a/sandbox/ant/container.rhino/src/main/resources/META-INF/sca/default.scdl b/sandbox/ant/container.rhino/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..61311036a8
--- /dev/null
+++ b/sandbox/ant/container.rhino/src/main/resources/META-INF/sca/default.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://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+
+ name="org.apache.tuscany.container.rhino.RhinoImplementation">
+
+ <component name="rhino.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.container.rhino.JavaScriptImplementationLoader"/>
+ </component>
+
+ <component name="rhino.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.container.easy.EasyComponentTypeLoader"/>
+ </component>
+
+ <component name="rhino.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.easy.EasyComponentBuilder"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/container.rhino/src/main/resources/META-INF/sca/script.system.scdl b/sandbox/ant/container.rhino/src/main/resources/META-INF/sca/script.system.scdl
new file mode 100644
index 0000000000..766374863c
--- /dev/null
+++ b/sandbox/ant/container.rhino/src/main/resources/META-INF/sca/script.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://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+
+ name="org.apache.tuscany.container.script.ScriptImplementation">
+
+ <component name="rhino.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.container.rhino.JavaScriptImplementationLoader"/>
+ </component>
+
+ <component name="rhino.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.container.easy.EasyComponentTypeLoader"/>
+ </component>
+
+ <component name="rhino.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.easy.EasyComponentBuilder"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/RhinoFunctionInvokerTestCase.java b/sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/RhinoFunctionInvokerTestCase.java
new file mode 100644
index 0000000000..132c602028
--- /dev/null
+++ b/sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/RhinoFunctionInvokerTestCase.java
@@ -0,0 +1,160 @@
+/*
+ * 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.rhino;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.rhino.mock.Foo;
+
+/**
+ * Tests for the RhinoFunctionInvoker
+ */
+public class RhinoFunctionInvokerTestCase extends TestCase {
+
+ public RhinoFunctionInvokerTestCase() {
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testNoArgsInvoke() {
+ RhinoScriptInstanceFactory instanceFactory = new RhinoScriptInstanceFactory("foo", null, "function getPetra() {return 'petra';}", getClass().getClassLoader());
+ RhinoScriptInstance instance = instanceFactory.createInstance(null, null);
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getPetra");
+ assertNotNull(invoker);
+ assertEquals("petra", invoker.invoke(null));
+ }
+
+ public void testOneArgInvoke() {
+ RhinoScriptInstanceFactory instanceFactory = new RhinoScriptInstanceFactory("foo", null, "function getS(s) {return s;}", getClass().getClassLoader());
+ RhinoScriptInstance instance = instanceFactory.createInstance(null, null);
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getS");
+ assertNotNull(invoker);
+ assertEquals("petra", invoker.invoke(new Object[] { "petra" }));
+ }
+
+ public void testMultiArgsInvoke() {
+ RhinoScriptInstanceFactory instanceFactory = new RhinoScriptInstanceFactory("foo", null, "function concat(x, y) {return x + y}", getClass().getClassLoader());
+ RhinoScriptInstance instance = instanceFactory.createInstance(null, new HashMap<String, Object>());
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("concat");
+ assertNotNull(invoker);
+ assertEquals("petrasue", invoker.invoke(new Object[] { "petra", "sue" }));
+ }
+
+ public void testNoResponseInvoke() {
+ RhinoScriptInstanceFactory instanceFactory = new RhinoScriptInstanceFactory("foo", null, "function getNull() {}", getClass().getClassLoader());
+ RhinoScriptInstance instance = instanceFactory.createInstance(null, new HashMap<String, Object>());
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getNull");
+ assertNotNull(invoker);
+ assertEquals(null, invoker.invoke(new Object[0]));
+ }
+
+ public void testNullResponseInvoke() {
+ RhinoScriptInstanceFactory instanceFactory = new RhinoScriptInstanceFactory("foo", null, "function getNull() {return null;}", getClass().getClassLoader());
+ RhinoScriptInstance instance = instanceFactory.createInstance(null, new HashMap<String, Object>());
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getNull");
+ assertNotNull(invoker);
+ assertEquals(null, invoker.invoke(new Object[0]));
+ }
+
+ public void testResponseTypeDefaultString() {
+ RhinoScriptInstanceFactory instanceFactory = new RhinoScriptInstanceFactory("foo", null, "function getTrue() {return true;}", getClass().getClassLoader());
+ RhinoScriptInstance instance = instanceFactory.createInstance(null, new HashMap<String, Object>());
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getTrue");
+ assertNotNull(invoker);
+ Object o = invoker.invoke(new Object[0]);
+ assertTrue(o instanceof String);
+ assertEquals("true", o);
+ }
+
+ public void testResponseTypeBoolean() {
+ RhinoScriptInstanceFactory instanceFactory = new RhinoScriptInstanceFactory("foo", null, "function getTrue() {return true;}", getClass().getClassLoader());
+ instanceFactory.setResponseClass("getTrue", Boolean.class);
+ List<Class> services = new ArrayList<Class>();
+ services.add(TestTypes.class);
+ RhinoScriptInstance instance = instanceFactory.createInstance(services, new HashMap<String, Object>());
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getTrue");
+ assertNotNull(invoker);
+ assertTrue((Boolean) invoker.invoke(new Object[0]));
+ }
+
+ interface TestTypes {
+ Boolean getTrue();
+ String[] getAs();
+ Boolean[] getBs();
+ }
+
+ public void testResponseTypeStringArray() {
+ RhinoScriptInstanceFactory instanceFactory = new RhinoScriptInstanceFactory("foo", null, "function getAs() {var as = new Array(1);as[0]='petra';return as;}", getClass().getClassLoader());
+ instanceFactory.setResponseClass("getAs", new String[0].getClass());
+ List<Class> services = new ArrayList<Class>();
+ services.add(TestTypes.class);
+ RhinoScriptInstance instance = instanceFactory.createInstance(services, new HashMap<String, Object>());
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getAs");
+ assertNotNull(invoker);
+ Object o = invoker.invoke(new Object[0]);
+ assertNotNull(o);
+ assertTrue(o.getClass().isArray());
+ assertEquals("petra", ((Object[]) o)[0]);
+ }
+
+ public void testResponseTypeBooleanArray() {
+ RhinoScriptInstanceFactory instanceFactory = new RhinoScriptInstanceFactory("foo", null, "function getBs() {var bs = new Array(1);bs[0]=true;return bs;}", getClass().getClassLoader());
+ instanceFactory.setResponseClass("getBs", new Boolean[0].getClass());
+ List<Class> services = new ArrayList<Class>();
+ services.add(TestTypes.class);
+ RhinoScriptInstance instance = instanceFactory.createInstance(services, new HashMap<String, Object>());
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getBs");
+ assertNotNull(invoker);
+ Object o = invoker.invoke(new Object[0]);
+ assertNotNull(o);
+ assertTrue(o.getClass().isArray());
+ assertTrue(((Boolean[]) o)[0]);
+ }
+
+ public void testRequestCustomType() {
+ RhinoScriptInstanceFactory instanceFactory = new RhinoScriptInstanceFactory("foo", null, "function getFooS(foo) {return foo.getS();}", getClass().getClassLoader());
+ RhinoScriptInstance instance = instanceFactory.createInstance(null, new HashMap<String, Object>());
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getFooS");
+ assertNotNull(invoker);
+
+ Foo foo = new Foo();
+ foo.setS("petra");
+ Object o = invoker.invoke(new Object[] { foo });
+ assertEquals(foo.getS(), o);
+ }
+
+ public void testResponseCustomType() {
+ RhinoScriptInstanceFactory instanceFactory = new RhinoScriptInstanceFactory("foo", null,
+ "importClass(Packages.org.apache.tuscany.container.rhino.mock.Foo);function getFoo(s) {var foo = new Foo(); foo.setS(s);return foo;}", getClass().getClassLoader());
+ RhinoScriptInstance instance = instanceFactory.createInstance(null, new HashMap<String, Object>());
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getFoo");
+ assertNotNull(invoker);
+
+ Object o = invoker.invoke(new Object[] { "petra" });
+ assertNotNull(o);
+ assertEquals("petra", ((Foo) o).getS());
+ }
+
+}
diff --git a/sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/RhinoScriptInstanceTestCase.java b/sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/RhinoScriptInstanceTestCase.java
new file mode 100644
index 0000000000..54e0d41b40
--- /dev/null
+++ b/sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/RhinoScriptInstanceTestCase.java
@@ -0,0 +1,52 @@
+/*
+ * 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.rhino;
+
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for the RhinoScriptInstance
+ */
+public class RhinoScriptInstanceTestCase extends TestCase {
+
+ public RhinoScriptInstanceTestCase() {
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+// public void testInvokeFunction() {
+// RhinoScriptInstanceFactory rhinoScript = new RhinoScriptInstanceFactory("foo", null, "function getPetra() {return 'petra';}", getClass().getClassLoader());
+// RhinoScriptInstance instance = rhinoScript.createInstance(new HashMap<String, Object>());
+// assertEquals("petra", instance.invokeFunction("getPetra", new Object[0]));
+// }
+
+ public void testCreateRhinoFunctionInvoker() {
+ RhinoScriptInstanceFactory rhinoScript = new RhinoScriptInstanceFactory("foo", null, "function getPetra() {return 'petra';}", getClass().getClassLoader());
+ RhinoScriptInstance instance = rhinoScript.createInstance(null, new HashMap<String, Object>());
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getPetra");
+ assertNotNull(invoker);
+ assertEquals("petra", invoker.invoke(new Object[0]));
+ }
+
+}
diff --git a/sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/RhinoScriptTestCase.java b/sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/RhinoScriptTestCase.java
new file mode 100644
index 0000000000..5c6b012832
--- /dev/null
+++ b/sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/RhinoScriptTestCase.java
@@ -0,0 +1,85 @@
+/*
+ * 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.rhino;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.container.rhino.RhinoFunctionInvokerTestCase.TestTypes;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for the RhinoScript
+ */
+public class RhinoScriptTestCase extends TestCase {
+
+ public RhinoScriptTestCase() {
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testSimpleConstructor() throws InvocationTargetException {
+ RhinoScriptInstanceFactory rhinoScript = new RhinoScriptInstanceFactory("foo", null,"function getPetra() {return 'petra';}", getClass().getClassLoader());
+ RhinoScriptInstance instance = rhinoScript.createInstance(null, new HashMap<String, Object>());
+ assertEquals("petra", instance.invokeTarget("getPetra", new Object[0]));
+ }
+
+ public void testCreateInstance() {
+ RhinoScriptInstanceFactory rhinoScript = new RhinoScriptInstanceFactory("foo", null,"function getPetra() {return 'petra';}", getClass().getClassLoader());
+ RhinoScriptInstance instance = rhinoScript.createInstance(null, new HashMap<String, Object>());
+ assertNotNull(instance);
+ }
+
+ public void testCreateInstanceWithContext() throws InvocationTargetException {
+ RhinoScriptInstanceFactory rhinoScript = new RhinoScriptInstanceFactory("foo", null,"function getName() {return name;}", getClass().getClassLoader());
+ Map<String, Object> contexts = new HashMap<String, Object>();
+ contexts.put("name", "petra");
+ RhinoScriptInstance instance = rhinoScript.createInstance(null, contexts);
+ assertEquals("petra", instance.invokeTarget("getName", new Object[0]));
+ }
+
+ public void testDefaultResponseType() throws InvocationTargetException {
+ RhinoScriptInstanceFactory rhinoScript = new RhinoScriptInstanceFactory("foo", null,"function getX() {return 42;}", getClass().getClassLoader());
+ RhinoScriptInstance instance = rhinoScript.createInstance(null, new HashMap<String, Object>());
+ assertEquals("42", instance.invokeTarget("getX", new Object[0]));
+ }
+
+ public void testSetResponseType() throws InvocationTargetException {
+ RhinoScriptInstanceFactory rhinoScript = new RhinoScriptInstanceFactory("foo", null,"function getX() {return 42;}", getClass().getClassLoader());
+ rhinoScript.setResponseClass("getX", Integer.class);
+ List<Class> services = new ArrayList<Class>();
+ services.add(TypeTest.class);
+ RhinoScriptInstance instance = rhinoScript.createInstance(services, new HashMap<String, Object>());
+ Object x = instance.invokeTarget("getX", new Object[0]);
+ assertTrue(x instanceof Integer);
+ assertEquals(new Integer(42), x);
+ }
+
+ interface TypeTest {
+ Integer getX();
+ }
+
+}
diff --git a/sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/ScriptImplementationLoaderTestCase.java b/sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/ScriptImplementationLoaderTestCase.java
new file mode 100644
index 0000000000..14ba71e86c
--- /dev/null
+++ b/sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/ScriptImplementationLoaderTestCase.java
@@ -0,0 +1,133 @@
+/*
+ * 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.rhino;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.rhino.JavaScriptImplementationLoader;
+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;
+
+/**
+ *
+ */
+public class ScriptImplementationLoaderTestCase extends TestCase {
+ private CompositeComponent parent;
+
+ private XMLStreamReader reader;
+
+ private DeploymentContext deploymentContext;
+
+ private ClassLoader classLoader;
+
+ private LoaderRegistry registry;
+
+ private JavaScriptImplementationLoader loader;
+
+ public void testLoadNoScriptAttribute() 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 testLoad() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn("foo.mock");
+ expect(reader.getAttributeValue(null, "class")).andReturn(null);
+ expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
+ expect(deploymentContext.getClassLoader()).andReturn(classLoader);
+
+ replay(reader);
+ replay(deploymentContext);
+
+ JavaScriptImplementationLoader mockLoader = new JavaScriptImplementationLoader(registry) {
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ assertSame(classLoader, cl);
+ assertEquals("foo.mock", resource);
+ return "var bar;";
+ }
+ };
+ mockLoader.load(parent, reader, deploymentContext);
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testLoadNoScriptPresent() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn("foo.py");
+ expect(reader.getAttributeValue(null, "class")).andReturn(null);
+ expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
+ expect(deploymentContext.getClassLoader()).andReturn(classLoader);
+
+ replay(reader);
+ replay(deploymentContext);
+
+ JavaScriptImplementationLoader mockLoader = new JavaScriptImplementationLoader(registry) {
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ assertSame(classLoader, cl);
+ assertEquals("foo.py", resource);
+ throw new MissingResourceException(resource);
+ }
+ };
+ try {
+ mockLoader.load(parent, reader, deploymentContext);
+ fail();
+ } catch (MissingResourceException e) {
+ assertEquals("foo.py", e.getMessage());
+ }
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testGetXMLType() throws LoaderException {
+ assertEquals(XML_NAMESPACE_1_0, loader.getXMLType().getNamespaceURI());
+ assertEquals("implementation.js", loader.getXMLType().getLocalPart());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = createMock(LoaderRegistry.class);
+ loader = new JavaScriptImplementationLoader(registry);
+
+ parent = createMock(CompositeComponent.class);
+ reader = createMock(XMLStreamReader.class);
+ deploymentContext = createMock(DeploymentContext.class);
+ classLoader = createMock(ClassLoader.class);
+ }
+}
diff --git a/sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/mock/Foo.java b/sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/mock/Foo.java
new file mode 100644
index 0000000000..ee5b0d6db1
--- /dev/null
+++ b/sandbox/ant/container.rhino/src/test/java/org/apache/tuscany/container/rhino/mock/Foo.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.rhino.mock;
+
+public class Foo {
+ private String s;
+
+ public Foo() {
+ }
+
+ public String getS() {
+ return s;
+ }
+
+ public void setS(String s) {
+ this.s = s;
+ }
+}
diff --git a/sandbox/ant/container.rhino/src/test/resources/org/apache/tuscany/container/script/foo.componentType b/sandbox/ant/container.rhino/src/test/resources/org/apache/tuscany/container/script/foo.componentType
new file mode 100644
index 0000000000..9c37e1cb3e
--- /dev/null
+++ b/sandbox/ant/container.rhino/src/test/resources/org/apache/tuscany/container/script/foo.componentType
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="not.used"/>
+ </service>
+
+</componentType>
diff --git a/sandbox/ant/container.rhino/src/test/resources/org/apache/tuscany/container/script/foo.mock b/sandbox/ant/container.rhino/src/test/resources/org/apache/tuscany/container/script/foo.mock
new file mode 100644
index 0000000000..b6fc4c620b
--- /dev/null
+++ b/sandbox/ant/container.rhino/src/test/resources/org/apache/tuscany/container/script/foo.mock
@@ -0,0 +1 @@
+hello \ No newline at end of file
diff --git a/sandbox/ant/container.ruby/LICENSE.txt b/sandbox/ant/container.ruby/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sandbox/ant/container.ruby/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/sandbox/ant/container.ruby/NOTICE.txt b/sandbox/ant/container.ruby/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sandbox/ant/container.ruby/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/sandbox/ant/container.ruby/pom.xml b/sandbox/ant/container.ruby/pom.xml
new file mode 100644
index 0000000000..813a43539b
--- /dev/null
+++ b/sandbox/ant/container.ruby/pom.xml
@@ -0,0 +1,76 @@
+<?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.containers</groupId>
+ <artifactId>containers</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-ruby</artifactId>
+ <name>Apache Tuscany Ruby Container</name>
+ <description>Apache Tuscany Ruby Container</description>
+
+ <repositories>
+ <repository>
+ <id>codehaus-snapshots-repository</id>
+ <name>Codehaus Snapshots Repository</name>
+ <url>http://snapshots.repository.codehaus.org</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.containers</groupId>
+ <artifactId>easy-container</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jruby</groupId>
+ <artifactId>jruby</artifactId>
+ <version>0.9.1-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany</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/sandbox/ant/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyImplementationLoader.java b/sandbox/ant/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyImplementationLoader.java
new file mode 100644
index 0000000000..2c50845839
--- /dev/null
+++ b/sandbox/ant/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyImplementationLoader.java
@@ -0,0 +1,81 @@
+/*
+ * 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.ruby;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.container.easy.EasyImplementation;
+import org.apache.tuscany.container.easy.EasyImplementationLoader;
+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.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.osoa.sca.annotations.Constructor;
+
+/**
+ * Loader for handling implementation.script elements.
+ *
+ * <implementation.script script="path/foo.py" class="myclass">
+ *
+ */
+public class RubyImplementationLoader extends EasyImplementationLoader {
+
+ private static final QName IMPLEMENTATION_RUBY = new QName(XML_NAMESPACE_1_0, "implementation.rb");
+
+ @Constructor( { "registry" })
+ public RubyImplementationLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return IMPLEMENTATION_RUBY;
+ }
+
+ @Override
+ public EasyImplementation load(CompositeComponent parent, XMLStreamReader reader, DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
+ String scriptName = reader.getAttributeValue(null, "script");
+ if (scriptName == null) {
+ throw new MissingResourceException("implementation element has no 'script' attribute");
+ }
+
+ String className = reader.getAttributeValue(null, "class");
+
+ LoaderUtil.skipToEndElement(reader);
+
+ ClassLoader cl = deploymentContext.getClassLoader();
+ String scriptSource = loadSource(cl, scriptName);
+
+ RubyInstanceFactory instanceFactory = new RubyInstanceFactory(scriptName, className, scriptSource, cl);
+
+ EasyImplementation implementation = new EasyImplementation();
+ implementation.setResourceName(scriptName);
+ implementation.setScriptInstanceFactory(instanceFactory);
+
+ registry.loadComponentType(parent, implementation, deploymentContext);
+
+ return implementation;
+ }
+}
diff --git a/sandbox/ant/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyInstance.java b/sandbox/ant/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyInstance.java
new file mode 100644
index 0000000000..83b98e72f1
--- /dev/null
+++ b/sandbox/ant/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyInstance.java
@@ -0,0 +1,63 @@
+/*
+ * 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.ruby;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.container.easy.EasyInstance;
+import org.jruby.javasupport.JavaEmbedUtils;
+import org.jruby.runtime.builtin.IRubyObject;
+
+/**
+ * An invokeable instance of a Ruby script.
+ */
+public class RubyInstance implements EasyInstance {
+
+ private IRubyObject rubyInstance;
+
+ private Map<String, Class> responseClasses;
+
+ public RubyInstance(IRubyObject rubyInstance, Map<String, Object> context, Map<String, Class> responseClasses) {
+ this.responseClasses = responseClasses;
+ this.rubyInstance = rubyInstance;
+ if (this.responseClasses == null) {
+ this.responseClasses = new HashMap<String, Class>();
+ }
+ }
+
+ public Object invokeTarget(String operationName, Object[] args) throws InvocationTargetException {
+ return JavaEmbedUtils.invokeMethod(rubyInstance.getRuntime(),
+ rubyInstance,
+ operationName,
+ args,
+ responseClasses.get(operationName));
+ }
+//
+//
+// public Object invokeTarget(String operationName, Object[] args, Class returnType) throws InvocationTargetException {
+// return JavaEmbedUtils.invokeMethod(rubyInstance.getRuntime(),
+// rubyInstance,
+// operationName,
+// args,
+// returnType);
+// }
+
+}
diff --git a/sandbox/ant/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyInstanceFactory.java b/sandbox/ant/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyInstanceFactory.java
new file mode 100644
index 0000000000..35f428f12d
--- /dev/null
+++ b/sandbox/ant/container.ruby/src/main/java/org/apache/tuscany/container/ruby/RubyInstanceFactory.java
@@ -0,0 +1,89 @@
+/*
+ * 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.ruby;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import org.apache.tuscany.container.easy.EasyInstanceFactory;
+import org.jruby.IRuby;
+import org.jruby.RubyString;
+import org.jruby.javasupport.JavaEmbedUtils;
+import org.jruby.javasupport.JavaUtil;
+
+/**
+ *
+ */
+public class RubyInstanceFactory extends EasyInstanceFactory<RubyInstance> {
+
+ protected String scriptSource;
+
+ protected final String NEW = ".new";
+
+// protected Map<String, Class> responseClasses;
+
+ private String className;
+
+ private IRuby rubyEngine = JavaEmbedUtils.initialize(new Vector());
+
+ public RubyInstanceFactory(String resourceName, String className, String scriptSource, ClassLoader classLoader) {
+ super(resourceName, classLoader);
+ this.className = className;
+ this.scriptSource = scriptSource;
+// this.responseClasses = new HashMap<String, Class>();
+ initScript(resourceName, scriptSource, null, classLoader);
+ }
+
+ @Override
+ public RubyInstance createInstance(List<Class> services, Map<String, Object> context) {
+ Map<String, Class> responseClasses = getResponseClasses(services);
+ if ( className == null ) {
+ return new RubyInstance(rubyEngine.evalScript(scriptSource), context, responseClasses);
+ }
+ else {
+ return new RubyInstance(rubyEngine.evalScript(className + NEW), context, responseClasses);
+ }
+ }
+
+
+ /**
+ *
+ */
+ public void initScript(String fileName, String scriptCode, Map context, ClassLoader cl) {
+ rubyEngine.loadScript((RubyString) JavaUtil.convertJavaToRuby(rubyEngine,
+ fileName,
+ String.class),
+ (RubyString) JavaUtil.convertJavaToRuby(rubyEngine,
+ scriptCode,
+ String.class),
+ false);
+ //TODO : add responseclasses here...
+ }
+
+
+// /**
+// * Set the Java type of a response value. Ruby is dynamically typed so JRuby cannot always work out what the intended Java type of a
+// * response should be, for example should the statement "return 42" be a Java int, or Integer or Double etc.
+// */
+// public void setResponseClass(String functionName, Class responseClasses) {
+// this.responseClasses.put(functionName, responseClasses);
+// }
+
+}
diff --git a/sandbox/ant/container.ruby/src/main/resources/META-INF/sca/default.scdl b/sandbox/ant/container.ruby/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..61311036a8
--- /dev/null
+++ b/sandbox/ant/container.ruby/src/main/resources/META-INF/sca/default.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://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+
+ name="org.apache.tuscany.container.rhino.RhinoImplementation">
+
+ <component name="rhino.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.container.rhino.JavaScriptImplementationLoader"/>
+ </component>
+
+ <component name="rhino.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.container.easy.EasyComponentTypeLoader"/>
+ </component>
+
+ <component name="rhino.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.easy.EasyComponentBuilder"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/container.ruby/src/main/resources/META-INF/sca/script.system.scdl b/sandbox/ant/container.ruby/src/main/resources/META-INF/sca/script.system.scdl
new file mode 100644
index 0000000000..766374863c
--- /dev/null
+++ b/sandbox/ant/container.ruby/src/main/resources/META-INF/sca/script.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://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+
+ name="org.apache.tuscany.container.script.ScriptImplementation">
+
+ <component name="rhino.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.container.rhino.JavaScriptImplementationLoader"/>
+ </component>
+
+ <component name="rhino.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.container.easy.EasyComponentTypeLoader"/>
+ </component>
+
+ <component name="rhino.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.easy.EasyComponentBuilder"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/container.ruby/src/test/java/org/apache/tuscany/container/ruby/RubyScriptTestCase.java b/sandbox/ant/container.ruby/src/test/java/org/apache/tuscany/container/ruby/RubyScriptTestCase.java
new file mode 100644
index 0000000000..9bcc17263e
--- /dev/null
+++ b/sandbox/ant/container.ruby/src/test/java/org/apache/tuscany/container/ruby/RubyScriptTestCase.java
@@ -0,0 +1,82 @@
+/*
+ * 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.ruby;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for the RhinoScript
+ */
+public class RubyScriptTestCase extends TestCase {
+
+ public RubyScriptTestCase() {
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testSimpleConstructor() throws InvocationTargetException {
+ RubyInstanceFactory rubyInstanceFactory = new RubyInstanceFactory("foo", null,"def getPetra() \n return 'petra' \n end", getClass().getClassLoader());
+ RubyInstance instance = rubyInstanceFactory.createInstance(null, new HashMap<String, Object>());
+ assertEquals("petra", instance.invokeTarget("getPetra", new Object[0]));
+ }
+
+ public void testCreateInstance() {
+ RubyInstanceFactory rubyInstanceFactory = new RubyInstanceFactory("foo", null,"def getPetra() \n return 'petra' \n end", getClass().getClassLoader());
+ RubyInstance instance = rubyInstanceFactory.createInstance(null, new HashMap<String, Object>());
+ assertNotNull(instance);
+ }
+
+ public void testCreateInstanceWithContext() throws InvocationTargetException {
+// RubyInstanceFactory rubyInstanceFactory = new RubyInstanceFactory("foo", null,"def getName() \n return name \n end", getClass().getClassLoader());
+// Map<String, Object> contexts = new HashMap<String, Object>();
+// contexts.put("name", "petra");
+// RubyInstance instance = rubyInstanceFactory.createInstance(null, contexts);
+// assertEquals("petra", instance.invokeTarget("getName", new Object[0]));
+ }
+
+ public void testDefaultResponseType() throws InvocationTargetException {
+ RubyInstanceFactory rubyInstanceFactory = new RubyInstanceFactory("foo", null,"def getX() \n return 42 \n end", getClass().getClassLoader());
+ RubyInstance instance = rubyInstanceFactory.createInstance(null, new HashMap<String, Object>());
+ assertEquals(42L, instance.invokeTarget("getX", new Object[0]));
+ }
+
+ public void testSetResponseType() throws InvocationTargetException {
+ RubyInstanceFactory rubyInstanceFactory = new RubyInstanceFactory("foo", null,"def getX() \n return 42 \n end", getClass().getClassLoader());
+ List<Class> services = new ArrayList<Class>();
+ services.add(TypeTest.class);
+ RubyInstance instance = rubyInstanceFactory.createInstance(services, new HashMap<String, Object>());
+ Object x = instance.invokeTarget("getX", new Object[0]);
+ assertTrue(x instanceof Integer);
+ assertEquals(new Integer(42), x);
+ }
+
+ interface TypeTest {
+ Integer getX();
+ String getPetra();
+ }
+
+}
diff --git a/sandbox/ant/container.ruby/src/test/java/org/apache/tuscany/container/ruby/ScriptImplementationLoaderTestCase.java b/sandbox/ant/container.ruby/src/test/java/org/apache/tuscany/container/ruby/ScriptImplementationLoaderTestCase.java
new file mode 100644
index 0000000000..5148e2800c
--- /dev/null
+++ b/sandbox/ant/container.ruby/src/test/java/org/apache/tuscany/container/ruby/ScriptImplementationLoaderTestCase.java
@@ -0,0 +1,133 @@
+/*
+ * 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.ruby;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.ruby.RubyImplementationLoader;
+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;
+
+/**
+ *
+ */
+public class ScriptImplementationLoaderTestCase extends TestCase {
+ private CompositeComponent parent;
+
+ private XMLStreamReader reader;
+
+ private DeploymentContext deploymentContext;
+
+ private ClassLoader classLoader;
+
+ private LoaderRegistry registry;
+
+ private RubyImplementationLoader loader;
+
+ public void testLoadNoScriptAttribute() 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 testLoad() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn("foo.mock");
+ expect(reader.getAttributeValue(null, "class")).andReturn(null);
+ expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
+ expect(deploymentContext.getClassLoader()).andReturn(classLoader);
+
+ replay(reader);
+ replay(deploymentContext);
+
+ RubyImplementationLoader mockLoader = new RubyImplementationLoader(registry) {
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ assertSame(classLoader, cl);
+ assertEquals("foo.mock", resource);
+ return "var bar;";
+ }
+ };
+ mockLoader.load(parent, reader, deploymentContext);
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testLoadNoScriptPresent() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn("foo.py");
+ expect(reader.getAttributeValue(null, "class")).andReturn(null);
+ expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
+ expect(deploymentContext.getClassLoader()).andReturn(classLoader);
+
+ replay(reader);
+ replay(deploymentContext);
+
+ RubyImplementationLoader mockLoader = new RubyImplementationLoader(registry) {
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ assertSame(classLoader, cl);
+ assertEquals("foo.py", resource);
+ throw new MissingResourceException(resource);
+ }
+ };
+ try {
+ mockLoader.load(parent, reader, deploymentContext);
+ fail();
+ } catch (MissingResourceException e) {
+ assertEquals("foo.py", e.getMessage());
+ }
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testGetXMLType() throws LoaderException {
+ assertEquals(XML_NAMESPACE_1_0, loader.getXMLType().getNamespaceURI());
+ assertEquals("implementation.js", loader.getXMLType().getLocalPart());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = createMock(LoaderRegistry.class);
+ loader = new RubyImplementationLoader(registry);
+
+ parent = createMock(CompositeComponent.class);
+ reader = createMock(XMLStreamReader.class);
+ deploymentContext = createMock(DeploymentContext.class);
+ classLoader = createMock(ClassLoader.class);
+ }
+}
diff --git a/sandbox/ant/container.ruby/src/test/java/org/apache/tuscany/container/ruby/mock/Foo.java b/sandbox/ant/container.ruby/src/test/java/org/apache/tuscany/container/ruby/mock/Foo.java
new file mode 100644
index 0000000000..8dec6ab591
--- /dev/null
+++ b/sandbox/ant/container.ruby/src/test/java/org/apache/tuscany/container/ruby/mock/Foo.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.ruby.mock;
+
+public class Foo {
+ private String s;
+
+ public Foo() {
+ }
+
+ public String getS() {
+ return s;
+ }
+
+ public void setS(String s) {
+ this.s = s;
+ }
+}
diff --git a/sandbox/ant/container.ruby/src/test/resources/org/apache/tuscany/container/script/foo.componentType b/sandbox/ant/container.ruby/src/test/resources/org/apache/tuscany/container/script/foo.componentType
new file mode 100644
index 0000000000..9c37e1cb3e
--- /dev/null
+++ b/sandbox/ant/container.ruby/src/test/resources/org/apache/tuscany/container/script/foo.componentType
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="not.used"/>
+ </service>
+
+</componentType>
diff --git a/sandbox/ant/container.ruby/src/test/resources/org/apache/tuscany/container/script/foo.mock b/sandbox/ant/container.ruby/src/test/resources/org/apache/tuscany/container/script/foo.mock
new file mode 100644
index 0000000000..b6fc4c620b
--- /dev/null
+++ b/sandbox/ant/container.ruby/src/test/resources/org/apache/tuscany/container/script/foo.mock
@@ -0,0 +1 @@
+hello \ No newline at end of file
diff --git a/sandbox/ant/container.script/NOTICE.txt b/sandbox/ant/container.script/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sandbox/ant/container.script/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/sandbox/ant/container.script/doc/sca-java-container-script.xml b/sandbox/ant/container.script/doc/sca-java-container-script.xml
new file mode 100644
index 0000000000..ec100de245
--- /dev/null
+++ b/sandbox/ant/container.script/doc/sca-java-container-script.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document>
+
+ <properties>
+ <title>Tuscany</title>
+ <bannertitle>Tuscany SCA Java Scripting Language Implementation</bannertitle>
+ </properties>
+
+ <body>
+
+<section name="Scripting Language Implementation">
+
+<p>
+The Tuscany Java SCA runtime has a script container allowing SCA components to be implemented with a variety of scripting languages.
+</p>
+<p>
+To use the script container you use the &lt;implementation.script&gt; element in the component SCDL. The &lt;implementation.script&gt; element has two attributes, 'script' and 'class'. The 'script' attribute is required and defines the location of the script program. The 'class' attribute is optional and enables specifying the class or prototype to be used if the script language supports such concepts.
+</p>
+<p>
+The language the script is implemented in is defined by the suffix of the script attribute value. For example, the '.js' suffix indicates a JavaScript program, or '.py' indicates a Python program. The script container uses the <a href='http://jakarta.apache.org/bsf/' target='_blank'>Apache BSF script engine</a>, so any script language supported by BSF can be used as an SCA component implementation.
+</p>
+
+<p>
+</p>
+
+<p>
+</p>
+
+<p>
+</p>
+
+<p>
+</p>
+
+<p>
+The following example shows the files necessary to implement a simple HelloWorld style SCA component using the script container and a JavaScript program.
+</p>
+
+<p>
+The composite SCDL:
+</p>
+<p>
+<table width="100%" class="ex" cellspacing="0" bgcolor="#f4f4f4">
+<tr><td>
+<pre>
+&lt;composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="HelloWorldComposite"&gt;
+
+ &lt;component name="HelloWorldComponent"&gt;
+ &lt;implementation.script script="HelloWorld.js"/&gt;
+ &lt;/component&gt;
+
+&lt;/composite&gt;
+</pre>
+</td></tr>
+</table>
+</p>
+
+<p>
+and the associated JavaScript program, 'HelloWorld.js':
+</p>
+<p>
+<table width="100%" class="ex" cellspacing="0" bgcolor="#f4f4f4">
+<tr><td>
+<pre>
+function sayHello(s) {
+ return "Hello " + s;
+}
+</pre>
+</td></tr>
+</table>
+</p>
+
+<p>
+This next example shows a HelloWorld program using the Ruby language, and the use of the &lt;implementation.script&gt; element 'class' attribute to specifying the class of the component implementation:
+</p>
+<p>
+The composite SCDL:
+</p>
+<p>
+<table width="100%" class="ex" cellspacing="0" bgcolor="#f4f4f4">
+<tr><td>
+<pre>
+&lt;composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="HelloWorldComposite"&gt;
+
+ &lt;component name="HelloWorldComponent"&gt;
+ &lt;implementation.script script="HelloWorld.rb" class="Helloworld"/&gt;
+ &lt;/component&gt;
+
+&lt;/composite&gt;
+</pre>
+</td></tr>
+</table>
+</p>
+
+<p>
+and the associated Ruby program, 'HelloWorld.rb':
+</p>
+<p>
+<table width="100%" class="ex" cellspacing="0" bgcolor="#f4f4f4">
+<tr><td>
+<pre>
+class Helloworld
+
+ def sayHello(s)
+ return "Hello to " + s + " from the Ruby World!"
+ end
+
+end
+</pre>
+</td></tr>
+</table>
+</p>
+
+
+ </section>
+ </body>
+</document>
diff --git a/sandbox/ant/container.script/pom.xml b/sandbox/ant/container.script/pom.xml
new file mode 100644
index 0000000000..337d507ea6
--- /dev/null
+++ b/sandbox/ant/container.script/pom.xml
@@ -0,0 +1,89 @@
+<?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>container-script</artifactId>
+ <name>Apache Tuscany Script Container</name>
+ <description>Apache Tuscany Script Container using BSF</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-spi</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>bsf</groupId>
+ <artifactId>bsf</artifactId>
+ <version>2.4.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>bsf</groupId>
+ <artifactId>bsf3</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ <version>1.6R2</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/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/ScriptImplementationLoader.java b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/ScriptImplementationLoader.java
new file mode 100644
index 0000000000..3e5d228cb5
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/ScriptImplementationLoader.java
@@ -0,0 +1,81 @@
+/*
+ * 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.script;
+
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.container.script.helper.ScriptHelperImplementation;
+import org.apache.tuscany.container.script.helper.ScriptHelperImplementationLoader;
+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.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.loader.MissingResourceException;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.osoa.sca.annotations.Constructor;
+
+/**
+ * Loader for handling implementation.script elements.
+ *
+ * <implementation.script script="path/foo.py" class="myclass">
+ *
+ */
+public class ScriptImplementationLoader extends ScriptHelperImplementationLoader {
+
+ private static final QName IMPLEMENTATION_SCRIPT = new QName(XML_NAMESPACE_1_0, "implementation.script");
+
+ @Constructor( { "registry" })
+ public ScriptImplementationLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return IMPLEMENTATION_SCRIPT;
+ }
+
+ public ScriptHelperImplementation load(CompositeComponent parent, ModelObject mo, XMLStreamReader reader, DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
+ String scriptName = reader.getAttributeValue(null, "script");
+ if (scriptName == null) {
+ throw new MissingResourceException("implementation element has no 'script' attribute");
+ }
+
+ String className = reader.getAttributeValue(null, "class");
+
+ LoaderUtil.skipToEndElement(reader);
+
+ ClassLoader cl = deploymentContext.getClassLoader();
+ String scriptSource = loadSource(cl, scriptName);
+
+ ScriptInstanceFactory instanceFactory = new ScriptInstanceFactory(scriptName, className, scriptSource, cl);
+
+ ScriptHelperImplementation implementation = new ScriptHelperImplementation();
+ implementation.setResourceName(scriptName);
+ implementation.setScriptInstanceFactory(instanceFactory);
+
+ registry.loadComponentType(parent, implementation, deploymentContext);
+
+ return implementation;
+ }
+}
diff --git a/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/ScriptInstance.java b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/ScriptInstance.java
new file mode 100644
index 0000000000..9910661f85
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/ScriptInstance.java
@@ -0,0 +1,52 @@
+/*
+ * 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.script;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.bsf.BSFEngine;
+import org.apache.tuscany.container.script.helper.ScriptHelperInstance;
+
+/**
+ * An invokable instance of a script
+ *
+ * Basically just a wrapper around a BSF engine with an optional script class object.
+ */
+public class ScriptInstance implements ScriptHelperInstance {
+
+ protected BSFEngine bsfEngine;
+
+ protected Object clazz;
+
+ public ScriptInstance(BSFEngine bsfEngine, Object clazz) {
+ this.bsfEngine = bsfEngine;
+ this.clazz = clazz;
+ }
+
+ public Object invokeTarget(String operationName, Object[] args) throws InvocationTargetException {
+ try {
+
+ return bsfEngine.call(clazz, operationName, args);
+
+ } catch (Exception e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+}
diff --git a/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/ScriptInstanceFactory.java b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/ScriptInstanceFactory.java
new file mode 100644
index 0000000000..7206eb9e8f
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/ScriptInstanceFactory.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.script;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.bsf.BSFEngine;
+import org.apache.bsf.BSFException;
+import org.apache.bsf.BSFManager;
+import org.apache.tuscany.container.script.helper.ScriptHelperInstanceFactory;
+import org.apache.tuscany.spi.ObjectCreationException;
+
+/**
+ * ScriptInstanceFactory creates ScriptInstances for a script
+ */
+public class ScriptInstanceFactory extends ScriptHelperInstanceFactory<ScriptInstance>{
+
+ private String className;
+
+ private String scriptSource;
+
+ public ScriptInstanceFactory(String resourceName, String className, String scriptSource, ClassLoader classLoader) {
+ super(resourceName, classLoader);
+ this.className = className;
+ this.scriptSource = scriptSource;
+ }
+
+ /**
+ * Create a new invokeable instance of the script
+ *
+ * @param context
+ * objects to add to scope of the script instance
+ * @return a RhinoScriptInstance
+ */
+ public ScriptInstance createInstance(List<Class> services, Map<String, Object> context) {
+ try {
+
+ //TODO: this uses a new manager and recompiles the scrip each time, may be able to optimize
+ // but need to be careful about instance scoping
+
+ BSFManager bsfManager = new BSFManager();
+ bsfManager.setClassLoader(BSFManager.class.getClassLoader());
+
+ // TODO: hack to get Ruby working with the standalone launcher
+ Thread.currentThread().setContextClassLoader(BSFManager.class.getClassLoader());
+
+ // register any context objects (SCA properties and references)
+ for (String beanName : context.keySet()) {
+ bsfManager.registerBean(beanName, context.get(beanName));
+ }
+
+ String scriptLanguage = BSFManager.getLangFromFilename(resourceName);
+ BSFEngine bsfEngine = bsfManager.loadScriptingEngine(scriptLanguage);
+ bsfEngine.exec(resourceName, 0, 0, scriptSource);
+
+ // if there's a className then get the class object
+ Object clazz = null;
+ if (className != null) {
+ // special case for Ruby which requires a .new call
+ if ("ruby".equals(scriptLanguage)) {
+ clazz = bsfEngine.eval(null, 1, 1, className + ".new");
+ } else {
+ clazz = bsfEngine.call(null, className, null);
+ }
+ }
+
+ return new ScriptInstance(bsfEngine, clazz);
+
+ } catch (BSFException e) {
+ if (e.getTargetException() != null) {
+ throw new ObjectCreationException(e.getTargetException());
+ }
+ throw new ObjectCreationException(e.getTargetException());
+ }
+ }
+
+}
diff --git a/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/AsyncInvoker.java b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/AsyncInvoker.java
new file mode 100644
index 0000000000..d5cfe581ce
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/AsyncInvoker.java
@@ -0,0 +1,210 @@
+/*
+ * 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.script.helper;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.component.TargetException;
+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.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+import org.osoa.sca.SCA;
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * Responsible for performing a non-blocking dispatch on a component implementation instance
+ *
+ * TODO: Pretty much a direct copy of what the groovy container does for async
+ */
+public class AsyncInvoker extends ScriptHelperInvoker {
+
+ private static final ContextBinder BINDER = new ContextBinder();
+ private static final Message RESPONSE = new AsyncInvoker.ImmutableMessage();
+
+ private InboundWire wire;
+ private WorkScheduler workScheduler;
+ private AsyncMonitor monitor;
+ private WorkContext workContext;
+ private Object target;
+ private Object messageId;
+
+ /**
+ * Creates a new invoker
+ *
+ * @param operation the operation the invoker is associated with
+ * @param wire
+ * @param component the target component
+ * @param workScheduler the work scheduler to run the invocation
+ * @param monitor the monitor to pass events to
+ * @param workContext
+ */
+ public AsyncInvoker(String operation,
+ InboundWire wire,
+ ScriptHelperComponent component,
+ WorkScheduler workScheduler,
+ AsyncMonitor monitor,
+ WorkContext workContext) {
+ super(operation, component);
+ this.wire = wire;
+ this.workScheduler = workScheduler;
+ this.monitor = monitor;
+ this.workContext = workContext;
+ }
+
+ // Override invocation methods to defer invocation to work item
+ // Both methods return null to indicate asynchrony; result will
+ // be conveyed by callback
+ @Override
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ final CompositeContext currentContext = CurrentCompositeContext.getContext();
+ // Schedule the invocation of the next interceptor in a new Work instance
+ try {
+ workScheduler.scheduleWork(new Runnable() {
+ private Object currentMessageId = messageId;
+
+ public void run() {
+ workContext.setCurrentMessageId(null);
+ workContext.setCurrentCorrelationId(currentMessageId);
+ CompositeContext oldContext = CurrentCompositeContext.getContext();
+ try {
+ BINDER.setContext(currentContext);
+ // REVIEW response must be null for one-way and non-null for callback
+ AsyncInvoker.super.invokeTarget(payload);
+ } catch (Exception e) {
+ // REVIEW uncomment when it is available
+ // monitor.executionError(e);
+ e.printStackTrace();
+ } finally {
+ BINDER.setContext(oldContext);
+ }
+ }
+ });
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ return RESPONSE;
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ // can't just call overriden invoke because it would bypass async
+ try {
+ messageId = msg.getMessageId();
+ wire.addMapping(messageId, msg.getFromAddress());
+ return (Message) invokeTarget(msg.getBody());
+ } catch (Throwable e) {
+ // FIXME need to log exceptions
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public AsyncInvoker clone() {
+ AsyncInvoker invoker = (AsyncInvoker) super.clone();
+ invoker.workScheduler = this.workScheduler;
+ invoker.monitor = this.monitor;
+ return invoker;
+ }
+
+ /**
+ * Resolves the target service instance or returns a cached one
+ */
+ protected Object getInstance() throws TargetException {
+ if (!isCacheable()) {
+ return component.getTargetInstance();
+ } else {
+ if (target == null) {
+ target = component.getTargetInstance();
+ }
+ return target;
+ }
+ }
+
+ protected static class ContextBinder extends SCA {
+ public void setContext(CompositeContext context) {
+ setCompositeContext(context);
+ }
+
+ public void start() {
+ throw new AssertionError();
+ }
+
+ public void stop() {
+ throw new AssertionError();
+ }
+ }
+
+ /**
+ * A dummy message passed back on an invocation
+ */
+ protected static class ImmutableMessage implements Message {
+
+ public Object getBody() {
+ return null;
+ }
+
+ public void setBody(Object body) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setTargetInvoker(TargetInvoker invoker) {
+ throw new UnsupportedOperationException();
+ }
+
+ public TargetInvoker getTargetInvoker() {
+ return null;
+ }
+
+ public Object getFromAddress() {
+ return null;
+ }
+
+ public void setFromAddress(Object fromAddress) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getMessageId() {
+ return null;
+ }
+
+ public void setMessageId(Object messageId) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getCorrelationId() {
+ return null;
+ }
+
+ public void setCorrelationId(Object correlationId) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isFault() {
+ return false;
+ }
+
+ public void setBodyWithFault(Object fault) {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/AsyncMonitor.java b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/AsyncMonitor.java
new file mode 100644
index 0000000000..a3aa9958c7
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/AsyncMonitor.java
@@ -0,0 +1,31 @@
+/*
+ * 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.script.helper;
+
+/**
+ * A monitor used to log events during non-blocking invocations
+ */
+public interface AsyncMonitor {
+
+ /**
+ * Logs an exception thrown during an invocation
+ */
+ void executionError(Exception e);
+
+}
diff --git a/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperComponent.java b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperComponent.java
new file mode 100644
index 0000000000..03f5da96ca
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperComponent.java
@@ -0,0 +1,117 @@
+/*
+ * 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.script.helper;
+
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.extension.AtomicComponentExtension;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * A component implementation for script languages.
+ */
+public class ScriptHelperComponent extends AtomicComponentExtension {
+
+ private final List<Class<?>> services;
+
+ private final Map<String, Object> properties;
+
+ protected ScriptHelperInstanceFactory instanceFactory;
+
+ public ScriptHelperComponent(String name, ScriptHelperInstanceFactory instanceFactory, Map<String, Object> properties, List<Class<?>> services, CompositeComponent parent, ScopeContainer scopeContainer,
+ WireService wireService, WorkContext workContext, WorkScheduler workScheduler) {
+
+ super(name, parent, scopeContainer, wireService, workContext, workScheduler, 0);
+
+ this.instanceFactory = instanceFactory;
+ this.services = services;
+ this.scope = scopeContainer.getScope();
+ this.properties = properties;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object createInstance() throws ObjectCreationException {
+
+ Map<String, Object> context = new HashMap<String, Object>(getProperties());
+
+ for (List<OutboundWire> referenceWires : getOutboundWires().values()) {
+ for (OutboundWire wire : referenceWires) {
+ Object wireProxy = wireService.createProxy(wire);
+ context.put(wire.getReferenceName(), wireProxy);
+ }
+ }
+
+ return instanceFactory.createInstance(services, context);
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
+ Method[] methods = operation.getServiceContract().getInterfaceClass().getMethods();
+ Method method = findMethod(operation, methods);
+ return new ScriptHelperInvoker(method.getName(), this);
+ }
+
+ public TargetInvoker createAsyncTargetInvoker(InboundWire wire, Operation operation) {
+ return new AsyncInvoker(operation.getName(), wire, this, workScheduler, null, workContext);
+ }
+
+ // TODO: move all the following up to AtomicComponentExtension?
+
+ public List<Class<?>> getServiceInterfaces() {
+ return services;
+ }
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ public Object getTargetInstance() throws TargetException {
+ return scopeContainer.getInstance(this);
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return getServiceInstance(null);
+ }
+
+ @SuppressWarnings("unchecked")
+ 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);
+ }
+
+}
diff --git a/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentBuilder.java b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentBuilder.java
new file mode 100644
index 0000000000..865827f83f
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentBuilder.java
@@ -0,0 +1,83 @@
+/*
+ * 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.script.helper;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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.component.ScopeContainer;
+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.PropertyValue;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+/**
+ * Extension point for creating {@link ScriptComponent}s from an assembly configuration
+ */
+public class ScriptHelperComponentBuilder extends ComponentBuilderExtension<ScriptHelperImplementation> {
+
+ public ScriptHelperComponentBuilder() {
+ }
+
+ protected Class<ScriptHelperImplementation> getImplementationType() {
+ return ScriptHelperImplementation.class;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Component build(CompositeComponent parent, ComponentDefinition<ScriptHelperImplementation> componentDefinition,
+ DeploymentContext deploymentContext) throws BuilderConfigException {
+
+ String name = componentDefinition.getName();
+ ScriptHelperImplementation implementation = componentDefinition.getImplementation();
+ ScriptHelperComponentType componentType = implementation.getComponentType();
+
+ // 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 properties for the component
+ Map<String, Object> properties = new HashMap<String, Object>();
+ for (PropertyValue propertyValue : componentDefinition.getPropertyValues().values()) {
+ properties.put(propertyValue.getName(), propertyValue.getValueFactory().getInstance());
+ }
+
+ // TODO: have ComponentBuilderExtension pass ScopeContainer in on build method?
+ ScopeContainer scopeContainer;
+ Scope scope = componentType.getLifecycleScope();
+ if (Scope.MODULE == scope) {
+ scopeContainer = deploymentContext.getModuleScope();
+ } else {
+ scopeContainer = scopeRegistry.getScopeContainer(scope);
+ }
+
+ return new ScriptHelperComponent(name, implementation.getScriptInstanceFactory(), properties, services, parent, scopeContainer, wireService, workContext, workScheduler);
+ }
+
+}
diff --git a/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentType.java b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentType.java
new file mode 100644
index 0000000000..b7abb9f60e
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentType.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.script.helper;
+
+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;
+
+/**
+ * A componentType for script components
+ * TODO: need lifecycle methods init/destroy
+ * TODO: really need a generic componentType that supports scope and lifecycle
+ */
+public class ScriptHelperComponentType extends ComponentType<ServiceDefinition, ReferenceDefinition, Property<?>> {
+
+ private Scope lifecycleScope = Scope.MODULE;
+
+ public ScriptHelperComponentType() {
+ }
+
+ @SuppressWarnings("unchecked")
+ public ScriptHelperComponentType(ComponentType ct) {
+ // TODO: A bit hacky but this is so the generic .componentType XML side file can be used for now
+ setInitLevel(ct.getInitLevel());
+ for (Object property : ct.getProperties().values()) {
+ add((Property) property);
+ }
+ for (Object reference : ct.getReferences().values()) {
+ add((ReferenceDefinition) reference);
+ }
+ for (Object service : ct.getServices().values()) {
+ add((ServiceDefinition) service);
+ }
+ }
+
+ public Scope getLifecycleScope() {
+ return lifecycleScope;
+ }
+
+ public void setLifecycleScope(Scope lifecycleScope) {
+ this.lifecycleScope = lifecycleScope;
+ }
+
+}
diff --git a/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentTypeLoader.java b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentTypeLoader.java
new file mode 100644
index 0000000000..2c7b1dd4e2
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentTypeLoader.java
@@ -0,0 +1,71 @@
+/*
+ * 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.script.helper;
+
+import java.net.URL;
+
+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.ComponentType;
+
+/**
+ * ComponentType loader for script components
+ */
+public class ScriptHelperComponentTypeLoader extends ComponentTypeLoaderExtension<ScriptHelperImplementation> {
+
+ public ScriptHelperComponentTypeLoader() {
+ }
+
+ @Override
+ protected Class<ScriptHelperImplementation> getImplementationClass() {
+ return ScriptHelperImplementation.class;
+ }
+
+ // TODO: must be possible to move all the following up in to ComponentTypeLoaderExtension
+
+ public void load(CompositeComponent parent, ScriptHelperImplementation implementation, DeploymentContext deploymentContext) throws LoaderException {
+ String sideFile = getSideFileName(implementation.getResourceName());
+ URL resource = implementation.getScriptInstanceFactory().getClassLoader().getResource(sideFile);
+ ScriptHelperComponentType componentType;
+ if (resource == null) {
+ throw new IllegalArgumentException("missing .componentType side file: " + sideFile);
+ // TODO: or else implement introspection
+ } else {
+ componentType = loadFromSidefile(resource, deploymentContext);
+ }
+ implementation.setComponentType(componentType);
+ }
+
+ protected ScriptHelperComponentType loadFromSidefile(URL url, DeploymentContext deploymentContext) throws LoaderException {
+ ComponentType ct = loaderRegistry.load(null, null, url, ComponentType.class, deploymentContext);
+ ScriptHelperComponentType scriptComponentType = new ScriptHelperComponentType(ct);
+ return scriptComponentType;
+ }
+
+ protected String getSideFileName(String resourceName) {
+ int lastDot = resourceName.lastIndexOf('.');
+ if (lastDot != -1) {
+ resourceName = resourceName.substring(0, lastDot);
+ }
+ return resourceName + ".componentType";
+ }
+
+}
diff --git a/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperImplementation.java b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperImplementation.java
new file mode 100644
index 0000000000..39b867c069
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperImplementation.java
@@ -0,0 +1,47 @@
+/*
+ * 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.script.helper;
+
+import org.apache.tuscany.spi.model.AtomicImplementation;
+
+/**
+ * Model object for a script implementation.
+ */
+public class ScriptHelperImplementation extends AtomicImplementation<ScriptHelperComponentType> {
+
+ private String resourceName;
+
+ private ScriptHelperInstanceFactory scriptInstanceFactory;
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public ScriptHelperInstanceFactory getScriptInstanceFactory() {
+ return scriptInstanceFactory;
+ }
+
+ public void setScriptInstanceFactory(ScriptHelperInstanceFactory scriptInstanceFactory) {
+ this.scriptInstanceFactory = scriptInstanceFactory;
+ }
+}
diff --git a/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperImplementationLoader.java b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperImplementationLoader.java
new file mode 100644
index 0000000000..cda196590c
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperImplementationLoader.java
@@ -0,0 +1,85 @@
+/*
+ * 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.script.helper;
+
+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 org.apache.tuscany.spi.annotation.Autowire;
+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.MissingResourceException;
+import org.osoa.sca.annotations.Constructor;
+
+/**
+ * Loader for handling implementation.script elements.
+ *
+ * <implementation.script script="path/foo.py" class="myclass">
+ *
+ */
+public abstract class ScriptHelperImplementationLoader extends LoaderExtension<ScriptHelperImplementation> {
+
+ @Constructor( { "registry" })
+ public ScriptHelperImplementationLoader(@Autowire LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public abstract QName getXMLType();
+
+ 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/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperInstance.java b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperInstance.java
new file mode 100644
index 0000000000..dda5c6e27f
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperInstance.java
@@ -0,0 +1,31 @@
+/*
+ * 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.script.helper;
+
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * An invokable instance of a script
+ *
+ * Basically just a wrapper around a BSF engine with an optional script class object.
+ */
+public interface ScriptHelperInstance {
+
+ public Object invokeTarget(String operationName, Object[] args) throws InvocationTargetException;
+}
diff --git a/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperInstanceFactory.java b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperInstanceFactory.java
new file mode 100644
index 0000000000..b3b13fc1a7
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperInstanceFactory.java
@@ -0,0 +1,71 @@
+/*
+ * 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.script.helper;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * ScriptInstanceFactory creates ScriptInstances for a script
+ */
+public abstract class ScriptHelperInstanceFactory<T extends ScriptHelperInstance> {
+
+ protected String resourceName;
+
+ protected ClassLoader classLoader;
+
+ public ScriptHelperInstanceFactory(String resourceName, ClassLoader classLoader) {
+ this.resourceName = resourceName;
+ this.classLoader = classLoader;
+ }
+
+ /**
+ * Create a new invokeable instance of the script
+ * @param services
+ *
+ * @param context
+ * objects to add to scope of the script instance
+ * @return a RhinoScriptInstance
+ * TODO: services should be on the constructor not on this method
+ */
+ public abstract T createInstance(List<Class> services, Map<String, Object> context);
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ protected Map<String, Class> getResponseClasses(List<Class> services) {
+ Map<String, Class> responseClasses = new HashMap<String, Class>();
+ if (services != null) {
+ for (Class s : services) {
+ for (Method m : s.getMethods()) {
+ responseClasses.put(m.getName(), m.getReturnType());
+ }
+ }
+ }
+ return responseClasses;
+ }
+
+}
diff --git a/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperInvoker.java b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperInvoker.java
new file mode 100644
index 0000000000..2a8ffe855a
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/helper/ScriptHelperInvoker.java
@@ -0,0 +1,53 @@
+/*
+ * 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.script.helper;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.extension.TargetInvokerExtension;
+
+/**
+ * TargetInvoker that calls a function on a ScriptInstance
+ */
+public class ScriptHelperInvoker extends TargetInvokerExtension {
+
+ protected ScriptHelperComponent component;
+
+ protected String functionName;
+
+ public ScriptHelperInvoker(String functionName, ScriptHelperComponent component) {
+ this.functionName = functionName;
+ this.component = component;
+ }
+
+ /**
+ * Invoke the function
+ */
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ ScriptHelperInstance target = (ScriptHelperInstance) component.getTargetInstance();
+ try {
+
+ return target.invokeTarget(functionName, (Object[]) payload);
+
+ } catch (Exception e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+}
diff --git a/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/jsr223/JSR223BSFEngine.java b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/jsr223/JSR223BSFEngine.java
new file mode 100644
index 0000000000..fab9813af4
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/java/org/apache/tuscany/container/script/jsr223/JSR223BSFEngine.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.script.jsr223;
+
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.script.Invocable;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineFactory;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+
+import org.apache.bsf.BSFDeclaredBean;
+import org.apache.bsf.BSFException;
+import org.apache.bsf.BSFManager;
+import org.apache.bsf.util.BSFEngineImpl;
+
+/**
+ * JSR223BSFEngine enables using any available JSR-223 script engine with BSF
+ *
+ * Use the static method JSR223BSFEngine.registerAllJSR223Engines to register all
+ * the available JSR-223 engines with BSF.
+ */
+public class JSR223BSFEngine extends BSFEngineImpl {
+
+ private ScriptEngine engine;
+
+ /*
+ * @see org.apache.bsf.BSFEngine.call(Object, String, Object[])
+ */
+ public Object call(Object object, String name, Object[] args) throws BSFException {
+ if (!(engine instanceof Invocable)) {
+ throw new BSFException(BSFException.REASON_OTHER_ERROR, "JSR223Bridge Error, call not supported by engine: "
+ + engine.getContext().getAttribute(ScriptEngine.ENGINE));
+ }
+ try {
+
+ return ((Invocable) engine).call(name, object, args);
+
+ } catch (Exception e) {
+ throw new BSFException(BSFException.REASON_OTHER_ERROR, "JSR223Bridge Error: " + e.getLocalizedMessage(), e);
+ }
+ }
+
+ /*
+ * @see org.apache.bsf.BSFEngine.call(Object, String, Object[])
+ */
+ public Object eval(String source, int lineNo, int columnNo, Object expr) throws BSFException {
+ try {
+
+ return engine.eval(expr.toString());
+
+ } catch (ScriptException e) {
+ throw new BSFException(BSFException.REASON_OTHER_ERROR, "JSR223Bridge Error: " + e.getLocalizedMessage(), e);
+ }
+ }
+
+ /*
+ * @see org.apache.bsf.BSFEngine.declareBean(BSFDeclaredBean)
+ */
+ public void declareBean(BSFDeclaredBean bean) throws BSFException {
+ engine.getContext().setAttribute(bean.name, bean.bean, ScriptContext.ENGINE_SCOPE);
+ }
+
+ /*
+ * @see org.apache.bsf.BSFEngine.undeclareBean(BSFDeclaredBean)
+ */
+ public void undeclareBean(BSFDeclaredBean bean) throws BSFException {
+ engine.getContext().removeAttribute(bean.name, ScriptContext.ENGINE_SCOPE);
+ }
+
+ /*
+ * @see org.apache.bsf.BSFEngine.initialize(BSFManager, String, Vector)
+ */
+ public void initialize(BSFManager mgr, String lang, Vector declaredBeans) throws BSFException {
+
+ super.initialize(mgr, lang, declaredBeans);
+
+ this.engine = new ScriptEngineManager().getEngineByName(lang);
+
+ for (Iterator it = declaredBeans.iterator(); it.hasNext();) {
+ declareBean((BSFDeclaredBean) it.next());
+ }
+
+ }
+
+ /**
+ * Register all the available JSR-223 engines with BSF.
+ *
+ * Any BSF engines for the same language will be replaced with the JSR-223 engine.
+ */
+ public static void registerAllJSR223Engines() {
+ ScriptEngineFactory[] engineFactories = new ScriptEngineManager().getEngineFactories();
+ for (int i = 0; i < engineFactories.length; i++) {
+ String[] names = engineFactories[i].getNames();
+ String[] extensions = engineFactories[i].getExtensions();
+ for (int j = 0; j < names.length; j ++) {
+ BSFManager.registerScriptingEngine(names[j], JSR223BSFEngine.class.getName(), extensions);
+ }
+ }
+ }
+
+}
diff --git a/sandbox/ant/container.script/src/main/resources/META-INF/sca/default.scdl b/sandbox/ant/container.script/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..1f059bdb08
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/resources/META-INF/sca/default.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://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+
+ name="org.apache.tuscany.container.script.ScriptImplementation">
+
+ <component name="script.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.container.script.ScriptImplementationLoader"/>
+ </component>
+
+ <component name="script.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.container.script.helper.ScriptHelperComponentTypeLoader"/>
+ </component>
+
+ <component name="script.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.script.helper.ScriptHelperComponentBuilder"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/container.script/src/main/resources/META-INF/sca/script.system.scdl b/sandbox/ant/container.script/src/main/resources/META-INF/sca/script.system.scdl
new file mode 100644
index 0000000000..1f059bdb08
--- /dev/null
+++ b/sandbox/ant/container.script/src/main/resources/META-INF/sca/script.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://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+
+ name="org.apache.tuscany.container.script.ScriptImplementation">
+
+ <component name="script.implementationLoader">
+ <system:implementation.system class="org.apache.tuscany.container.script.ScriptImplementationLoader"/>
+ </component>
+
+ <component name="script.componentTypeLoader">
+ <system:implementation.system class="org.apache.tuscany.container.script.helper.ScriptHelperComponentTypeLoader"/>
+ </component>
+
+ <component name="script.componentBuilder">
+ <system:implementation.system class="org.apache.tuscany.container.script.helper.ScriptHelperComponentBuilder"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/ScriptImplementationLoaderTestCase.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/ScriptImplementationLoaderTestCase.java
new file mode 100644
index 0000000000..6db6cf1200
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/ScriptImplementationLoaderTestCase.java
@@ -0,0 +1,132 @@
+/*
+ * 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.script;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
+import static org.osoa.sca.Version.XML_NAMESPACE_1_0;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+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;
+
+/**
+ *
+ */
+public class ScriptImplementationLoaderTestCase extends TestCase {
+ private CompositeComponent parent;
+
+ private XMLStreamReader reader;
+
+ private DeploymentContext deploymentContext;
+
+ private ClassLoader classLoader;
+
+ private LoaderRegistry registry;
+
+ private ScriptImplementationLoader loader;
+
+ public void testLoadNoScriptAttribute() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn(null);
+ replay(reader);
+ replay(deploymentContext);
+
+ try {
+ loader.load(parent, null, reader, deploymentContext);
+ fail();
+ } catch (MissingResourceException e) {
+ // ok
+ }
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testLoad() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn("foo.mock");
+ expect(reader.getAttributeValue(null, "class")).andReturn(null);
+ expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
+ expect(deploymentContext.getClassLoader()).andReturn(classLoader);
+
+ replay(reader);
+ replay(deploymentContext);
+
+ ScriptImplementationLoader mockLoader = new ScriptImplementationLoader(registry) {
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ assertSame(classLoader, cl);
+ assertEquals("foo.mock", resource);
+ return "bar";
+ }
+ };
+ mockLoader.load(parent, null, reader, deploymentContext);
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testLoadNoScriptPresent() throws LoaderException, XMLStreamException {
+ expect(reader.getAttributeValue(null, "script")).andReturn("foo.py");
+ expect(reader.getAttributeValue(null, "class")).andReturn(null);
+ expect(reader.next()).andReturn(XMLStreamConstants.END_ELEMENT);
+ expect(deploymentContext.getClassLoader()).andReturn(classLoader);
+
+ replay(reader);
+ replay(deploymentContext);
+
+ ScriptImplementationLoader mockLoader = new ScriptImplementationLoader(registry) {
+ protected String loadSource(ClassLoader cl, String resource) throws LoaderException {
+ assertSame(classLoader, cl);
+ assertEquals("foo.py", resource);
+ throw new MissingResourceException(resource);
+ }
+ };
+ try {
+ mockLoader.load(parent, null, reader, deploymentContext);
+ fail();
+ } catch (MissingResourceException e) {
+ assertEquals("foo.py", e.getMessage());
+ }
+ verify(reader);
+ verify(deploymentContext);
+ }
+
+ public void testGetXMLType() throws LoaderException {
+ assertEquals(XML_NAMESPACE_1_0, loader.getXMLType().getNamespaceURI());
+ assertEquals("implementation.script", loader.getXMLType().getLocalPart());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = createMock(LoaderRegistry.class);
+ loader = new ScriptImplementationLoader(registry);
+
+ parent = createMock(CompositeComponent.class);
+ reader = createMock(XMLStreamReader.class);
+ deploymentContext = createMock(DeploymentContext.class);
+ classLoader = createMock(ClassLoader.class);
+ }
+}
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/ScriptInstanceFactoryTestCase.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/ScriptInstanceFactoryTestCase.java
new file mode 100644
index 0000000000..2e72de6074
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/ScriptInstanceFactoryTestCase.java
@@ -0,0 +1,69 @@
+package org.apache.tuscany.container.script;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.bsf.BSFManager;
+import org.apache.tuscany.container.script.mock.MockBSFEngine;
+import org.apache.tuscany.spi.ObjectCreationException;
+
+public class ScriptInstanceFactoryTestCase extends TestCase {
+
+ public void testCreateInstance() throws InvocationTargetException {
+ BSFManager.registerScriptingEngine("mock", MockBSFEngine.class.getName(), new String[] {"mock"});
+ ScriptInstanceFactory factory = new ScriptInstanceFactory("foo.mock", "bar", "baz", getClass().getClassLoader());
+ Map<String, Object> context = new HashMap<String, Object>();
+ context.put("foo", "bar");
+ ScriptInstance instance = factory.createInstance(null, context);
+ assertNotNull(instance);
+ assertNotNull(instance.bsfEngine);
+// assertNotNull(instance.clazz);
+ }
+
+ public void testCreateInstanceNoClass() throws InvocationTargetException {
+ BSFManager.registerScriptingEngine("mock", MockBSFEngine.class.getName(), new String[] {"mock"});
+ ScriptInstanceFactory factory = new ScriptInstanceFactory("foo.mock", null, "baz", getClass().getClassLoader());
+ Map<String, Object> context = new HashMap<String, Object>();
+ context.put("foo", "bar");
+ ScriptInstance instance = factory.createInstance(null, context);
+ assertNotNull(instance);
+ assertNotNull(instance.bsfEngine);
+ }
+
+ public void testCreateInstanceRuby() throws InvocationTargetException {
+ BSFManager.registerScriptingEngine("ruby", MockBSFEngine.class.getName(), new String[] {"mock"});
+ ScriptInstanceFactory factory = new ScriptInstanceFactory("foo.mock", "bar", "baz", getClass().getClassLoader());
+ Map<String, Object> context = new HashMap<String, Object>();
+ context.put("foo", "bar");
+ ScriptInstance instance = factory.createInstance(null, context);
+ assertNotNull(instance);
+ assertNotNull(instance.bsfEngine);
+// assertNotNull(instance.clazz);
+ }
+
+ public void testBadCreateInstance() throws InvocationTargetException {
+ ScriptInstanceFactory factory = new ScriptInstanceFactory("foo", "bar", "baz", getClass().getClassLoader());
+ Map<String, Object> context = new HashMap<String, Object>();
+ try {
+ factory.createInstance(null, context);
+ fail();
+ } catch (ObjectCreationException e) {
+ // expected
+ }
+ }
+
+ public void testGetters() throws InvocationTargetException {
+ ScriptInstanceFactory factory = new ScriptInstanceFactory("foo", "bar", "baz", getClass().getClassLoader());
+// assertEquals("foo", factory.getScriptName());
+// assertEquals("bar", factory.getClassName());
+// assertEquals("baz", factory.getScriptSource());
+ assertEquals(getClass().getClassLoader(), factory.getClassLoader());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+}
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/ScriptInstanceTestCase.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/ScriptInstanceTestCase.java
new file mode 100644
index 0000000000..9784721b83
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/ScriptInstanceTestCase.java
@@ -0,0 +1,30 @@
+package org.apache.tuscany.container.script;
+
+import java.lang.reflect.InvocationTargetException;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.script.mock.MockBSFEngine;
+
+public class ScriptInstanceTestCase extends TestCase {
+
+ private ScriptInstance instance;
+
+ public void testInvokeTarget() throws InvocationTargetException {
+ assertEquals("hello:", instance.invokeTarget("hello", null));
+ }
+
+ public void testInvokeTargetException() throws InvocationTargetException {
+ try {
+ instance.invokeTarget("bang", null);
+ fail();
+ } catch (InvocationTargetException e) {
+ // expected
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.instance = new ScriptInstance(new MockBSFEngine(), null);
+ }
+}
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/AsyncInvokerTestCase.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/AsyncInvokerTestCase.java
new file mode 100644
index 0000000000..9c99cf306f
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/AsyncInvokerTestCase.java
@@ -0,0 +1,211 @@
+/*
+ * 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.script.helper;
+
+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 java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.script.helper.AsyncInvoker;
+import org.apache.tuscany.container.script.helper.AsyncMonitor;
+import org.apache.tuscany.container.script.helper.ScriptHelperComponent;
+import org.apache.tuscany.container.script.helper.ScriptHelperInstance;
+import org.apache.tuscany.container.script.helper.AsyncInvoker.ContextBinder;
+import org.apache.tuscany.container.script.helper.AsyncInvoker.ImmutableMessage;
+import org.apache.tuscany.container.script.helper.mock.AsyncTarget;
+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 org.easymock.IAnswer;
+import org.easymock.classextension.EasyMock;
+
+/**
+ */
+public class AsyncInvokerTestCase extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testInvoke() throws Exception {
+ ScriptHelperInstance instance = createMock(ScriptHelperInstance.class);
+ expect(instance.invokeTarget("invoke", null)).andReturn(null).once();
+ replay(instance);
+ ScriptHelperComponent component = EasyMock.createMock(ScriptHelperComponent.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);
+ AsyncInvoker invoker = new AsyncInvoker("invoke", wire, component, scheduler, monitor, context);
+ Message msg = new MessageImpl();
+ invoker.invoke(msg);
+ verify(instance);
+ }
+
+ public void testClone() {
+ AsyncInvoker invoker = new AsyncInvoker(null, null, null,null,null,null);
+ assertNotNull(invoker.clone());
+ }
+
+ public void testGetInstance() {
+ ScriptHelperComponent component = EasyMock.createMock(ScriptHelperComponent.class);
+ expect(component.getTargetInstance()).andReturn("petra");
+ EasyMock.replay(component);
+ AsyncInvoker invoker = new AsyncInvoker(null, null, component,null,null,null);
+ assertEquals("petra", invoker.getInstance());
+ }
+
+ public void testGetInstanceCacheable() {
+ ScriptHelperComponent component = EasyMock.createMock(ScriptHelperComponent.class);
+ expect(component.getTargetInstance()).andReturn("petra");
+ EasyMock.replay(component);
+ AsyncInvoker invoker = new AsyncInvoker(null, null, component,null,null,null);
+ invoker.setCacheable(true);
+ assertEquals("petra", invoker.getInstance());
+ }
+
+ public void testGetBody() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertNull(message.getBody());
+ }
+
+ public void testSetBody() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setBody(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetTargetInvoker() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertNull(message.getTargetInvoker());
+ }
+
+ public void testSetTargetInvoker() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setTargetInvoker(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetFromAddress() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertNull(message.getFromAddress());
+ }
+
+ public void testSetFromAddress() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setFromAddress(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetMessageId() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertNull(message.getMessageId());
+ }
+
+ public void testSetMessageId() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setMessageId(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetCorrelationId() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertNull(message.getCorrelationId());
+ }
+
+ public void testSetCorrelationId() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setCorrelationId(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testIsFault() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ assertFalse(message.isFault());
+ }
+
+ public void testSetBodyWithFault() {
+ ImmutableMessage message = new AsyncInvoker.ImmutableMessage();
+ try {
+ message.setBodyWithFault(null);
+ fail();
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testContextBinder() {
+ ContextBinder contextBinder = new AsyncInvoker.ContextBinder();
+ contextBinder.setContext(null);
+ try {
+ contextBinder.start();
+ fail();
+ } catch (AssertionError e) {
+ // expected
+ }
+ try {
+ contextBinder.stop();
+ fail();
+ } catch (AssertionError e) {
+ // expected
+ }
+ }
+}
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentBuilderTestCase.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentBuilderTestCase.java
new file mode 100644
index 0000000000..5b93df3d76
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentBuilderTestCase.java
@@ -0,0 +1,107 @@
+package org.apache.tuscany.container.script.helper;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.script.helper.ScriptHelperComponentBuilder;
+import org.apache.tuscany.container.script.helper.ScriptHelperComponentType;
+import org.apache.tuscany.container.script.helper.ScriptHelperImplementation;
+import org.apache.tuscany.core.component.scope.ModuleScopeObjectFactory;
+import org.apache.tuscany.core.component.scope.ScopeRegistryImpl;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.PropertyValue;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+import org.easymock.IAnswer;
+
+public class ScriptHelperComponentBuilderTestCase extends TestCase {
+
+ public void testGetImplementationType() {
+ ScriptHelperComponentBuilder builder = new ScriptHelperComponentBuilder();
+ assertEquals(ScriptHelperImplementation.class, builder.getImplementationType());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testBuild() {
+ ScriptHelperComponentBuilder builder = new ScriptHelperComponentBuilder();
+ ScopeRegistry scopeRegistry = new ScopeRegistryImpl();
+ scopeRegistry.registerFactory(Scope.COMPOSITE, new ModuleScopeObjectFactory(scopeRegistry));
+ builder.setScopeRegistry(scopeRegistry);
+ DeploymentContext deploymentContext = createMock(DeploymentContext.class);
+ final ScopeContainer scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.COMPOSITE;
+ }
+ });
+ expect(deploymentContext.getModuleScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return scopeContainer;
+ }
+ });
+ replay(deploymentContext);
+ ComponentDefinition<ScriptHelperImplementation> impl = new ComponentDefinition<ScriptHelperImplementation>(new ScriptHelperImplementation());
+ ScriptHelperComponentType componentType = new ScriptHelperComponentType();
+ componentType.setLifecycleScope(Scope.COMPOSITE);
+ ServiceDefinition service = new ServiceDefinition();
+ ServiceContract serviceContract = new JavaServiceContract();
+ service.setServiceContract(serviceContract);
+ componentType.add(service);
+ impl.getImplementation().setComponentType(componentType);
+
+ PropertyValue pv = new PropertyValue("foo", "", "");
+ ObjectFactory pvFactory = createMock(ObjectFactory.class);
+ expect(pvFactory.getInstance()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return null;
+ }
+ });
+ replay(pvFactory);
+ pv.setValueFactory(pvFactory);
+ impl.add(pv);
+
+ Component component = builder.build(null, impl, deploymentContext);
+ assertNotNull(component);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testBuildModuleScope() {
+ ScriptHelperComponentBuilder builder = new ScriptHelperComponentBuilder();
+ DeploymentContext deploymentContext = createMock(DeploymentContext.class);
+ final ScopeContainer scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.MODULE;
+ }
+ });
+ expect(deploymentContext.getModuleScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return scopeContainer;
+ }
+ });
+ replay(deploymentContext);
+ ComponentDefinition<ScriptHelperImplementation> impl = new ComponentDefinition<ScriptHelperImplementation>(new ScriptHelperImplementation());
+ ScriptHelperComponentType componentType = new ScriptHelperComponentType();
+ ServiceDefinition service = new ServiceDefinition();
+ ServiceContract serviceContract = new JavaServiceContract();
+ service.setServiceContract(serviceContract);
+ componentType.add(service);
+ impl.getImplementation().setComponentType(componentType);
+ Component component = builder.build(null, impl, deploymentContext);
+ assertNotNull(component);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+}
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentTestCase.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentTestCase.java
new file mode 100644
index 0000000000..a1e300051d
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentTestCase.java
@@ -0,0 +1,145 @@
+package org.apache.tuscany.container.script.helper;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.script.helper.ScriptHelperComponent;
+import org.apache.tuscany.container.script.helper.ScriptHelperInstance;
+import org.apache.tuscany.container.script.helper.ScriptHelperInstanceFactory;
+import org.apache.tuscany.container.script.helper.mock.MockInstanceFactory;
+import org.apache.tuscany.core.wire.InboundWireImpl;
+import org.apache.tuscany.core.wire.OutboundWireImpl;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.RuntimeWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+import org.easymock.IAnswer;
+
+public class ScriptHelperComponentTestCase extends TestCase {
+
+ private ScopeContainer scopeContainer;
+
+ @SuppressWarnings("unchecked")
+ public void testCreateTargetInvoker() {
+ ScriptHelperComponent component = new ScriptHelperComponent(null,null, null, null, null, scopeContainer, null, null, null);
+
+ Operation operation = new Operation("hashCode", null,null,null,false,null);
+ ServiceContract contract = new ServiceContract(List.class){};
+ operation.setServiceContract(contract);
+ TargetInvoker invoker = component.createTargetInvoker("hashCode", operation);
+
+ assertNotNull(invoker);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testCreateInstance() throws IOException {
+ ScriptHelperComponent pc = new ScriptHelperComponent(null,createBSFEasy(), new HashMap(), null, null, scopeContainer, null, null, null);
+ Object o = pc.createInstance();
+ assertNotNull(o);
+ assertTrue(o instanceof ScriptHelperInstance);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testCreateInstanceWithRef() throws IOException {
+ WireService wireService = createMock(WireService.class);
+ expect(wireService.createProxy(isA(RuntimeWire.class))).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.MODULE;
+ }
+ });
+
+ ScriptHelperComponent pc = new ScriptHelperComponent(null,createBSFEasy(), new HashMap(), null, null, scopeContainer, wireService, null, null);
+ OutboundWire wire = new OutboundWireImpl();
+ wire.setReferenceName("foo");
+ pc.addOutboundWire(wire);
+ Object o = pc.createInstance();
+ assertNotNull(o);
+ assertTrue(o instanceof ScriptHelperInstance);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testGetServiceInstance() {
+ WireService wireService = createMock(WireService.class);
+ expect(wireService.createProxy(isA(RuntimeWire.class))).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return "foo";
+ }
+ });
+ replay(wireService);
+ ScriptHelperComponent pc = new ScriptHelperComponent(null,null, null, null, null, scopeContainer, wireService, null, null);
+ InboundWire wire = new InboundWireImpl();
+ pc.addInboundWire(wire);
+ assertEquals("foo", pc.getServiceInstance());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testGetServiceInstanceFail() {
+ ScriptHelperComponent pc = new ScriptHelperComponent(null,null, null, null, null, scopeContainer, null, null, null);
+ try {
+ pc.getServiceInstance();
+ fail();
+ } catch (TargetException e) {
+ // expected
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testGetproperties() {
+ ScriptHelperComponent pc = new ScriptHelperComponent(null,null, new HashMap(), null, null, scopeContainer, null, null, null);
+ assertNotNull(pc.getProperties());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testGetServiceInterfaces() {
+ List services = new ArrayList();
+ ScriptHelperComponent pc = new ScriptHelperComponent(null,null,null, services, null, scopeContainer, null, null, null);
+ assertEquals(services, pc.getServiceInterfaces());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testCreateAsyncTargetInvoker() {
+ ScriptHelperComponent pc = new ScriptHelperComponent(null,null,null, new ArrayList<Class<?>>(), null, scopeContainer, null, null, null);
+ assertNotNull(pc.createAsyncTargetInvoker(null, new Operation("foo", null,null,null)));
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.MODULE;
+ }
+ });
+ }
+
+ public ScriptHelperInstanceFactory createBSFEasy() throws IOException {
+// URL scriptURL = getClass().getResource("foo.mock");
+// InputStream is = scriptURL.openStream();
+// StringBuilder sb = new StringBuilder();
+// int i = 0;
+// while ((i = is.read()) != -1) {
+// sb.append((char) i);
+// }
+// is.close();
+// String script = sb.toString();
+ MockInstanceFactory bsfEasy = new MockInstanceFactory("foo.mock", null);
+ return bsfEasy;
+ }
+}
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentTypeLoaderTestCase.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentTypeLoaderTestCase.java
new file mode 100644
index 0000000000..4686d1b9f1
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentTypeLoaderTestCase.java
@@ -0,0 +1,144 @@
+/*
+ * 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.script.helper;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.stream.XMLStreamException;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.script.helper.ScriptHelperComponentTypeLoader;
+import org.apache.tuscany.container.script.helper.ScriptHelperImplementation;
+import org.apache.tuscany.container.script.helper.ScriptHelperInstanceFactory;
+import org.apache.tuscany.container.script.helper.mock.MockInstanceFactory;
+import org.apache.tuscany.core.loader.LoaderRegistryImpl;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+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.model.ComponentType;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.apache.tuscany.spi.model.Scope;
+import org.easymock.IAnswer;
+
+/**
+ *
+ */
+public class ScriptHelperComponentTypeLoaderTestCase extends TestCase {
+
+ public void testGetSideFileName() {
+ ScriptHelperComponentTypeLoader loader = new ScriptHelperComponentTypeLoader();
+ assertEquals("BSFEasyTestCase.componentType", loader.getSideFileName("BSFEasyTestCase.mock"));
+ }
+
+ public void testGetSideFileNameNoDot() {
+ ScriptHelperComponentTypeLoader loader = new ScriptHelperComponentTypeLoader();
+ assertEquals("BSFEasyTestCase.componentType", loader.getSideFileName("BSFEasyTestCase"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testLoadFromSideFile() throws MalformedURLException, LoaderException, XMLStreamException {
+ ScriptHelperComponentTypeLoader loader = new ScriptHelperComponentTypeLoader();
+ LoaderRegistry loaderRegistry = new LoaderRegistryImpl() {
+ public <MO extends ModelObject> MO load(CompositeComponent parent, ModelObject mo, URL url, Class<MO> type, DeploymentContext ctx) throws LoaderException {
+ return (MO) new ComponentType();
+ }
+ };
+ loader.setLoaderRegistry(loaderRegistry);
+ loader.loadFromSidefile(null, null);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testLoad() throws LoaderException {
+ ScriptHelperInstanceFactory bsfEasy = new MockInstanceFactory("org/apache/tuscany/container/script/helper/foo.mock", getClass().getClassLoader());
+ ScriptHelperComponentTypeLoader loader = new ScriptHelperComponentTypeLoader();
+ LoaderRegistry loaderRegistry = new LoaderRegistryImpl() {
+ public <MO extends ModelObject> MO load(CompositeComponent parent,
+ ModelObject mo,
+ URL url,
+ Class<MO> type,
+ DeploymentContext ctx) throws LoaderException {
+ return (MO) new ComponentType();
+ }
+ };
+ loader.setLoaderRegistry(loaderRegistry);
+ ScriptHelperImplementation implementation = new ScriptHelperImplementation();
+ implementation.setResourceName("org/apache/tuscany/container/script/helper/foo.mock");
+ implementation.setScriptInstanceFactory(bsfEasy);
+ DeploymentContext deploymentContext = createMock(DeploymentContext.class);
+ final ScopeContainer scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.MODULE;
+ }
+ });
+ expect(deploymentContext.getModuleScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return scopeContainer;
+ }
+ });
+ replay(deploymentContext);
+ loader.load(null, implementation, deploymentContext);
+ assertNotNull(implementation.getComponentType());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testLoadMissingSideFile() throws LoaderException {
+ ScriptHelperInstanceFactory bsfEasy = new MockInstanceFactory("org/apche/tuscany/container/script/helper/foo.mock", getClass().getClassLoader());
+ ScriptHelperComponentTypeLoader loader = new ScriptHelperComponentTypeLoader();
+ ScriptHelperImplementation implementation = new ScriptHelperImplementation();
+ implementation.setResourceName("org/apache/tuscany/container/script/helper/doesntExist");
+ implementation.setScriptInstanceFactory(bsfEasy);
+ DeploymentContext deploymentContext = createMock(DeploymentContext.class);
+ final ScopeContainer scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.MODULE;
+ }
+ });
+ expect(deploymentContext.getModuleScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return scopeContainer;
+ }
+ });
+ replay(deploymentContext);
+ try {
+ loader.load(null, implementation, deploymentContext);
+ fail();
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ public void testGetImplementationClass() {
+ ScriptHelperComponentTypeLoader loader = new ScriptHelperComponentTypeLoader();
+ assertEquals(ScriptHelperImplementation.class, loader.getImplementationClass());
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+}
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentTypeTestCase.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentTypeTestCase.java
new file mode 100644
index 0000000000..dd29f85e44
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperComponentTypeTestCase.java
@@ -0,0 +1,37 @@
+package org.apache.tuscany.container.script.helper;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.script.helper.ScriptHelperComponentType;
+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;
+
+public class ScriptHelperComponentTypeTestCase extends TestCase {
+
+ public void testLifecycleScope() {
+ ScriptHelperComponentType ct = new ScriptHelperComponentType();
+ assertEquals(Scope.MODULE, ct.getLifecycleScope());
+ ct.setLifecycleScope(Scope.COMPOSITE);
+ assertEquals(Scope.COMPOSITE, ct.getLifecycleScope());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testComponentTypeConstructor() {
+ ComponentType ct = new ComponentType();
+ Property property = new Property();
+ ct.add(property);
+ ReferenceDefinition reference = new ReferenceDefinition();
+ ct.add(reference);
+ ServiceDefinition service = new ServiceDefinition();
+ ct.add(service);
+
+ ScriptHelperComponentType pct = new ScriptHelperComponentType(ct);
+
+ assertEquals(property, pct.getProperties().values().iterator().next());
+ assertEquals(reference, pct.getReferences().values().iterator().next());
+ assertEquals(service, pct.getServices().values().iterator().next());
+ }
+}
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperImplementationLoaderTestCase.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperImplementationLoaderTestCase.java
new file mode 100644
index 0000000000..be3d4de909
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperImplementationLoaderTestCase.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.script.helper;
+
+import static org.easymock.classextension.EasyMock.createMock;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.script.helper.ScriptHelperImplementation;
+import org.apache.tuscany.container.script.helper.ScriptHelperImplementationLoader;
+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 org.apache.tuscany.spi.model.ModelObject;
+
+/**
+ *
+ */
+public class ScriptHelperImplementationLoaderTestCase extends TestCase {
+
+ private LoaderRegistry registry;
+
+ private ScriptHelperImplementationLoader loader;
+
+ public void testLoadSource() throws LoaderException {
+ String script = loader.loadSource(getClass().getClassLoader(), "org/apache/tuscany/container/script/helper/foo.mock");
+ assertTrue(script.startsWith("hello"));
+ }
+
+ public void testLoadSourceMissingResource() throws LoaderException {
+ try {
+ loader.loadSource(getClass().getClassLoader(), "doesnt.exist");
+ fail();
+ } catch (MissingResourceException e) {
+ // expected
+ }
+ }
+
+ public void testGetXMLType() throws LoaderException {
+ assertEquals("http://foo", loader.getXMLType().getNamespaceURI());
+ assertEquals("bar", loader.getXMLType().getLocalPart());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registry = createMock(LoaderRegistry.class);
+ loader = new ScriptHelperImplementationLoader(registry){
+ public QName getXMLType() {
+ return new QName("http://foo", "bar");
+ }
+// @Override
+ public ScriptHelperImplementation load(CompositeComponent arg0, ModelObject arg1, XMLStreamReader arg2, DeploymentContext arg3) throws XMLStreamException, LoaderException {
+ return null;
+ }};
+ }
+}
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperImplementationTestCase.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperImplementationTestCase.java
new file mode 100644
index 0000000000..f906c701f3
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperImplementationTestCase.java
@@ -0,0 +1,30 @@
+package org.apache.tuscany.container.script.helper;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.script.helper.ScriptHelperImplementation;
+import org.apache.tuscany.container.script.helper.ScriptHelperInstanceFactory;
+import org.apache.tuscany.container.script.helper.mock.MockInstanceFactory;
+
+public class ScriptHelperImplementationTestCase extends TestCase {
+
+ private ScriptHelperInstanceFactory bsfEasy;
+
+ public void testGetBSFEasy() {
+ ScriptHelperImplementation impl = new ScriptHelperImplementation();
+ impl.setScriptInstanceFactory(bsfEasy);
+ assertEquals(bsfEasy, impl.getScriptInstanceFactory());
+ }
+
+ public void testGetResourceName() {
+ ScriptHelperImplementation impl = new ScriptHelperImplementation();
+ impl.setResourceName("foo");
+ assertEquals("foo", impl.getResourceName());
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ bsfEasy = new MockInstanceFactory("BSFEasyTestCase", null);
+ }
+
+}
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperInstanceFactoryTestCase.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperInstanceFactoryTestCase.java
new file mode 100644
index 0000000000..132ea2bdfc
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperInstanceFactoryTestCase.java
@@ -0,0 +1,56 @@
+package org.apache.tuscany.container.script.helper;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.script.helper.ScriptHelperInstance;
+import org.apache.tuscany.container.script.helper.mock.MockInstanceFactory;
+
+public class ScriptHelperInstanceFactoryTestCase extends TestCase {
+
+ public void testCreateInstance() throws InvocationTargetException {
+ MockInstanceFactory factory = new MockInstanceFactory("foo.mock", getClass().getClassLoader());
+ Map<String, Object> context = new HashMap<String, Object>();
+ context.put("foo", "bar");
+ ScriptHelperInstance instance = factory.createInstance(null, context);
+ assertNotNull(instance);
+ }
+
+ public void testCreateInstanceNoClass() throws InvocationTargetException {
+ MockInstanceFactory factory = new MockInstanceFactory("foo.mock", getClass().getClassLoader());
+ Map<String, Object> context = new HashMap<String, Object>();
+ context.put("foo", "bar");
+ ScriptHelperInstance instance = factory.createInstance(null, context);
+ assertNotNull(instance);
+ }
+
+ public void testCreateInstanceRuby() throws InvocationTargetException {
+ MockInstanceFactory factory = new MockInstanceFactory("foo.mock", getClass().getClassLoader());
+ Map<String, Object> context = new HashMap<String, Object>();
+ context.put("foo", "bar");
+ ScriptHelperInstance instance = factory.createInstance(null, context);
+ assertNotNull(instance);
+ }
+
+ public void testGetters() throws InvocationTargetException {
+ MockInstanceFactory factory = new MockInstanceFactory("foo", getClass().getClassLoader());
+ assertEquals("foo", factory.getResourceName());
+ assertEquals(getClass().getClassLoader(), factory.getClassLoader());
+ }
+
+ public void testGetResponseClasses() {
+ MockInstanceFactory factory = new MockInstanceFactory("foo", getClass().getClassLoader());
+ Map<String, Class> classes = factory.getResponseClasses(Arrays.asList( new Class[]{ Runnable.class}));
+ assertEquals(1, classes.size());
+ assertEquals("run", classes.keySet().iterator().next());
+ assertEquals(void.class, classes.get("run"));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+}
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperInvokerTestCase.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperInvokerTestCase.java
new file mode 100644
index 0000000000..6a40eae163
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/ScriptHelperInvokerTestCase.java
@@ -0,0 +1,64 @@
+package org.apache.tuscany.container.script.helper;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+
+import java.lang.reflect.InvocationTargetException;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.script.helper.ScriptHelperComponent;
+import org.apache.tuscany.container.script.helper.ScriptHelperInstance;
+import org.apache.tuscany.container.script.helper.ScriptHelperInvoker;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.model.Scope;
+import org.easymock.IAnswer;
+
+public class ScriptHelperInvokerTestCase extends TestCase {
+
+ private ScriptHelperComponent component;
+
+ public void testInvokeTarget() throws InvocationTargetException {
+ ScriptHelperInvoker invoker = new ScriptHelperInvoker("hello", component);
+ assertEquals("hello petra", invoker.invokeTarget(null));
+ }
+
+ public void testInvokeTargetException() throws InvocationTargetException, SecurityException, NoSuchMethodException {
+ ScriptHelperInvoker badInvoker = new ScriptHelperInvoker("bang", component);
+ try {
+ badInvoker.invokeTarget(null);
+ fail();
+ } catch (InvocationTargetException e) {
+ // expected
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ ScopeContainer scopeContainer = createMock(ScopeContainer.class);
+ expect(scopeContainer.getScope()).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return Scope.MODULE;
+ }
+ });
+ expect(scopeContainer.getInstance(isA(AtomicComponent.class))).andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ return new ScriptHelperInstance(){
+ public Object invokeTarget(String operationName, Object[] args) throws InvocationTargetException {
+ if ("bang".equals(operationName)) {
+ throw new RuntimeException("bang");
+ }
+ return "hello petra";
+ }};
+ }
+ });
+ replay(scopeContainer);
+
+ this.component = new ScriptHelperComponent(null, null, null, null, null, scopeContainer, null, null, null);
+ }
+}
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/mock/AsyncTarget.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/mock/AsyncTarget.java
new file mode 100644
index 0000000000..8961f882f1
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/mock/AsyncTarget.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.container.script.helper.mock;
+
+/**
+ */
+public interface AsyncTarget {
+
+ void invoke();
+}
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/mock/MockInstanceFactory.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/mock/MockInstanceFactory.java
new file mode 100644
index 0000000000..6f90913938
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/helper/mock/MockInstanceFactory.java
@@ -0,0 +1,30 @@
+package org.apache.tuscany.container.script.helper.mock;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.container.script.helper.ScriptHelperInstance;
+import org.apache.tuscany.container.script.helper.ScriptHelperInstanceFactory;
+
+public class MockInstanceFactory extends ScriptHelperInstanceFactory<MockInstance> {
+
+ public MockInstanceFactory(String scriptName, ClassLoader classLoader) {
+ super(scriptName, classLoader);
+ }
+
+ @Override
+ public MockInstance createInstance(List<Class> services, Map<String, Object> context) {
+ return new MockInstance();
+ }
+
+}
+
+class MockInstance implements ScriptHelperInstance {
+
+ public Object invokeTarget(String operationName, Object[] args) throws InvocationTargetException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/jsr223/JSR223BSFEngineTestCase.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/jsr223/JSR223BSFEngineTestCase.java
new file mode 100644
index 0000000000..a9cc459627
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/jsr223/JSR223BSFEngineTestCase.java
@@ -0,0 +1,45 @@
+package org.apache.tuscany.container.script.jsr223;
+
+import junit.framework.TestCase;
+
+import org.apache.bsf.BSFEngine;
+import org.apache.bsf.BSFException;
+import org.apache.bsf.BSFManager;
+import org.mozilla.javascript.EcmaError;
+
+public class JSR223BSFEngineTestCase extends TestCase {
+
+ public void testRegisterAllJSR223Engines() throws BSFException {
+ JSR223BSFEngine.registerAllJSR223Engines();
+ BSFEngine engine = new BSFManager().loadScriptingEngine("rhino");
+ assertTrue(engine instanceof JSR223BSFEngine);
+ }
+
+ public void testDeclareBean() throws BSFException {
+ JSR223BSFEngine.registerAllJSR223Engines();
+ BSFManager manager = new BSFManager();
+ manager.declareBean("foo", "foo", String.class);
+ BSFEngine engine = manager.loadScriptingEngine("rhino");
+ assertEquals("foo", engine.eval("testDeclareBean", 0, 0, "foo"));
+ manager.undeclareBean("foo");
+ try {
+ engine.eval("testDeclareBean", 0, 0, "foo");
+ fail();
+ } catch (EcmaError e) {
+ //expected
+ }
+ }
+
+ public void testEval() throws BSFException {
+ JSR223BSFEngine.registerAllJSR223Engines();
+ BSFEngine engine = new BSFManager().loadScriptingEngine("rhino");
+ assertEquals(true, engine.eval("testDeclareBean", 0, 0, "true"));
+ }
+
+ public void testCall() throws BSFException {
+ JSR223BSFEngine.registerAllJSR223Engines();
+ BSFEngine engine = new BSFManager().loadScriptingEngine("rhino");
+ engine.eval("testDeclareBean", 0, 0, "function foo() { return true;}");
+ assertEquals(true, engine.call(null, "foo", new Object[]{}));
+ }
+}
diff --git a/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/mock/MockBSFEngine.java b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/mock/MockBSFEngine.java
new file mode 100644
index 0000000000..7c2434ea13
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/java/org/apache/tuscany/container/script/mock/MockBSFEngine.java
@@ -0,0 +1,27 @@
+package org.apache.tuscany.container.script.mock;
+
+import org.apache.bsf.BSFException;
+import org.apache.bsf.util.BSFEngineImpl;
+
+public class MockBSFEngine extends BSFEngineImpl {
+
+ public Object call(Object object, String name, Object[] args) throws BSFException {
+ if ("bang".equals(name)) {
+ throw new RuntimeException(name);
+ }
+
+ String resp = name + ":";
+ if (args != null) {
+ for (Object o : args) {
+ resp += " " + String.valueOf(o);
+ }
+ }
+ return resp;
+ }
+
+ public Object eval(String source, int lineNo, int columnNo, Object expr) throws BSFException {
+ // not used for the mock tests
+ return null;
+ }
+
+}
diff --git a/sandbox/ant/container.script/src/test/resources/org/apache/tuscany/container/script/foo.componentType b/sandbox/ant/container.script/src/test/resources/org/apache/tuscany/container/script/foo.componentType
new file mode 100644
index 0000000000..9c37e1cb3e
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/resources/org/apache/tuscany/container/script/foo.componentType
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="not.used"/>
+ </service>
+
+</componentType>
diff --git a/sandbox/ant/container.script/src/test/resources/org/apache/tuscany/container/script/foo.mock b/sandbox/ant/container.script/src/test/resources/org/apache/tuscany/container/script/foo.mock
new file mode 100644
index 0000000000..b6fc4c620b
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/resources/org/apache/tuscany/container/script/foo.mock
@@ -0,0 +1 @@
+hello \ No newline at end of file
diff --git a/sandbox/ant/container.script/src/test/resources/org/apache/tuscany/container/script/helper/foo.componentType b/sandbox/ant/container.script/src/test/resources/org/apache/tuscany/container/script/helper/foo.componentType
new file mode 100644
index 0000000000..9c37e1cb3e
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/resources/org/apache/tuscany/container/script/helper/foo.componentType
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="not.used"/>
+ </service>
+
+</componentType>
diff --git a/sandbox/ant/container.script/src/test/resources/org/apache/tuscany/container/script/helper/foo.mock b/sandbox/ant/container.script/src/test/resources/org/apache/tuscany/container/script/helper/foo.mock
new file mode 100644
index 0000000000..b6fc4c620b
--- /dev/null
+++ b/sandbox/ant/container.script/src/test/resources/org/apache/tuscany/container/script/helper/foo.mock
@@ -0,0 +1 @@
+hello \ No newline at end of file
diff --git a/sandbox/ant/implementation-das/pom.xml b/sandbox/ant/implementation-das/pom.xml
new file mode 100644
index 0000000000..6edde7ea7c
--- /dev/null
+++ b/sandbox/ant/implementation-das/pom.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-das</artifactId>
+ <name>Apache Tuscany Data Access Service Implementation</name>
+
+ <repositories>
+ <repository>
+ <id>apache.incubator</id>
+ <url>http://people.apache.org/repo/m2-incubating-repository</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.das</groupId>
+ <artifactId>tuscany-das-rdb</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commonj</groupId>
+ <artifactId>sdo-api-r2.1</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extension-helper</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.1.2.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
diff --git a/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementation.java b/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementation.java
new file mode 100644
index 0000000000..3d5877cb21
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementation.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.das;
+
+/**
+ * The model representing a sample DAS implementation in an SCA assembly model.
+ */
+public class DASImplementation {
+
+ private String config;
+ private String dataAccessType;
+
+ /**
+ * Return the DAS configuration side file
+ *
+ * @return the name of the das configuration side file
+ */
+ public String getConfig() {
+ return config;
+ }
+
+ /**
+ * Sets the DAS configuration side file
+ *
+ * @param config The name of the das configuration side file
+ */
+ public void setConfig(String config) {
+ this.config = config;
+ }
+
+ /**
+ * Return the data store type being used
+ * @return The data store type
+ */
+ public String getDataAccessType() {
+ return dataAccessType;
+ }
+
+ /**
+ * Sets the data store type being used
+ * @param dataAccessType The data store type in use
+ */
+ public void setDataAccessType(String dataAccessType) {
+ this.dataAccessType = dataAccessType;
+ }
+}
diff --git a/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementationActivator.java b/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementationActivator.java
new file mode 100644
index 0000000000..184805188c
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASImplementationActivator.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.das;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.spi.ImplementationActivator;
+import org.apache.tuscany.sca.spi.InvokerFactory;
+
+public class DASImplementationActivator implements ImplementationActivator<DASImplementation>{
+
+ private final DataAccessEngineManager dataAccessEngineManager;
+
+ private static final QName IMPLEMENTATION_DAS = new QName(Constants.SCA10_NS, "implementation.das");
+
+ public DASImplementationActivator() {
+ this.dataAccessEngineManager = new DataAccessEngineManager();
+ }
+
+ public InvokerFactory createInvokerFactory(RuntimeComponent rc, ComponentType ct, DASImplementation impl) {
+ return new DASInvokerFactory(rc, ct, impl, dataAccessEngineManager);
+ }
+
+ public Class<DASImplementation> getImplementationClass() {
+ return DASImplementation.class;
+ }
+
+ public QName getSCDLQName() {
+ return IMPLEMENTATION_DAS;
+ }
+
+}
diff --git a/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASInvoker.java b/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASInvoker.java
new file mode 100644
index 0000000000..0949b41f6e
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASInvoker.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.das;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+/**
+ * Implements a target invoker for DAS component implementations.
+ *
+ * The target invoker is responsible for dispatching invocations to the particular
+ * component implementation logic. The current component implementation will
+ * dispatch calls to the DAS apis to retrieve the requested data from the backend store
+ *
+ */
+public class DASInvoker implements Invoker {
+
+ private final Operation operation;
+ private final DataAccessEngine dataAccessEngine;
+
+ public DASInvoker(Operation operation, DataAccessEngine dataAccessEngine) {
+ this.operation = operation;
+ this.dataAccessEngine = dataAccessEngine;
+ }
+
+ public Message invoke(Message msg) {
+ Object[] args = msg.getBody();
+ Object resp = doTheWork(args);
+ msg.setBody(resp);
+ return msg;
+ }
+
+ public Object doTheWork(Object[] args) {
+ //simple execute command by name
+ if(args==null || args.length < 1){
+ return this.dataAccessEngine.executeCommand(operation.getName());
+ } else {
+ String xPath = (String) args[0];
+ return this.dataAccessEngine.executeCommand(operation.getName(), xPath);
+ }
+ }
+}
diff --git a/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASInvokerFactory.java b/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASInvokerFactory.java
new file mode 100644
index 0000000000..f81cf29202
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DASInvokerFactory.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.das;
+
+import org.apache.tuscany.das.rdb.DAS;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.spi.InvokerFactory;
+import org.osoa.sca.ServiceRuntimeException;
+
+public class DASInvokerFactory implements InvokerFactory {
+
+ DASImplementation impl;
+ DataAccessEngineManager dataAccessEngineManager;
+
+ public DASInvokerFactory(RuntimeComponent rc, ComponentType ct, DASImplementation impl, DataAccessEngineManager dataAccessEngineManager) {
+ this.impl = impl;
+ this.dataAccessEngineManager = dataAccessEngineManager;
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ DAS das = null;
+ try {
+ das = dataAccessEngineManager.getDAS(impl.getConfig());
+ } catch(Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ return new DASInvoker(operation, new DataAccessEngine(das) );
+ }
+
+}
diff --git a/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DataAccessEngine.java b/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DataAccessEngine.java
new file mode 100644
index 0000000000..a847695480
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DataAccessEngine.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.das;
+
+import org.apache.tuscany.das.rdb.Command;
+import org.apache.tuscany.das.rdb.DAS;
+
+import commonj.sdo.DataObject;
+
+/**
+ * Facade to hide DAS implementation details of handling commands
+ */
+public class DataAccessEngine {
+ private final DAS das;
+
+ public DataAccessEngine(DAS das) {
+ this.das = das;
+ }
+
+ public DataObject executeCommand(String commandName) {
+ try {
+ Command command = this.das.getCommand(commandName);
+ return command.executeQuery();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public DataObject executeCommand(String commandName, String xPath) {
+ DataObject root = executeCommand(commandName);
+ return root.getDataObject(xPath);
+ }
+
+}
diff --git a/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DataAccessEngineManager.java b/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DataAccessEngineManager.java
new file mode 100644
index 0000000000..6701ca993c
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/main/java/org/apache/tuscany/sca/implementation/das/DataAccessEngineManager.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.das;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.das.rdb.DAS;
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * The DataAccessEngineManager acts like a registry and factory for DAS instances
+ * It holds DAS by it's config file name, reusing the same DAS for all components
+ * using the same config file.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataAccessEngineManager {
+
+ private final Map<String, DAS> registry = new HashMap<String, DAS>();
+
+ protected DAS initializeDAS(String config) {
+ //load the config file
+ System.out.println("Initializing DAS");
+ DAS das = DAS.FACTORY.createDAS(this.getConfigStream(config));
+
+ return das;
+ }
+
+ protected InputStream getConfigStream(String config) {
+ InputStream configStream = null;
+
+ try {
+ configStream = this.getClass().getResourceAsStream(config);
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+
+ return configStream;
+ }
+
+ public DAS getDAS(String config) {
+ DAS das = registry.get(config);
+ if ( das == null) {
+ das = this.initializeDAS(config);
+ this.registry.put(config, das);
+ }
+ return das;
+ }
+
+
+}
diff --git a/sandbox/ant/implementation-das/src/main/resources/META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator b/sandbox/ant/implementation-das/src/main/resources/META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator
new file mode 100644
index 0000000000..4e48eb63dd
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/main/resources/META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# Implementation class for the ExtensionActivator
+#
+org.apache.tuscany.sca.implementation.das.DASImplementationActivator
diff --git a/sandbox/ant/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/company/CompanyService.java b/sandbox/ant/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/company/CompanyService.java
new file mode 100644
index 0000000000..c487352661
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/company/CompanyService.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.das.company;
+
+import commonj.sdo.DataObject;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CompanyService {
+
+ public DataObject getCompanies();
+
+}
diff --git a/sandbox/ant/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/company/CompanyServiceTestCase.java b/sandbox/ant/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/company/CompanyServiceTestCase.java
new file mode 100644
index 0000000000..24f941a06f
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/java/org/apache/tuscany/sca/implementation/das/company/CompanyServiceTestCase.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.das.company;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+import commonj.sdo.DataObject;
+
+/**
+ * Tests the DAS service
+ */
+public class CompanyServiceTestCase extends TestCase {
+
+ private SCADomain scaDomain;
+ private CompanyService dasCompanyService;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ protected void setUp() throws Exception {
+ scaDomain = SCADomain.newInstance("company.composite");
+ dasCompanyService = scaDomain.getService(CompanyService.class, "CompanyComponent");
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ protected void tearDown() throws Exception {
+ scaDomain.close();
+ }
+
+ public void testExecuteCommand() throws Exception {
+ DataObject root = dasCompanyService.getCompanies();
+ assertNotNull(root);
+ }
+
+
+}
diff --git a/sandbox/ant/implementation-das/src/test/resources/CompanyConfig.xml b/sandbox/ant/implementation-das/src/test/resources/CompanyConfig.xml
new file mode 100644
index 0000000000..2667f86f83
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/CompanyConfig.xml
@@ -0,0 +1,52 @@
+<?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.
+ -->
+<Config xmlns="http:///org.apache.tuscany.das.rdb/config.xsd">
+
+ <ConnectionInfo>
+ <ConnectionProperties
+ driverClass="org.apache.derby.jdbc.EmbeddedDriver"
+ databaseURL="jdbc:derby:target/test-classes/dastest; create = true"
+ loginTimeout="600000"/>
+ </ConnectionInfo>
+
+ <Command name="getCompanies" SQL="select * from COMPANY" kind="Select"/>
+
+ <Command name="all companies" SQL="select * from COMPANY" kind="Select"/>
+
+ <Command name="all companies and departments" SQL="select * from COMPANY left outer join DEPARTMENT on COMPANY.ID = DEPARTMENT.COMPANYID" kind="Select"/>
+
+ <Command name="all departments for company" SQL="select * from COMPANY inner join DEPARTMENT on COMPANY.ID = DEPARTMENT.COMPANYID where COMPANY.ID = ?" kind="Select"/>
+
+ <Command name="company by id with departments" SQL="select * from COMPANY left outer join DEPARTMENT on COMPANY.ID = DEPARTMENT.COMPANYID where COMPANY.ID = ?" kind="Select"/>
+
+ <Table tableName="COMPANY">
+ <Column columnName="ID" primaryKey="true" generated="true"/>
+ </Table>
+
+ <Table tableName="DEPARTMENT">
+ <Column columnName="ID" primaryKey="true" generated="true"/>
+ </Table>
+
+ <Relationship name="departments" primaryKeyTable="COMPANY" foreignKeyTable="DEPARTMENT" many="true">
+ <KeyPair primaryKeyColumn="ID" foreignKeyColumn="COMPANYID"/>
+ </Relationship>
+
+
+</Config>
diff --git a/sandbox/ant/implementation-das/src/test/resources/company.composite b/sandbox/ant/implementation-das/src/test/resources/company.composite
new file mode 100644
index 0000000000..98166bc7b6
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/company.composite
@@ -0,0 +1,31 @@
+<?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"
+ targetNamespace="http://sample/das"
+ name="das">
+
+ <service name="CompanyServiceComponent" promote="CompanyComponent">
+ <interface.java interface="org.apache.tuscany.sca.implementation.das.company.CompanyService"/>
+ </service>
+
+ <component name="CompanyComponent">
+ <implementation.das config="/CompanyConfig.xml" dataAccessType="rdb" />
+ </component>
+</composite>
diff --git a/sandbox/ant/implementation-das/src/test/resources/das.composite b/sandbox/ant/implementation-das/src/test/resources/das.composite
new file mode 100644
index 0000000000..a2b4096b9d
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/das.composite
@@ -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"
+ targetNamespace="http://sample/das"
+ name="das">
+
+ <component name="DASServiceComponent">
+ <implementation.das config="/CompanyConfig.xml" dataAccessType="rdb" />
+ </component>
+
+</composite>
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/log/log.ctrl b/sandbox/ant/implementation-das/src/test/resources/dastest/log/log.ctrl
new file mode 100644
index 0000000000..ee27053d7a
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/log/log.ctrl
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/log/log1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/log/log1.dat
new file mode 100644
index 0000000000..0149980537
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/log/log1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/log/logmirror.ctrl b/sandbox/ant/implementation-das/src/test/resources/dastest/log/logmirror.ctrl
new file mode 100644
index 0000000000..ee27053d7a
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/log/logmirror.ctrl
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c10.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c10.dat
new file mode 100644
index 0000000000..5d8ecaa10f
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c10.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c101.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c101.dat
new file mode 100644
index 0000000000..0f79fa7574
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c101.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c111.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c111.dat
new file mode 100644
index 0000000000..39d49e3d19
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c111.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c121.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c121.dat
new file mode 100644
index 0000000000..2a4311779b
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c121.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c130.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c130.dat
new file mode 100644
index 0000000000..64e3c18d62
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c130.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c141.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c141.dat
new file mode 100644
index 0000000000..0632d04164
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c141.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c150.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c150.dat
new file mode 100644
index 0000000000..10b6a8db65
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c150.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c161.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c161.dat
new file mode 100644
index 0000000000..acee7bc80b
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c161.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c171.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c171.dat
new file mode 100644
index 0000000000..5f415d1c5c
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c171.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c180.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c180.dat
new file mode 100644
index 0000000000..cb9391aed1
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c180.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c191.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c191.dat
new file mode 100644
index 0000000000..d3cf1d6364
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c191.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1a1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1a1.dat
new file mode 100644
index 0000000000..a7a2d536e9
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1a1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1b1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1b1.dat
new file mode 100644
index 0000000000..19097e69e7
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1b1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1c0.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1c0.dat
new file mode 100644
index 0000000000..359525a31a
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1c0.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1d1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1d1.dat
new file mode 100644
index 0000000000..9f257df932
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1d1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1e0.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1e0.dat
new file mode 100644
index 0000000000..e43e52fb7f
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1e0.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1f1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1f1.dat
new file mode 100644
index 0000000000..7e6ee3b1e0
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c1f1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c20.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c20.dat
new file mode 100644
index 0000000000..1be6390f06
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c20.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c200.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c200.dat
new file mode 100644
index 0000000000..b15d56855c
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c200.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c211.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c211.dat
new file mode 100644
index 0000000000..84b0022312
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c211.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c221.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c221.dat
new file mode 100644
index 0000000000..63106a9523
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c221.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c230.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c230.dat
new file mode 100644
index 0000000000..0665ddc16b
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c230.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c241.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c241.dat
new file mode 100644
index 0000000000..835c645a16
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c241.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c251.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c251.dat
new file mode 100644
index 0000000000..d3d6adf4fb
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c251.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c260.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c260.dat
new file mode 100644
index 0000000000..8d7333df7d
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c260.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c271.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c271.dat
new file mode 100644
index 0000000000..af722f7d73
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c271.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c281.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c281.dat
new file mode 100644
index 0000000000..3972983c2e
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c281.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c290.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c290.dat
new file mode 100644
index 0000000000..31577b8124
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c290.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2a1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2a1.dat
new file mode 100644
index 0000000000..0f700d13a7
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2a1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2b1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2b1.dat
new file mode 100644
index 0000000000..1d6382fb3d
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2b1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2c1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2c1.dat
new file mode 100644
index 0000000000..3bc60d886b
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2c1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2d0.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2d0.dat
new file mode 100644
index 0000000000..c542d3c91c
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2d0.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2e1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2e1.dat
new file mode 100644
index 0000000000..16abd20b5f
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2e1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2f0.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2f0.dat
new file mode 100644
index 0000000000..eb26be5932
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c2f0.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c300.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c300.dat
new file mode 100644
index 0000000000..1214f1df4b
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c300.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c31.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c31.dat
new file mode 100644
index 0000000000..18c16f1123
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c31.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c311.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c311.dat
new file mode 100644
index 0000000000..926cbf25b5
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c311.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c320.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c320.dat
new file mode 100644
index 0000000000..07e7bc023c
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c320.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c331.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c331.dat
new file mode 100644
index 0000000000..fd827f9dc2
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c331.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c340.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c340.dat
new file mode 100644
index 0000000000..ca70319886
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c340.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c351.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c351.dat
new file mode 100644
index 0000000000..8fbe2a527c
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c351.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c360.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c360.dat
new file mode 100644
index 0000000000..dcf9c746e1
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c360.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c371.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c371.dat
new file mode 100644
index 0000000000..6f21a840ea
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c371.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c380.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c380.dat
new file mode 100644
index 0000000000..68a5643e15
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c380.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c391.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c391.dat
new file mode 100644
index 0000000000..27006e95a1
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c391.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3a0.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3a0.dat
new file mode 100644
index 0000000000..565dca97ac
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3a0.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3b1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3b1.dat
new file mode 100644
index 0000000000..36894c9818
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3b1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3c0.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3c0.dat
new file mode 100644
index 0000000000..ceedacf6f3
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3c0.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3d1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3d1.dat
new file mode 100644
index 0000000000..195be93689
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3d1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3e0.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3e0.dat
new file mode 100644
index 0000000000..bdab359420
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3e0.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3f1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3f1.dat
new file mode 100644
index 0000000000..dc2d278b57
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c3f1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c400.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c400.dat
new file mode 100644
index 0000000000..3072709cec
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c400.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c41.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c41.dat
new file mode 100644
index 0000000000..61086690f2
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c41.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c411.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c411.dat
new file mode 100644
index 0000000000..ca551d8249
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c411.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c420.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c420.dat
new file mode 100644
index 0000000000..f04de0840e
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c420.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c431.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c431.dat
new file mode 100644
index 0000000000..398b1672cc
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c431.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c440.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c440.dat
new file mode 100644
index 0000000000..af259d0872
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c440.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c451.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c451.dat
new file mode 100644
index 0000000000..772a18c658
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c451.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c460.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c460.dat
new file mode 100644
index 0000000000..505428362d
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c460.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c471.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c471.dat
new file mode 100644
index 0000000000..484d0df42d
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c471.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c481.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c481.dat
new file mode 100644
index 0000000000..faac073076
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c481.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c490.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c490.dat
new file mode 100644
index 0000000000..7585319d21
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c490.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c4a1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c4a1.dat
new file mode 100644
index 0000000000..4fe8b786e3
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c4a1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c51.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c51.dat
new file mode 100644
index 0000000000..7fc7937b15
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c51.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c60.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c60.dat
new file mode 100644
index 0000000000..d1fb08c946
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c60.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c71.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c71.dat
new file mode 100644
index 0000000000..d4c2090a3b
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c71.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c81.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c81.dat
new file mode 100644
index 0000000000..38b6ea6520
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c81.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c90.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c90.dat
new file mode 100644
index 0000000000..620732e253
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/c90.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/ca1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/ca1.dat
new file mode 100644
index 0000000000..51d32658ca
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/ca1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/cb1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/cb1.dat
new file mode 100644
index 0000000000..4e2c8aef68
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/cb1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/cc0.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/cc0.dat
new file mode 100644
index 0000000000..d1eef3bb56
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/cc0.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/cd1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/cd1.dat
new file mode 100644
index 0000000000..c7e6db3ef7
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/cd1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/ce1.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/ce1.dat
new file mode 100644
index 0000000000..8fd3bf17a8
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/ce1.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/cf0.dat b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/cf0.dat
new file mode 100644
index 0000000000..332b3d9a8a
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/seg0/cf0.dat
Binary files differ
diff --git a/sandbox/ant/implementation-das/src/test/resources/dastest/service.properties b/sandbox/ant/implementation-das/src/test/resources/dastest/service.properties
new file mode 100644
index 0000000000..8cfe3b09a5
--- /dev/null
+++ b/sandbox/ant/implementation-das/src/test/resources/dastest/service.properties
@@ -0,0 +1,22 @@
+#C:\apacheSVN\java\target\dastest
+# ********************************************************************
+# *** Please do NOT edit this file. ***
+# *** CHANGING THE CONTENT OF THIS FILE MAY CAUSE DATA CORRUPTION. ***
+# ********************************************************************
+#Fri Feb 17 08:55:29 MST 2006
+SysschemasIndex2Identifier=225
+SyscolumnsIdentifier=144
+SysconglomeratesIndex1Identifier=49
+SysconglomeratesIdentifier=32
+SyscolumnsIndex2Identifier=177
+SysschemasIndex1Identifier=209
+SysconglomeratesIndex3Identifier=81
+SystablesIndex2Identifier=129
+SyscolumnsIndex1Identifier=161
+derby.serviceProtocol=org.apache.derby.database.Database
+SysschemasIdentifier=192
+derby.storage.propertiesId=16
+SysconglomeratesIndex2Identifier=65
+derby.serviceLocale=en_US
+SystablesIdentifier=96
+SystablesIndex1Identifier=113
diff --git a/sandbox/ant/performance/README b/sandbox/ant/performance/README
new file mode 100644
index 0000000000..1a9b32fa02
--- /dev/null
+++ b/sandbox/ant/performance/README
@@ -0,0 +1,10 @@
+Initial stab at doing some performance testing of Tuscany WS, Java and script components
+
+Download Apache JMeter from: http://jakarta.apache.org/site/downloads/downloads_jmeter.cgi
+
+Unzip JMeter, startup with startup script in jakarta-jmeter-2.3\bin folder.
+
+Load testplan, from JMeter: File -> Open, navigate to helloworld1.jmx (in the same folder as this README
+
+
+ \ No newline at end of file
diff --git a/sandbox/ant/performance/helloworld-ws-java-run/pom.xml b/sandbox/ant/performance/helloworld-ws-java-run/pom.xml
new file mode 100644
index 0000000000..4dd43cc9a1
--- /dev/null
+++ b/sandbox/ant/performance/helloworld-ws-java-run/pom.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>helloworld-ws-java-run</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>helloworld-ws-java</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
diff --git a/sandbox/ant/performance/helloworld-ws-java-run/src/test/java/helloworld/HelloWorldTestCase.java b/sandbox/ant/performance/helloworld-ws-java-run/src/test/java/helloworld/HelloWorldTestCase.java
new file mode 100644
index 0000000000..6fd5b2bc65
--- /dev/null
+++ b/sandbox/ant/performance/helloworld-ws-java-run/src/test/java/helloworld/HelloWorldTestCase.java
@@ -0,0 +1,46 @@
+/*
+ * 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 helloworld;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class HelloWorldTestCase extends TestCase {
+
+ private SCADomain scaDomain;
+
+ @Override
+ protected void setUp() throws Exception {
+ scaDomain = SCADomain.newInstance("http://foo", "file:///C:/Tuscany/SVN/sandbox-ant/performance/helloworld-ws-java/target/helloworld-ws-java.jar", null);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ scaDomain.close();
+ }
+
+ public void testCalculator() throws Exception {
+ System.out.println("Hit enter to end...");
+ System.in.read();
+ }
+}
diff --git a/sandbox/ant/performance/helloworld-ws-java/pom.xml b/sandbox/ant/performance/helloworld-ws-java/pom.xml
new file mode 100644
index 0000000000..a1f11ed07e
--- /dev/null
+++ b/sandbox/ant/performance/helloworld-ws-java/pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>helloworld-ws-java</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
diff --git a/sandbox/ant/performance/helloworld-ws-java/src/main/java/helloworld/HelloWorldImpl.java b/sandbox/ant/performance/helloworld-ws-java/src/main/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..0de3c70303
--- /dev/null
+++ b/sandbox/ant/performance/helloworld-ws-java/src/main/java/helloworld/HelloWorldImpl.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldImpl implements HelloWorldService {
+
+ public String getGreetings(String name) {
+ return "Hello " + name;
+ }
+
+}
diff --git a/sandbox/ant/performance/helloworld-ws-java/src/main/java/helloworld/HelloWorldService.java b/sandbox/ant/performance/helloworld-ws-java/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..268d90e910
--- /dev/null
+++ b/sandbox/ant/performance/helloworld-ws-java/src/main/java/helloworld/HelloWorldService.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package helloworld;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+ public String getGreetings(String name);
+}
diff --git a/sandbox/ant/performance/helloworld-ws-java/src/main/resources/META-INF/sca-deployables/application.composite b/sandbox/ant/performance/helloworld-ws-java/src/main/resources/META-INF/sca-deployables/application.composite
new file mode 100644
index 0000000000..00f8135b3d
--- /dev/null
+++ b/sandbox/ant/performance/helloworld-ws-java/src/main/resources/META-INF/sca-deployables/application.composite
@@ -0,0 +1,35 @@
+<?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:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://helloworld"
+ name="helloworldwsjava">
+
+ <component name="HelloWorldComponentJava">
+
+ <implementation.java class="helloworld.HelloWorldImpl" />
+
+ <service name="HelloWorldService">
+ <binding.ws/>
+ </service>
+
+ </component>
+
+</composite>
diff --git a/sandbox/ant/performance/helloworld-ws-js-run/pom.xml b/sandbox/ant/performance/helloworld-ws-js-run/pom.xml
new file mode 100644
index 0000000000..235adc5ab3
--- /dev/null
+++ b/sandbox/ant/performance/helloworld-ws-js-run/pom.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>helloworld-ws-js-run</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-script</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.wso2.wsf.javascript</groupId>
+ <artifactId>axiom-e4x</artifactId>
+ <version>0.29</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>rhino</groupId>
+ <artifactId>js-core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
diff --git a/sandbox/ant/performance/helloworld-ws-js-run/src/test/java/helloworld/HelloWorldTestCase.java b/sandbox/ant/performance/helloworld-ws-js-run/src/test/java/helloworld/HelloWorldTestCase.java
new file mode 100644
index 0000000000..7eb205e5b8
--- /dev/null
+++ b/sandbox/ant/performance/helloworld-ws-js-run/src/test/java/helloworld/HelloWorldTestCase.java
@@ -0,0 +1,46 @@
+/*
+ * 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 helloworld;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class HelloWorldTestCase extends TestCase {
+
+ private SCADomain scaDomain;
+
+ @Override
+ protected void setUp() throws Exception {
+ scaDomain = SCADomain.newInstance("http://foo", "file:///C:/Tuscany/SVN/sandbox-ant/performance/helloworld-ws-js/target/helloworld-ws-js.jar", null);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ scaDomain.close();
+ }
+
+ public void testCalculator() throws Exception {
+ System.out.println("Hit enter to end...");
+ System.in.read();
+ }
+}
diff --git a/sandbox/ant/performance/helloworld-ws-js/pom.xml b/sandbox/ant/performance/helloworld-ws-js/pom.xml
new file mode 100644
index 0000000000..d28dabf17f
--- /dev/null
+++ b/sandbox/ant/performance/helloworld-ws-js/pom.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>helloworld-ws-js</artifactId>
+
+ <repositories>
+ <repository>
+ <id>apache.incubator</id>
+ <url>http://people.apache.org/repo/m2-incubating-repository</url>
+ </repository>
+ <!-- This is for the WSO2 E4X impl -->
+ <repository>
+ <id>wso2</id>
+ <url>http://dist.wso2.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-script</artifactId>
+ <version>1.1-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ <version>1.6R7</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.wso2.wsf.javascript</groupId>
+ <artifactId>axiom-e4x</artifactId>
+ <version>0.29</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>rhino</groupId>
+ <artifactId>js-core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
diff --git a/sandbox/ant/performance/helloworld-ws-js/src/main/resources/META-INF/sca-deployables/application.composite b/sandbox/ant/performance/helloworld-ws-js/src/main/resources/META-INF/sca-deployables/application.composite
new file mode 100644
index 0000000000..38e14845f7
--- /dev/null
+++ b/sandbox/ant/performance/helloworld-ws-js/src/main/resources/META-INF/sca-deployables/application.composite
@@ -0,0 +1,44 @@
+<?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:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://helloworld"
+ name="helloworldwsjs">
+
+ <component name="HelloWorldComponentJS">
+
+ <tuscany:implementation.script language="js"><![CDATA[
+
+ function getGreetings(xmlIn) {
+ return <ns1:getGreetingsResponse xmlns:ns1="http://helloworld">
+ <ns1:getGreetingsReturn>jsHello { xmlIn..*::name.toString() }</ns1:getGreetingsReturn>
+ </ns1:getGreetingsResponse>
+ }
+
+ ]]></tuscany:implementation.script>
+
+ <service name="HelloWorldService">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws/>
+ </service>
+
+ </component>
+
+</composite>
diff --git a/sandbox/ant/performance/helloworld-ws-js/src/main/resources/helloworld.wsdl b/sandbox/ant/performance/helloworld-ws-js/src/main/resources/helloworld.wsdl
new file mode 100644
index 0000000000..0b95fbd14f
--- /dev/null
+++ b/sandbox/ant/performance/helloworld-ws-js/src/main/resources/helloworld.wsdl
@@ -0,0 +1,79 @@
+<?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.
+-->
+<wsdl:definitions targetNamespace="http://helloworld" xmlns:tns="http://helloworld" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="helloworld">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworld" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="getGreetings">
+ <complexType>
+ <sequence>
+ <element name="name" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetingsRequest">
+ <wsdl:part element="tns:getGreetings" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+ <wsdl:part element="tns:getGreetingsResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:portType name="HelloWorld">
+ <wsdl:operation name="getGreetings">
+ <wsdl:input message="tns:getGreetingsRequest" name="getGreetingsRequest"/>
+ <wsdl:output message="tns:getGreetingsResponse" name="getGreetingsResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="HelloWorldSoapBinding" type="tns:HelloWorld">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getGreetings">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="getGreetingsRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="getGreetingsResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="HelloWorldService">
+ <wsdl:port binding="tns:HelloWorldSoapBinding" name="HelloWorldSoapPort">
+ <wsdlsoap:address location="http://localhost:8080/services/HelloWorldWebService"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/ant/performance/helloworld.jmx b/sandbox/ant/performance/helloworld.jmx
new file mode 100644
index 0000000000..f5f028caa9
--- /dev/null
+++ b/sandbox/ant/performance/helloworld.jmx
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jmeterTestPlan version="1.2" properties="1.8">
+ <hashTree>
+ <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
+ <stringProp name="TestPlan.comments"></stringProp>
+ <boolProp name="TestPlan.functional_mode">false</boolProp>
+ <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
+ <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
+ <collectionProp name="Arguments.arguments"/>
+ </elementProp>
+ <stringProp name="TestPlan.user_define_classpath"></stringProp>
+ </TestPlan>
+ <hashTree>
+ <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
+ <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
+ <boolProp name="LoopController.continue_forever">false</boolProp>
+ <intProp name="LoopController.loops">-1</intProp>
+ </elementProp>
+ <stringProp name="ThreadGroup.num_threads">1</stringProp>
+ <stringProp name="ThreadGroup.ramp_time">1</stringProp>
+ <longProp name="ThreadGroup.start_time">1193655867000</longProp>
+ <longProp name="ThreadGroup.end_time">1193655867000</longProp>
+ <boolProp name="ThreadGroup.scheduler">false</boolProp>
+ <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
+ <stringProp name="ThreadGroup.duration"></stringProp>
+ <stringProp name="ThreadGroup.delay"></stringProp>
+ </ThreadGroup>
+ <hashTree>
+ <SoapSampler guiclass="SoapSamplerGui" testclass="SoapSampler" testname="SOAP/XML-RPC Request" enabled="true">
+ <elementProp name="HTTPsampler.Arguments" elementType="Arguments">
+ <collectionProp name="Arguments.arguments"/>
+ </elementProp>
+ <stringProp name="SoapSampler.URL_DATA">http://localhost:8080/HelloWorldComponentJS</stringProp>
+ <stringProp name="HTTPSamper.xml_data">&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;
+ &lt;soapenv:Header&gt;
+ &lt;To xmlns=&quot;http://www.w3.org/2005/08/addressing&quot;&gt;
+ &lt;wsa:Address xmlns:wsa=&quot;http://www.w3.org/2005/08/addressing&quot;&gt;http://localhost:8089/HelloWorldService&lt;/wsa:Address&gt;
+ &lt;/To&gt;
+ &lt;/soapenv:Header&gt;
+ &lt;soapenv:Body&gt;
+ &lt;_ns_:getGreetings xmlns:_ns_=&quot;http://helloworld&quot;&gt;
+ &lt;_ns_:name&gt;World&lt;/_ns_:name&gt;
+ &lt;/_ns_:getGreetings&gt;
+ &lt;/soapenv:Body&gt;
+ &lt;/soapenv:Envelope&gt;</stringProp>
+ <stringProp name="SoapSampler.xml_data_file"></stringProp>
+ <stringProp name="SoapSampler.SOAP_ACTION"></stringProp>
+ <stringProp name="SoapSampler.SEND_SOAP_ACTION">true</stringProp>
+ </SoapSampler>
+ <hashTree/>
+ <ResultCollector guiclass="GraphVisualizer" testclass="ResultCollector" testname="Graph Results" enabled="true">
+ <boolProp name="ResultCollector.error_logging">false</boolProp>
+ <objProp>
+ <value class="SampleSaveConfiguration">
+ <time>true</time>
+ <latency>true</latency>
+ <timestamp>true</timestamp>
+ <success>true</success>
+ <label>true</label>
+ <code>true</code>
+ <message>true</message>
+ <threadName>true</threadName>
+ <dataType>true</dataType>
+ <encoding>false</encoding>
+ <assertions>true</assertions>
+ <subresults>true</subresults>
+ <responseData>false</responseData>
+ <samplerData>false</samplerData>
+ <xml>true</xml>
+ <fieldNames>false</fieldNames>
+ <responseHeaders>false</responseHeaders>
+ <requestHeaders>false</requestHeaders>
+ <responseDataOnError>false</responseDataOnError>
+ <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
+ <assertionsResultsToSave>0</assertionsResultsToSave>
+ <bytes>true</bytes>
+ </value>
+ <name>saveConfig</name>
+ </objProp>
+ <stringProp name="filename"></stringProp>
+ </ResultCollector>
+ <hashTree/>
+ </hashTree>
+ </hashTree>
+ </hashTree>
+</jmeterTestPlan>
diff --git a/sandbox/ant/relax-ws/DISCLAIMER b/sandbox/ant/relax-ws/DISCLAIMER
new file mode 100644
index 0000000000..d68a410903
--- /dev/null
+++ b/sandbox/ant/relax-ws/DISCLAIMER
@@ -0,0 +1,8 @@
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
diff --git a/sandbox/ant/relax-ws/LICENSE b/sandbox/ant/relax-ws/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sandbox/ant/relax-ws/LICENSE
@@ -0,0 +1,205 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+
diff --git a/sandbox/ant/relax-ws/NOTICE b/sandbox/ant/relax-ws/NOTICE
new file mode 100644
index 0000000000..aeeca5ef8d
--- /dev/null
+++ b/sandbox/ant/relax-ws/NOTICE
@@ -0,0 +1,8 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
+This product uses Relax WS (http://code.google.com/p/relax-ws/) with the following copyright:
+ * Copyright 2008 Jason Sando
diff --git a/sandbox/ant/relax-ws/pom.xml b/sandbox/ant/relax-ws/pom.xml
new file mode 100644
index 0000000000..483008859e
--- /dev/null
+++ b/sandbox/ant/relax-ws/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>1.2-incubating-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-interface-relax-ws</artifactId>
+ <name>Apache Tuscany SCA Relax WS Interface</name>
+
+ <repositories>
+ <repository>
+ <!-- for relaxws -->
+ <id>antelder.apache</id>
+ <url>http://people.apache.org/~antelder/maven</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl-xml</artifactId>
+ <version>1.2-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.p.relaxws</groupId>
+ <artifactId>relaxws</artifactId>
+ <version>0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.p.relaxws</groupId>
+ <artifactId>isorelax</artifactId>
+ <version>0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.p.relaxws</groupId>
+ <artifactId>jing</artifactId>
+ <version>0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.p.relaxws</groupId>
+ <artifactId>trang</artifactId>
+ <version>0.1</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/Convert2Wsdl.java b/sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/Convert2Wsdl.java
new file mode 100644
index 0000000000..33726a6f8c
--- /dev/null
+++ b/sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/Convert2Wsdl.java
@@ -0,0 +1,342 @@
+/*
+ * Copyright 2008 Jason Sando
+ *
+ * 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.
+ */
+package org.apache.tuscany.sca.interfacedef.relaxws;
+
+import com.thaiopensource.relaxng.edit.SchemaCollection;
+import com.thaiopensource.relaxng.input.InputFailedException;
+import com.thaiopensource.relaxng.input.InputFormat;
+import com.thaiopensource.relaxng.input.parse.compact.CompactParseInputFormat;
+import com.thaiopensource.relaxng.output.LocalOutputDirectory;
+import com.thaiopensource.relaxng.output.OutputDirectory;
+import com.thaiopensource.relaxng.output.OutputFormat;
+import com.thaiopensource.relaxng.output.xsd.XsdOutputFormat;
+import com.thaiopensource.xml.sax.ErrorHandlerImpl;
+import com.google.code.p.relaxws.parser.*;
+
+import java.io.*;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * TUSCANY: change to support calling programatically
+ * - avoid using Files
+ * - add constructor
+ * - make convert method public
+ */
+
+/**
+ * Convert from relaxws-wiz to wsdl.
+ *
+ * 1. parse the input file
+ * 2. append all rnc blocks into a single buffer, then convert to XSD, to be
+ * embedded in the wsdl.
+ * 3. Output wsdl.
+ */
+public class Convert2Wsdl {
+
+ private PrintWriter out;
+ private ASTservice tree;
+
+ private static void usage (String reason) {
+ if (reason != null)
+ System.err.println ("Command failed: " + reason);
+ System.err.println ("\nUSAGE:");
+ System.err.println("Convert2Wsdl [-d output-folder] <input.rws>");
+ System.exit (1);
+ }
+
+ private static void fail (String reason) {
+ if (reason != null)
+ System.err.println ("Command failed: " + reason);
+ System.exit (1);
+ }
+
+ private static String fileBase (String name) {
+ int dot = name.lastIndexOf('.');
+ if (dot != -1) {
+ name = name.substring (0, dot);
+ }
+ return name;
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ String outputPath = null;
+ String inputFilePath = null;
+
+ int lastArg = args.length - 1;
+ for (int i = 0; i < args.length; i++) {
+ if ("-d".equals (args[i]) && (i < lastArg)) {
+ outputPath = args[i + 1];
+ i++;
+ } else if (args[i].startsWith("-")) {
+ usage("unrecognized option " + args[i]);
+ } else {
+ if (inputFilePath != null) {
+ usage("Multiple input files specified: " + inputFilePath + "," + args[i]);
+ }
+ inputFilePath = args[i];
+ }
+ }
+
+ if (inputFilePath == null) {
+ usage(null);
+ }
+
+ File inputFile = new File (inputFilePath);
+ if (!inputFile.exists()) {
+ fail ("'" + inputFilePath + "' not found.");
+ }
+ if (outputPath == null) {
+ outputPath = inputFile.getParent();
+ }
+
+ File outputFileDir = new File (outputPath);
+ if (!outputFileDir.exists()) {
+ if (!outputFileDir.mkdirs()) {
+ fail ("failed to create output folder '" + outputPath + "'");
+ }
+ }
+
+ BufferedReader rdr = new BufferedReader (new FileReader(inputFile));
+ RelaxWizParser p = new RelaxWizParser (rdr);
+ ASTservice tree = p.service ();
+
+ File outputFile = new File(outputFileDir, fileBase(inputFile.getName()) + ".wsdl");
+ System.err.println("Convert2Wsdl: processing '" + inputFile.getName() + "' to '" + outputFile.getPath());
+
+ PrintWriter out = new PrintWriter(new FileWriter(outputFile));
+
+ Convert2Wsdl converter = new Convert2Wsdl(tree, out);
+ converter.convert();
+
+ out.close();
+ }
+
+ public Convert2Wsdl(ASTservice tree, PrintWriter out) {
+ this.tree = tree;
+ this.out = out;
+ }
+
+ public void convert() throws Exception {
+
+ if (tree.getNamespace() == null) {
+ tree.setNamespace("http://tempuri.org/" + tree.getName());
+ }
+ String ns = tree.getNamespace();
+
+ out.print ("<?xml version=\"1.0\"?>\n");
+ out.print ("<definitions name=\"" + tree.getName() + "\"\n" +
+ " targetNamespace=\"" + ns + "\"\n" +
+ " xmlns:tns=\"" + ns + "\"\n" +
+ " xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\"\n" +
+ " xmlns=\"http://schemas.xmlsoap.org/wsdl/\">\n" +
+ "\n" +
+ " <types>\n");
+
+ // Make a pass through and assign all message names, and build proper rnc block
+ Set<String> messageNames = new HashSet<String>();
+ StringBuffer rncBuff = new StringBuffer();
+ rncBuff.append ("default namespace = \"" + ns + "\"\n");
+// rncBuff.append ("(\n");
+ for (Node portNode: tree.getChildren()) {
+ if (portNode instanceof ASTtypesDecl) {
+ rncBuff.append(((ASTtypesDecl) portNode).getRnc());
+ continue;
+ }
+
+ ASTportDecl port = (ASTportDecl) portNode;
+
+ // patch up default name if not set.
+ if (port.getName() == null) {
+ port.setName (tree.getName() + "Port");
+ }
+
+ // enumerate operations in this port
+ for (Node opNode: port.getChildren()) {
+ ASToperationDecl op = (ASToperationDecl) opNode;
+
+ // children of op node
+ for (Node msgNode: op.getChildren()) {
+ ASTMessageDef message = (ASTMessageDef) msgNode;
+ message.setDefaultMessageName(op.getName());
+
+ if (messageNames.contains(message.getMessageName())) {
+ // todo: loop searching for unique name
+ message.setMessageName(message.getMessageName() + "1");
+ } else {
+ messageNames.add(message.getMessageName());
+ }
+
+ if (message.getName() == null) {
+ message.setDefaultName (op.getName());
+ }
+
+ rncBuff.append (message.getName() + " = ");
+ rncBuff.append ("element " + message.getName() + " {\n");
+ String s = message.getRnc();
+ if (s.trim().length() == 0) {
+ s = "text";
+ }
+ rncBuff.append (s);
+ rncBuff.append ("}\n");
+ }
+ }
+ }
+// rncBuff.append (")");
+
+ // convert rnc to xsd
+ String xsdText = toXsd(rncBuff.toString());
+ out.print (xsdText);
+
+ out.print (" </types>\n");
+
+ // declare messages for each in and out of each operation for each port (must be unique)
+ out.println ();
+ for (Node portNode: tree.getChildren()) {
+
+ if (portNode instanceof ASTtypesDecl) {
+ continue;
+ }
+
+ ASTportDecl port = (ASTportDecl) portNode;
+
+ // enumerate operations in this port
+ for (Node opNode: port.getChildren()) {
+ ASToperationDecl op = (ASToperationDecl) opNode;
+
+ // children of op node
+ for (Node msgNode: op.getChildren()) {
+ ASTMessageDef message = (ASTMessageDef) msgNode;
+ // declare message type
+ out.println (" <message name=\"" + message.getMessageName() + "\">");
+ out.println (" <part name=\"body\" element=\"tns:" + message.getName() + "\"/>");
+ out.println (" </message>");
+ }
+
+ }
+
+ out.println ();
+ out.println (" <portType name=\"" + port.getName() + "\">");
+ for (Node opNode: port.getChildren()) {
+ ASToperationDecl op = (ASToperationDecl) opNode;
+
+ out.println (" <operation name=\"" + op.getName() + "\">");
+
+ // children of op node
+ for (Node msgNode: op.getChildren()) {
+ ASTMessageDef message = (ASTMessageDef) msgNode;
+
+ switch (message.getType()) {
+ case In:
+ out.println (" <input message=\"tns:" + message.getMessageName() + "\"/>");
+ break;
+
+ case Out:
+ out.println (" <output message=\"tns:" + message.getMessageName() + "\"/>");
+ break;
+
+ case Fault:
+ // todo
+ }
+ }
+
+ out.println (" </operation>");
+ }
+ out.println (" </portType>");
+
+ // binding to soap
+ out.println ();
+ out.println (" <binding name=\"" + port.getName() + "SoapBinding\" type=\"tns:" + port.getName() + "\">");
+ out.println (" <soap:binding style=\"document\" transport=\"http://schemas.xmlsoap.org/soap/http\"/>");
+ for (Node opNode: port.getChildren()) {
+ ASToperationDecl op = (ASToperationDecl) opNode;
+
+ out.println (" <operation name=\"" + op.getName() + "\">");
+ out.println (" <soap:operation soapAction=\"" + ns + "/" + port.getName() + "#" + op.getName() + "\"/>");
+ out.println (" <input>\n" +
+ " <soap:body use=\"literal\"/>\n" +
+ " </input>\n" +
+ " <output>\n" +
+ " <soap:body use=\"literal\"/>\n" +
+ " </output>");
+ out.println (" </operation>");
+ }
+ out.println (" </binding>");
+
+ out.println();
+ out.println (" <service name=\"" + tree.getName() + port.getName() + "Service\">\n" +
+ " <port name=\"" + port.getName() + "\" binding=\"tns:" + port.getName() + "SoapBinding\">\n" +
+ " <soap:address location=\"http://example.com/" + tree.getName() + "\"/>\n" +
+ " </port>\n" +
+ " </service>");
+ }
+
+
+ out.print ("</definitions>\n");
+ out.close();
+ }
+
+ private static String toXsd (String rnc) throws Exception {
+
+ // write the rnc to a temp file
+ File rncInput = File.createTempFile("relaxwiz", ".rnc");
+ FileWriter fw = new FileWriter (rncInput);
+ fw.write(rnc);
+ fw.close();
+
+ // Use Trang to convert to an XSD file
+ InputFormat inFormat = new CompactParseInputFormat();
+ ErrorHandlerImpl handler = new ErrorHandlerImpl();
+ SchemaCollection sc = null;
+ try {
+ sc = inFormat.load(new URL("file", "", rncInput.getAbsolutePath()).toString(), new String[0], "xsd", handler);
+ } catch (InputFailedException e) {
+ System.err.println("Error in RNC preprocessor, source follows:");
+ int line = 0;
+ for (String s: rnc.split("\n")) {
+ line++;
+ System.err.printf("%3d: %s\n", line, s);
+ }
+ System.exit (1);
+ }
+ OutputFormat of = new XsdOutputFormat();
+ File xsdOutput = File.createTempFile("relaxwiz", ".xsd");
+ OutputDirectory od = new LocalOutputDirectory(sc.getMainUri(),
+ xsdOutput,
+ "xsd",
+ "UTF-8",
+ 80,
+ 2);
+ String[] outParams = new String[]{new URL("file", "", xsdOutput.getAbsolutePath()).toString()};
+ of.output(sc, od, new String[]{}, "rnc", handler);
+
+ // read in file and return as string.
+ BufferedReader reader = new BufferedReader(new FileReader (xsdOutput));
+ String line;
+ StringBuffer buf = new StringBuffer();
+ while ((line = reader.readLine()) != null) {
+ if (line.startsWith("<?xml")) {
+ continue;
+ }
+ buf.append (line).append ('\n');
+ }
+ reader.close();
+ return buf.toString();
+ }
+
+}
diff --git a/sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSDocumentProcessor.java b/sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSDocumentProcessor.java
new file mode 100644
index 0000000000..0bf9ccbee8
--- /dev/null
+++ b/sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSDocumentProcessor.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.sca.interfacedef.relaxws;
+
+import java.net.URI;
+import java.net.URL;
+
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.xml.WSDLLocator;
+import javax.wsdl.xml.WSDLReader;
+
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+
+/**
+ * An ArtifactProcessor for Relax WS documents.
+ * For files with the .rws suffix this creates a RelaxWSModel instance which will
+ *
+ *
+ *
+ */
+public class RelaxWSDocumentProcessor implements URLArtifactProcessor<RelaxWSModel> {
+
+ private WSDLFactory factory;
+
+ public RelaxWSDocumentProcessor(ModelFactoryExtensionPoint modelFactories) {
+ this.factory = modelFactories.getFactory(WSDLFactory.class);
+ }
+
+ public RelaxWSModel read(URL contributionURL, URI artifactURI, URL artifactURL) throws ContributionReadException {
+
+ try {
+
+ javax.wsdl.factory.WSDLFactory wsdlFactory = javax.wsdl.factory.WSDLFactory.newInstance();
+ WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.verbose",false);
+ wsdlReader.setFeature("javax.wsdl.importDocuments",false);
+
+ WSDLLocator locator = new RelaxWSWSDLLocator(artifactURL);
+ Definition definition = wsdlReader.readWSDL(locator);
+ WSDLDefinition wsdlDefinition = factory.createWSDLDefinition();
+
+ wsdlDefinition.setDefinition(definition);
+ wsdlDefinition.setUnresolved(true);
+ wsdlDefinition.setNamespace(definition.getTargetNamespace());
+ wsdlDefinition.setUnresolved(false);
+
+ RelaxWSModel rwsModel = new RelaxWSModel(wsdlDefinition);
+ return rwsModel;
+
+ } catch (WSDLException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+
+ public String getArtifactType() {
+ return ".rws";
+ }
+
+ public Class<RelaxWSModel> getModelType() {
+ return RelaxWSModel.class;
+ }
+
+ public void resolve(RelaxWSModel arg0, ModelResolver arg1) throws ContributionResolveException {
+ }
+
+}
diff --git a/sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSModel.java b/sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSModel.java
new file mode 100644
index 0000000000..c47a5853a5
--- /dev/null
+++ b/sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSModel.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.relaxws;
+
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+
+/**
+ * Model object for Relax WS documents.
+ * Just a holder for a WSDLDefinition needed so the RelaxWSModelResolver
+ * can get a hook in to add the WSDLDefinition to the WSDLModelResolver
+ */
+public class RelaxWSModel {
+
+ protected WSDLDefinition wsdlDefinition;
+
+ public RelaxWSModel(WSDLDefinition wsdlDefinition) {
+ this.wsdlDefinition = wsdlDefinition;
+ }
+
+ public WSDLDefinition getWsdlDefinition() {
+ return wsdlDefinition;
+ }
+
+}
diff --git a/sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSModelResolver.java b/sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSModelResolver.java
new file mode 100644
index 0000000000..190f1d2b81
--- /dev/null
+++ b/sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSModelResolver.java
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.relaxws;
+
+import static org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLModelResolver.XSD_QNAME_LIST;
+
+import java.net.URI;
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Types;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.UnknownExtensibilityElement;
+import javax.wsdl.extensions.schema.Schema;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.XSDefinition;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ * A ModelResolver that takes a RelaxWSModel object and gives the
+ * underlying WSDLDefinition to the WSDL model resolver.
+ */
+public class RelaxWSModelResolver implements ModelResolver {
+
+ private ModelResolver modelresolver;
+ Contribution contribution;
+ private WSDLFactory wsdlFactory;
+
+ public RelaxWSModelResolver(Contribution contribution, ModelFactoryExtensionPoint modelFactories) {
+ modelresolver = contribution.getModelResolver();
+ this.contribution = contribution;
+ this.wsdlFactory = modelFactories.getFactory(WSDLFactory.class);
+ }
+
+ public void addModel(Object arg0) {
+ RelaxWSModel rwsModel = (RelaxWSModel)arg0;
+ readInlineSchemas(rwsModel.wsdlDefinition, rwsModel.wsdlDefinition.getDefinition());
+ modelresolver.addModel(rwsModel.wsdlDefinition);
+ }
+
+ public Object removeModel(Object arg0) {
+ RelaxWSModel rwsModel = (RelaxWSModel)arg0;
+ return modelresolver.removeModel(rwsModel.wsdlDefinition);
+ }
+
+ public <T> T resolveModel(Class<T> arg0, T arg1) {
+ // nothing needed for RelaxWSModelResolver
+ return null;
+ }
+
+ // TODO following methods are a direct copy from the WSDLModelResolver
+ // need to refactor so the code can be shared
+
+ protected void readInlineSchemas(WSDLDefinition wsdlDefinition, Definition definition) {
+ if (contribution == null) {
+ // Check null for test cases
+ return;
+ }
+ Types types = definition.getTypes();
+ if (types != null) {
+ int index = 0;
+ for (Object ext : types.getExtensibilityElements()) {
+ ExtensibilityElement extElement = (ExtensibilityElement)ext;
+ Element element = null;
+ if (XSD_QNAME_LIST.contains(extElement.getElementType())) {
+ if (extElement instanceof Schema) {
+ element = ((Schema)extElement).getElement();
+ } else if (extElement instanceof UnknownExtensibilityElement) {
+ element = ((UnknownExtensibilityElement)extElement).getElement();
+ }
+ }
+ if (element != null) {
+ Document doc = promote(element);
+ XSDefinition xsDefinition = wsdlFactory.createXSDefinition();
+ xsDefinition.setUnresolved(true);
+ xsDefinition.setNamespace(element.getAttribute("targetNamespace"));
+ xsDefinition.setDocument(doc);
+ xsDefinition.setLocation(URI.create(doc.getDocumentURI() + "#" + index));
+ XSDefinition resolved =
+ contribution.getModelResolver().resolveModel(XSDefinition.class, xsDefinition);
+ if (resolved != null && !resolved.isUnresolved()) {
+ if (!wsdlDefinition.getXmlSchemas().contains(resolved)) {
+ wsdlDefinition.getXmlSchemas().add(xsDefinition);
+ }
+ }
+ index++;
+ }
+ }
+ }
+ for (Object imports : definition.getImports().values()) {
+ List impList = (List)imports;
+ for (Object i : impList) {
+ javax.wsdl.Import anImport = (javax.wsdl.Import)i;
+ // Read inline schemas
+ if (anImport.getDefinition() != null) {
+ readInlineSchemas(wsdlDefinition, anImport.getDefinition());
+ }
+ }
+ }
+ }
+
+ private Document promote(Element element) {
+ Document doc = (Document)element.getOwnerDocument().cloneNode(false);
+ Element schema = (Element)doc.importNode(element, true);
+ doc.appendChild(schema);
+ Node parent = element.getParentNode();
+ while (parent instanceof Element) {
+ Element root = (Element)parent;
+ NamedNodeMap nodeMap = root.getAttributes();
+ for (int i = 0; i < nodeMap.getLength(); i++) {
+ Attr attr = (Attr)nodeMap.item(i);
+ String name = attr.getName();
+ if ("xmlns".equals(name) || name.startsWith("xmlns:")) {
+ if (schema.getAttributeNode(name) == null) {
+ schema.setAttributeNodeNS((Attr)doc.importNode(attr, true));
+ }
+ }
+ }
+ parent = parent.getParentNode();
+ }
+ doc.setDocumentURI(element.getOwnerDocument().getDocumentURI());
+ return doc;
+ }
+
+}
diff --git a/sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSWSDLLocator.java b/sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSWSDLLocator.java
new file mode 100644
index 0000000000..d5b12eef95
--- /dev/null
+++ b/sandbox/ant/relax-ws/src/main/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSWSDLLocator.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.relaxws;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.net.URL;
+
+import javax.wsdl.xml.WSDLLocator;
+
+import org.xml.sax.InputSource;
+
+import com.google.code.p.relaxws.parser.RelaxWizParser;
+
+/**
+ * WSDLLocator for reading a Relax WS .rws file into a WSDL4J Definition
+ */
+public class RelaxWSWSDLLocator implements WSDLLocator {
+
+ URL rwsURL;
+ String wsdlString;
+
+ public RelaxWSWSDLLocator(URL rwsURL) {
+ this.rwsURL = rwsURL;
+ }
+
+ public void close() {
+ }
+
+ public InputSource getBaseInputSource() {
+ if (wsdlString == null) {
+ try {
+ convertRwsToWsdl();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return new InputSource(new StringReader(wsdlString));
+ }
+
+ protected void convertRwsToWsdl() throws Exception {
+ RelaxWizParser parser = new RelaxWizParser (new BufferedReader (new InputStreamReader(rwsURL.openStream())));
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ Convert2Wsdl convertor = new Convert2Wsdl(parser.service(), new PrintWriter(baos));
+ convertor.convert();
+ wsdlString = baos.toString();
+ }
+
+ public String getBaseURI() {
+ return rwsURL.toString();
+ }
+
+ public InputSource getImportInputSource(String arg0, String arg1) {
+ return null;
+ }
+
+ public String getLatestImportURI() {
+ return null;
+ }
+
+}
diff --git a/sandbox/ant/relax-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/sandbox/ant/relax-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
new file mode 100644
index 0000000000..2a0baf793c
--- /dev/null
+++ b/sandbox/ant/relax-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.interfacedef.relaxws.RelaxWSDocumentProcessor;type=.rws,model=org.apache.tuscany.sca.interfacedef.relaxws.RelaxWSModel
diff --git a/sandbox/ant/relax-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/sandbox/ant/relax-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
new file mode 100644
index 0000000000..a173f77a52
--- /dev/null
+++ b/sandbox/ant/relax-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+org.apache.tuscany.sca.interfacedef.relaxws.RelaxWSModelResolver;model=org.apache.tuscany.sca.interfacedef.relaxws.RelaxWSModel
diff --git a/sandbox/ant/relax-ws/src/test/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSTestCase.java b/sandbox/ant/relax-ws/src/test/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSTestCase.java
new file mode 100644
index 0000000000..30b53c0e7b
--- /dev/null
+++ b/sandbox/ant/relax-ws/src/test/java/org/apache/tuscany/sca/interfacedef/relaxws/RelaxWSTestCase.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.interfacedef.relaxws;
+
+import java.net.URL;
+
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.xml.WSDLReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.interfacedef.relaxws.RelaxWSWSDLLocator;
+
+public class RelaxWSTestCase extends TestCase {
+
+ public void testConvert() throws WSDLException {
+ URL rwsURL = this.getClass().getClassLoader().getResource("org/apache/tuscany/sca/interfacedef/relaxws/helloworld.rws");
+ RelaxWSWSDLLocator locator = new RelaxWSWSDLLocator(rwsURL);
+ javax.wsdl.factory.WSDLFactory wsdlFactory = javax.wsdl.factory.WSDLFactory.newInstance();
+ WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.verbose",false);
+ wsdlReader.setFeature("javax.wsdl.importDocuments",false);
+ Definition definition = wsdlReader.readWSDL(locator);
+ assertNotNull(definition);
+ }
+}
diff --git a/sandbox/ant/relax-ws/src/test/resources/org/apache/tuscany/sca/interfacedef/relaxws/helloworld.rws b/sandbox/ant/relax-ws/src/test/resources/org/apache/tuscany/sca/interfacedef/relaxws/helloworld.rws
new file mode 100644
index 0000000000..602298e8ee
--- /dev/null
+++ b/sandbox/ant/relax-ws/src/test/resources/org/apache/tuscany/sca/interfacedef/relaxws/helloworld.rws
@@ -0,0 +1,21 @@
+#
+# This is "hello world" in relax-ws.
+#
+namespace http://tuscany.apache.org/samples
+
+service HelloWorld {
+
+ port {
+ operation SayHello {
+ in {
+ element name {xsd:string}
+ }
+
+ out {
+ element message {xsd:string}
+ }
+
+ }
+
+ }
+} \ No newline at end of file
diff --git a/sandbox/ant/sample.php/pom.xml b/sandbox/ant/sample.php/pom.xml
new file mode 100644
index 0000000000..0dfc5f0686
--- /dev/null
+++ b/sandbox/ant/sample.php/pom.xml
@@ -0,0 +1,74 @@
+<?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.samples.sca</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-php-helloworld</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany helloworld Sample using PHP</name>
+ <description>A helloworld sample using a single SCA PHP component</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>container-jsr223</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency> <!-- Strangely, the JSR223 PHP engine has a dependency on the servlet API -->
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.3</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>helloworld.HelloWorldClient</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/ant/sample.php/src/main/java/helloworld/HelloWorldClient.java b/sandbox/ant/sample.php/src/main/java/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..8c83ee7c4a
--- /dev/null
+++ b/sandbox/ant/sample.php/src/main/java/helloworld/HelloWorldClient.java
@@ -0,0 +1,35 @@
+/*
+ * 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 helloworld;
+
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * This client program shows how to create an SCA runtime, start it, locate the HelloWorld service and invoke it.
+ */
+public class HelloWorldClient {
+ public static void main(String[] args) throws Exception {
+
+ HelloWorldService helloWorldService = CurrentCompositeContext.getContext().
+ locateService(HelloWorldService.class, "HelloWorldComponent");
+
+ System.out.println(helloWorldService.sayHello(args.length < 1 ? "world" : args[0]));
+
+ }
+}
diff --git a/sandbox/ant/sample.php/src/main/java/helloworld/HelloWorldService.java b/sandbox/ant/sample.php/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..fd126a197a
--- /dev/null
+++ b/sandbox/ant/sample.php/src/main/java/helloworld/HelloWorldService.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 helloworld;
+
+public interface HelloWorldService {
+
+ String sayHello(String s);
+
+}
diff --git a/sandbox/ant/sample.php/src/main/resources/HelloWorld.componentType b/sandbox/ant/sample.php/src/main/resources/HelloWorld.componentType
new file mode 100644
index 0000000000..75b44eba2a
--- /dev/null
+++ b/sandbox/ant/sample.php/src/main/resources/HelloWorld.componentType
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </service>
+
+</componentType>
diff --git a/sandbox/ant/sample.php/src/main/resources/HelloWorld.php b/sandbox/ant/sample.php/src/main/resources/HelloWorld.php
new file mode 100644
index 0000000000..f272383720
--- /dev/null
+++ b/sandbox/ant/sample.php/src/main/resources/HelloWorld.php
@@ -0,0 +1,7 @@
+<?
+
+function sayHello($value) {
+ return "Hello " . $value;
+}
+
+?>
diff --git a/sandbox/ant/sample.php/src/main/resources/META-INF/sca/default.scdl b/sandbox/ant/sample.php/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..eb8b87a6ca
--- /dev/null
+++ b/sandbox/ant/sample.php/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="HelloWorldComposite">
+
+ <component name="HelloWorldComponent">
+ <implementation.script script="HelloWorld.php"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/sample.php/src/test/java/helloworld/HelloWorldTestCase.java b/sandbox/ant/sample.php/src/test/java/helloworld/HelloWorldTestCase.java
new file mode 100644
index 0000000000..0b667829ef
--- /dev/null
+++ b/sandbox/ant/sample.php/src/test/java/helloworld/HelloWorldTestCase.java
@@ -0,0 +1,56 @@
+/*
+ * 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 helloworld;
+
+import java.io.FileReader;
+import java.net.URL;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * This shows how to test the HelloWorld service component.
+ */
+public class HelloWorldTestCase extends SCATestCase {
+
+ private CompositeContext context;
+
+ protected void setUp() throws Exception {
+ URL scdl = getClass().getClassLoader().getResource("META-INF/sca/script.system.scdl");
+ addExtension("ScriptContainer", scdl);
+ setApplicationSCDL(HelloWorldClient.class, "META-INF/sca/default.scdl");
+ super.setUp();
+
+ context = CurrentCompositeContext.getContext();
+ }
+
+ protected void tearDown() throws Exception {
+ }
+
+ public void testHelloWorld() throws Exception {
+
+ HelloWorldService helloWorldService = context.locateService(HelloWorldService.class, "HelloWorldComponent");
+ assertEquals(helloWorldService.sayHello("petra"), "Hello petra");
+ }
+
+}
diff --git a/sandbox/ant/sample.script.async/LICENSE.txt b/sandbox/ant/sample.script.async/LICENSE.txt
new file mode 100644
index 0000000000..0084319535
--- /dev/null
+++ b/sandbox/ant/sample.script.async/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/sandbox/ant/sample.script.async/NOTICE.txt b/sandbox/ant/sample.script.async/NOTICE.txt
new file mode 100644
index 0000000000..d83ebbe236
--- /dev/null
+++ b/sandbox/ant/sample.script.async/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/sandbox/ant/sample.script.async/pom.xml b/sandbox/ant/sample.script.async/pom.xml
new file mode 100644
index 0000000000..1c054d9441
--- /dev/null
+++ b/sandbox/ant/sample.script.async/pom.xml
@@ -0,0 +1,74 @@
+<?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.samples.sca</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>sample-script-async</artifactId>
+ <packaging>jar</packaging>
+ <name>Tuscany Async Script Sample</name>
+ <description>A Tuscany sample demonstrating async with the script container</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r0.95</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.services.containers</groupId>
+ <artifactId>tuscany-script</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ <version>1.6R2</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0-incubator-M2-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>helloworld.HelloWorldClient</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sandbox/ant/sample.script.async/src/main/java/sample/AsyncClient.java b/sandbox/ant/sample.script.async/src/main/java/sample/AsyncClient.java
new file mode 100644
index 0000000000..4115757f88
--- /dev/null
+++ b/sandbox/ant/sample.script.async/src/main/java/sample/AsyncClient.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package sample;
+
+import org.osoa.sca.CurrentCompositeContext;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * locate the OneWayComponent service and invoke it.
+ */
+public class AsyncClient {
+
+ public static void main(String[] args) throws Exception {
+
+ AsyncService service = CurrentCompositeContext.getContext().locateService(
+ AsyncService.class, "ClientComponent");
+
+ System.out.println("Calling service on thread + " + Thread.currentThread());
+ service.doitOneWay("foo");
+ System.out.println("returned from service");
+ Thread.sleep(500);
+
+ }
+}
diff --git a/sandbox/ant/sample.script.async/src/main/java/sample/AsyncService.java b/sandbox/ant/sample.script.async/src/main/java/sample/AsyncService.java
new file mode 100644
index 0000000000..5ca61dc4e8
--- /dev/null
+++ b/sandbox/ant/sample.script.async/src/main/java/sample/AsyncService.java
@@ -0,0 +1,28 @@
+/*
+ * 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 sample;
+
+import org.osoa.sca.annotations.OneWay;
+
+public interface AsyncService {
+
+ @OneWay
+ public void doitOneWay(String s);
+
+}
diff --git a/sandbox/ant/sample.script.async/src/main/java/sample/ClientComponent.java b/sandbox/ant/sample.script.async/src/main/java/sample/ClientComponent.java
new file mode 100644
index 0000000000..dc806645e3
--- /dev/null
+++ b/sandbox/ant/sample.script.async/src/main/java/sample/ClientComponent.java
@@ -0,0 +1,38 @@
+/*
+ * 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 sample;
+
+import org.osoa.sca.annotations.Reference;
+
+public class ClientComponent implements AsyncService {
+
+ private AsyncService asyncComponent;
+
+ public void doitOneWay(String s) {
+ System.out.println("ClientComponent calling asyncService on thread + " + Thread.currentThread());
+ asyncComponent.doitOneWay(s);
+ }
+
+ @Reference
+ public void setAsyncComponent(AsyncService asyncComponent) {
+ this.asyncComponent = asyncComponent;
+ }
+
+
+}
diff --git a/sandbox/ant/sample.script.async/src/main/resources/AsyncServiceImpl.componentType b/sandbox/ant/sample.script.async/src/main/resources/AsyncServiceImpl.componentType
new file mode 100644
index 0000000000..f6bf9c7752
--- /dev/null
+++ b/sandbox/ant/sample.script.async/src/main/resources/AsyncServiceImpl.componentType
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="ASCII"?>
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="OneWayService">
+ <interface.java interface="sample.AsyncService"/>
+ </service>
+
+</componentType>
diff --git a/sandbox/ant/sample.script.async/src/main/resources/AsyncServiceImpl.js b/sandbox/ant/sample.script.async/src/main/resources/AsyncServiceImpl.js
new file mode 100644
index 0000000000..fbde7da611
--- /dev/null
+++ b/sandbox/ant/sample.script.async/src/main/resources/AsyncServiceImpl.js
@@ -0,0 +1,7 @@
+function doitOneWay(s) {
+ java.lang.System.out.println(
+ "function doitOneWay received '" + s + "' on thread " + java.lang.Thread.currentThread());
+}
+
+
+
diff --git a/sandbox/ant/sample.script.async/src/main/resources/META-INF/sca/default.scdl b/sandbox/ant/sample.script.async/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..1797974c75
--- /dev/null
+++ b/sandbox/ant/sample.script.async/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+
+ name="AsyncSampleComposite">
+
+ <component name="ClientComponent">
+ <implementation.java class="sample.ClientComponent"/>
+ <reference name="asyncComponent">AsyncComponent</reference>
+ </component>
+
+ <component name="AsyncComponent">
+ <implementation.script script="AsyncServiceImpl.js"/>
+ </component>
+
+</composite>
diff --git a/sandbox/ant/sample.script.async/src/test/java/sample/AsyncTestCase.java b/sandbox/ant/sample.script.async/src/test/java/sample/AsyncTestCase.java
new file mode 100644
index 0000000000..ccb816b121
--- /dev/null
+++ b/sandbox/ant/sample.script.async/src/test/java/sample/AsyncTestCase.java
@@ -0,0 +1,54 @@
+/*
+ * 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 sample;
+
+import java.net.URL;
+
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CurrentCompositeContext;
+
+import sample.AsyncService;
+
+
+/**
+ * Tests the AsyncService component.
+ */
+public class AsyncTestCase extends SCATestCase {
+
+ protected void setUp() throws Exception {
+ URL scdl = getClass().getClassLoader().getResource("META-INF/sca/script.system.scdl");
+ addExtension("ScriptContainer", scdl);
+ setApplicationSCDL(AsyncClient.class, "META-INF/sca/default.scdl");
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ }
+
+ public void testHelloWorld() throws Exception {
+
+ AsyncService service = CurrentCompositeContext.getContext().locateService(
+ AsyncService.class, "ClientComponent");
+
+ System.out.println("Calling async service oneWay on thread + " + Thread.currentThread());
+ service.doitOneWay("foo");
+ System.out.println("returned from oneWay service");
+ Thread.sleep(500);
+ }
+}
diff --git a/sandbox/ant/tuscany-container-rhino/LICENSE.txt b/sandbox/ant/tuscany-container-rhino/LICENSE.txt
new file mode 100644
index 0000000000..d8a0663857
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/LICENSE.txt
@@ -0,0 +1,777 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+===============================================================================
+
+For the Rhino JavaScript project:
+
+Netscape Public License V1.1
+
+ AMENDMENTS
+
+ The Netscape Public License Version 1.1 ("NPL") consists of the
+ Mozilla Public License Version 1.1 with the following Amendments,
+ including Exhibit A-Netscape Public License. Files identified with
+ "Exhibit A-Netscape Public License" are governed by the Netscape
+ Public License Version 1.1.
+
+ Additional Terms applicable to the Netscape Public License.
+ I. Effect.
+ These additional terms described in this Netscape Public
+ License -- Amendments shall apply to the Mozilla Communicator
+ client code and to all Covered Code under this License.
+
+ II. "Netscape's Branded Code" means Covered Code that Netscape
+ distributes and/or permits others to distribute under one or more
+ trademark(s) which are controlled by Netscape but which are not
+ licensed for use under this License.
+
+ III. Netscape and logo.
+ This License does not grant any rights to use the trademarks
+ "Netscape", the "Netscape N and horizon" logo or the "Netscape
+ lighthouse" logo, "Netcenter", "Gecko", "Java" or "JavaScript",
+ "Smart Browsing" even if such marks are included in the Original
+ Code or Modifications.
+
+ IV. Inability to Comply Due to Contractual Obligation.
+ Prior to licensing the Original Code under this License, Netscape
+ has licensed third party code for use in Netscape's Branded Code.
+ To the extent that Netscape is limited contractually from making
+ such third party code available under this License, Netscape may
+ choose to reintegrate such code into Covered Code without being
+ required to distribute such code in Source Code form, even if
+ such code would otherwise be considered "Modifications" under
+ this License.
+
+ V. Use of Modifications and Covered Code by Initial Developer.
+ V.1. In General.
+ The obligations of Section 3 apply to Netscape, except to
+ the extent specified in this Amendment, Section V.2 and V.3.
+
+ V.2. Other Products.
+ Netscape may include Covered Code in products other than the
+ Netscape's Branded Code which are released by Netscape
+ during the two (2) years following the release date of the
+ Original Code, without such additional products becoming
+ subject to the terms of this License, and may license such
+ additional products on different terms from those contained
+ in this License.
+
+ V.3. Alternative Licensing.
+ Netscape may license the Source Code of Netscape's Branded
+ Code, including Modifications incorporated therein, without
+ such Netscape Branded Code becoming subject to the terms of
+ this License, and may license such Netscape Branded Code on
+ different terms from those contained in this License.
+
+ VI. Litigation.
+ Notwithstanding the limitations of Section 11 above, the
+ provisions regarding litigation in Section 11(a), (b) and (c) of
+ the License shall apply to all disputes relating to this License.
+
+ EXHIBIT A-Netscape Public License.
+
+ "The contents of this file are subject to the Netscape Public
+ License Version 1.1 (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.mozilla.org/NPL/
+
+ Software distributed under the License is distributed on an "AS
+ IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ rights and limitations under the License.
+
+ The Original Code is Mozilla Communicator client code, released
+ March 31, 1998.
+
+ The Initial Developer of the Original Code is Netscape
+ Communications Corporation. Portions created by Netscape are
+ Copyright (C) 1998-1999 Netscape Communications Corporation. All
+ Rights Reserved.
+
+ Contributor(s): ______________________________________.
+
+ Alternatively, the contents of this file may be used under the
+ terms of the _____ license (the "[___] License"), in which case
+ the provisions of [______] License are applicable instead of
+ those above. If you wish to allow use of your version of this
+ file only under the terms of the [____] License and not to allow
+ others to use your version of this file under the NPL, indicate
+ your decision by deleting the provisions above and replace them
+ with the notice and other provisions required by the [___]
+ License. If you do not delete the provisions above, a recipient
+ may use your version of this file under either the NPL or the
+ [___] License."
+
+ ----------------------------------------------------------------------
+
+ MOZILLA PUBLIC LICENSE
+ Version 1.1
+
+ ---------------
+
+1. Definitions.
+
+ 1.0.1. "Commercial Use" means distribution or otherwise making the
+ Covered Code available to a third party.
+
+ 1.1. "Contributor" means each entity that creates or contributes to
+ the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the Original
+ Code, prior Modifications used by a Contributor, and the Modifications
+ made by that particular Contributor.
+
+ 1.3. "Covered Code" means the Original Code or Modifications or the
+ combination of the Original Code and Modifications, in each case
+ including portions thereof.
+
+ 1.4. "Electronic Distribution Mechanism" means a mechanism generally
+ accepted in the software development community for the electronic
+ transfer of data.
+
+ 1.5. "Executable" means Covered Code in any form other than Source
+ Code.
+
+ 1.6. "Initial Developer" means the individual or entity identified
+ as the Initial Developer in the Source Code notice required by Exhibit
+ A.
+
+ 1.7. "Larger Work" means a work which combines Covered Code or
+ portions thereof with code not governed by the terms of this License.
+
+ 1.8. "License" means this document.
+
+ 1.8.1. "Licensable" means having the right to grant, to the maximum
+ extent possible, whether at the time of the initial grant or
+ subsequently acquired, any and all of the rights conveyed herein.
+
+ 1.9. "Modifications" means any addition to or deletion from the
+ substance or structure of either the Original Code or any previous
+ Modifications. When Covered Code is released as a series of files, a
+ Modification is:
+ A. Any addition to or deletion from the contents of a file
+ containing Original Code or previous Modifications.
+
+ B. Any new file that contains any part of the Original Code or
+ previous Modifications.
+
+ 1.10. "Original Code" means Source Code of computer software code
+ which is described in the Source Code notice required by Exhibit A as
+ Original Code, and which, at the time of its release under this
+ License is not already Covered Code governed by this License.
+
+ 1.10.1. "Patent Claims" means any patent claim(s), now owned or
+ hereafter acquired, including without limitation, method, process,
+ and apparatus claims, in any patent Licensable by grantor.
+
+ 1.11. "Source Code" means the preferred form of the Covered Code for
+ making modifications to it, including all modules it contains, plus
+ any associated interface definition files, scripts used to control
+ compilation and installation of an Executable, or source code
+ differential comparisons against either the Original Code or another
+ well known, available Covered Code of the Contributor's choice. The
+ Source Code can be in a compressed or archival form, provided the
+ appropriate decompression or de-archiving software is widely available
+ for no charge.
+
+ 1.12. "You" (or "Your") means an individual or a legal entity
+ exercising rights under, and complying with all of the terms of, this
+ License or a future version of this License issued under Section 6.1.
+ For legal entities, "You" includes any entity which controls, is
+ controlled by, or is under common control with You. For purposes of
+ this definition, "control" means (a) the power, direct or indirect,
+ to cause the direction or management of such entity, whether by
+ contract or otherwise, or (b) ownership of more than fifty percent
+ (50%) of the outstanding shares or beneficial ownership of such
+ entity.
+
+2. Source Code License.
+
+ 2.1. The Initial Developer Grant.
+ The Initial Developer hereby grants You a world-wide, royalty-free,
+ non-exclusive license, subject to third party intellectual property
+ claims:
+ (a) under intellectual property rights (other than patent or
+ trademark) Licensable by Initial Developer to use, reproduce,
+ modify, display, perform, sublicense and distribute the Original
+ Code (or portions thereof) with or without Modifications, and/or
+ as part of a Larger Work; and
+
+ (b) under Patents Claims infringed by the making, using or
+ selling of Original Code, to make, have made, use, practice,
+ sell, and offer for sale, and/or otherwise dispose of the
+ Original Code (or portions thereof).
+
+ (c) the licenses granted in this Section 2.1(a) and (b) are
+ effective on the date Initial Developer first distributes
+ Original Code under the terms of this License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent license is
+ granted: 1) for code that You delete from the Original Code; 2)
+ separate from the Original Code; or 3) for infringements caused
+ by: i) the modification of the Original Code or ii) the
+ combination of the Original Code with other software or devices.
+
+ 2.2. Contributor Grant.
+ Subject to third party intellectual property claims, each Contributor
+ hereby grants You a world-wide, royalty-free, non-exclusive license
+
+ (a) under intellectual property rights (other than patent or
+ trademark) Licensable by Contributor, to use, reproduce, modify,
+ display, perform, sublicense and distribute the Modifications
+ created by such Contributor (or portions thereof) either on an
+ unmodified basis, with other Modifications, as Covered Code
+ and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making, using, or
+ selling of Modifications made by that Contributor either alone
+ and/or in combination with its Contributor Version (or portions
+ of such combination), to make, use, sell, offer for sale, have
+ made, and/or otherwise dispose of: 1) Modifications made by that
+ Contributor (or portions thereof); and 2) the combination of
+ Modifications made by that Contributor with its Contributor
+ Version (or portions of such combination).
+
+ (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
+ effective on the date Contributor first makes Commercial Use of
+ the Covered Code.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent license is
+ granted: 1) for any code that Contributor has deleted from the
+ Contributor Version; 2) separate from the Contributor Version;
+ 3) for infringements caused by: i) third party modifications of
+ Contributor Version or ii) the combination of Modifications made
+ by that Contributor with other software (except as part of the
+ Contributor Version) or other devices; or 4) under Patent Claims
+ infringed by Covered Code in the absence of Modifications made by
+ that Contributor.
+
+3. Distribution Obligations.
+
+ 3.1. Application of License.
+ The Modifications which You create or to which You contribute are
+ governed by the terms of this License, including without limitation
+ Section 2.2. The Source Code version of Covered Code may be
+ distributed only under the terms of this License or a future version
+ of this License released under Section 6.1, and You must include a
+ copy of this License with every copy of the Source Code You
+ distribute. You may not offer or impose any terms on any Source Code
+ version that alters or restricts the applicable version of this
+ License or the recipients' rights hereunder. However, You may include
+ an additional document offering the additional rights described in
+ Section 3.5.
+
+ 3.2. Availability of Source Code.
+ Any Modification which You create or to which You contribute must be
+ made available in Source Code form under the terms of this License
+ either on the same media as an Executable version or via an accepted
+ Electronic Distribution Mechanism to anyone to whom you made an
+ Executable version available; and if made available via Electronic
+ Distribution Mechanism, must remain available for at least twelve (12)
+ months after the date it initially became available, or at least six
+ (6) months after a subsequent version of that particular Modification
+ has been made available to such recipients. You are responsible for
+ ensuring that the Source Code version remains available even if the
+ Electronic Distribution Mechanism is maintained by a third party.
+
+ 3.3. Description of Modifications.
+ You must cause all Covered Code to which You contribute to contain a
+ file documenting the changes You made to create that Covered Code and
+ the date of any change. You must include a prominent statement that
+ the Modification is derived, directly or indirectly, from Original
+ Code provided by the Initial Developer and including the name of the
+ Initial Developer in (a) the Source Code, and (b) in any notice in an
+ Executable version or related documentation in which You describe the
+ origin or ownership of the Covered Code.
+
+ 3.4. Intellectual Property Matters
+ (a) Third Party Claims.
+ If Contributor has knowledge that a license under a third party's
+ intellectual property rights is required to exercise the rights
+ granted by such Contributor under Sections 2.1 or 2.2,
+ Contributor must include a text file with the Source Code
+ distribution titled "LEGAL" which describes the claim and the
+ party making the claim in sufficient detail that a recipient will
+ know whom to contact. If Contributor obtains such knowledge after
+ the Modification is made available as described in Section 3.2,
+ Contributor shall promptly modify the LEGAL file in all copies
+ Contributor makes available thereafter and shall take other steps
+ (such as notifying appropriate mailing lists or newsgroups)
+ reasonably calculated to inform those who received the Covered
+ Code that new knowledge has been obtained.
+
+ (b) Contributor APIs.
+ If Contributor's Modifications include an application programming
+ interface and Contributor has knowledge of patent licenses which
+ are reasonably necessary to implement that API, Contributor must
+ also include this information in the LEGAL file.
+
+ (c) Representations.
+ Contributor represents that, except as disclosed pursuant to
+ Section 3.4(a) above, Contributor believes that Contributor's
+ Modifications are Contributor's original creation(s) and/or
+ Contributor has sufficient rights to grant the rights conveyed by
+ this License.
+
+ 3.5. Required Notices.
+ You must duplicate the notice in Exhibit A in each file of the Source
+ Code. If it is not possible to put such notice in a particular Source
+ Code file due to its structure, then You must include such notice in a
+ location (such as a relevant directory) where a user would be likely
+ to look for such a notice. If You created one or more Modification(s)
+ You may add your name as a Contributor to the notice described in
+ Exhibit A. You must also duplicate this License in any documentation
+ for the Source Code where You describe recipients' rights or ownership
+ rights relating to Covered Code. You may choose to offer, and to
+ charge a fee for, warranty, support, indemnity or liability
+ obligations to one or more recipients of Covered Code. However, You
+ may do so only on Your own behalf, and not on behalf of the Initial
+ Developer or any Contributor. You must make it absolutely clear than
+ any such warranty, support, indemnity or liability obligation is
+ offered by You alone, and You hereby agree to indemnify the Initial
+ Developer and every Contributor for any liability incurred by the
+ Initial Developer or such Contributor as a result of warranty,
+ support, indemnity or liability terms You offer.
+
+ 3.6. Distribution of Executable Versions.
+ You may distribute Covered Code in Executable form only if the
+ requirements of Section 3.1-3.5 have been met for that Covered Code,
+ and if You include a notice stating that the Source Code version of
+ the Covered Code is available under the terms of this License,
+ including a description of how and where You have fulfilled the
+ obligations of Section 3.2. The notice must be conspicuously included
+ in any notice in an Executable version, related documentation or
+ collateral in which You describe recipients' rights relating to the
+ Covered Code. You may distribute the Executable version of Covered
+ Code or ownership rights under a license of Your choice, which may
+ contain terms different from this License, provided that You are in
+ compliance with the terms of this License and that the license for the
+ Executable version does not attempt to limit or alter the recipient's
+ rights in the Source Code version from the rights set forth in this
+ License. If You distribute the Executable version under a different
+ license You must make it absolutely clear that any terms which differ
+ from this License are offered by You alone, not by the Initial
+ Developer or any Contributor. You hereby agree to indemnify the
+ Initial Developer and every Contributor for any liability incurred by
+ the Initial Developer or such Contributor as a result of any such
+ terms You offer.
+
+ 3.7. Larger Works.
+ You may create a Larger Work by combining Covered Code with other code
+ not governed by the terms of this License and distribute the Larger
+ Work as a single product. In such a case, You must make sure the
+ requirements of this License are fulfilled for the Covered Code.
+
+4. Inability to Comply Due to Statute or Regulation.
+
+ If it is impossible for You to comply with any of the terms of this
+ License with respect to some or all of the Covered Code due to
+ statute, judicial order, or regulation then You must: (a) comply with
+ the terms of this License to the maximum extent possible; and (b)
+ describe the limitations and the code they affect. Such description
+ must be included in the LEGAL file described in Section 3.4 and must
+ be included with all distributions of the Source Code. Except to the
+ extent prohibited by statute or regulation, such description must be
+ sufficiently detailed for a recipient of ordinary skill to be able to
+ understand it.
+
+5. Application of this License.
+
+ This License applies to code to which the Initial Developer has
+ attached the notice in Exhibit A and to related Covered Code.
+
+6. Versions of the License.
+
+ 6.1. New Versions.
+ Netscape Communications Corporation ("Netscape") may publish revised
+ and/or new versions of the License from time to time. Each version
+ will be given a distinguishing version number.
+
+ 6.2. Effect of New Versions.
+ Once Covered Code has been published under a particular version of the
+ License, You may always continue to use it under the terms of that
+ version. You may also choose to use such Covered Code under the terms
+ of any subsequent version of the License published by Netscape. No one
+ other than Netscape has the right to modify the terms applicable to
+ Covered Code created under this License.
+
+ 6.3. Derivative Works.
+ If You create or use a modified version of this License (which you may
+ only do in order to apply it to code which is not already Covered Code
+ governed by this License), You must (a) rename Your license so that
+ the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
+ "MPL", "NPL" or any confusingly similar phrase do not appear in your
+ license (except to note that your license differs from this License)
+ and (b) otherwise make it clear that Your version of the license
+ contains terms which differ from the Mozilla Public License and
+ Netscape Public License. (Filling in the name of the Initial
+ Developer, Original Code or Contributor in the notice described in
+ Exhibit A shall not of themselves be deemed to be modifications of
+ this License.)
+
+7. DISCLAIMER OF WARRANTY.
+
+ COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
+ DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
+ THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
+ IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
+ YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
+ COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
+ OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+ ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+8. TERMINATION.
+
+ 8.1. This License and the rights granted hereunder will terminate
+ automatically if You fail to comply with terms herein and fail to cure
+ such breach within 30 days of becoming aware of the breach. All
+ sublicenses to the Covered Code which are properly granted shall
+ survive any termination of this License. Provisions which, by their
+ nature, must remain in effect beyond the termination of this License
+ shall survive.
+
+ 8.2. If You initiate litigation by asserting a patent infringement
+ claim (excluding declatory judgment actions) against Initial Developer
+ or a Contributor (the Initial Developer or Contributor against whom
+ You file such action is referred to as "Participant") alleging that:
+
+ (a) such Participant's Contributor Version directly or indirectly
+ infringes any patent, then any and all rights granted by such
+ Participant to You under Sections 2.1 and/or 2.2 of this License
+ shall, upon 60 days notice from Participant terminate prospectively,
+ unless if within 60 days after receipt of notice You either: (i)
+ agree in writing to pay Participant a mutually agreeable reasonable
+ royalty for Your past and future use of Modifications made by such
+ Participant, or (ii) withdraw Your litigation claim with respect to
+ the Contributor Version against such Participant. If within 60 days
+ of notice, a reasonable royalty and payment arrangement are not
+ mutually agreed upon in writing by the parties or the litigation claim
+ is not withdrawn, the rights granted by Participant to You under
+ Sections 2.1 and/or 2.2 automatically terminate at the expiration of
+ the 60 day notice period specified above.
+
+ (b) any software, hardware, or device, other than such Participant's
+ Contributor Version, directly or indirectly infringes any patent, then
+ any rights granted to You by such Participant under Sections 2.1(b)
+ and 2.2(b) are revoked effective as of the date You first made, used,
+ sold, distributed, or had made, Modifications made by that
+ Participant.
+
+ 8.3. If You assert a patent infringement claim against Participant
+ alleging that such Participant's Contributor Version directly or
+ indirectly infringes any patent where such claim is resolved (such as
+ by license or settlement) prior to the initiation of patent
+ infringement litigation, then the reasonable value of the licenses
+ granted by such Participant under Sections 2.1 or 2.2 shall be taken
+ into account in determining the amount or value of any payment or
+ license.
+
+ 8.4. In the event of termination under Sections 8.1 or 8.2 above,
+ all end user license agreements (excluding distributors and resellers)
+ which have been validly granted by You or any distributor hereunder
+ prior to termination shall survive termination.
+
+9. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
+ DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
+ OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
+ ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
+ CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
+ WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+ COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
+ INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+ LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
+ RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
+ PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
+ EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
+ THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+10. U.S. GOVERNMENT END USERS.
+
+ The Covered Code is a "commercial item," as that term is defined in
+ 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
+ software" and "commercial computer software documentation," as such
+ terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
+ C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
+ all U.S. Government End Users acquire Covered Code with only those
+ rights set forth herein.
+
+11. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the extent
+ necessary to make it enforceable. This License shall be governed by
+ California law provisions (except to the extent applicable law, if
+ any, provides otherwise), excluding its conflict-of-law provisions.
+ With respect to disputes in which at least one party is a citizen of,
+ or an entity chartered or registered to do business in the United
+ States of America, any litigation relating to this License shall be
+ subject to the jurisdiction of the Federal Courts of the Northern
+ District of California, with venue lying in Santa Clara County,
+ California, with the losing party responsible for costs, including
+ without limitation, court costs and reasonable attorneys' fees and
+ expenses. The application of the United Nations Convention on
+ Contracts for the International Sale of Goods is expressly excluded.
+ Any law or regulation which provides that the language of a contract
+ shall be construed against the drafter shall not apply to this
+ License.
+
+12. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+ responsible for claims and damages arising, directly or indirectly,
+ out of its utilization of rights under this License and You agree to
+ work with Initial Developer and Contributors to distribute such
+ responsibility on an equitable basis. Nothing herein is intended or
+ shall be deemed to constitute any admission of liability.
+
+13. MULTIPLE-LICENSED CODE.
+
+ Initial Developer may designate portions of the Covered Code as
+ "Multiple-Licensed". "Multiple-Licensed" means that the Initial
+ Developer permits you to utilize portions of the Covered Code under
+ Your choice of the NPL or the alternative licenses, if any, specified
+ by the Initial Developer in the file described in Exhibit A.
+
+EXHIBIT A -Mozilla Public License.
+
+ ``The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (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.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS"
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ License for the specific language governing rights and limitations
+ under the License.
+
+ The Original Code is ______________________________________.
+
+ The Initial Developer of the Original Code is ________________________.
+ Portions created by ______________________ are Copyright (C) ______
+ _______________________. All Rights Reserved.
+
+ Contributor(s): ______________________________________.
+
+ Alternatively, the contents of this file may be used under the terms
+ of the _____ license (the "[___] License"), in which case the
+ provisions of [______] License are applicable instead of those
+ above. If you wish to allow use of your version of this file only
+ under the terms of the [____] License and not to allow others to use
+ your version of this file under the MPL, indicate your decision by
+ deleting the provisions above and replace them with the notice and
+ other provisions required by the [___] License. If you do not delete
+ the provisions above, a recipient may use your version of this file
+ under either the MPL or the [___] License."
+
+ [NOTE: The text of this Exhibit A may differ slightly from the text of
+ the notices in the Source Code files of the Original Code. You should
+ use the text of this Exhibit A rather than the text found in the
+ Original Code Source Code for Your Modifications.]
+
diff --git a/sandbox/ant/tuscany-container-rhino/README.txt b/sandbox/ant/tuscany-container-rhino/README.txt
new file mode 100644
index 0000000000..723f3fd3ab
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/README.txt
@@ -0,0 +1,35 @@
+Apache Tuscany M1 build (May, 2006)
+===================================
+
+http://incubator.apache.org/tuscany/
+
+Tuscany is an effort undergoing incubation at the Apache Software Foundation
+(ASF), sponsored by the 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.
+
+
+Support
+-------
+
+Any problem with this release can be reported to the Tuscany mailing list
+or in the JIRA issue tracker.
+
+Mailing list subscription:
+ tuscany-dev-subscribe@ws.apache.org
+
+Jira:
+ http://issues.apache.org/jira/browse/Tuscany
+
+
+Thank you for using Tuscany!
+
+
+The Tuscany Team.
+
diff --git a/sandbox/ant/tuscany-container-rhino/pom.xml b/sandbox/ant/tuscany-container-rhino/pom.xml
new file mode 100644
index 0000000000..5596f680fe
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
+<project>
+
+ <parent>
+ <groupId>org.apache.tuscany.sca.containers</groupId>
+ <artifactId>tuscany-sca-containers</artifactId>
+ <version>incubating-M1</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-container-rhino</artifactId>
+ <name>Tuscany Rhino JavaScript Container</name>
+ <description>Tuscany Rhino JavaScript Container</description>
+ <version>incubating-M1</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ <version>1.6R2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.databinding</groupId>
+ <artifactId>tuscany-databinding-sdo</artifactId> <!-- Reqd for E4X -->
+ <version>${pom.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>xmlbeans</groupId>
+ <artifactId>xbean</artifactId> <!-- Reqd for E4X -->
+ <version>2.1.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/assembly/JavaScriptImplementation.java b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/assembly/JavaScriptImplementation.java
new file mode 100644
index 0000000000..5b570d5d41
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/assembly/JavaScriptImplementation.java
@@ -0,0 +1,74 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.assembly;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.model.assembly.impl.AtomicImplementationImpl;
+
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ * Default implementation of a JavScript component implementation type
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaScriptImplementation extends AtomicImplementationImpl {
+
+ private String scriptFile;
+
+ private String script;
+
+ private ResourceLoader resourceLoader;
+
+ private TypeHelper typeHelper;
+
+ public JavaScriptImplementation() {
+ super();
+ }
+
+ public void setResourceLoader(ResourceLoader resourceLoader) {
+ this.resourceLoader = resourceLoader;
+ }
+
+ public ResourceLoader getResourceLoader() {
+ return resourceLoader;
+ }
+
+ public TypeHelper getTypeHelper() {
+ return typeHelper;
+ }
+
+ public void setTypeHelper(TypeHelper typeHelper) {
+ this.typeHelper = typeHelper;
+ }
+
+ public String getScriptFile() {
+ return scriptFile;
+ }
+
+ public void setScriptFile(String fn) {
+ scriptFile = fn;
+ }
+
+ public String getScript() {
+ return script;
+ }
+
+ public void setScript(String script) {
+ this.script = script;
+ }
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/builder/JavaScriptContextFactoryBuilder.java b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/builder/JavaScriptContextFactoryBuilder.java
new file mode 100644
index 0000000000..4f58758a7e
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/builder/JavaScriptContextFactoryBuilder.java
@@ -0,0 +1,62 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.builder;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.container.rhino.assembly.JavaScriptImplementation;
+import org.apache.tuscany.container.rhino.config.JavaScriptContextFactory;
+import org.apache.tuscany.container.rhino.rhino.RhinoScript;
+import org.apache.tuscany.core.builder.ContextFactory;
+import org.apache.tuscany.core.extension.ContextFactoryBuilderSupport;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.Service;
+
+/**
+ * Builds {@link org.apache.tuscany.container.rhino.config.JavaScriptContextFactory}s from a JavaScript component type
+ *
+ * @version $Rev$ $Date$
+ */
+@org.osoa.sca.annotations.Scope("MODULE")
+public class JavaScriptContextFactoryBuilder extends ContextFactoryBuilderSupport<JavaScriptImplementation> {
+
+ @Override
+ protected ContextFactory createContextFactory(String componentName, JavaScriptImplementation jsImplementation, Scope scope) {
+
+ String script = jsImplementation.getScript();
+
+ Map<String, Object> defaultProperties = new HashMap<String, Object>();
+ for (org.apache.tuscany.model.assembly.Property property : jsImplementation.getComponentType().getProperties()) {
+ defaultProperties.put(property.getName(), property.getDefaultValue());
+ }
+
+ ClassLoader cl = jsImplementation.getResourceLoader().getClassLoader();
+
+ RhinoScript rhinoScript = new RhinoScript(componentName, script, defaultProperties, cl);
+
+ for (Service service : jsImplementation.getComponentType().getServices()) {
+ for (Method serviceMethod : service.getServiceContract().getInterface().getMethods()) {
+ rhinoScript.setResponseClass(serviceMethod.getName(), serviceMethod.getReturnType());
+ }
+ }
+
+ return new JavaScriptContextFactory(componentName, scope, rhinoScript);
+ }
+
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/builder/JavaScriptTargetWireBuilder.java b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/builder/JavaScriptTargetWireBuilder.java
new file mode 100644
index 0000000000..0c45aee35e
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/builder/JavaScriptTargetWireBuilder.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.builder;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.container.rhino.config.JavaScriptContextFactory;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.extension.ComponentTargetInvoker;
+import org.apache.tuscany.core.extension.WireBuilderSupport;
+import org.apache.tuscany.core.wire.TargetInvoker;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * Responsible for bridging source- and target-side invocations chains when the target type is a JavaScript implementation
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class JavaScriptTargetWireBuilder extends WireBuilderSupport<JavaScriptContextFactory> {
+
+ protected TargetInvoker createInvoker(QualifiedName targetName, Method operation, ScopeContext context, boolean downScope) {
+ return new ComponentTargetInvoker(targetName, operation, context);
+ }
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/config/JavaScriptContextFactory.java b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/config/JavaScriptContextFactory.java
new file mode 100644
index 0000000000..7ea35075fc
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/config/JavaScriptContextFactory.java
@@ -0,0 +1,111 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.config;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.container.rhino.context.JavaScriptComponentContext;
+import org.apache.tuscany.container.rhino.rhino.RhinoScript;
+import org.apache.tuscany.core.builder.ContextCreationException;
+import org.apache.tuscany.core.builder.ContextFactory;
+import org.apache.tuscany.core.builder.ContextResolver;
+import org.apache.tuscany.core.context.AtomicContext;
+import org.apache.tuscany.core.context.CompositeContext;
+import org.apache.tuscany.core.wire.SourceWireFactory;
+import org.apache.tuscany.core.wire.TargetWireFactory;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Creates instance contexts for JavaScript component types
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaScriptContextFactory implements ContextFactory<AtomicContext>, ContextResolver {
+
+ private Scope scope;
+
+ private String name;
+
+ private Map<String, TargetWireFactory> targetProxyFactories = new HashMap<String, TargetWireFactory>();
+
+ private List<SourceWireFactory> sourceProxyFactories = new ArrayList<SourceWireFactory>();
+
+ private Map<String, Object> properties;
+
+ private RhinoScript rhinoScript;
+
+ private CompositeContext parentContext;
+
+ public JavaScriptContextFactory(String name, Scope scope, RhinoScript rhinoScript) {
+ this.name = name;
+ this.scope = scope;
+ this.rhinoScript = rhinoScript;
+ this.properties = new HashMap<String, Object>();
+ }
+
+ public AtomicContext createContext() throws ContextCreationException {
+ return new JavaScriptComponentContext(name, properties, sourceProxyFactories, targetProxyFactories, rhinoScript);
+ }
+
+ public Scope getScope() {
+ return scope;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void addProperty(String propertyName, Object value) {
+ properties.put(propertyName, value);
+ }
+
+ public void addTargetWireFactory(String serviceName, TargetWireFactory factory) {
+ targetProxyFactories.put(serviceName, factory);
+ }
+
+ public TargetWireFactory getTargetWireFactory(String serviceName) {
+ return targetProxyFactories.get(serviceName);
+ }
+
+ public Map<String, TargetWireFactory> getTargetWireFactories() {
+ return targetProxyFactories;
+ }
+
+ public void addSourceWireFactory(String referenceName, SourceWireFactory factory) {
+ sourceProxyFactories.add(factory);
+ }
+
+ public void addSourceWireFactories(String referenceName, Class referenceInterface, List<SourceWireFactory> factories, boolean multiplicity) {
+ sourceProxyFactories.addAll(factories);
+ }
+
+ public List<SourceWireFactory> getSourceWireFactories() {
+ return sourceProxyFactories;
+ }
+
+ public void prepare(CompositeContext parent) {
+ parentContext = parent;
+ }
+
+ public CompositeContext getCurrentContext() {
+ return parentContext;
+ }
+
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/context/CopyOfJavaScriptComponentContext.java b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/context/CopyOfJavaScriptComponentContext.java
new file mode 100644
index 0000000000..c4690e2170
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/context/CopyOfJavaScriptComponentContext.java
@@ -0,0 +1,165 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.context;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.container.rhino.rhino.RhinoScript;
+import org.apache.tuscany.container.rhino.rhino.RhinoScriptInstance;
+import org.apache.tuscany.core.context.AtomicContext;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.context.event.InstanceCreated;
+import org.apache.tuscany.core.context.impl.AbstractContext;
+import org.apache.tuscany.core.extension.ExternalServiceInvoker;
+import org.apache.tuscany.core.wire.ProxyCreationException;
+import org.apache.tuscany.core.wire.SourceWireFactory;
+import org.apache.tuscany.core.wire.TargetWireFactory;
+import org.apache.tuscany.core.wire.WireFactory;
+import org.osoa.sca.ServiceRuntimeException;
+
+public class CopyOfJavaScriptComponentContext extends AbstractContext implements AtomicContext {
+
+ private RhinoScript rhinoScript;
+
+ private Map<String, Object> properties;
+
+ private List<SourceWireFactory> sourceProxyFactories;
+
+ private Map<String, TargetWireFactory> targetProxyFactories;
+
+ public CopyOfJavaScriptComponentContext(String name, Map<String, Object> properties, List<SourceWireFactory> sourceProxyFactories,
+ Map<String, TargetWireFactory> targetProxyFactories, RhinoScript rhinoScript) {
+ super(name);
+ this.properties = properties;
+ this.rhinoScript = rhinoScript;
+ this.sourceProxyFactories = sourceProxyFactories;
+ this.targetProxyFactories = targetProxyFactories;
+ }
+
+ public Object getInstance(QualifiedName qName) throws TargetException {
+ return getInstance(qName, true);
+ }
+
+ public void init() throws TargetException {
+ getInstance(null, false);
+ }
+
+ public void destroy() throws TargetException {
+
+ }
+
+ private synchronized Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
+ String portName = qName.getPortName();
+ WireFactory targetFactory;
+ if (portName != null) {
+ targetFactory = targetProxyFactories.get(portName);
+ } else {
+ // FIXME The port name is null here, either locateService needs more information (the expected interface) to
+ // select the correct port, or we need to return a factory that matches the whole set of services exposed by
+ // the component.
+ targetFactory = targetProxyFactories.values().iterator().next();
+ }
+ if (targetFactory == null) {
+ TargetException e = new TargetException("Target service not found");
+ e.setIdentifier(qName.getPortName());
+ e.addContextName(getName());
+ throw e;
+ }
+ try {
+ Object proxy = targetFactory.createProxy(); // createProxy(new Class[] { iface });
+ if (notify) {
+ publish(new InstanceCreated(this));
+ }
+ return proxy;
+ } catch (ProxyCreationException e) {
+ TargetException te = new TargetException("Error returning target", e);
+ e.setIdentifier(qName.getPortName());
+ e.addContextName(getName());
+ throw te;
+ }
+ }
+
+ public Object getTargetInstance() throws TargetException {
+ Map<String, Object> contexts = createServiceReferences();
+ contexts.putAll(properties);
+
+ final RhinoScriptInstance rhinoScriptInstance = rhinoScript.createRhinoScriptInstance(contexts);
+
+ ExternalServiceInvoker esi = new ExternalServiceInvoker() {
+ public Object invoke(String methodName, Object[] args) {
+ return rhinoScriptInstance.invokeFunction(methodName, args);
+ }
+ };
+
+ return esi;
+ }
+
+ /**
+ * Creates a map containing any ServiceReferences
+ */
+ private Map<String, Object> createServiceReferences() {
+ try {
+ Map<String, Object> context = new HashMap<String, Object>();
+ for (SourceWireFactory proxyFactory : sourceProxyFactories) {
+ Object referenceProxy = createReferenceProxy(proxyFactory);
+ context.put(proxyFactory.getConfiguration().getReferenceName(), referenceProxy);
+ }
+ return context;
+ } catch (ProxyCreationException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ private Object createReferenceProxy(SourceWireFactory proxyFactory) throws ProxyCreationException {
+ Object proxy = proxyFactory.createProxy();
+ Class proxyClass = proxy.getClass();
+ if (Proxy.isProxyClass(proxyClass)) {
+ Class[] ifaces = proxyClass.getInterfaces();
+ Class[] newIfaces = new Class[ifaces.length+1];
+ System.arraycopy(ifaces,0,newIfaces,0,ifaces.length);
+ newIfaces[ifaces.length] = E4XReference.class;
+ InvocationHandler ih = Proxy.getInvocationHandler(proxy);
+ proxy = Proxy.newProxyInstance(proxyClass.getClassLoader(), newIfaces, ih);
+ }
+ return proxy;
+ }
+
+ interface E4XReference {
+ public Object process(Object xml);
+ }
+
+ public boolean isEagerInit() {
+ return false;
+ }
+
+ public boolean isDestroyable() {
+ return false;
+ }
+
+ public void start() throws CoreRuntimeException {
+ }
+
+ public void stop() throws CoreRuntimeException {
+ }
+
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/context/JavaScriptComponentContext.java b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/context/JavaScriptComponentContext.java
new file mode 100644
index 0000000000..74c3bea5eb
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/context/JavaScriptComponentContext.java
@@ -0,0 +1,144 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.context;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.container.rhino.rhino.RhinoScript;
+import org.apache.tuscany.container.rhino.rhino.RhinoScriptInstance;
+import org.apache.tuscany.core.context.AtomicContext;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.context.event.InstanceCreated;
+import org.apache.tuscany.core.context.impl.AbstractContext;
+import org.apache.tuscany.core.extension.ExternalServiceInvoker;
+import org.apache.tuscany.core.wire.ProxyCreationException;
+import org.apache.tuscany.core.wire.SourceWireFactory;
+import org.apache.tuscany.core.wire.TargetWireFactory;
+import org.apache.tuscany.core.wire.WireFactory;
+import org.osoa.sca.ServiceRuntimeException;
+
+public class JavaScriptComponentContext extends AbstractContext implements AtomicContext {
+
+ private RhinoScript rhinoScript;
+
+ private Map<String, Object> properties;
+
+ private List<SourceWireFactory> sourceProxyFactories;
+
+ private Map<String, TargetWireFactory> targetProxyFactories;
+
+ public JavaScriptComponentContext(String name, Map<String, Object> properties, List<SourceWireFactory> sourceProxyFactories,
+ Map<String, TargetWireFactory> targetProxyFactories, RhinoScript rhinoScript) {
+ super(name);
+ this.properties = properties;
+ this.rhinoScript = rhinoScript;
+ this.sourceProxyFactories = sourceProxyFactories;
+ this.targetProxyFactories = targetProxyFactories;
+ }
+
+ public Object getInstance(QualifiedName qName) throws TargetException {
+ return getInstance(qName, true);
+ }
+
+ public void init() throws TargetException {
+ getInstance(null, false);
+ }
+
+ public void destroy() throws TargetException {
+
+ }
+
+ private synchronized Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
+ String portName = qName.getPortName();
+ WireFactory targetFactory;
+ if (portName != null) {
+ targetFactory = targetProxyFactories.get(portName);
+ } else {
+ // FIXME The port name is null here, either locateService needs more information (the expected interface) to
+ // select the correct port, or we need to return a factory that matches the whole set of services exposed by
+ // the component.
+ targetFactory = targetProxyFactories.values().iterator().next();
+ }
+ if (targetFactory == null) {
+ TargetException e = new TargetException("Target service not found");
+ e.setIdentifier(qName.getPortName());
+ e.addContextName(getName());
+ throw e;
+ }
+ try {
+ Object proxy = targetFactory.createProxy(); // createProxy(new Class[] { iface });
+ if (notify) {
+ publish(new InstanceCreated(this));
+ }
+ return proxy;
+ } catch (ProxyCreationException e) {
+ TargetException te = new TargetException("Error returning target", e);
+ e.setIdentifier(qName.getPortName());
+ e.addContextName(getName());
+ throw te;
+ }
+ }
+
+ public Object getTargetInstance() throws TargetException {
+ Map<String, Object> contexts = createServiceReferences();
+ contexts.putAll(properties);
+
+ final RhinoScriptInstance rhinoScriptInstance = rhinoScript.createRhinoScriptInstance(contexts);
+
+ ExternalServiceInvoker esi = new ExternalServiceInvoker() {
+ public Object invoke(String methodName, Object[] args) {
+ return rhinoScriptInstance.invokeFunction(methodName, args);
+ }
+ };
+
+ return esi;
+ }
+
+ /**
+ * Creates a map containing any ServiceReferences
+ */
+ private Map<String, Object> createServiceReferences() {
+ try {
+ Map<String, Object> context = new HashMap<String, Object>();
+ for (SourceWireFactory proxyFactory : sourceProxyFactories) {
+ context.put(proxyFactory.getConfiguration().getReferenceName(), proxyFactory.createProxy());
+ }
+ return context;
+ } catch (ProxyCreationException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public boolean isEagerInit() {
+ return false;
+ }
+
+ public boolean isDestroyable() {
+ return false;
+ }
+
+ public void start() throws CoreRuntimeException {
+ }
+
+ public void stop() throws CoreRuntimeException {
+ }
+
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/e4x/E4XInterceptor.java b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/e4x/E4XInterceptor.java
new file mode 100644
index 0000000000..1031a2577c
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/e4x/E4XInterceptor.java
@@ -0,0 +1,65 @@
+package org.apache.tuscany.container.rhino.e4x;
+
+import java.io.ByteArrayInputStream;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.wire.Interceptor;
+import org.apache.tuscany.core.wire.InvocationRuntimeException;
+import org.apache.tuscany.databinding.sdo.SDOXMLHelper;
+import org.apache.xmlbeans.XmlObject;
+
+import commonj.sdo.helper.TypeHelper;
+
+public class E4XInterceptor implements Interceptor {
+
+ private Interceptor next;
+
+ private QName elementQN;
+
+ private TypeHelper typeHelper;
+
+ private ClassLoader classLoader;
+
+ E4XInterceptor(QName elementQN, TypeHelper typeHelper, ClassLoader classLoader) {
+ this.elementQN = elementQN;
+ this.typeHelper = typeHelper;
+ this.classLoader = classLoader;
+ }
+
+ public Message invoke(Message message) {
+ toXmlObject(message);
+ Message responseMessage = next.invoke(message);
+ fromXmlObject(responseMessage);
+ return responseMessage;
+ }
+
+ protected void toXmlObject(Message message) {
+ Object[] body = (Object[]) message.getBody();
+ byte[] xmlBytes = SDOXMLHelper.toXMLBytes(classLoader, typeHelper, body, elementQN, true);
+ try {
+ message.setBody(new Object[] { XmlObject.Factory.parse(new ByteArrayInputStream(xmlBytes)) });
+ } catch (Exception e) {
+ throw new InvocationRuntimeException(e);
+ }
+ }
+
+ protected void fromXmlObject(Message message) {
+ Object body = message.getBody();
+ if (body instanceof XmlObject) {
+ byte[] xmlBytes = ((XmlObject) body).toString().getBytes();
+ Object[] os = SDOXMLHelper.toObjects(classLoader, typeHelper, xmlBytes, true);
+ if (os == null || os.length < 1) {
+ message.setBody(os);
+ } else {
+ message.setBody(os[0]);
+ }
+ }
+ }
+
+ public void setNext(Interceptor next) {
+ this.next = next;
+ }
+
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/e4x/E4XPolicyBuilder.java b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/e4x/E4XPolicyBuilder.java
new file mode 100644
index 0000000000..985a0efcc8
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/e4x/E4XPolicyBuilder.java
@@ -0,0 +1,117 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.e4x;
+
+import java.util.List;
+
+import javax.wsdl.Input;
+import javax.wsdl.Message;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.container.rhino.assembly.JavaScriptImplementation;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.SourcePolicyBuilder;
+import org.apache.tuscany.core.builder.TargetPolicyBuilder;
+import org.apache.tuscany.core.builder.system.PolicyBuilderRegistry;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.core.wire.TargetInvocationConfiguration;
+import org.apache.tuscany.core.wire.WireSourceConfiguration;
+import org.apache.tuscany.core.wire.WireTargetConfiguration;
+import org.apache.tuscany.model.assembly.AtomicComponent;
+import org.apache.tuscany.model.assembly.AtomicImplementation;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.Part;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.ServiceContract;
+import org.apache.tuscany.model.types.wsdl.WSDLServiceContract;
+import org.osoa.sca.annotations.Init;
+
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ */
+@org.osoa.sca.annotations.Scope("MODULE")
+public class E4XPolicyBuilder implements SourcePolicyBuilder, TargetPolicyBuilder {
+
+ private PolicyBuilderRegistry builderRegistry;
+
+ public E4XPolicyBuilder() {
+ }
+
+ @Init(eager = true)
+ public void init() {
+ builderRegistry.registerSourceBuilder(this);
+ builderRegistry.registerTargetBuilder(this);
+ }
+
+ @Autowire
+ public void setBuilderRegistry(PolicyBuilderRegistry builderRegistry) {
+ this.builderRegistry = builderRegistry;
+ }
+
+ public void build(ConfiguredReference service, List<WireSourceConfiguration> wireSourceConfigurations) throws BuilderException {
+ }
+
+ public void build(ConfiguredService service, WireTargetConfiguration wireTargetConfiguration) throws BuilderException {
+ Part part = service.getPart();
+ if (part instanceof AtomicComponent) {
+ AtomicImplementation implementation = ((AtomicComponent) part).getImplementation();
+ if (implementation instanceof JavaScriptImplementation) {
+ JavaScriptImplementation javaScriptImplementation = (JavaScriptImplementation) implementation;
+ for (TargetInvocationConfiguration configuration : wireTargetConfiguration.getInvocationConfigurations().values()) {
+ TypeHelper typeHelper = javaScriptImplementation.getTypeHelper();
+ ClassLoader classLoader = javaScriptImplementation.getResourceLoader().getClassLoader();
+ String methodName = configuration.getMethod().getName();
+ QName responseQN = getElementQName(javaScriptImplementation, methodName);
+ if (responseQN != null) {
+ configuration.addInterceptor(new E4XInterceptor(responseQN, typeHelper, classLoader));
+ }
+ }
+ }
+ }
+ }
+
+ protected QName getElementQName(JavaScriptImplementation javaScriptImplementation, String methodName) {
+ for (Service service : javaScriptImplementation.getComponentType().getServices()) {
+ ServiceContract sc = service.getServiceContract();
+ if (sc instanceof WSDLServiceContract) {
+ PortType pt = ((WSDLServiceContract) sc).getPortType();
+ for (Object o : pt.getOperations()) {
+ Operation operation = (Operation) o;
+ if (methodName.equals(operation.getName())) {
+ Input input = operation.getInput();
+ if (input != null) {
+ Message message = input.getMessage();
+ if (message != null) {
+ List parts = message.getOrderedParts(null);
+ if (parts != null && parts.size() > 0) {
+ javax.wsdl.Part part = (javax.wsdl.Part) parts.get(0);
+ return part.getElementName();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/loader/JavaScriptImplementationLoader.java b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/loader/JavaScriptImplementationLoader.java
new file mode 100644
index 0000000000..a39537b789
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/loader/JavaScriptImplementationLoader.java
@@ -0,0 +1,169 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.loader;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.container.rhino.assembly.JavaScriptImplementation;
+import org.apache.tuscany.core.config.ConfigurationLoadException;
+import org.apache.tuscany.core.config.InvalidRootElementException;
+import org.apache.tuscany.core.config.MissingResourceException;
+import org.apache.tuscany.core.config.SidefileLoadException;
+import org.apache.tuscany.core.loader.LoaderContext;
+import org.apache.tuscany.core.loader.StAXElementLoader;
+import org.apache.tuscany.core.loader.StAXLoaderRegistry;
+import org.apache.tuscany.core.loader.assembly.AssemblyConstants;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class JavaScriptImplementationLoader implements StAXElementLoader<JavaScriptImplementation> {
+
+ public static final QName IMPLEMENTATION_JS = new QName("http://org.apache.tuscany/xmlns/js/0.9", "implementation.js");
+
+ protected StAXLoaderRegistry registry;
+
+ private XMLInputFactory xmlFactory;
+
+ public JavaScriptImplementationLoader() {
+ // todo make this a reference to a system service
+ xmlFactory = XMLInputFactory.newInstance();
+ }
+
+ @Autowire
+ public void setRegistry(StAXLoaderRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Init(eager = true)
+ public void start() {
+ registry.registerLoader(IMPLEMENTATION_JS, this);
+ }
+
+ @Destroy
+ public void stop() {
+ registry.unregisterLoader(IMPLEMENTATION_JS, this);
+ }
+
+ @SuppressWarnings("deprecation")
+ public JavaScriptImplementation load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException {
+ String scriptFile = reader.getAttributeValue(null, "scriptFile");
+ String script = loadScript(scriptFile, loaderContext.getResourceLoader());
+ ComponentType componentType = loadComponentType(scriptFile, loaderContext);
+
+ JavaScriptImplementation jsImpl = new JavaScriptImplementation();
+ jsImpl.setComponentType(componentType);
+ jsImpl.setScriptFile(scriptFile);
+ jsImpl.setScript(script);
+ jsImpl.setResourceLoader(loaderContext.getResourceLoader());
+ jsImpl.setTypeHelper(registry.getContext().getTypeHelper());
+ return jsImpl;
+ }
+
+ protected String loadScript(String scriptFile, ResourceLoader resourceLoader) throws ConfigurationLoadException {
+ URL url = resourceLoader.getResource(scriptFile);
+ if (url == null) {
+ throw new ConfigurationLoadException(scriptFile);
+ }
+ InputStream inputStream;
+ try {
+ inputStream = url.openStream();
+ } catch (IOException e) {
+ throw new ConfigurationLoadException(scriptFile, e);
+ }
+ try {
+ StringBuilder sb = new StringBuilder(1024);
+ int n;
+ while ((n = inputStream.read()) != -1) {
+ sb.append((char) n);
+ }
+ return sb.toString();
+ } catch (IOException e) {
+ throw new ConfigurationLoadException(scriptFile, e);
+ } finally {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+
+ protected ComponentType loadComponentType(String scriptFile, LoaderContext loaderContext) throws SidefileLoadException, MissingResourceException{
+ String sidefile = scriptFile.substring(0, scriptFile.lastIndexOf('.')) + ".componentType";
+ URL componentTypeFile = loaderContext.getResourceLoader().getResource(sidefile);
+ if (componentTypeFile == null) {
+ throw new MissingResourceException(sidefile);
+ }
+
+ try {
+ XMLStreamReader reader;
+ InputStream is;
+ is = componentTypeFile.openStream();
+ try {
+ reader = xmlFactory.createXMLStreamReader(is);
+ try {
+ reader.nextTag();
+ if (!AssemblyConstants.COMPONENT_TYPE.equals(reader.getName())) {
+ InvalidRootElementException e = new InvalidRootElementException(AssemblyConstants.COMPONENT_TYPE, reader.getName());
+ e.setResourceURI(componentTypeFile.toString());
+ throw e;
+ }
+ return (ComponentType) registry.load(reader, loaderContext);
+ } finally {
+ try {
+ reader.close();
+ } catch (XMLStreamException e) {
+ // ignore
+ }
+ }
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ } catch (IOException e) {
+ SidefileLoadException sfe = new SidefileLoadException(e.getMessage());
+ sfe.setResourceURI(componentTypeFile.toString());
+ throw sfe;
+ } catch (XMLStreamException e) {
+ SidefileLoadException sfe = new SidefileLoadException(e.getMessage());
+ sfe.setResourceURI(componentTypeFile.toString());
+ throw sfe;
+ } catch (ConfigurationLoadException e) {
+ SidefileLoadException sfe = new SidefileLoadException(e.getMessage());
+ sfe.setResourceURI(componentTypeFile.toString());
+ throw sfe;
+ }
+ }
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/rhino/RhinoFunctionInvoker.java b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/rhino/RhinoFunctionInvoker.java
new file mode 100644
index 0000000000..1f0321f60c
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/rhino/RhinoFunctionInvoker.java
@@ -0,0 +1,79 @@
+package org.apache.tuscany.container.rhino.rhino;
+
+import org.apache.xmlbeans.XmlObject;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Function;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
+import org.mozilla.javascript.Wrapper;
+import org.mozilla.javascript.xml.XMLObject;
+
+/**
+ * An invoker for a specific function in a JavaScript script
+ */
+public class RhinoFunctionInvoker {
+
+ private Scriptable instanceScope;
+
+ private Function function;
+
+ private Class responseClass;
+
+ public RhinoFunctionInvoker(Scriptable instanceScope, Function function, Class responseClass) {
+ this.instanceScope = instanceScope;
+ this.function = function;
+ this.responseClass = responseClass;
+ }
+
+ public Object invoke(Object[] args) {
+ Context cx = Context.enter();
+ try {
+
+ Object[] jsArgs = toJavaScript(args, instanceScope, cx);
+ Object jsResponse = function.call(cx, instanceScope, instanceScope, jsArgs);
+ Object response = fromJavaScript(jsResponse);
+ return response;
+
+ } finally {
+ Context.exit();
+ }
+ }
+
+ protected Object[] toJavaScript(Object[] arg, Scriptable scope, Context cx) {
+ Object[] jsArgs;
+ if (arg == null) {
+ jsArgs = new Object[0];
+ } else if (arg.length == 1 && arg[0] instanceof XmlObject) {
+ Object jsXML = cx.getWrapFactory().wrap(cx, scope, (XmlObject) arg[0], XmlObject.class);
+ jsArgs = new Object[] { cx.newObject(scope, "XML", new Object[] { jsXML }) };
+ } else {
+ jsArgs = (Object[]) arg;
+ for (int i = 0; i < jsArgs.length; i++) {
+ jsArgs[i] = Context.toObject(jsArgs[i], scope);
+ }
+ }
+ return jsArgs;
+ }
+
+ protected Object fromJavaScript(Object o) {
+ Object response;
+ if (Context.getUndefinedValue().equals(o)) {
+ response = null;
+ } else if (o instanceof XMLObject) {
+ // TODO: E4X Bug? Shouldn't need this copy, but without it the outer element gets lost???
+ Scriptable jsXML = (Scriptable) ScriptableObject.callMethod((Scriptable) o, "copy", new Object[0]);
+ Wrapper wrapper = (Wrapper) ScriptableObject.callMethod(jsXML, "getXmlObject", new Object[0]);
+ response = wrapper.unwrap();
+ } else if (o instanceof Wrapper) {
+ response = ((Wrapper) o).unwrap();
+ } else {
+ if (responseClass != null) {
+ response = Context.jsToJava(o, responseClass);
+ } else {
+ response = Context.jsToJava(o, String.class);
+ }
+ }
+ return response;
+ }
+
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/rhino/RhinoScript.java b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/rhino/RhinoScript.java
new file mode 100644
index 0000000000..dafc8b585f
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/rhino/RhinoScript.java
@@ -0,0 +1,194 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.rhino;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.ContextFactory;
+import org.mozilla.javascript.ImporterTopLevel;
+import org.mozilla.javascript.Script;
+import org.mozilla.javascript.Scriptable;
+
+/**
+ * A RhinoScript represents a compiled JavaScript script
+ */
+public class RhinoScript {
+
+ protected String scriptName;
+
+ protected String script;
+
+ protected Scriptable scriptScope;
+
+ protected Map<String, Class> responseClasses;
+
+ /*
+ * Enable dynamic scopes so a script can be used concurrently with a global shared scope and individual execution scopes. See
+ * http://www.mozilla.org/rhino/scopes.html
+ */
+ private static class MyFactory extends ContextFactory {
+ protected boolean hasFeature(Context cx, int featureIndex) {
+ if (featureIndex == Context.FEATURE_DYNAMIC_SCOPE) {
+ return true;
+ }
+ return super.hasFeature(cx, featureIndex);
+ }
+ }
+
+ static {
+ ContextFactory.initGlobal(new MyFactory());
+ }
+
+ /**
+ * Create a new RhinoScript.
+ *
+ * @param scriptName
+ * the name of the script. Can be anything, only used in messages to identify the script
+ * @param script
+ * the complete script
+ */
+ public RhinoScript(String scriptName, String script) {
+ this(scriptName, script, (Map) null, null);
+ }
+
+ /**
+ * Create a new RhinoInvoker.
+ *
+ * @param scriptName
+ * the name of the script. Can be anything, only used in messages to identify the script
+ * @param script
+ * the complete script
+ * @param context
+ * name-value pairs that are added in to the scope where the script is compiled. May be null. The value objects are made available to
+ * the script by using a variable with the name.
+ * @param classLoader
+ * the ClassLoader Rhino should use to locate any user Java classes used in the script
+ */
+ public RhinoScript(String scriptName, String script, Map context, ClassLoader cl) {
+ this.scriptName = scriptName;
+ this.script = script;
+ this.responseClasses = new HashMap<String, Class>();
+ initScriptScope(scriptName, script, context, cl);
+ }
+
+ /**
+ * Create a new invokeable instance of the script
+ *
+ * @return a RhinoScriptInstance
+ */
+ public RhinoScriptInstance createRhinoScriptInstance() {
+ return createRhinoScriptInstance(null);
+ }
+
+ /**
+ * Create a new invokeable instance of the script
+ *
+ * @param context
+ * objects to add to scope of the script instance
+ * @return a RhinoScriptInstance
+ */
+ public RhinoScriptInstance createRhinoScriptInstance(Map<String, Object> context) {
+ Scriptable instanceScope = createInstanceScope(context);
+ RhinoScriptInstance rsi = new RhinoScriptInstance(scriptScope, instanceScope, context, responseClasses);
+ return rsi;
+ }
+
+ /**
+ * Initialize the Rhino Scope for this script instance
+ */
+ protected Scriptable createInstanceScope(Map<String, Object> context) {
+ Context cx = Context.enter();
+ try {
+
+ Scriptable instanceScope = cx.newObject(scriptScope);
+ instanceScope.setPrototype(scriptScope);
+ instanceScope.setParentScope(null);
+
+ addContexts(instanceScope, context);
+
+ return instanceScope;
+
+ } finally {
+ Context.exit();
+ }
+ }
+
+ /**
+ * Create a Rhino scope and compile the script into it
+ */
+ protected void initScriptScope(String fileName, String scriptCode, Map context, ClassLoader cl) {
+ Context cx = Context.enter();
+ try {
+ if (cl != null) {
+ cx.setApplicationClassLoader(cl);
+ }
+ this.scriptScope = new ImporterTopLevel(cx, true);
+ Script compiledScript = cx.compileString(scriptCode, fileName, 1, null);
+ compiledScript.exec(cx, scriptScope);
+ addContexts(scriptScope, context);
+
+ } finally {
+ Context.exit();
+ }
+ }
+
+ /**
+ * Add the context to the scope. This will make the objects available to a script by using the name it was added with.
+ */
+ protected void addContexts(Scriptable scope, Map contexts) {
+ if (contexts != null) {
+ for (Iterator i = contexts.keySet().iterator(); i.hasNext();) {
+ String name = (String) i.next();
+ Object value = contexts.get(name);
+ if (value != null) {
+ scope.put(name, scope, Context.toObject(value, scope));
+ }
+ }
+ }
+ }
+
+ public String getScript() {
+ return script;
+ }
+
+ public String getScriptName() {
+ return scriptName;
+ }
+
+ public Scriptable getScriptScope() {
+ return scriptScope;
+ }
+
+ public Map<String, Class> getResponseClasses() {
+ return responseClasses;
+ }
+
+ /**
+ * Set the Java type of a response value. JavaScript is dynamically typed so Rhino
+ * cannot always work out what the intended Java type of a response should be, for
+ * example should the statement "return 42" be a Java int, or Integer or Double etc.
+ * When Rhino can't determine the type it will default to returning a String, using
+ * this method enables overriding the Rhino default to use a specific Java type.
+ */
+ public void setResponseClass(String functionName, Class responseClasses) {
+ this.responseClasses.put(functionName, responseClasses);
+ }
+
+} \ No newline at end of file
diff --git a/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/rhino/RhinoScriptInstance.java b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/rhino/RhinoScriptInstance.java
new file mode 100644
index 0000000000..8f22ae30f2
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/main/java/org/apache/tuscany/container/rhino/rhino/RhinoScriptInstance.java
@@ -0,0 +1,82 @@
+package org.apache.tuscany.container.rhino.rhino;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.Function;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.UniqueTag;
+
+/**
+ * An invokeable instance of a JavaScript script.
+ */
+public class RhinoScriptInstance {
+
+ private Scriptable scriptScope;
+
+ private Scriptable instanceScope;
+
+ private Map<String, Class> responseClasses;
+
+ public RhinoScriptInstance(Scriptable scriptScope, Scriptable instanceScope, Map<String, Object> context, Map<String, Class> responseClasses) {
+ this.scriptScope = scriptScope;
+ this.instanceScope = instanceScope;
+ this.responseClasses = responseClasses;
+ if (this.responseClasses == null) {
+ this.responseClasses = new HashMap<String, Class>();
+ }
+ addContexts(instanceScope, context);
+ }
+
+ public Object invokeFunction(String functionName, Object[] args) {
+ RhinoFunctionInvoker invoker = createRhinoFunctionInvoker(functionName);
+ return invoker.invoke(args);
+ }
+
+ public RhinoFunctionInvoker createRhinoFunctionInvoker(String functionName) {
+ Function function = getFunction(functionName);
+ Class responseClass = responseClasses.get(functionName);
+ RhinoFunctionInvoker invoker = new RhinoFunctionInvoker(instanceScope, function, responseClass);
+ return invoker;
+ }
+
+ /**
+ * Add the context to the scope. This will make the objects available to a script by using the name it was added with.
+ */
+ protected void addContexts(Scriptable scope, Map contexts) {
+ if (contexts != null) {
+ Context.enter();
+ try {
+ for (Iterator i = contexts.keySet().iterator(); i.hasNext();) {
+ String name = (String) i.next();
+ Object value = contexts.get(name);
+ if (value != null) {
+ scope.put(name, scope, Context.toObject(value, scope));
+ }
+ }
+ } finally {
+ Context.exit();
+ }
+ }
+ }
+
+ /**
+ * Get the Rhino Function object for the named script function
+ */
+ protected Function getFunction(String functionName) {
+
+ Object handleObj = scriptScope.get(functionName, instanceScope);
+ if (UniqueTag.NOT_FOUND.equals(handleObj)) {
+ // Bit of a hack so E4X scripts don't need to define a function for every operation
+ handleObj = scriptScope.get("process", instanceScope);
+ }
+ if (!(handleObj instanceof Function)) {
+ throw new RuntimeException("script function '" + functionName + "' is undefined or not a function");
+ }
+
+ return (Function) handleObj;
+ }
+
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/main/resources/system.fragment b/sandbox/ant/tuscany-container-rhino/src/main/resources/system.fragment
new file mode 100644
index 0000000000..928e637481
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/main/resources/system.fragment
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<moduleFragment xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ xmlns:tuscany="http://org.apache.tuscany/xmlns/system/0.9"
+ name="org.apache.tuscany.container.rhino">
+
+ <component name="org.apache.tuscany.container.rhino.builder.JavaScriptContextFactoryBuilder">
+ <tuscany:implementation.system class="org.apache.tuscany.container.rhino.builder.JavaScriptContextFactoryBuilder"/>
+ </component>
+
+ <component name="org.apache.tuscany.container.rhino.builder.JavaScriptTargetWireBuilder">
+ <tuscany:implementation.system class="org.apache.tuscany.container.rhino.builder.JavaScriptTargetWireBuilder"/>
+ </component>
+
+ <component name="org.apache.tuscany.container.rhino.loader.JavaScriptImplementationLoader">
+ <tuscany:implementation.system class="org.apache.tuscany.container.rhino.loader.JavaScriptImplementationLoader"/>
+ </component>
+
+ <component name="org.apache.tuscany.container.rhino.e4x.E4XPolicyBuilder">
+ <tuscany:implementation.system class="org.apache.tuscany.container.rhino.e4x.E4XPolicyBuilder"/>
+ </component>
+
+</moduleFragment>
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/builder/JavaScriptContextFactoryBuilderTestCase.java b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/builder/JavaScriptContextFactoryBuilderTestCase.java
new file mode 100644
index 0000000000..8d25183386
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/builder/JavaScriptContextFactoryBuilderTestCase.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.container.rhino.assembly.JavaScriptImplementation;
+import org.apache.tuscany.container.rhino.context.JavaScriptComponentContext;
+import org.apache.tuscany.core.builder.ContextFactory;
+import org.apache.tuscany.core.extension.ExternalServiceInvoker;
+import org.apache.tuscany.model.assembly.AssemblyContext;
+import org.apache.tuscany.model.assembly.AssemblyInitializationException;
+import org.apache.tuscany.model.assembly.AssemblyVisitor;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Property;
+import org.apache.tuscany.model.assembly.Reference;
+import org.apache.tuscany.model.assembly.Service;
+
+/**
+ * Tests for the RhinoScript
+ */
+public class JavaScriptContextFactoryBuilderTestCase extends TestCase {
+
+ public JavaScriptContextFactoryBuilderTestCase() {
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testSimpleConstructor() {
+ JavaScriptContextFactoryBuilder builder = new JavaScriptContextFactoryBuilder();
+ JavaScriptImplementation jsImpl = createMockJSImpl();
+ jsImpl.setScript("function foo() { return 'petra';}");
+
+ ContextFactory cf = builder.createContextFactory("foo", jsImpl, null);
+ assertNotNull(cf);
+
+ JavaScriptComponentContext context = (JavaScriptComponentContext) cf.createContext();
+ assertNotNull(context);
+
+ ExternalServiceInvoker invoker = (ExternalServiceInvoker) context.getTargetInstance();
+ assertNotNull(invoker);
+
+ Object response = invoker.invoke("foo", new Object[0]);
+ assertEquals("petra", response);
+ }
+
+ private JavaScriptImplementation createMockJSImpl() {
+ JavaScriptImplementation jsImpl = new JavaScriptImplementation();
+
+ jsImpl.setComponentType(new ComponentType() {
+
+ public List<Service> getServices() {
+ return new ArrayList<Service>();
+ }
+
+ public Service getService(String name) {
+ return null;
+ }
+
+ public List<Reference> getReferences() {
+ return null;
+ }
+
+ public Reference getReference(String name) {
+ return null;
+ }
+
+ public List<Property> getProperties() {
+ return new ArrayList<Property>();
+ }
+
+ public Property getProperty(String name) {
+ return null;
+ }
+
+ public List<Object> getExtensibilityElements() {
+ return null;
+ }
+
+ public List<Object> getExtensibilityAttributes() {
+ return null;
+ }
+
+ public void initialize(AssemblyContext modelContext) throws AssemblyInitializationException {
+ }
+
+ public void freeze() {
+ }
+
+ public boolean accept(AssemblyVisitor visitor) {
+ return false;
+ }
+ });
+
+ jsImpl.setResourceLoader(new ResourceLoaderImpl(getClass().getClassLoader()));
+
+ return jsImpl;
+ }
+
+} \ No newline at end of file
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/e4x/E4XInterceptorTestCase.java b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/e4x/E4XInterceptorTestCase.java
new file mode 100644
index 0000000000..a5c778acf2
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/e4x/E4XInterceptorTestCase.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.e4x;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.wire.Interceptor;
+import org.apache.tuscany.core.wire.MessageChannel;
+import org.apache.tuscany.core.wire.TargetInvoker;
+import org.apache.tuscany.sdo.util.DataObjectUtil;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.apache.xmlbeans.XmlObject;
+
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XSDHelper;
+
+/**
+ * Tests for the E4XInterceptor
+ */
+public class E4XInterceptorTestCase extends TestCase {
+
+ private E4XInterceptor interceptor;
+
+ private Message msg;
+
+ public E4XInterceptorTestCase() {
+ }
+
+ public void testFromXmlObject() {
+ msg.setBody(new Object[] { "petra" });
+
+ interceptor.toXmlObject(msg);
+ assertTrue(((Object[])msg.getBody())[0] instanceof XmlObject);
+
+ msg.setBody(((Object[])msg.getBody())[0]);
+ interceptor.fromXmlObject(msg);
+ assertEquals("petra", msg.getBody());
+ }
+
+ public void testToXmlObject() {
+ msg.setBody(new Object[] { "petra" });
+ interceptor.toXmlObject(msg);
+ assertTrue(((Object[])msg.getBody())[0] instanceof XmlObject);
+ }
+
+ public void testInvoke() {
+ msg.setBody(new Object[] { "petra" });
+ interceptor.invoke(msg);
+ assertEquals("petra", msg.getBody());
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ DataObjectUtil.initRuntime();
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+
+ TypeHelper typeHelper = SDOUtil.createTypeHelper();
+ XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper);
+
+ URL url = getClass().getResource("helloworld.wsdl");
+ xsdHelper.define(url.openStream(), null);
+
+ QName qn = new QName("http://integration.rhino.container.tuscany.apache.org", "getGreetings");
+ this.interceptor = new E4XInterceptor(qn, typeHelper, getClass().getClassLoader());
+ interceptor.setNext(new Interceptor() {
+ public Message invoke(Message msg) {
+ msg.setBody(((Object[])msg.getBody())[0]);
+ return msg;
+ }
+ public void setNext(Interceptor next) {
+ }});
+
+ this.msg = createMessage();
+
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+
+ private Message createMessage() {
+ Message msg = new Message() {
+
+ Object body;
+
+ public Object getBody() {
+ return body;
+ }
+
+ public void setBody(Object body) {
+ this.body = body;
+ }
+
+ public void setTargetInvoker(TargetInvoker invoker) {
+ }
+
+ public TargetInvoker getTargetInvoker() {
+ return null;
+ }
+
+ public MessageChannel getCallbackChannel() {
+ return null;
+ }
+
+ public Message getRelatedCallbackMessage() {
+ return null;
+ }
+ };
+ return msg;
+ }
+
+} \ No newline at end of file
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/e4x/E4XPolicyBuilderTestCase.java b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/e4x/E4XPolicyBuilderTestCase.java
new file mode 100644
index 0000000000..09638e7eae
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/e4x/E4XPolicyBuilderTestCase.java
@@ -0,0 +1,325 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.e4x;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Input;
+import javax.wsdl.Message;
+import javax.wsdl.Operation;
+import javax.wsdl.Part;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.container.rhino.assembly.JavaScriptImplementation;
+import org.apache.tuscany.core.wire.Interceptor;
+import org.apache.tuscany.core.wire.TargetInvocationConfiguration;
+import org.apache.tuscany.core.wire.WireTargetConfiguration;
+import org.apache.tuscany.model.assembly.AssemblyContext;
+import org.apache.tuscany.model.assembly.AssemblyInitializationException;
+import org.apache.tuscany.model.assembly.AssemblyVisitor;
+import org.apache.tuscany.model.assembly.AtomicComponent;
+import org.apache.tuscany.model.assembly.AtomicImplementation;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Composite;
+import org.apache.tuscany.model.assembly.ConfiguredProperty;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.Property;
+import org.apache.tuscany.model.assembly.Reference;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.ServiceContract;
+import org.apache.tuscany.model.types.wsdl.impl.WSDLServiceContractImpl;
+
+import com.ibm.wsdl.InputImpl;
+import com.ibm.wsdl.MessageImpl;
+import com.ibm.wsdl.OperationImpl;
+import com.ibm.wsdl.PartImpl;
+import com.ibm.wsdl.PortTypeImpl;
+
+/**
+ * Tests for the E4XPolicyBuilder
+ */
+public class E4XPolicyBuilderTestCase extends TestCase {
+
+ public E4XPolicyBuilderTestCase() {
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testGetElementQName() {
+ E4XPolicyBuilder builder = new E4XPolicyBuilder();
+ QName qn = new QName("foo");
+ JavaScriptImplementation jsImpl = createMockJSImpl("foo", qn);
+ QName qn2 = builder.getElementQName(jsImpl, "foo");
+ assertEquals(qn, qn2);
+ }
+
+ public void testBuild() throws SecurityException, NoSuchMethodException {
+ E4XPolicyBuilder builder = new E4XPolicyBuilder();
+ ConfiguredService service = createMockConfiguredService();
+ WireTargetConfiguration config = createMockWireTargetConfiguration();
+ builder.build(service, config);
+ Map<Method, TargetInvocationConfiguration> configs = config.getInvocationConfigurations();
+ assertNotNull(configs);
+ assertEquals(1, configs.size());
+ TargetInvocationConfiguration tic = configs.values().iterator().next();
+ Interceptor interceptor = tic.getHeadInterceptor();
+ assertTrue(interceptor instanceof E4XInterceptor);
+ }
+
+ private WireTargetConfiguration createMockWireTargetConfiguration() throws SecurityException, NoSuchMethodException {
+ Map<Method, TargetInvocationConfiguration> configs = new HashMap<Method, TargetInvocationConfiguration>();
+ Method foo = Foo.class.getMethod("foo", new Class[0]);
+ TargetInvocationConfiguration config = new TargetInvocationConfiguration(foo);
+ configs.put(foo, config);
+ WireTargetConfiguration wtf = new WireTargetConfiguration(null, configs, null, null);
+ return wtf;
+ }
+
+ interface Foo {
+ public void foo();
+ }
+
+ private ConfiguredService createMockConfiguredService() {
+ ConfiguredService service = new ConfiguredService() {
+
+ public String getName() {
+ return null;
+ }
+
+ public void setName(String name) {
+ }
+
+ public Service getPort() {
+ return null;
+ }
+
+ public void setPort(Service port) {
+ }
+
+ public org.apache.tuscany.model.assembly.Part getPart() {
+ return createPart();
+ }
+
+ public void setPart(org.apache.tuscany.model.assembly.Part part) {
+ }
+
+ public void initialize(AssemblyContext modelContext) throws AssemblyInitializationException {
+ }
+
+ public void freeze() {
+ }
+
+ public boolean accept(AssemblyVisitor visitor) {
+ return false;
+ }
+
+ public void setProxyFactory(Object proxyFactory) {
+ }
+
+ public Object getProxyFactory() {
+ return null;
+ }
+ };
+
+ return service;
+ }
+
+ private org.apache.tuscany.model.assembly.Part createPart() {
+ org.apache.tuscany.model.assembly.Part part = new AtomicComponent() {
+
+ public AtomicImplementation getImplementation() {
+ return createMockJSImpl("foo", new QName("foo"));
+ }
+
+ public void setImplementation(AtomicImplementation value) {
+ }
+
+ public List<ConfiguredProperty> getConfiguredProperties() {
+ return null;
+ }
+
+ public ConfiguredProperty getConfiguredProperty(String name) {
+ return null;
+ }
+
+ public List<ConfiguredReference> getConfiguredReferences() {
+ return null;
+ }
+
+ public ConfiguredReference getConfiguredReference(String name) {
+ return null;
+ }
+
+ public List<ConfiguredService> getConfiguredServices() {
+ return null;
+ }
+
+ public ConfiguredService getConfiguredService(String name) {
+ return null;
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public void setName(String value) {
+ }
+
+ public Composite getComposite() {
+ return null;
+ }
+
+ public void setComposite(Composite composite) {
+ }
+
+ public List<Object> getExtensibilityElements() {
+ return null;
+ }
+
+ public List<Object> getExtensibilityAttributes() {
+ return null;
+ }
+
+ public void initialize(AssemblyContext modelContext) throws AssemblyInitializationException {
+ }
+
+ public void freeze() {
+ }
+
+ public boolean accept(AssemblyVisitor visitor) {
+ return false;
+ }
+
+ public void setContextFactory(Object contextFactory) {
+ }
+
+ public Object getContextFactory() {
+ return null;
+ }
+ };
+ return part;
+ }
+
+ private JavaScriptImplementation createMockJSImpl(final String name, final QName qn) {
+ JavaScriptImplementation jsImpl = new JavaScriptImplementation();
+
+ jsImpl.setComponentType(new ComponentType() {
+
+ public List<Service> getServices() {
+ return Arrays.asList(new Service[] { createMockService(name, qn) });
+ }
+
+ public Service getService(String name) {
+ return null;
+ }
+
+ public List<Reference> getReferences() {
+ return null;
+ }
+
+ public Reference getReference(String name) {
+ return null;
+ }
+
+ public List<Property> getProperties() {
+ return new ArrayList<Property>();
+ }
+
+ public Property getProperty(String name) {
+ return null;
+ }
+
+ public List<Object> getExtensibilityElements() {
+ return null;
+ }
+
+ public List<Object> getExtensibilityAttributes() {
+ return null;
+ }
+
+ public void initialize(AssemblyContext modelContext) throws AssemblyInitializationException {
+ }
+
+ public void freeze() {
+ }
+
+ public boolean accept(AssemblyVisitor visitor) {
+ return false;
+ }
+ });
+
+ jsImpl.setResourceLoader(new ResourceLoaderImpl(getClass().getClassLoader()));
+
+ return jsImpl;
+ }
+
+ private Service createMockService(final String name, final QName qn) {
+ Service service = new Service() {
+
+ public ServiceContract getServiceContract() {
+ WSDLServiceContractImpl sc = new WSDLServiceContractImpl();
+ PortType pt = new PortTypeImpl();
+ Operation op = new OperationImpl();
+ op.setName(name);
+ Input input = new InputImpl();
+ Message msg = new MessageImpl();
+ Part p = new PartImpl();
+ p.setElementName(qn);
+ msg.addPart(p);
+ input.setMessage(msg);
+ op.setInput(input);
+ pt.addOperation(op);
+ sc.setPortType(pt);
+ return sc;
+ }
+
+ public void setServiceContract(ServiceContract contract) {
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public void setName(String name) {
+ }
+
+ public void initialize(AssemblyContext modelContext) throws AssemblyInitializationException {
+ }
+
+ public void freeze() {
+ }
+
+ public boolean accept(AssemblyVisitor visitor) {
+ return false;
+ }
+ };
+ return service;
+ }
+
+} \ No newline at end of file
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/AbstractJavaScriptTestCase.java b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/AbstractJavaScriptTestCase.java
new file mode 100644
index 0000000000..ee6b533ddf
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/AbstractJavaScriptTestCase.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.integration;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.client.TuscanyRuntime;
+import org.osoa.sca.CurrentModuleContext;
+import org.osoa.sca.ModuleContext;
+
+/**
+ * Integration tests for JavaScript components
+ */
+public abstract class AbstractJavaScriptTestCase extends TestCase {
+
+ protected TuscanyRuntime tuscany;
+
+ protected ModuleContext moduleContext;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ tuscany = new TuscanyRuntime("tests", null);
+ tuscany.start();
+ moduleContext = CurrentModuleContext.getContext();
+
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ tuscany.stop();
+ }
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/BasicTestCase.java b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/BasicTestCase.java
new file mode 100644
index 0000000000..f66f2e1079
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/BasicTestCase.java
@@ -0,0 +1,27 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.integration;
+
+/**
+ * Integration tests for JavaScript components
+ */
+public class BasicTestCase extends AbstractJavaScriptTestCase {
+
+ public void testBasicInvocation() throws Exception {
+ HelloWorld helloworldService = (HelloWorld) moduleContext.locateService("HelloWorldComponent1");
+ String response = helloworldService.getGreetings("petra");
+ assertEquals("jsHello petra", response);
+ }
+
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/E4XServiceRefsTestCase.java b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/E4XServiceRefsTestCase.java
new file mode 100644
index 0000000000..76908b48d1
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/E4XServiceRefsTestCase.java
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.integration;
+
+
+/**
+ * Integration tests for JavaScript components and composite contexts
+ *
+ * @version $Rev$ $Date$
+ */
+public class E4XServiceRefsTestCase extends AbstractJavaScriptTestCase {
+
+ public void testE4X() throws Exception {
+ //TODO: E4X serviceRefs don't work yet
+// HelloWorld helloworldService = (HelloWorld) moduleContext.locateService("HelloWorldComponentE4XProxy");
+// String response = helloworldService.getGreetings("petra");
+// assertEquals("e4xHello proxy:petra", response);
+ }
+
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/E4XTestCase.java b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/E4XTestCase.java
new file mode 100644
index 0000000000..d6060aea90
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/E4XTestCase.java
@@ -0,0 +1,29 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.integration;
+
+/**
+ * Integration tests for JavaScript components and composite contexts
+ *
+ * @version $Rev$ $Date$
+ */
+public class E4XTestCase extends AbstractJavaScriptTestCase {
+
+ public void testE4X() throws Exception {
+ HelloWorld helloworldService = (HelloWorld) moduleContext.locateService("HelloWorldComponentE4X");
+ String response = helloworldService.getGreetings("petra");
+ assertEquals("e4xHello petra", response);
+ }
+
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/HelloWorld.java b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/HelloWorld.java
new file mode 100644
index 0000000000..3a90be0102
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/HelloWorld.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.integration;
+
+/**
+ * This is the business interface of the HelloWorld service component.
+ */
+public interface HelloWorld {
+
+ public String getGreetings(String name);
+
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/InitializationTestCase.java b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/InitializationTestCase.java
new file mode 100644
index 0000000000..138d9a8452
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/InitializationTestCase.java
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.integration;
+
+/**
+ * Integration tests for JavaScript components
+ */
+public class InitializationTestCase extends AbstractJavaScriptTestCase {
+
+ public void testInitialization() throws Exception {
+ HelloWorld helloworldService = (HelloWorld) moduleContext.locateService("HelloWorldComponent4");
+ String response = helloworldService.getGreetings("petra");
+ assertEquals("Bonjour petra", response);
+ }
+
+ public void testImports1() throws Exception {
+ HelloWorld helloworldService = (HelloWorld) moduleContext.locateService("HelloWorldComponent5");
+ String response = helloworldService.getGreetings("petra");
+ assertEquals("Kia ora petra", response);
+ }
+
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/PropertiesTestCase.java b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/PropertiesTestCase.java
new file mode 100644
index 0000000000..7b14376dbe
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/PropertiesTestCase.java
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.integration;
+
+/**
+ * Integration tests for JavaScript components
+ */
+public class PropertiesTestCase extends AbstractJavaScriptTestCase {
+
+ public void testDefaultProperty() throws Exception {
+ HelloWorld helloworldService = (HelloWorld) moduleContext.locateService("HelloWorldComponent2a");
+ String response = helloworldService.getGreetings("petra");
+ assertEquals("Hi petra", response);
+ }
+
+ public void testOverrideProperty() throws Exception {
+ HelloWorld helloworldService = (HelloWorld) moduleContext.locateService("HelloWorldComponent2b");
+ String response = helloworldService.getGreetings("petra");
+ assertEquals("Guten Tag petra", response);
+ }
+
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/ServiceRefsTestCase.java b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/ServiceRefsTestCase.java
new file mode 100644
index 0000000000..7a6ac040d1
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/ServiceRefsTestCase.java
@@ -0,0 +1,27 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.integration;
+
+/**
+ * Integration tests for JavaScript components
+ */
+public class ServiceRefsTestCase extends AbstractJavaScriptTestCase {
+
+ public void testServiceReference() throws Exception {
+ HelloWorld helloworldService = (HelloWorld) moduleContext.locateService("HelloWorldProxyComponent");
+ String response = helloworldService.getGreetings("petra");
+ assertEquals("Hi proxy:petra", response);
+ }
+
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/TestMethods.java b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/TestMethods.java
new file mode 100644
index 0000000000..327edd1cbb
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/integration/TestMethods.java
@@ -0,0 +1,30 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.integration;
+
+public class TestMethods {
+
+ private String salutation = "Kia ora";
+
+ public String getSalutation() {
+ return salutation;
+ }
+
+ public void getSalutation(String s) {
+ salutation = s;
+ }
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/rhino/Foo.java b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/rhino/Foo.java
new file mode 100644
index 0000000000..6bcad30c23
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/rhino/Foo.java
@@ -0,0 +1,16 @@
+package org.apache.tuscany.container.rhino.rhino;
+
+class Foo {
+ private String s;
+
+ public Foo() {
+ }
+
+ public String getS() {
+ return s;
+ }
+
+ public void setS(String s) {
+ this.s = s;
+ }
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/rhino/RhinoFunctionInvokerTestCase.java b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/rhino/RhinoFunctionInvokerTestCase.java
new file mode 100644
index 0000000000..38705841f6
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/rhino/RhinoFunctionInvokerTestCase.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.rhino;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.rhino.rhino.RhinoFunctionInvoker;
+import org.apache.tuscany.container.rhino.rhino.RhinoScript;
+import org.apache.tuscany.container.rhino.rhino.RhinoScriptInstance;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlObject;
+
+/**
+ * Tests for the RhinoScript
+ */
+public class RhinoFunctionInvokerTestCase extends TestCase {
+
+ public RhinoFunctionInvokerTestCase() {
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testNoArgsInvoke() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getPetra() {return 'petra';}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getPetra");
+ assertNotNull(invoker);
+ assertEquals("petra", invoker.invoke(null));
+ }
+
+ public void testOneArgInvoke() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getS(s) {return s;}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getS");
+ assertNotNull(invoker);
+ assertEquals("petra", invoker.invoke(new Object[]{"petra"}));
+ }
+
+ public void testMultiArgsInvoke() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function concat(x, y) {return x + y}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("concat");
+ assertNotNull(invoker);
+ assertEquals("petrasue", invoker.invoke(new Object[] { "petra", "sue"}));
+ }
+
+ public void testNoResponseInvoke() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getNull() {}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getNull");
+ assertNotNull(invoker);
+ assertEquals(null, invoker.invoke(new Object[0]));
+ }
+
+ public void testNullResponseInvoke() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getNull() {return null;}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getNull");
+ assertNotNull(invoker);
+ assertEquals(null, invoker.invoke(new Object[0]));
+ }
+
+ public void testResponseTypeDefaultString() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getTrue() {return true;}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getTrue");
+ assertNotNull(invoker);
+ Object o = invoker.invoke(new Object[0]);
+ assertTrue(o instanceof String);
+ assertEquals( "true", o);
+ }
+
+ public void testResponseTypeBoolean() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getTrue() {return true;}");
+ rhinoScript.setResponseClass("getTrue", Boolean.class);
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getTrue");
+ assertNotNull(invoker);
+ assertTrue((Boolean)invoker.invoke(new Object[0]));
+ }
+
+ public void testResponseTypeStringArray() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getAs() {var as = new Array(1);as[0]='petra';return as;}");
+ rhinoScript.setResponseClass("getAs", new String[0].getClass());
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getAs");
+ assertNotNull(invoker);
+ Object o = invoker.invoke(new Object[0]);
+ assertNotNull(o);
+ assertTrue(o.getClass().isArray());
+ assertEquals("petra", ((Object[])o)[0]);
+ }
+
+
+ public void testResponseTypeBooleanArray() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getBs() {var bs = new Array(1);bs[0]=true;return bs;}");
+ rhinoScript.setResponseClass("getBs", new Boolean[0].getClass());
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getBs");
+ assertNotNull(invoker);
+ Object o = invoker.invoke(new Object[0]);
+ assertNotNull(o);
+ assertTrue(o.getClass().isArray());
+ assertTrue(((Boolean[])o)[0]);
+ }
+
+ public void testRequestCustomType() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getFooS(foo) {return foo.getS();}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getFooS");
+ assertNotNull(invoker);
+
+ Foo foo = new Foo();
+ foo.setS("petra");
+ Object o = invoker.invoke(new Object[] {foo});
+ assertEquals(foo.getS(), o);
+ }
+
+ public void testResponseCustomType() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "importClass(Packages.org.apache.tuscany.container.rhino.rhino.Foo);function getFoo(s) {var foo = new Foo(); foo.setS(s);return foo;}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getFoo");
+ assertNotNull(invoker);
+
+ Object o = invoker.invoke(new Object[] {"petra"});
+ assertNotNull(o);
+ assertEquals("petra", ((Foo)o).getS());
+ }
+
+ public void testXMLRequest() throws XmlException, IOException {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function isXML(x) {return 'xml' == (typeof x);}");
+ rhinoScript.setResponseClass("isXML", Boolean.class);
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("isXML");
+ assertNotNull(invoker);
+
+ Object xml = XmlObject.Factory.parse("<a><b/></a>");
+ assertTrue((Boolean) invoker.invoke(new Object[]{xml}));
+
+ Object notXML = "notXML";
+ assertFalse((Boolean) invoker.invoke(new Object[]{notXML}));
+ }
+
+ public void testXMLResponse() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getXML(s) {return <a> { s } </a>;}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getXML");
+ assertNotNull(invoker);
+
+ Object xml = invoker.invoke(new Object[]{"petra"});
+ assertNotNull(xml);
+ assertTrue(xml instanceof XmlObject);
+ assertEquals("<a>petra</a>",((XmlObject)xml).toString());
+ }
+
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/rhino/RhinoScriptInstanceTestCase.java b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/rhino/RhinoScriptInstanceTestCase.java
new file mode 100644
index 0000000000..480bbfb2d8
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/rhino/RhinoScriptInstanceTestCase.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.rhino;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for the RhinoScript
+ */
+public class RhinoScriptInstanceTestCase extends TestCase {
+
+ public RhinoScriptInstanceTestCase() {
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testInvokeFunction() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getPetra() {return 'petra';}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ assertEquals("petra", instance.invokeFunction("getPetra", new Object[0]));
+ }
+
+ public void testCreateRhinoFunctionInvoker() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getPetra() {return 'petra';}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ RhinoFunctionInvoker invoker = instance.createRhinoFunctionInvoker("getPetra");
+ assertNotNull(invoker);
+ assertEquals("petra", invoker.invoke(new Object[0]));
+ }
+
+} \ No newline at end of file
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/rhino/RhinoScriptTestCase.java b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/rhino/RhinoScriptTestCase.java
new file mode 100644
index 0000000000..05f5624e7c
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/java/org/apache/tuscany/container/rhino/rhino/RhinoScriptTestCase.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+package org.apache.tuscany.container.rhino.rhino;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for the RhinoScript
+ */
+public class RhinoScriptTestCase extends TestCase {
+
+ public RhinoScriptTestCase() {
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testSimpleConstructor() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getPetra() {return 'petra';}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ assertEquals("petra", instance.invokeFunction("getPetra", new Object[0]));
+ }
+
+ public void testFullConstructor() {
+ ClassLoader cl = getClass().getClassLoader();
+ Map<String, Object> contexts = new HashMap<String, Object>();
+ contexts.put("name", "petra");
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getName() {return name;}",contexts , cl);
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ assertEquals("petra", instance.invokeFunction("getName", new Object[0]));
+ }
+
+ public void testCreateInstance() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getPetra() {return 'petra';}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ assertNotNull(instance);
+ }
+
+ public void testCreateInstanceWithContext() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getName() {return name;}");
+ Map<String, Object> contexts = new HashMap<String, Object>();
+ contexts.put("name", "petra");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance(contexts);
+ assertEquals("petra", instance.invokeFunction("getName", new Object[0]));
+ }
+
+ public void testDefaultResponseType() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getX() {return 42;}");
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ assertEquals("42", instance.invokeFunction("getX", new Object[0]));
+ }
+
+ public void testSetResponseType() {
+ RhinoScript rhinoScript = new RhinoScript("foo", "function getX() {return 42;}");
+ rhinoScript.setResponseClass("getX", Integer.class);
+ RhinoScriptInstance instance = rhinoScript.createRhinoScriptInstance();
+ Object x = instance.invokeFunction("getX", new Object[0]);
+ assertTrue(x instanceof Integer);
+ assertEquals(new Integer(42), x);
+ }
+
+} \ No newline at end of file
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/org/apache/tuscany/container/rhino/e4x/helloworld.wsdl b/sandbox/ant/tuscany-container-rhino/src/test/resources/org/apache/tuscany/container/rhino/e4x/helloworld.wsdl
new file mode 100644
index 0000000000..7bcb48dcf2
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/org/apache/tuscany/container/rhino/e4x/helloworld.wsdl
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<wsdl:definitions targetNamespace="http://integration.rhino.container.tuscany.apache.org" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://integration.rhino.container.tuscany.apache.org" xmlns:intf="http://helloworld.samples.tuscany.apache.org" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="helloworld">
+ <!--WSDL created by Apache Axis version: 1.2.1
+Built on Jun 14, 2005 (09:15:57 EDT)-->
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://integration.rhino.container.tuscany.apache.org" xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="getGreetings">
+ <complexType>
+ <sequence>
+ <element name="in0" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="getGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetingsRequest">
+
+ <wsdl:part element="impl:getGreetings" name="parameters"/>
+
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+
+ <wsdl:part element="impl:getGreetingsResponse" name="parameters"/>
+
+ </wsdl:message>
+
+ <wsdl:portType name="HelloWorld">
+
+ <wsdl:operation name="getGreetings">
+
+ <wsdl:input message="impl:getGreetingsRequest" name="getGreetingsRequest"/>
+
+ <wsdl:output message="impl:getGreetingsResponse" name="getGreetingsResponse"/>
+
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="helloworldSoapBinding" type="impl:HelloWorld">
+
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="getGreetings">
+
+ <wsdlsoap:operation soapAction=""/>
+
+ <wsdl:input name="getGreetingsRequest">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:input>
+
+ <wsdl:output name="getGreetingsResponse">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:output>
+
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="HelloWorldServiceImplService">
+
+ <wsdl:port binding="impl:helloworldSoapBinding" name="helloworld">
+
+ <wsdlsoap:address location="http://localhost:8080/helloworldws/services/HelloWorldService"/>
+
+ </wsdl:port>
+
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/sca.module b/sandbox/ant/tuscany-container-rhino/src/test/resources/sca.module
new file mode 100644
index 0000000000..d25cc1304a
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/sca.module
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ xmlns:js="http://org.apache.tuscany/xmlns/js/0.9"
+
+ name="JavaScriptTests">
+
+ <component name="HelloWorldComponent1">
+ <js:implementation.js scriptFile="tests/HelloWorldImpl1.js"/>
+ </component>
+
+ <component name="HelloWorldComponent2a">
+ <js:implementation.js scriptFile="tests/HelloWorldImpl2.js"/>
+ </component>
+
+ <component name="HelloWorldComponent2b">
+ <js:implementation.js scriptFile="tests/HelloWorldImpl2.js"/>
+ <properties>
+ <v:salutation>Guten Tag</v:salutation>
+ </properties>
+ </component>
+
+ <component name="HelloWorldProxyComponent">
+ <js:implementation.js scriptFile="tests/HelloWorldProxyImpl.js"/>
+ <references>
+ <v:HelloWorldService>HelloWorldComponent2b</v:HelloWorldService>
+ </references>
+ </component>
+
+ <component name="HelloWorldComponent4">
+ <js:implementation.js scriptFile="tests/HelloWorldImpl4.js"/>
+ </component>
+
+ <component name="HelloWorldComponent5">
+ <js:implementation.js scriptFile="tests/HelloWorldImpl5.js"/>
+ </component>
+
+ <import.sdo wsdlLocation="wsdl/helloworld.wsdl"/>
+ <import.wsdl wsdlLocation="wsdl/helloworld.wsdl"/>
+
+ <component name="HelloWorldComponentE4X">
+ <js:implementation.js scriptFile="tests/e4x.js"/>
+ </component>
+
+ <component name="HelloWorldComponentE4XProxy">
+ <js:implementation.js scriptFile="tests/HelloWorldE4XProxyImpl.js"/>
+ <references>
+ <v:HelloWorldService>HelloWorldComponentE4X</v:HelloWorldService>
+ </references>
+ </component>
+
+</module>
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldE4XProxyImpl.componentType b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldE4XProxyImpl.componentType
new file mode 100644
index 0000000000..19e8708bf4
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldE4XProxyImpl.componentType
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldProxyService">
+ <interface.java interface="org.apache.tuscany.container.rhino.integration.HelloWorld"/>
+ </service>
+
+ <reference name="HelloWorldService">
+ <interface.wsdl interface="http://integration.rhino.container.tuscany.apache.org#HelloWorld"/>
+ </reference>
+
+</componentType> \ No newline at end of file
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldE4XProxyImpl.js b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldE4XProxyImpl.js
new file mode 100644
index 0000000000..505ce33204
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldE4XProxyImpl.js
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+
+function getGreetings(name) {
+
+ var requestXML =
+ <ns:getGreetings xmlns:ns="http://integration.rhino.container.tuscany.apache.org">
+ <ns:in0>{ "proxy:" + name }</ns:in0>
+ </ns:getGreetings>;
+
+ var responseXML = HelloWorldService.process(requestXML);
+
+ return responseXML..*::getGreetingsReturn;
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl1.componentType b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl1.componentType
new file mode 100644
index 0000000000..90b6c09015
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl1.componentType
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="org.apache.tuscany.container.rhino.integration.HelloWorld"/>
+ </service>
+
+</componentType> \ No newline at end of file
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl1.js b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl1.js
new file mode 100644
index 0000000000..b3104f78a5
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl1.js
@@ -0,0 +1,20 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+
+function getGreetings(name) {
+ return "jsHello " + name;
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl2.componentType b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl2.componentType
new file mode 100644
index 0000000000..33208811bf
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl2.componentType
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="org.apache.tuscany.container.rhino.integration.HelloWorld"/>
+ </service>
+
+ <property name="salutation" type="xsd:string" default="Hi"/>
+
+</componentType> \ No newline at end of file
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl2.js b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl2.js
new file mode 100644
index 0000000000..4f91dba40e
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl2.js
@@ -0,0 +1,20 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+
+function getGreetings(name) {
+ return salutation + " " + name;
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl4.componentType b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl4.componentType
new file mode 100644
index 0000000000..90b6c09015
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl4.componentType
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="org.apache.tuscany.container.rhino.integration.HelloWorld"/>
+ </service>
+
+</componentType> \ No newline at end of file
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl4.js b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl4.js
new file mode 100644
index 0000000000..338c3ac3cd
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl4.js
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+
+initSalutation();
+
+function getGreetings(name) {
+ return SALUTATION + name;
+}
+
+function initSalutation() {
+ SALUTATION = "Bonjour ";
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl5.componentType b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl5.componentType
new file mode 100644
index 0000000000..90b6c09015
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl5.componentType
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldService">
+ <interface.java interface="org.apache.tuscany.container.rhino.integration.HelloWorld"/>
+ </service>
+
+</componentType> \ No newline at end of file
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl5.js b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl5.js
new file mode 100644
index 0000000000..f01cd1727f
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldImpl5.js
@@ -0,0 +1,29 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+
+//importPackage(Packages.sample.utils);
+importClass(Packages.org.apache.tuscany.container.rhino.integration.TestMethods);
+
+initSalutation();
+
+function getGreetings(name) {
+ return SALUTATION.getSalutation() + " " + name;
+}
+
+function initSalutation() {
+ SALUTATION = new TestMethods();
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldProxyImpl.componentType b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldProxyImpl.componentType
new file mode 100644
index 0000000000..18192988ee
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldProxyImpl.componentType
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldProxyService">
+ <interface.java interface="org.apache.tuscany.container.rhino.integration.HelloWorld"/>
+ </service>
+
+ <reference name="HelloWorldService">
+ <interface.java interface="org.apache.tuscany.container.rhino.integration.HelloWorld"/>
+ </reference>
+
+</componentType> \ No newline at end of file
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldProxyImpl.js b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldProxyImpl.js
new file mode 100644
index 0000000000..ef1c176c76
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/HelloWorldProxyImpl.js
@@ -0,0 +1,20 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+
+function getGreetings(name) {
+ return HelloWorldService.getGreetings("proxy:" + name);
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/e4x.componentType b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/e4x.componentType
new file mode 100644
index 0000000000..9eccef8ad6
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/e4x.componentType
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <service name="HelloWorldE4XService">
+ <interface.wsdl interface="http://integration.rhino.container.tuscany.apache.org#HelloWorld"/>
+ </service>
+
+</componentType> \ No newline at end of file
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/e4x.js b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/e4x.js
new file mode 100644
index 0000000000..7fe882df55
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/tests/e4x.js
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+
+function process(xmlIn) {
+
+ var greeting = "e4xHello " + xmlIn..*::in0;
+
+ var xmlOut =
+ <helloworld:getGreetingsResponse xmlns:helloworld="http://integration.rhino.container.tuscany.apache.org">
+ <helloworld:getGreetingsReturn> { greeting } </helloworld:getGreetingsReturn>
+ </helloworld:getGreetingsResponse>;
+
+ return xmlOut;
+}
diff --git a/sandbox/ant/tuscany-container-rhino/src/test/resources/wsdl/helloworld.wsdl b/sandbox/ant/tuscany-container-rhino/src/test/resources/wsdl/helloworld.wsdl
new file mode 100644
index 0000000000..7bcb48dcf2
--- /dev/null
+++ b/sandbox/ant/tuscany-container-rhino/src/test/resources/wsdl/helloworld.wsdl
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ 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.
+ -->
+<wsdl:definitions targetNamespace="http://integration.rhino.container.tuscany.apache.org" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://integration.rhino.container.tuscany.apache.org" xmlns:intf="http://helloworld.samples.tuscany.apache.org" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="helloworld">
+ <!--WSDL created by Apache Axis version: 1.2.1
+Built on Jun 14, 2005 (09:15:57 EDT)-->
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://integration.rhino.container.tuscany.apache.org" xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="getGreetings">
+ <complexType>
+ <sequence>
+ <element name="in0" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="getGreetingsResponse">
+ <complexType>
+ <sequence>
+ <element name="getGreetingsReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getGreetingsRequest">
+
+ <wsdl:part element="impl:getGreetings" name="parameters"/>
+
+ </wsdl:message>
+
+ <wsdl:message name="getGreetingsResponse">
+
+ <wsdl:part element="impl:getGreetingsResponse" name="parameters"/>
+
+ </wsdl:message>
+
+ <wsdl:portType name="HelloWorld">
+
+ <wsdl:operation name="getGreetings">
+
+ <wsdl:input message="impl:getGreetingsRequest" name="getGreetingsRequest"/>
+
+ <wsdl:output message="impl:getGreetingsResponse" name="getGreetingsResponse"/>
+
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="helloworldSoapBinding" type="impl:HelloWorld">
+
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="getGreetings">
+
+ <wsdlsoap:operation soapAction=""/>
+
+ <wsdl:input name="getGreetingsRequest">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:input>
+
+ <wsdl:output name="getGreetingsResponse">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:output>
+
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="HelloWorldServiceImplService">
+
+ <wsdl:port binding="impl:helloworldSoapBinding" name="helloworld">
+
+ <wsdlsoap:address location="http://localhost:8080/helloworldws/services/HelloWorldService"/>
+
+ </wsdl:port>
+
+ </wsdl:service>
+
+</wsdl:definitions>